babylon.module.d.ts 6.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Instrumentation/timeToken" {
  586. import { Nullable } from "babylonjs/types";
  587. /**
  588. * @hidden
  589. **/
  590. export class _TimeToken {
  591. _startTimeQuery: Nullable<WebGLQuery>;
  592. _endTimeQuery: Nullable<WebGLQuery>;
  593. _timeElapsedQuery: Nullable<WebGLQuery>;
  594. _timeElapsedQueryEnded: boolean;
  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. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1065. * @param fallback defines the fallback internal texture if any
  1066. * @param isBase64 defines whether the texture is encoded as a base64
  1067. * @param isBuffer defines whether the texture data are stored as a buffer
  1068. * @returns true if the loader can load the specified file
  1069. */
  1070. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1071. /**
  1072. * Transform the url before loading if required.
  1073. * @param rootUrl the url of the texture
  1074. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1075. * @returns the transformed texture
  1076. */
  1077. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1078. /**
  1079. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1080. * @param rootUrl the url of the texture
  1081. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1082. * @returns the fallback texture
  1083. */
  1084. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1085. /**
  1086. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1087. * @param data contains the texture data
  1088. * @param texture defines the BabylonJS internal texture
  1089. * @param createPolynomials will be true if polynomials have been requested
  1090. * @param onLoad defines the callback to trigger once the texture is ready
  1091. * @param onError defines the callback to trigger in case of error
  1092. */
  1093. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1094. /**
  1095. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1096. * @param data contains the texture data
  1097. * @param texture defines the BabylonJS internal texture
  1098. * @param callback defines the method to call once ready to upload
  1099. */
  1100. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1101. }
  1102. }
  1103. declare module "babylonjs/Engines/IPipelineContext" {
  1104. /**
  1105. * Class used to store and describe the pipeline context associated with an effect
  1106. */
  1107. export interface IPipelineContext {
  1108. /**
  1109. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1110. */
  1111. isAsync: boolean;
  1112. /**
  1113. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1114. */
  1115. isReady: boolean;
  1116. /** @hidden */
  1117. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1118. }
  1119. }
  1120. declare module "babylonjs/Meshes/dataBuffer" {
  1121. /**
  1122. * Class used to store gfx data (like WebGLBuffer)
  1123. */
  1124. export class DataBuffer {
  1125. /**
  1126. * Gets or sets the number of objects referencing this buffer
  1127. */
  1128. references: number;
  1129. /** Gets or sets the size of the underlying buffer */
  1130. capacity: number;
  1131. /**
  1132. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1133. */
  1134. is32Bits: boolean;
  1135. /**
  1136. * Gets the underlying buffer
  1137. */
  1138. get underlyingResource(): any;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1142. /** @hidden */
  1143. export interface IShaderProcessor {
  1144. attributeProcessor?: (attribute: string) => string;
  1145. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1146. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1147. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1148. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1149. lineProcessor?: (line: string, isFragment: boolean) => string;
  1150. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1151. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1152. }
  1153. }
  1154. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1155. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1156. /** @hidden */
  1157. export interface ProcessingOptions {
  1158. defines: string[];
  1159. indexParameters: any;
  1160. isFragment: boolean;
  1161. shouldUseHighPrecisionShader: boolean;
  1162. supportsUniformBuffers: boolean;
  1163. shadersRepository: string;
  1164. includesShadersStore: {
  1165. [key: string]: string;
  1166. };
  1167. processor?: IShaderProcessor;
  1168. version: string;
  1169. platformName: string;
  1170. lookForClosingBracketForUniformBuffer?: boolean;
  1171. }
  1172. }
  1173. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1174. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1175. /** @hidden */
  1176. export class ShaderCodeNode {
  1177. line: string;
  1178. children: ShaderCodeNode[];
  1179. additionalDefineKey?: string;
  1180. additionalDefineValue?: string;
  1181. isValid(preprocessors: {
  1182. [key: string]: string;
  1183. }): boolean;
  1184. process(preprocessors: {
  1185. [key: string]: string;
  1186. }, options: ProcessingOptions): string;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1190. /** @hidden */
  1191. export class ShaderCodeCursor {
  1192. private _lines;
  1193. lineIndex: number;
  1194. get currentLine(): string;
  1195. get canRead(): boolean;
  1196. set lines(value: string[]);
  1197. }
  1198. }
  1199. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1200. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1201. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1202. /** @hidden */
  1203. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1204. process(preprocessors: {
  1205. [key: string]: string;
  1206. }, options: ProcessingOptions): string;
  1207. }
  1208. }
  1209. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1210. /** @hidden */
  1211. export class ShaderDefineExpression {
  1212. isTrue(preprocessors: {
  1213. [key: string]: string;
  1214. }): boolean;
  1215. }
  1216. }
  1217. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1218. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1219. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1220. /** @hidden */
  1221. export class ShaderCodeTestNode extends ShaderCodeNode {
  1222. testExpression: ShaderDefineExpression;
  1223. isValid(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1232. define: string;
  1233. not: boolean;
  1234. constructor(define: string, not?: boolean);
  1235. isTrue(preprocessors: {
  1236. [key: string]: string;
  1237. }): boolean;
  1238. }
  1239. }
  1240. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1241. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1242. /** @hidden */
  1243. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1244. leftOperand: ShaderDefineExpression;
  1245. rightOperand: ShaderDefineExpression;
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1252. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. operand: string;
  1268. testValue: string;
  1269. constructor(define: string, operand: string, testValue: string);
  1270. isTrue(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Offline/IOfflineProvider" {
  1276. /**
  1277. * Class used to enable access to offline support
  1278. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1279. */
  1280. export interface IOfflineProvider {
  1281. /**
  1282. * Gets a boolean indicating if scene must be saved in the database
  1283. */
  1284. enableSceneOffline: boolean;
  1285. /**
  1286. * Gets a boolean indicating if textures must be saved in the database
  1287. */
  1288. enableTexturesOffline: boolean;
  1289. /**
  1290. * Open the offline support and make it available
  1291. * @param successCallback defines the callback to call on success
  1292. * @param errorCallback defines the callback to call on error
  1293. */
  1294. open(successCallback: () => void, errorCallback: () => void): void;
  1295. /**
  1296. * Loads an image from the offline support
  1297. * @param url defines the url to load from
  1298. * @param image defines the target DOM image
  1299. */
  1300. loadImage(url: string, image: HTMLImageElement): void;
  1301. /**
  1302. * Loads a file from offline support
  1303. * @param url defines the URL to load from
  1304. * @param sceneLoaded defines a callback to call on success
  1305. * @param progressCallBack defines a callback to call when progress changed
  1306. * @param errorCallback defines a callback to call on error
  1307. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1308. */
  1309. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1310. }
  1311. }
  1312. declare module "babylonjs/Misc/filesInputStore" {
  1313. /**
  1314. * Class used to help managing file picking and drag'n'drop
  1315. * File Storage
  1316. */
  1317. export class FilesInputStore {
  1318. /**
  1319. * List of files ready to be loaded
  1320. */
  1321. static FilesToLoad: {
  1322. [key: string]: File;
  1323. };
  1324. }
  1325. }
  1326. declare module "babylonjs/Misc/retryStrategy" {
  1327. import { WebRequest } from "babylonjs/Misc/webRequest";
  1328. /**
  1329. * Class used to define a retry strategy when error happens while loading assets
  1330. */
  1331. export class RetryStrategy {
  1332. /**
  1333. * Function used to defines an exponential back off strategy
  1334. * @param maxRetries defines the maximum number of retries (3 by default)
  1335. * @param baseInterval defines the interval between retries
  1336. * @returns the strategy function to use
  1337. */
  1338. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1339. }
  1340. }
  1341. declare module "babylonjs/Misc/baseError" {
  1342. /**
  1343. * @ignore
  1344. * Application error to support additional information when loading a file
  1345. */
  1346. export abstract class BaseError extends Error {
  1347. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/fileTools" {
  1351. import { WebRequest } from "babylonjs/Misc/webRequest";
  1352. import { Nullable } from "babylonjs/types";
  1353. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1354. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1355. import { BaseError } from "babylonjs/Misc/baseError";
  1356. /** @ignore */
  1357. export class LoadFileError extends BaseError {
  1358. request?: WebRequest;
  1359. file?: File;
  1360. /**
  1361. * Creates a new LoadFileError
  1362. * @param message defines the message of the error
  1363. * @param request defines the optional web request
  1364. * @param file defines the optional file
  1365. */
  1366. constructor(message: string, object?: WebRequest | File);
  1367. }
  1368. /** @ignore */
  1369. export class RequestFileError extends BaseError {
  1370. request: WebRequest;
  1371. /**
  1372. * Creates a new LoadFileError
  1373. * @param message defines the message of the error
  1374. * @param request defines the optional web request
  1375. */
  1376. constructor(message: string, request: WebRequest);
  1377. }
  1378. /** @ignore */
  1379. export class ReadFileError extends BaseError {
  1380. file: File;
  1381. /**
  1382. * Creates a new ReadFileError
  1383. * @param message defines the message of the error
  1384. * @param file defines the optional file
  1385. */
  1386. constructor(message: string, file: File);
  1387. }
  1388. /**
  1389. * @hidden
  1390. */
  1391. export class FileTools {
  1392. /**
  1393. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1394. */
  1395. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1396. /**
  1397. * Gets or sets the base URL to use to load assets
  1398. */
  1399. static BaseUrl: string;
  1400. /**
  1401. * Default behaviour for cors in the application.
  1402. * It can be a string if the expected behavior is identical in the entire app.
  1403. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1404. */
  1405. static CorsBehavior: string | ((url: string | string[]) => string);
  1406. /**
  1407. * Gets or sets a function used to pre-process url before using them to load assets
  1408. */
  1409. static PreprocessUrl: (url: string) => string;
  1410. /**
  1411. * Removes unwanted characters from an url
  1412. * @param url defines the url to clean
  1413. * @returns the cleaned url
  1414. */
  1415. private static _CleanUrl;
  1416. /**
  1417. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1418. * @param url define the url we are trying
  1419. * @param element define the dom element where to configure the cors policy
  1420. */
  1421. static SetCorsBehavior(url: string | string[], element: {
  1422. crossOrigin: string | null;
  1423. }): void;
  1424. /**
  1425. * Loads an image as an HTMLImageElement.
  1426. * @param input url string, ArrayBuffer, or Blob to load
  1427. * @param onLoad callback called when the image successfully loads
  1428. * @param onError callback called when the image fails to load
  1429. * @param offlineProvider offline provider for caching
  1430. * @param mimeType optional mime type
  1431. * @returns the HTMLImageElement of the loaded image
  1432. */
  1433. 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>;
  1434. /**
  1435. * Reads a file from a File object
  1436. * @param file defines the file to load
  1437. * @param onSuccess defines the callback to call when data is loaded
  1438. * @param onProgress defines the callback to call during loading process
  1439. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1440. * @param onError defines the callback to call when an error occurs
  1441. * @returns a file request object
  1442. */
  1443. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1444. /**
  1445. * Loads a file from a url
  1446. * @param url url to load
  1447. * @param onSuccess callback called when the file successfully loads
  1448. * @param onProgress callback called while file is loading (if the server supports this mode)
  1449. * @param offlineProvider defines the offline provider for caching
  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. * @returns a file request object
  1453. */
  1454. 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;
  1455. /**
  1456. * Loads a file
  1457. * @param url url to load
  1458. * @param onSuccess callback called when the file successfully loads
  1459. * @param onProgress callback called while file is loading (if the server supports this mode)
  1460. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1461. * @param onError callback called when the file fails to load
  1462. * @param onOpened callback called when the web request is opened
  1463. * @returns a file request object
  1464. */
  1465. 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;
  1466. /**
  1467. * Checks if the loaded document was accessed via `file:`-Protocol.
  1468. * @returns boolean
  1469. */
  1470. static IsFileURL(): boolean;
  1471. }
  1472. }
  1473. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1474. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1475. import { WebRequest } from "babylonjs/Misc/webRequest";
  1476. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1477. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1478. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1479. /** @hidden */
  1480. export class ShaderProcessor {
  1481. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1482. private static _ProcessPrecision;
  1483. private static _ExtractOperation;
  1484. private static _BuildSubExpression;
  1485. private static _BuildExpression;
  1486. private static _MoveCursorWithinIf;
  1487. private static _MoveCursor;
  1488. private static _EvaluatePreProcessors;
  1489. private static _PreparePreProcessors;
  1490. private static _ProcessShaderConversion;
  1491. private static _ProcessIncludes;
  1492. /**
  1493. * Loads a file from a url
  1494. * @param url url to load
  1495. * @param onSuccess callback called when the file successfully loads
  1496. * @param onProgress callback called while file is loading (if the server supports this mode)
  1497. * @param offlineProvider defines the offline provider for caching
  1498. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1499. * @param onError callback called when the file fails to load
  1500. * @returns a file request object
  1501. * @hidden
  1502. */
  1503. 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;
  1504. }
  1505. }
  1506. declare module "babylonjs/Maths/math.like" {
  1507. import { float, int, DeepImmutable } from "babylonjs/types";
  1508. /**
  1509. * @hidden
  1510. */
  1511. export interface IColor4Like {
  1512. r: float;
  1513. g: float;
  1514. b: float;
  1515. a: float;
  1516. }
  1517. /**
  1518. * @hidden
  1519. */
  1520. export interface IColor3Like {
  1521. r: float;
  1522. g: float;
  1523. b: float;
  1524. }
  1525. /**
  1526. * @hidden
  1527. */
  1528. export interface IVector4Like {
  1529. x: float;
  1530. y: float;
  1531. z: float;
  1532. w: float;
  1533. }
  1534. /**
  1535. * @hidden
  1536. */
  1537. export interface IVector3Like {
  1538. x: float;
  1539. y: float;
  1540. z: float;
  1541. }
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IVector2Like {
  1546. x: float;
  1547. y: float;
  1548. }
  1549. /**
  1550. * @hidden
  1551. */
  1552. export interface IMatrixLike {
  1553. toArray(): DeepImmutable<Float32Array>;
  1554. updateFlag: int;
  1555. }
  1556. /**
  1557. * @hidden
  1558. */
  1559. export interface IViewportLike {
  1560. x: float;
  1561. y: float;
  1562. width: float;
  1563. height: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IPlaneLike {
  1569. normal: IVector3Like;
  1570. d: float;
  1571. normalize(): void;
  1572. }
  1573. }
  1574. declare module "babylonjs/Materials/iEffectFallbacks" {
  1575. import { Effect } from "babylonjs/Materials/effect";
  1576. /**
  1577. * Interface used to define common properties for effect fallbacks
  1578. */
  1579. export interface IEffectFallbacks {
  1580. /**
  1581. * Removes the defines that should be removed when falling back.
  1582. * @param currentDefines defines the current define statements for the shader.
  1583. * @param effect defines the current effect we try to compile
  1584. * @returns The resulting defines with defines of the current rank removed.
  1585. */
  1586. reduce(currentDefines: string, effect: Effect): string;
  1587. /**
  1588. * Removes the fallback from the bound mesh.
  1589. */
  1590. unBindMesh(): void;
  1591. /**
  1592. * Checks to see if more fallbacks are still availible.
  1593. */
  1594. hasMoreFallbacks: boolean;
  1595. }
  1596. }
  1597. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1598. /**
  1599. * Class used to evalaute queries containing `and` and `or` operators
  1600. */
  1601. export class AndOrNotEvaluator {
  1602. /**
  1603. * Evaluate a query
  1604. * @param query defines the query to evaluate
  1605. * @param evaluateCallback defines the callback used to filter result
  1606. * @returns true if the query matches
  1607. */
  1608. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1609. private static _HandleParenthesisContent;
  1610. private static _SimplifyNegation;
  1611. }
  1612. }
  1613. declare module "babylonjs/Misc/tags" {
  1614. /**
  1615. * Class used to store custom tags
  1616. */
  1617. export class Tags {
  1618. /**
  1619. * Adds support for tags on the given object
  1620. * @param obj defines the object to use
  1621. */
  1622. static EnableFor(obj: any): void;
  1623. /**
  1624. * Removes tags support
  1625. * @param obj defines the object to use
  1626. */
  1627. static DisableFor(obj: any): void;
  1628. /**
  1629. * Gets a boolean indicating if the given object has tags
  1630. * @param obj defines the object to use
  1631. * @returns a boolean
  1632. */
  1633. static HasTags(obj: any): boolean;
  1634. /**
  1635. * Gets the tags available on a given object
  1636. * @param obj defines the object to use
  1637. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1638. * @returns the tags
  1639. */
  1640. static GetTags(obj: any, asString?: boolean): any;
  1641. /**
  1642. * Adds tags to an object
  1643. * @param obj defines the object to use
  1644. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1645. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1646. */
  1647. static AddTagsTo(obj: any, tagsString: string): void;
  1648. /**
  1649. * @hidden
  1650. */
  1651. static _AddTagTo(obj: any, tag: string): void;
  1652. /**
  1653. * Removes specific tags from a specific object
  1654. * @param obj defines the object to use
  1655. * @param tagsString defines the tags to remove
  1656. */
  1657. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1658. /**
  1659. * @hidden
  1660. */
  1661. static _RemoveTagFrom(obj: any, tag: string): void;
  1662. /**
  1663. * Defines if tags hosted on an object match a given query
  1664. * @param obj defines the object to use
  1665. * @param tagsQuery defines the tag query
  1666. * @returns a boolean
  1667. */
  1668. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1669. }
  1670. }
  1671. declare module "babylonjs/Maths/math.scalar" {
  1672. /**
  1673. * Scalar computation library
  1674. */
  1675. export class Scalar {
  1676. /**
  1677. * Two pi constants convenient for computation.
  1678. */
  1679. static TwoPi: number;
  1680. /**
  1681. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1682. * @param a number
  1683. * @param b number
  1684. * @param epsilon (default = 1.401298E-45)
  1685. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1686. */
  1687. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1688. /**
  1689. * Returns a string : the upper case translation of the number i to hexadecimal.
  1690. * @param i number
  1691. * @returns the upper case translation of the number i to hexadecimal.
  1692. */
  1693. static ToHex(i: number): string;
  1694. /**
  1695. * Returns -1 if value is negative and +1 is value is positive.
  1696. * @param value the value
  1697. * @returns the value itself if it's equal to zero.
  1698. */
  1699. static Sign(value: number): number;
  1700. /**
  1701. * Returns the value itself if it's between min and max.
  1702. * Returns min if the value is lower than min.
  1703. * Returns max if the value is greater than max.
  1704. * @param value the value to clmap
  1705. * @param min the min value to clamp to (default: 0)
  1706. * @param max the max value to clamp to (default: 1)
  1707. * @returns the clamped value
  1708. */
  1709. static Clamp(value: number, min?: number, max?: number): number;
  1710. /**
  1711. * the log2 of value.
  1712. * @param value the value to compute log2 of
  1713. * @returns the log2 of value.
  1714. */
  1715. static Log2(value: number): number;
  1716. /**
  1717. * Loops the value, so that it is never larger than length and never smaller than 0.
  1718. *
  1719. * This is similar to the modulo operator but it works with floating point numbers.
  1720. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1721. * With t = 5 and length = 2.5, the result would be 0.0.
  1722. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1723. * @param value the value
  1724. * @param length the length
  1725. * @returns the looped value
  1726. */
  1727. static Repeat(value: number, length: number): number;
  1728. /**
  1729. * Normalize the value between 0.0 and 1.0 using min and max values
  1730. * @param value value to normalize
  1731. * @param min max to normalize between
  1732. * @param max min to normalize between
  1733. * @returns the normalized value
  1734. */
  1735. static Normalize(value: number, min: number, max: number): number;
  1736. /**
  1737. * Denormalize the value from 0.0 and 1.0 using min and max values
  1738. * @param normalized value to denormalize
  1739. * @param min max to denormalize between
  1740. * @param max min to denormalize between
  1741. * @returns the denormalized value
  1742. */
  1743. static Denormalize(normalized: number, min: number, max: number): number;
  1744. /**
  1745. * Calculates the shortest difference between two given angles given in degrees.
  1746. * @param current current angle in degrees
  1747. * @param target target angle in degrees
  1748. * @returns the delta
  1749. */
  1750. static DeltaAngle(current: number, target: number): number;
  1751. /**
  1752. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1753. * @param tx value
  1754. * @param length length
  1755. * @returns The returned value will move back and forth between 0 and length
  1756. */
  1757. static PingPong(tx: number, length: number): number;
  1758. /**
  1759. * Interpolates between min and max with smoothing at the limits.
  1760. *
  1761. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1762. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1763. * @param from from
  1764. * @param to to
  1765. * @param tx value
  1766. * @returns the smooth stepped value
  1767. */
  1768. static SmoothStep(from: number, to: number, tx: number): number;
  1769. /**
  1770. * Moves a value current towards target.
  1771. *
  1772. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1773. * Negative values of maxDelta pushes the value away from target.
  1774. * @param current current value
  1775. * @param target target value
  1776. * @param maxDelta max distance to move
  1777. * @returns resulting value
  1778. */
  1779. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1780. /**
  1781. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1782. *
  1783. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1784. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1785. * @param current current value
  1786. * @param target target value
  1787. * @param maxDelta max distance to move
  1788. * @returns resulting angle
  1789. */
  1790. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1791. /**
  1792. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1793. * @param start start value
  1794. * @param end target value
  1795. * @param amount amount to lerp between
  1796. * @returns the lerped value
  1797. */
  1798. static Lerp(start: number, end: number, amount: number): number;
  1799. /**
  1800. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1801. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1802. * @param start start value
  1803. * @param end target value
  1804. * @param amount amount to lerp between
  1805. * @returns the lerped value
  1806. */
  1807. static LerpAngle(start: number, end: number, amount: number): number;
  1808. /**
  1809. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1810. * @param a start value
  1811. * @param b target value
  1812. * @param value value between a and b
  1813. * @returns the inverseLerp value
  1814. */
  1815. static InverseLerp(a: number, b: number, value: number): number;
  1816. /**
  1817. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1818. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1819. * @param value1 spline value
  1820. * @param tangent1 spline value
  1821. * @param value2 spline value
  1822. * @param tangent2 spline value
  1823. * @param amount input value
  1824. * @returns hermite result
  1825. */
  1826. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1827. /**
  1828. * Returns a random float number between and min and max values
  1829. * @param min min value of random
  1830. * @param max max value of random
  1831. * @returns random value
  1832. */
  1833. static RandomRange(min: number, max: number): number;
  1834. /**
  1835. * This function returns percentage of a number in a given range.
  1836. *
  1837. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1838. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1839. * @param number to convert to percentage
  1840. * @param min min range
  1841. * @param max max range
  1842. * @returns the percentage
  1843. */
  1844. static RangeToPercent(number: number, min: number, max: number): number;
  1845. /**
  1846. * This function returns number that corresponds to the percentage in a given range.
  1847. *
  1848. * PercentToRange(0.34,0,100) will return 34.
  1849. * @param percent to convert to number
  1850. * @param min min range
  1851. * @param max max range
  1852. * @returns the number
  1853. */
  1854. static PercentToRange(percent: number, min: number, max: number): number;
  1855. /**
  1856. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1857. * @param angle The angle to normalize in radian.
  1858. * @return The converted angle.
  1859. */
  1860. static NormalizeRadians(angle: number): number;
  1861. }
  1862. }
  1863. declare module "babylonjs/Maths/math.constants" {
  1864. /**
  1865. * Constant used to convert a value to gamma space
  1866. * @ignorenaming
  1867. */
  1868. export const ToGammaSpace: number;
  1869. /**
  1870. * Constant used to convert a value to linear space
  1871. * @ignorenaming
  1872. */
  1873. export const ToLinearSpace = 2.2;
  1874. /**
  1875. * Constant used to define the minimal number value in Babylon.js
  1876. * @ignorenaming
  1877. */
  1878. let Epsilon: number;
  1879. export { Epsilon };
  1880. }
  1881. declare module "babylonjs/Maths/math.viewport" {
  1882. /**
  1883. * Class used to represent a viewport on screen
  1884. */
  1885. export class Viewport {
  1886. /** viewport left coordinate */
  1887. x: number;
  1888. /** viewport top coordinate */
  1889. y: number;
  1890. /**viewport width */
  1891. width: number;
  1892. /** viewport height */
  1893. height: number;
  1894. /**
  1895. * Creates a Viewport object located at (x, y) and sized (width, height)
  1896. * @param x defines viewport left coordinate
  1897. * @param y defines viewport top coordinate
  1898. * @param width defines the viewport width
  1899. * @param height defines the viewport height
  1900. */
  1901. constructor(
  1902. /** viewport left coordinate */
  1903. x: number,
  1904. /** viewport top coordinate */
  1905. y: number,
  1906. /**viewport width */
  1907. width: number,
  1908. /** viewport height */
  1909. height: number);
  1910. /**
  1911. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1912. * @param renderWidth defines the rendering width
  1913. * @param renderHeight defines the rendering height
  1914. * @returns a new Viewport
  1915. */
  1916. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1917. /**
  1918. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1919. * @param renderWidth defines the rendering width
  1920. * @param renderHeight defines the rendering height
  1921. * @param ref defines the target viewport
  1922. * @returns the current viewport
  1923. */
  1924. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1925. /**
  1926. * Returns a new Viewport copied from the current one
  1927. * @returns a new Viewport
  1928. */
  1929. clone(): Viewport;
  1930. }
  1931. }
  1932. declare module "babylonjs/Misc/arrayTools" {
  1933. /**
  1934. * Class containing a set of static utilities functions for arrays.
  1935. */
  1936. export class ArrayTools {
  1937. /**
  1938. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1939. * @param size the number of element to construct and put in the array
  1940. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1941. * @returns a new array filled with new objects
  1942. */
  1943. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1944. }
  1945. }
  1946. declare module "babylonjs/Maths/math.vector" {
  1947. import { Viewport } from "babylonjs/Maths/math.viewport";
  1948. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1949. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1950. /**
  1951. * Class representing a vector containing 2 coordinates
  1952. */
  1953. export class Vector2 {
  1954. /** defines the first coordinate */
  1955. x: number;
  1956. /** defines the second coordinate */
  1957. y: number;
  1958. /**
  1959. * Creates a new Vector2 from the given x and y coordinates
  1960. * @param x defines the first coordinate
  1961. * @param y defines the second coordinate
  1962. */
  1963. constructor(
  1964. /** defines the first coordinate */
  1965. x?: number,
  1966. /** defines the second coordinate */
  1967. y?: number);
  1968. /**
  1969. * Gets a string with the Vector2 coordinates
  1970. * @returns a string with the Vector2 coordinates
  1971. */
  1972. toString(): string;
  1973. /**
  1974. * Gets class name
  1975. * @returns the string "Vector2"
  1976. */
  1977. getClassName(): string;
  1978. /**
  1979. * Gets current vector hash code
  1980. * @returns the Vector2 hash code as a number
  1981. */
  1982. getHashCode(): number;
  1983. /**
  1984. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1985. * @param array defines the source array
  1986. * @param index defines the offset in source array
  1987. * @returns the current Vector2
  1988. */
  1989. toArray(array: FloatArray, index?: number): Vector2;
  1990. /**
  1991. * Copy the current vector to an array
  1992. * @returns a new array with 2 elements: the Vector2 coordinates.
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1997. * @param source defines the source Vector2
  1998. * @returns the current updated Vector2
  1999. */
  2000. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2001. /**
  2002. * Sets the Vector2 coordinates with the given floats
  2003. * @param x defines the first coordinate
  2004. * @param y defines the second coordinate
  2005. * @returns the current updated Vector2
  2006. */
  2007. copyFromFloats(x: number, y: number): Vector2;
  2008. /**
  2009. * Sets the Vector2 coordinates with the given floats
  2010. * @param x defines the first coordinate
  2011. * @param y defines the second coordinate
  2012. * @returns the current updated Vector2
  2013. */
  2014. set(x: number, y: number): Vector2;
  2015. /**
  2016. * Add another vector with the current one
  2017. * @param otherVector defines the other vector
  2018. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2019. */
  2020. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2021. /**
  2022. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2023. * @param otherVector defines the other vector
  2024. * @param result defines the target vector
  2025. * @returns the unmodified current Vector2
  2026. */
  2027. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2028. /**
  2029. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2030. * @param otherVector defines the other vector
  2031. * @returns the current updated Vector2
  2032. */
  2033. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2034. /**
  2035. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2036. * @param otherVector defines the other vector
  2037. * @returns a new Vector2
  2038. */
  2039. addVector3(otherVector: Vector3): Vector2;
  2040. /**
  2041. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2042. * @param otherVector defines the other vector
  2043. * @returns a new Vector2
  2044. */
  2045. subtract(otherVector: Vector2): Vector2;
  2046. /**
  2047. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2048. * @param otherVector defines the other vector
  2049. * @param result defines the target vector
  2050. * @returns the unmodified current Vector2
  2051. */
  2052. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2053. /**
  2054. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @returns the current updated Vector2
  2057. */
  2058. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Multiplies in place the current Vector2 coordinates by the given ones
  2061. * @param otherVector defines the other vector
  2062. * @returns the current updated Vector2
  2063. */
  2064. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2065. /**
  2066. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2067. * @param otherVector defines the other vector
  2068. * @returns a new Vector2
  2069. */
  2070. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2071. /**
  2072. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2073. * @param otherVector defines the other vector
  2074. * @param result defines the target vector
  2075. * @returns the unmodified current Vector2
  2076. */
  2077. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2078. /**
  2079. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2080. * @param x defines the first coordinate
  2081. * @param y defines the second coordinate
  2082. * @returns a new Vector2
  2083. */
  2084. multiplyByFloats(x: number, y: number): Vector2;
  2085. /**
  2086. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2087. * @param otherVector defines the other vector
  2088. * @returns a new Vector2
  2089. */
  2090. divide(otherVector: Vector2): Vector2;
  2091. /**
  2092. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2093. * @param otherVector defines the other vector
  2094. * @param result defines the target vector
  2095. * @returns the unmodified current Vector2
  2096. */
  2097. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2098. /**
  2099. * Divides the current Vector2 coordinates by the given ones
  2100. * @param otherVector defines the other vector
  2101. * @returns the current updated Vector2
  2102. */
  2103. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2104. /**
  2105. * Gets a new Vector2 with current Vector2 negated coordinates
  2106. * @returns a new Vector2
  2107. */
  2108. negate(): Vector2;
  2109. /**
  2110. * Multiply the Vector2 coordinates by scale
  2111. * @param scale defines the scaling factor
  2112. * @returns the current updated Vector2
  2113. */
  2114. scaleInPlace(scale: number): Vector2;
  2115. /**
  2116. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2117. * @param scale defines the scaling factor
  2118. * @returns a new Vector2
  2119. */
  2120. scale(scale: number): Vector2;
  2121. /**
  2122. * Scale the current Vector2 values by a factor to a given Vector2
  2123. * @param scale defines the scale factor
  2124. * @param result defines the Vector2 object where to store the result
  2125. * @returns the unmodified current Vector2
  2126. */
  2127. scaleToRef(scale: number, result: Vector2): Vector2;
  2128. /**
  2129. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2130. * @param scale defines the scale factor
  2131. * @param result defines the Vector2 object where to store the result
  2132. * @returns the unmodified current Vector2
  2133. */
  2134. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2135. /**
  2136. * Gets a boolean if two vectors are equals
  2137. * @param otherVector defines the other vector
  2138. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2139. */
  2140. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2141. /**
  2142. * Gets a boolean if two vectors are equals (using an epsilon value)
  2143. * @param otherVector defines the other vector
  2144. * @param epsilon defines the minimal distance to consider equality
  2145. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2146. */
  2147. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2148. /**
  2149. * Gets a new Vector2 from current Vector2 floored values
  2150. * @returns a new Vector2
  2151. */
  2152. floor(): Vector2;
  2153. /**
  2154. * Gets a new Vector2 from current Vector2 floored values
  2155. * @returns a new Vector2
  2156. */
  2157. fract(): Vector2;
  2158. /**
  2159. * Gets the length of the vector
  2160. * @returns the vector length (float)
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Gets the vector squared length
  2165. * @returns the vector squared length (float)
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalize the vector
  2170. * @returns the current updated Vector2
  2171. */
  2172. normalize(): Vector2;
  2173. /**
  2174. * Gets a new Vector2 copied from the Vector2
  2175. * @returns a new Vector2
  2176. */
  2177. clone(): Vector2;
  2178. /**
  2179. * Gets a new Vector2(0, 0)
  2180. * @returns a new Vector2
  2181. */
  2182. static Zero(): Vector2;
  2183. /**
  2184. * Gets a new Vector2(1, 1)
  2185. * @returns a new Vector2
  2186. */
  2187. static One(): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set from the given index element of the given array
  2190. * @param array defines the data source
  2191. * @param offset defines the offset in the data source
  2192. * @returns a new Vector2
  2193. */
  2194. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2195. /**
  2196. * Sets "result" from the given index element of the given array
  2197. * @param array defines the data source
  2198. * @param offset defines the offset in the data source
  2199. * @param result defines the target vector
  2200. */
  2201. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2202. /**
  2203. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2204. * @param value1 defines 1st point of control
  2205. * @param value2 defines 2nd point of control
  2206. * @param value3 defines 3rd point of control
  2207. * @param value4 defines 4th point of control
  2208. * @param amount defines the interpolation factor
  2209. * @returns a new Vector2
  2210. */
  2211. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2212. /**
  2213. * 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".
  2214. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2215. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2216. * @param value defines the value to clamp
  2217. * @param min defines the lower limit
  2218. * @param max defines the upper limit
  2219. * @returns a new Vector2
  2220. */
  2221. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2222. /**
  2223. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2224. * @param value1 defines the 1st control point
  2225. * @param tangent1 defines the outgoing tangent
  2226. * @param value2 defines the 2nd control point
  2227. * @param tangent2 defines the incoming tangent
  2228. * @param amount defines the interpolation factor
  2229. * @returns a new Vector2
  2230. */
  2231. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2232. /**
  2233. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2234. * @param start defines the start vector
  2235. * @param end defines the end vector
  2236. * @param amount defines the interpolation factor
  2237. * @returns a new Vector2
  2238. */
  2239. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2240. /**
  2241. * Gets the dot product of the vector "left" and the vector "right"
  2242. * @param left defines first vector
  2243. * @param right defines second vector
  2244. * @returns the dot product (float)
  2245. */
  2246. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2247. /**
  2248. * Returns a new Vector2 equal to the normalized given vector
  2249. * @param vector defines the vector to normalize
  2250. * @returns a new Vector2
  2251. */
  2252. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2253. /**
  2254. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2255. * @param left defines 1st vector
  2256. * @param right defines 2nd vector
  2257. * @returns a new Vector2
  2258. */
  2259. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2260. /**
  2261. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2262. * @param left defines 1st vector
  2263. * @param right defines 2nd vector
  2264. * @returns a new Vector2
  2265. */
  2266. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2267. /**
  2268. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2269. * @param vector defines the vector to transform
  2270. * @param transformation defines the matrix to apply
  2271. * @returns a new Vector2
  2272. */
  2273. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2274. /**
  2275. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2276. * @param vector defines the vector to transform
  2277. * @param transformation defines the matrix to apply
  2278. * @param result defines the target vector
  2279. */
  2280. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2281. /**
  2282. * Determines if a given vector is included in a triangle
  2283. * @param p defines the vector to test
  2284. * @param p0 defines 1st triangle point
  2285. * @param p1 defines 2nd triangle point
  2286. * @param p2 defines 3rd triangle point
  2287. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2288. */
  2289. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2290. /**
  2291. * Gets the distance between the vectors "value1" and "value2"
  2292. * @param value1 defines first vector
  2293. * @param value2 defines second vector
  2294. * @returns the distance between vectors
  2295. */
  2296. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2297. /**
  2298. * Returns the squared distance between the vectors "value1" and "value2"
  2299. * @param value1 defines first vector
  2300. * @param value2 defines second vector
  2301. * @returns the squared distance between vectors
  2302. */
  2303. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2304. /**
  2305. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2306. * @param value1 defines first vector
  2307. * @param value2 defines second vector
  2308. * @returns a new Vector2
  2309. */
  2310. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2311. /**
  2312. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2313. * @param p defines the middle point
  2314. * @param segA defines one point of the segment
  2315. * @param segB defines the other point of the segment
  2316. * @returns the shortest distance
  2317. */
  2318. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2319. }
  2320. /**
  2321. * Class used to store (x,y,z) vector representation
  2322. * A Vector3 is the main object used in 3D geometry
  2323. * It can represent etiher the coordinates of a point the space, either a direction
  2324. * Reminder: js uses a left handed forward facing system
  2325. */
  2326. export class Vector3 {
  2327. /**
  2328. * Defines the first coordinates (on X axis)
  2329. */
  2330. x: number;
  2331. /**
  2332. * Defines the second coordinates (on Y axis)
  2333. */
  2334. y: number;
  2335. /**
  2336. * Defines the third coordinates (on Z axis)
  2337. */
  2338. z: number;
  2339. private static _UpReadOnly;
  2340. private static _ZeroReadOnly;
  2341. /**
  2342. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2343. * @param x defines the first coordinates (on X axis)
  2344. * @param y defines the second coordinates (on Y axis)
  2345. * @param z defines the third coordinates (on Z axis)
  2346. */
  2347. constructor(
  2348. /**
  2349. * Defines the first coordinates (on X axis)
  2350. */
  2351. x?: number,
  2352. /**
  2353. * Defines the second coordinates (on Y axis)
  2354. */
  2355. y?: number,
  2356. /**
  2357. * Defines the third coordinates (on Z axis)
  2358. */
  2359. z?: number);
  2360. /**
  2361. * Creates a string representation of the Vector3
  2362. * @returns a string with the Vector3 coordinates.
  2363. */
  2364. toString(): string;
  2365. /**
  2366. * Gets the class name
  2367. * @returns the string "Vector3"
  2368. */
  2369. getClassName(): string;
  2370. /**
  2371. * Creates the Vector3 hash code
  2372. * @returns a number which tends to be unique between Vector3 instances
  2373. */
  2374. getHashCode(): number;
  2375. /**
  2376. * Creates an array containing three elements : the coordinates of the Vector3
  2377. * @returns a new array of numbers
  2378. */
  2379. asArray(): number[];
  2380. /**
  2381. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2382. * @param array defines the destination array
  2383. * @param index defines the offset in the destination array
  2384. * @returns the current Vector3
  2385. */
  2386. toArray(array: FloatArray, index?: number): Vector3;
  2387. /**
  2388. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2389. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2390. */
  2391. toQuaternion(): Quaternion;
  2392. /**
  2393. * Adds the given vector to the current Vector3
  2394. * @param otherVector defines the second operand
  2395. * @returns the current updated Vector3
  2396. */
  2397. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2398. /**
  2399. * Adds the given coordinates to the current Vector3
  2400. * @param x defines the x coordinate of the operand
  2401. * @param y defines the y coordinate of the operand
  2402. * @param z defines the z coordinate of the operand
  2403. * @returns the current updated Vector3
  2404. */
  2405. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2406. /**
  2407. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2408. * @param otherVector defines the second operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2412. /**
  2413. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2414. * @param otherVector defines the second operand
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2419. /**
  2420. * Subtract the given vector from the current Vector3
  2421. * @param otherVector defines the second operand
  2422. * @returns the current updated Vector3
  2423. */
  2424. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2425. /**
  2426. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2427. * @param otherVector defines the second operand
  2428. * @returns the resulting Vector3
  2429. */
  2430. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2431. /**
  2432. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2433. * @param otherVector defines the second operand
  2434. * @param result defines the Vector3 object where to store the result
  2435. * @returns the current Vector3
  2436. */
  2437. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2438. /**
  2439. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2440. * @param x defines the x coordinate of the operand
  2441. * @param y defines the y coordinate of the operand
  2442. * @param z defines the z coordinate of the operand
  2443. * @returns the resulting Vector3
  2444. */
  2445. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2446. /**
  2447. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2448. * @param x defines the x coordinate of the operand
  2449. * @param y defines the y coordinate of the operand
  2450. * @param z defines the z coordinate of the operand
  2451. * @param result defines the Vector3 object where to store the result
  2452. * @returns the current Vector3
  2453. */
  2454. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2455. /**
  2456. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2457. * @returns a new Vector3
  2458. */
  2459. negate(): Vector3;
  2460. /**
  2461. * Negate this vector in place
  2462. * @returns this
  2463. */
  2464. negateInPlace(): Vector3;
  2465. /**
  2466. * Multiplies the Vector3 coordinates by the float "scale"
  2467. * @param scale defines the multiplier factor
  2468. * @returns the current updated Vector3
  2469. */
  2470. scaleInPlace(scale: number): Vector3;
  2471. /**
  2472. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2473. * @param scale defines the multiplier factor
  2474. * @returns a new Vector3
  2475. */
  2476. scale(scale: number): Vector3;
  2477. /**
  2478. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2479. * @param scale defines the multiplier factor
  2480. * @param result defines the Vector3 object where to store the result
  2481. * @returns the current Vector3
  2482. */
  2483. scaleToRef(scale: number, result: Vector3): Vector3;
  2484. /**
  2485. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2486. * @param scale defines the scale factor
  2487. * @param result defines the Vector3 object where to store the result
  2488. * @returns the unmodified current Vector3
  2489. */
  2490. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2491. /**
  2492. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2493. * @param otherVector defines the second operand
  2494. * @returns true if both vectors are equals
  2495. */
  2496. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2497. /**
  2498. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2499. * @param otherVector defines the second operand
  2500. * @param epsilon defines the minimal distance to define values as equals
  2501. * @returns true if both vectors are distant less than epsilon
  2502. */
  2503. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2504. /**
  2505. * Returns true if the current Vector3 coordinates equals the given floats
  2506. * @param x defines the x coordinate of the operand
  2507. * @param y defines the y coordinate of the operand
  2508. * @param z defines the z coordinate of the operand
  2509. * @returns true if both vectors are equals
  2510. */
  2511. equalsToFloats(x: number, y: number, z: number): boolean;
  2512. /**
  2513. * Multiplies the current Vector3 coordinates by the given ones
  2514. * @param otherVector defines the second operand
  2515. * @returns the current updated Vector3
  2516. */
  2517. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2518. /**
  2519. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2520. * @param otherVector defines the second operand
  2521. * @returns the new Vector3
  2522. */
  2523. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2524. /**
  2525. * Multiplies the current Vector3 by the given one and stores the result in the given 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. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2531. /**
  2532. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2533. * @param x defines the x coordinate of the operand
  2534. * @param y defines the y coordinate of the operand
  2535. * @param z defines the z coordinate of the operand
  2536. * @returns the new Vector3
  2537. */
  2538. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2539. /**
  2540. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2541. * @param otherVector defines the second operand
  2542. * @returns the new Vector3
  2543. */
  2544. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2545. /**
  2546. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2547. * @param otherVector defines the second operand
  2548. * @param result defines the Vector3 object where to store the result
  2549. * @returns the current Vector3
  2550. */
  2551. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2552. /**
  2553. * Divides the current Vector3 coordinates by the given ones.
  2554. * @param otherVector defines the second operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. divideInPlace(otherVector: Vector3): Vector3;
  2558. /**
  2559. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2560. * @param other defines the second operand
  2561. * @returns the current updated Vector3
  2562. */
  2563. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2564. /**
  2565. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2566. * @param other defines the second operand
  2567. * @returns the current updated Vector3
  2568. */
  2569. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2570. /**
  2571. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2572. * @param x defines the x coordinate of the operand
  2573. * @param y defines the y coordinate of the operand
  2574. * @param z defines the z coordinate of the operand
  2575. * @returns the current updated Vector3
  2576. */
  2577. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2578. /**
  2579. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2580. * @param x defines the x coordinate of the operand
  2581. * @param y defines the y coordinate of the operand
  2582. * @param z defines the z coordinate of the operand
  2583. * @returns the current updated Vector3
  2584. */
  2585. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2586. /**
  2587. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2588. * Check if is non uniform within a certain amount of decimal places to account for this
  2589. * @param epsilon the amount the values can differ
  2590. * @returns if the the vector is non uniform to a certain number of decimal places
  2591. */
  2592. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2593. /**
  2594. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2595. */
  2596. get isNonUniform(): boolean;
  2597. /**
  2598. * Gets a new Vector3 from current Vector3 floored values
  2599. * @returns a new Vector3
  2600. */
  2601. floor(): Vector3;
  2602. /**
  2603. * Gets a new Vector3 from current Vector3 floored values
  2604. * @returns a new Vector3
  2605. */
  2606. fract(): Vector3;
  2607. /**
  2608. * Gets the length of the Vector3
  2609. * @returns the length of the Vector3
  2610. */
  2611. length(): number;
  2612. /**
  2613. * Gets the squared length of the Vector3
  2614. * @returns squared length of the Vector3
  2615. */
  2616. lengthSquared(): number;
  2617. /**
  2618. * Normalize the current Vector3.
  2619. * Please note that this is an in place operation.
  2620. * @returns the current updated Vector3
  2621. */
  2622. normalize(): Vector3;
  2623. /**
  2624. * Reorders the x y z properties of the vector in place
  2625. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2626. * @returns the current updated vector
  2627. */
  2628. reorderInPlace(order: string): this;
  2629. /**
  2630. * Rotates the vector around 0,0,0 by a quaternion
  2631. * @param quaternion the rotation quaternion
  2632. * @param result vector to store the result
  2633. * @returns the resulting vector
  2634. */
  2635. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2636. /**
  2637. * Rotates a vector around a given point
  2638. * @param quaternion the rotation quaternion
  2639. * @param point the point to rotate around
  2640. * @param result vector to store the result
  2641. * @returns the resulting vector
  2642. */
  2643. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2644. /**
  2645. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2646. * The cross product is then orthogonal to both current and "other"
  2647. * @param other defines the right operand
  2648. * @returns the cross product
  2649. */
  2650. cross(other: Vector3): Vector3;
  2651. /**
  2652. * Normalize the current Vector3 with the given input length.
  2653. * Please note that this is an in place operation.
  2654. * @param len the length of the vector
  2655. * @returns the current updated Vector3
  2656. */
  2657. normalizeFromLength(len: number): Vector3;
  2658. /**
  2659. * Normalize the current Vector3 to a new vector
  2660. * @returns the new Vector3
  2661. */
  2662. normalizeToNew(): Vector3;
  2663. /**
  2664. * Normalize the current Vector3 to the reference
  2665. * @param reference define the Vector3 to update
  2666. * @returns the updated Vector3
  2667. */
  2668. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2669. /**
  2670. * Creates a new Vector3 copied from the current Vector3
  2671. * @returns the new Vector3
  2672. */
  2673. clone(): Vector3;
  2674. /**
  2675. * Copies the given vector coordinates to the current Vector3 ones
  2676. * @param source defines the source Vector3
  2677. * @returns the current updated Vector3
  2678. */
  2679. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2680. /**
  2681. * Copies the given floats to the current Vector3 coordinates
  2682. * @param x defines the x coordinate of the operand
  2683. * @param y defines the y coordinate of the operand
  2684. * @param z defines the z coordinate of the operand
  2685. * @returns the current updated Vector3
  2686. */
  2687. copyFromFloats(x: number, y: number, z: number): Vector3;
  2688. /**
  2689. * Copies the given floats to the current Vector3 coordinates
  2690. * @param x defines the x coordinate of the operand
  2691. * @param y defines the y coordinate of the operand
  2692. * @param z defines the z coordinate of the operand
  2693. * @returns the current updated Vector3
  2694. */
  2695. set(x: number, y: number, z: number): Vector3;
  2696. /**
  2697. * Copies the given float to the current Vector3 coordinates
  2698. * @param v defines the x, y and z coordinates of the operand
  2699. * @returns the current updated Vector3
  2700. */
  2701. setAll(v: number): Vector3;
  2702. /**
  2703. * Get the clip factor between two vectors
  2704. * @param vector0 defines the first operand
  2705. * @param vector1 defines the second operand
  2706. * @param axis defines the axis to use
  2707. * @param size defines the size along the axis
  2708. * @returns the clip factor
  2709. */
  2710. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2711. /**
  2712. * Get angle between two vectors
  2713. * @param vector0 angle between vector0 and vector1
  2714. * @param vector1 angle between vector0 and vector1
  2715. * @param normal direction of the normal
  2716. * @return the angle between vector0 and vector1
  2717. */
  2718. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2719. /**
  2720. * Returns a new Vector3 set from the index "offset" of the given array
  2721. * @param array defines the source array
  2722. * @param offset defines the offset in the source array
  2723. * @returns the new Vector3
  2724. */
  2725. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2726. /**
  2727. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2728. * @param array defines the source array
  2729. * @param offset defines the offset in the source array
  2730. * @returns the new Vector3
  2731. * @deprecated Please use FromArray instead.
  2732. */
  2733. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2734. /**
  2735. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2736. * @param array defines the source array
  2737. * @param offset defines the offset in the source array
  2738. * @param result defines the Vector3 where to store the result
  2739. */
  2740. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2741. /**
  2742. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2743. * @param array defines the source array
  2744. * @param offset defines the offset in the source array
  2745. * @param result defines the Vector3 where to store the result
  2746. * @deprecated Please use FromArrayToRef instead.
  2747. */
  2748. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2749. /**
  2750. * Sets the given vector "result" with the given floats.
  2751. * @param x defines the x coordinate of the source
  2752. * @param y defines the y coordinate of the source
  2753. * @param z defines the z coordinate of the source
  2754. * @param result defines the Vector3 where to store the result
  2755. */
  2756. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2759. * @returns a new empty Vector3
  2760. */
  2761. static Zero(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2764. * @returns a new unit Vector3
  2765. */
  2766. static One(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2769. * @returns a new up Vector3
  2770. */
  2771. static Up(): Vector3;
  2772. /**
  2773. * Gets a up Vector3 that must not be updated
  2774. */
  2775. static get UpReadOnly(): DeepImmutable<Vector3>;
  2776. /**
  2777. * Gets a zero Vector3 that must not be updated
  2778. */
  2779. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2780. /**
  2781. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2782. * @returns a new down Vector3
  2783. */
  2784. static Down(): Vector3;
  2785. /**
  2786. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2787. * @returns a new forward Vector3
  2788. */
  2789. static Forward(): Vector3;
  2790. /**
  2791. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2792. * @returns a new forward Vector3
  2793. */
  2794. static Backward(): Vector3;
  2795. /**
  2796. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2797. * @returns a new right Vector3
  2798. */
  2799. static Right(): Vector3;
  2800. /**
  2801. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2802. * @returns a new left Vector3
  2803. */
  2804. static Left(): Vector3;
  2805. /**
  2806. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2807. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2808. * @param vector defines the Vector3 to transform
  2809. * @param transformation defines the transformation matrix
  2810. * @returns the transformed Vector3
  2811. */
  2812. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2813. /**
  2814. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2815. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2816. * @param vector defines the Vector3 to transform
  2817. * @param transformation defines the transformation matrix
  2818. * @param result defines the Vector3 where to store the result
  2819. */
  2820. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2821. /**
  2822. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2823. * This method computes tranformed coordinates only, not transformed direction vectors
  2824. * @param x define the x coordinate of the source vector
  2825. * @param y define the y coordinate of the source vector
  2826. * @param z define the z coordinate of the source vector
  2827. * @param transformation defines the transformation matrix
  2828. * @param result defines the Vector3 where to store the result
  2829. */
  2830. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2831. /**
  2832. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2833. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2834. * @param vector defines the Vector3 to transform
  2835. * @param transformation defines the transformation matrix
  2836. * @returns the new Vector3
  2837. */
  2838. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2839. /**
  2840. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2841. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2842. * @param vector defines the Vector3 to transform
  2843. * @param transformation defines the transformation matrix
  2844. * @param result defines the Vector3 where to store the result
  2845. */
  2846. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2847. /**
  2848. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2849. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2850. * @param x define the x coordinate of the source vector
  2851. * @param y define the y coordinate of the source vector
  2852. * @param z define the z coordinate of the source vector
  2853. * @param transformation defines the transformation matrix
  2854. * @param result defines the Vector3 where to store the result
  2855. */
  2856. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2857. /**
  2858. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2859. * @param value1 defines the first control point
  2860. * @param value2 defines the second control point
  2861. * @param value3 defines the third control point
  2862. * @param value4 defines the fourth control point
  2863. * @param amount defines the amount on the spline to use
  2864. * @returns the new Vector3
  2865. */
  2866. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2867. /**
  2868. * 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"
  2869. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2870. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2871. * @param value defines the current value
  2872. * @param min defines the lower range value
  2873. * @param max defines the upper range value
  2874. * @returns the new Vector3
  2875. */
  2876. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2877. /**
  2878. * 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"
  2879. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2880. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2881. * @param value defines the current value
  2882. * @param min defines the lower range value
  2883. * @param max defines the upper range value
  2884. * @param result defines the Vector3 where to store the result
  2885. */
  2886. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2887. /**
  2888. * Checks if a given vector is inside a specific range
  2889. * @param v defines the vector to test
  2890. * @param min defines the minimum range
  2891. * @param max defines the maximum range
  2892. */
  2893. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2894. /**
  2895. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2896. * @param value1 defines the first control point
  2897. * @param tangent1 defines the first tangent vector
  2898. * @param value2 defines the second control point
  2899. * @param tangent2 defines the second tangent vector
  2900. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2901. * @returns the new Vector3
  2902. */
  2903. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2904. /**
  2905. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2906. * @param start defines the start value
  2907. * @param end defines the end value
  2908. * @param amount max defines amount between both (between 0 and 1)
  2909. * @returns the new Vector3
  2910. */
  2911. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2912. /**
  2913. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2914. * @param start defines the start value
  2915. * @param end defines the end value
  2916. * @param amount max defines amount between both (between 0 and 1)
  2917. * @param result defines the Vector3 where to store the result
  2918. */
  2919. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2920. /**
  2921. * Returns the dot product (float) between the vectors "left" and "right"
  2922. * @param left defines the left operand
  2923. * @param right defines the right operand
  2924. * @returns the dot product
  2925. */
  2926. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2927. /**
  2928. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2929. * The cross product is then orthogonal to both "left" and "right"
  2930. * @param left defines the left operand
  2931. * @param right defines the right operand
  2932. * @returns the cross product
  2933. */
  2934. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2935. /**
  2936. * Sets the given vector "result" with the cross product of "left" and "right"
  2937. * The cross product is then orthogonal to both "left" and "right"
  2938. * @param left defines the left operand
  2939. * @param right defines the right operand
  2940. * @param result defines the Vector3 where to store the result
  2941. */
  2942. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2943. /**
  2944. * Returns a new Vector3 as the normalization of the given vector
  2945. * @param vector defines the Vector3 to normalize
  2946. * @returns the new Vector3
  2947. */
  2948. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2949. /**
  2950. * Sets the given vector "result" with the normalization of the given first vector
  2951. * @param vector defines the Vector3 to normalize
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2955. /**
  2956. * Project a Vector3 onto screen space
  2957. * @param vector defines the Vector3 to project
  2958. * @param world defines the world matrix to use
  2959. * @param transform defines the transform (view x projection) matrix to use
  2960. * @param viewport defines the screen viewport to use
  2961. * @returns the new Vector3
  2962. */
  2963. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2964. /** @hidden */
  2965. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Unproject from screen space to object space
  2968. * @param source defines the screen space Vector3 to use
  2969. * @param viewportWidth defines the current width of the viewport
  2970. * @param viewportHeight defines the current height of the viewport
  2971. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2972. * @param transform defines the transform (view x projection) matrix to use
  2973. * @returns the new Vector3
  2974. */
  2975. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2976. /**
  2977. * Unproject from screen space to object space
  2978. * @param source defines the screen space Vector3 to use
  2979. * @param viewportWidth defines the current width of the viewport
  2980. * @param viewportHeight defines the current height of the viewport
  2981. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2982. * @param view defines the view matrix to use
  2983. * @param projection defines the projection matrix to use
  2984. * @returns the new Vector3
  2985. */
  2986. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2987. /**
  2988. * Unproject from screen space to object space
  2989. * @param source defines the screen space Vector3 to use
  2990. * @param viewportWidth defines the current width of the viewport
  2991. * @param viewportHeight defines the current height of the viewport
  2992. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2993. * @param view defines the view matrix to use
  2994. * @param projection defines the projection matrix to use
  2995. * @param result defines the Vector3 where to store the result
  2996. */
  2997. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2998. /**
  2999. * Unproject from screen space to object space
  3000. * @param sourceX defines the screen space x coordinate to use
  3001. * @param sourceY defines the screen space y coordinate to use
  3002. * @param sourceZ defines the screen space z coordinate to use
  3003. * @param viewportWidth defines the current width of the viewport
  3004. * @param viewportHeight defines the current height of the viewport
  3005. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3006. * @param view defines the view matrix to use
  3007. * @param projection defines the projection matrix to use
  3008. * @param result defines the Vector3 where to store the result
  3009. */
  3010. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3011. /**
  3012. * Gets the minimal coordinate values between two Vector3
  3013. * @param left defines the first operand
  3014. * @param right defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Gets the maximal coordinate values between two Vector3
  3020. * @param left defines the first operand
  3021. * @param right defines the second operand
  3022. * @returns the new Vector3
  3023. */
  3024. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3025. /**
  3026. * Returns the distance between the vectors "value1" and "value2"
  3027. * @param value1 defines the first operand
  3028. * @param value2 defines the second operand
  3029. * @returns the distance
  3030. */
  3031. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3032. /**
  3033. * Returns the squared distance between the vectors "value1" and "value2"
  3034. * @param value1 defines the first operand
  3035. * @param value2 defines the second operand
  3036. * @returns the squared distance
  3037. */
  3038. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3039. /**
  3040. * Returns a new Vector3 located at the center between "value1" and "value2"
  3041. * @param value1 defines the first operand
  3042. * @param value2 defines the second operand
  3043. * @returns the new Vector3
  3044. */
  3045. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3046. /**
  3047. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3048. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3049. * to something in order to rotate it from its local system to the given target system
  3050. * Note: axis1, axis2 and axis3 are normalized during this operation
  3051. * @param axis1 defines the first axis
  3052. * @param axis2 defines the second axis
  3053. * @param axis3 defines the third axis
  3054. * @returns a new Vector3
  3055. */
  3056. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3057. /**
  3058. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3059. * @param axis1 defines the first axis
  3060. * @param axis2 defines the second axis
  3061. * @param axis3 defines the third axis
  3062. * @param ref defines the Vector3 where to store the result
  3063. */
  3064. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3065. }
  3066. /**
  3067. * Vector4 class created for EulerAngle class conversion to Quaternion
  3068. */
  3069. export class Vector4 {
  3070. /** x value of the vector */
  3071. x: number;
  3072. /** y value of the vector */
  3073. y: number;
  3074. /** z value of the vector */
  3075. z: number;
  3076. /** w value of the vector */
  3077. w: number;
  3078. /**
  3079. * Creates a Vector4 object from the given floats.
  3080. * @param x x value of the vector
  3081. * @param y y value of the vector
  3082. * @param z z value of the vector
  3083. * @param w w value of the vector
  3084. */
  3085. constructor(
  3086. /** x value of the vector */
  3087. x: number,
  3088. /** y value of the vector */
  3089. y: number,
  3090. /** z value of the vector */
  3091. z: number,
  3092. /** w value of the vector */
  3093. w: number);
  3094. /**
  3095. * Returns the string with the Vector4 coordinates.
  3096. * @returns a string containing all the vector values
  3097. */
  3098. toString(): string;
  3099. /**
  3100. * Returns the string "Vector4".
  3101. * @returns "Vector4"
  3102. */
  3103. getClassName(): string;
  3104. /**
  3105. * Returns the Vector4 hash code.
  3106. * @returns a unique hash code
  3107. */
  3108. getHashCode(): number;
  3109. /**
  3110. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3111. * @returns the resulting array
  3112. */
  3113. asArray(): number[];
  3114. /**
  3115. * Populates the given array from the given index with the Vector4 coordinates.
  3116. * @param array array to populate
  3117. * @param index index of the array to start at (default: 0)
  3118. * @returns the Vector4.
  3119. */
  3120. toArray(array: FloatArray, index?: number): Vector4;
  3121. /**
  3122. * Adds the given vector to the current Vector4.
  3123. * @param otherVector the vector to add
  3124. * @returns the updated Vector4.
  3125. */
  3126. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3127. /**
  3128. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3129. * @param otherVector the vector to add
  3130. * @returns the resulting vector
  3131. */
  3132. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3133. /**
  3134. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3135. * @param otherVector the vector to add
  3136. * @param result the vector to store the result
  3137. * @returns the current Vector4.
  3138. */
  3139. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3140. /**
  3141. * Subtract in place the given vector from the current Vector4.
  3142. * @param otherVector the vector to subtract
  3143. * @returns the updated Vector4.
  3144. */
  3145. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3146. /**
  3147. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3148. * @param otherVector the vector to add
  3149. * @returns the new vector with the result
  3150. */
  3151. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3152. /**
  3153. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3154. * @param otherVector the vector to subtract
  3155. * @param result the vector to store the result
  3156. * @returns the current Vector4.
  3157. */
  3158. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3159. /**
  3160. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3161. */
  3162. /**
  3163. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3164. * @param x value to subtract
  3165. * @param y value to subtract
  3166. * @param z value to subtract
  3167. * @param w value to subtract
  3168. * @returns new vector containing the result
  3169. */
  3170. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3171. /**
  3172. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3173. * @param x value to subtract
  3174. * @param y value to subtract
  3175. * @param z value to subtract
  3176. * @param w value to subtract
  3177. * @param result the vector to store the result in
  3178. * @returns the current Vector4.
  3179. */
  3180. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3181. /**
  3182. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3183. * @returns a new vector with the negated values
  3184. */
  3185. negate(): Vector4;
  3186. /**
  3187. * Multiplies the current Vector4 coordinates by scale (float).
  3188. * @param scale the number to scale with
  3189. * @returns the updated Vector4.
  3190. */
  3191. scaleInPlace(scale: number): Vector4;
  3192. /**
  3193. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3194. * @param scale the number to scale with
  3195. * @returns a new vector with the result
  3196. */
  3197. scale(scale: number): Vector4;
  3198. /**
  3199. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3200. * @param scale the number to scale with
  3201. * @param result a vector to store the result in
  3202. * @returns the current Vector4.
  3203. */
  3204. scaleToRef(scale: number, result: Vector4): Vector4;
  3205. /**
  3206. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3207. * @param scale defines the scale factor
  3208. * @param result defines the Vector4 object where to store the result
  3209. * @returns the unmodified current Vector4
  3210. */
  3211. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3212. /**
  3213. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3214. * @param otherVector the vector to compare against
  3215. * @returns true if they are equal
  3216. */
  3217. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3218. /**
  3219. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3220. * @param otherVector vector to compare against
  3221. * @param epsilon (Default: very small number)
  3222. * @returns true if they are equal
  3223. */
  3224. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3225. /**
  3226. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3227. * @param x x value to compare against
  3228. * @param y y value to compare against
  3229. * @param z z value to compare against
  3230. * @param w w value to compare against
  3231. * @returns true if equal
  3232. */
  3233. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3234. /**
  3235. * Multiplies in place the current Vector4 by the given one.
  3236. * @param otherVector vector to multiple with
  3237. * @returns the updated Vector4.
  3238. */
  3239. multiplyInPlace(otherVector: Vector4): Vector4;
  3240. /**
  3241. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3242. * @param otherVector vector to multiple with
  3243. * @returns resulting new vector
  3244. */
  3245. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3246. /**
  3247. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3248. * @param otherVector vector to multiple with
  3249. * @param result vector to store the result
  3250. * @returns the current Vector4.
  3251. */
  3252. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3253. /**
  3254. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3255. * @param x x value multiply with
  3256. * @param y y value multiply with
  3257. * @param z z value multiply with
  3258. * @param w w value multiply with
  3259. * @returns resulting new vector
  3260. */
  3261. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3262. /**
  3263. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3264. * @param otherVector vector to devide with
  3265. * @returns resulting new vector
  3266. */
  3267. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3268. /**
  3269. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3270. * @param otherVector vector to devide with
  3271. * @param result vector to store the result
  3272. * @returns the current Vector4.
  3273. */
  3274. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3275. /**
  3276. * Divides the current Vector3 coordinates by the given ones.
  3277. * @param otherVector vector to devide with
  3278. * @returns the updated Vector3.
  3279. */
  3280. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3281. /**
  3282. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3283. * @param other defines the second operand
  3284. * @returns the current updated Vector4
  3285. */
  3286. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3287. /**
  3288. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3289. * @param other defines the second operand
  3290. * @returns the current updated Vector4
  3291. */
  3292. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3293. /**
  3294. * Gets a new Vector4 from current Vector4 floored values
  3295. * @returns a new Vector4
  3296. */
  3297. floor(): Vector4;
  3298. /**
  3299. * Gets a new Vector4 from current Vector3 floored values
  3300. * @returns a new Vector4
  3301. */
  3302. fract(): Vector4;
  3303. /**
  3304. * Returns the Vector4 length (float).
  3305. * @returns the length
  3306. */
  3307. length(): number;
  3308. /**
  3309. * Returns the Vector4 squared length (float).
  3310. * @returns the length squared
  3311. */
  3312. lengthSquared(): number;
  3313. /**
  3314. * Normalizes in place the Vector4.
  3315. * @returns the updated Vector4.
  3316. */
  3317. normalize(): Vector4;
  3318. /**
  3319. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3320. * @returns this converted to a new vector3
  3321. */
  3322. toVector3(): Vector3;
  3323. /**
  3324. * Returns a new Vector4 copied from the current one.
  3325. * @returns the new cloned vector
  3326. */
  3327. clone(): Vector4;
  3328. /**
  3329. * Updates the current Vector4 with the given one coordinates.
  3330. * @param source the source vector to copy from
  3331. * @returns the updated Vector4.
  3332. */
  3333. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Updates the current Vector4 coordinates with the given floats.
  3336. * @param x float to copy from
  3337. * @param y float to copy from
  3338. * @param z float to copy from
  3339. * @param w float to copy from
  3340. * @returns the updated Vector4.
  3341. */
  3342. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3343. /**
  3344. * Updates the current Vector4 coordinates with the given floats.
  3345. * @param x float to set from
  3346. * @param y float to set from
  3347. * @param z float to set from
  3348. * @param w float to set from
  3349. * @returns the updated Vector4.
  3350. */
  3351. set(x: number, y: number, z: number, w: number): Vector4;
  3352. /**
  3353. * Copies the given float to the current Vector3 coordinates
  3354. * @param v defines the x, y, z and w coordinates of the operand
  3355. * @returns the current updated Vector3
  3356. */
  3357. setAll(v: number): Vector4;
  3358. /**
  3359. * Returns a new Vector4 set from the starting index of the given array.
  3360. * @param array the array to pull values from
  3361. * @param offset the offset into the array to start at
  3362. * @returns the new vector
  3363. */
  3364. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3365. /**
  3366. * Updates the given vector "result" from the starting index of the given array.
  3367. * @param array the array to pull values from
  3368. * @param offset the offset into the array to start at
  3369. * @param result the vector to store the result in
  3370. */
  3371. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3372. /**
  3373. * Updates the given vector "result" from the starting index of the given Float32Array.
  3374. * @param array the array to pull values from
  3375. * @param offset the offset into the array to start at
  3376. * @param result the vector to store the result in
  3377. */
  3378. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3379. /**
  3380. * Updates the given vector "result" coordinates from the given floats.
  3381. * @param x float to set from
  3382. * @param y float to set from
  3383. * @param z float to set from
  3384. * @param w float to set from
  3385. * @param result the vector to the floats in
  3386. */
  3387. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3388. /**
  3389. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3390. * @returns the new vector
  3391. */
  3392. static Zero(): Vector4;
  3393. /**
  3394. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3395. * @returns the new vector
  3396. */
  3397. static One(): Vector4;
  3398. /**
  3399. * Returns a new normalized Vector4 from the given one.
  3400. * @param vector the vector to normalize
  3401. * @returns the vector
  3402. */
  3403. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3404. /**
  3405. * Updates the given vector "result" from the normalization of the given one.
  3406. * @param vector the vector to normalize
  3407. * @param result the vector to store the result in
  3408. */
  3409. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3410. /**
  3411. * Returns a vector with the minimum values from the left and right vectors
  3412. * @param left left vector to minimize
  3413. * @param right right vector to minimize
  3414. * @returns a new vector with the minimum of the left and right vector values
  3415. */
  3416. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3417. /**
  3418. * Returns a vector with the maximum values from the left and right vectors
  3419. * @param left left vector to maximize
  3420. * @param right right vector to maximize
  3421. * @returns a new vector with the maximum of the left and right vector values
  3422. */
  3423. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3424. /**
  3425. * Returns the distance (float) between the vectors "value1" and "value2".
  3426. * @param value1 value to calulate the distance between
  3427. * @param value2 value to calulate the distance between
  3428. * @return the distance between the two vectors
  3429. */
  3430. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3431. /**
  3432. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3433. * @param value1 value to calulate the distance between
  3434. * @param value2 value to calulate the distance between
  3435. * @return the distance between the two vectors squared
  3436. */
  3437. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3438. /**
  3439. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3440. * @param value1 value to calulate the center between
  3441. * @param value2 value to calulate the center between
  3442. * @return the center between the two vectors
  3443. */
  3444. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3445. /**
  3446. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3447. * This methods computes transformed normalized direction vectors only.
  3448. * @param vector the vector to transform
  3449. * @param transformation the transformation matrix to apply
  3450. * @returns the new vector
  3451. */
  3452. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3453. /**
  3454. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3455. * This methods computes transformed normalized direction vectors only.
  3456. * @param vector the vector to transform
  3457. * @param transformation the transformation matrix to apply
  3458. * @param result the vector to store the result in
  3459. */
  3460. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3461. /**
  3462. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3463. * This methods computes transformed normalized direction vectors only.
  3464. * @param x value to transform
  3465. * @param y value to transform
  3466. * @param z value to transform
  3467. * @param w value to transform
  3468. * @param transformation the transformation matrix to apply
  3469. * @param result the vector to store the results in
  3470. */
  3471. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3472. /**
  3473. * Creates a new Vector4 from a Vector3
  3474. * @param source defines the source data
  3475. * @param w defines the 4th component (default is 0)
  3476. * @returns a new Vector4
  3477. */
  3478. static FromVector3(source: Vector3, w?: number): Vector4;
  3479. }
  3480. /**
  3481. * Class used to store quaternion data
  3482. * @see https://en.wikipedia.org/wiki/Quaternion
  3483. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3484. */
  3485. export class Quaternion {
  3486. /** defines the first component (0 by default) */
  3487. x: number;
  3488. /** defines the second component (0 by default) */
  3489. y: number;
  3490. /** defines the third component (0 by default) */
  3491. z: number;
  3492. /** defines the fourth component (1.0 by default) */
  3493. w: number;
  3494. /**
  3495. * Creates a new Quaternion from the given floats
  3496. * @param x defines the first component (0 by default)
  3497. * @param y defines the second component (0 by default)
  3498. * @param z defines the third component (0 by default)
  3499. * @param w defines the fourth component (1.0 by default)
  3500. */
  3501. constructor(
  3502. /** defines the first component (0 by default) */
  3503. x?: number,
  3504. /** defines the second component (0 by default) */
  3505. y?: number,
  3506. /** defines the third component (0 by default) */
  3507. z?: number,
  3508. /** defines the fourth component (1.0 by default) */
  3509. w?: number);
  3510. /**
  3511. * Gets a string representation for the current quaternion
  3512. * @returns a string with the Quaternion coordinates
  3513. */
  3514. toString(): string;
  3515. /**
  3516. * Gets the class name of the quaternion
  3517. * @returns the string "Quaternion"
  3518. */
  3519. getClassName(): string;
  3520. /**
  3521. * Gets a hash code for this quaternion
  3522. * @returns the quaternion hash code
  3523. */
  3524. getHashCode(): number;
  3525. /**
  3526. * Copy the quaternion to an array
  3527. * @returns a new array populated with 4 elements from the quaternion coordinates
  3528. */
  3529. asArray(): number[];
  3530. /**
  3531. * Check if two quaternions are equals
  3532. * @param otherQuaternion defines the second operand
  3533. * @return true if the current quaternion and the given one coordinates are strictly equals
  3534. */
  3535. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3536. /**
  3537. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3538. * @param otherQuaternion defines the other quaternion
  3539. * @param epsilon defines the minimal distance to consider equality
  3540. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3541. */
  3542. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3543. /**
  3544. * Clone the current quaternion
  3545. * @returns a new quaternion copied from the current one
  3546. */
  3547. clone(): Quaternion;
  3548. /**
  3549. * Copy a quaternion to the current one
  3550. * @param other defines the other quaternion
  3551. * @returns the updated current quaternion
  3552. */
  3553. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3554. /**
  3555. * Updates the current quaternion with the given float coordinates
  3556. * @param x defines the x coordinate
  3557. * @param y defines the y coordinate
  3558. * @param z defines the z coordinate
  3559. * @param w defines the w coordinate
  3560. * @returns the updated current quaternion
  3561. */
  3562. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3563. /**
  3564. * Updates the current quaternion from the given float coordinates
  3565. * @param x defines the x coordinate
  3566. * @param y defines the y coordinate
  3567. * @param z defines the z coordinate
  3568. * @param w defines the w coordinate
  3569. * @returns the updated current quaternion
  3570. */
  3571. set(x: number, y: number, z: number, w: number): Quaternion;
  3572. /**
  3573. * Adds two quaternions
  3574. * @param other defines the second operand
  3575. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3576. */
  3577. add(other: DeepImmutable<Quaternion>): Quaternion;
  3578. /**
  3579. * Add a quaternion to the current one
  3580. * @param other defines the quaternion to add
  3581. * @returns the current quaternion
  3582. */
  3583. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3584. /**
  3585. * Subtract two quaternions
  3586. * @param other defines the second operand
  3587. * @returns a new quaternion as the subtraction result of the given one from the current one
  3588. */
  3589. subtract(other: Quaternion): Quaternion;
  3590. /**
  3591. * Multiplies the current quaternion by a scale factor
  3592. * @param value defines the scale factor
  3593. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3594. */
  3595. scale(value: number): Quaternion;
  3596. /**
  3597. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3598. * @param scale defines the scale factor
  3599. * @param result defines the Quaternion object where to store the result
  3600. * @returns the unmodified current quaternion
  3601. */
  3602. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3603. /**
  3604. * Multiplies in place the current quaternion by a scale factor
  3605. * @param value defines the scale factor
  3606. * @returns the current modified quaternion
  3607. */
  3608. scaleInPlace(value: number): Quaternion;
  3609. /**
  3610. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3611. * @param scale defines the scale factor
  3612. * @param result defines the Quaternion object where to store the result
  3613. * @returns the unmodified current quaternion
  3614. */
  3615. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3616. /**
  3617. * Multiplies two quaternions
  3618. * @param q1 defines the second operand
  3619. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3620. */
  3621. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3622. /**
  3623. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3624. * @param q1 defines the second operand
  3625. * @param result defines the target quaternion
  3626. * @returns the current quaternion
  3627. */
  3628. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3629. /**
  3630. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3631. * @param q1 defines the second operand
  3632. * @returns the currentupdated quaternion
  3633. */
  3634. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3635. /**
  3636. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3637. * @param ref defines the target quaternion
  3638. * @returns the current quaternion
  3639. */
  3640. conjugateToRef(ref: Quaternion): Quaternion;
  3641. /**
  3642. * Conjugates in place (1-q) the current quaternion
  3643. * @returns the current updated quaternion
  3644. */
  3645. conjugateInPlace(): Quaternion;
  3646. /**
  3647. * Conjugates in place (1-q) the current quaternion
  3648. * @returns a new quaternion
  3649. */
  3650. conjugate(): Quaternion;
  3651. /**
  3652. * Gets length of current quaternion
  3653. * @returns the quaternion length (float)
  3654. */
  3655. length(): number;
  3656. /**
  3657. * Normalize in place the current quaternion
  3658. * @returns the current updated quaternion
  3659. */
  3660. normalize(): Quaternion;
  3661. /**
  3662. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3663. * @param order is a reserved parameter and is ignore for now
  3664. * @returns a new Vector3 containing the Euler angles
  3665. */
  3666. toEulerAngles(order?: string): Vector3;
  3667. /**
  3668. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3669. * @param result defines the vector which will be filled with the Euler angles
  3670. * @param order is a reserved parameter and is ignore for now
  3671. * @returns the current unchanged quaternion
  3672. */
  3673. toEulerAnglesToRef(result: Vector3): Quaternion;
  3674. /**
  3675. * Updates the given rotation matrix with the current quaternion values
  3676. * @param result defines the target matrix
  3677. * @returns the current unchanged quaternion
  3678. */
  3679. toRotationMatrix(result: Matrix): Quaternion;
  3680. /**
  3681. * Updates the current quaternion from the given rotation matrix values
  3682. * @param matrix defines the source matrix
  3683. * @returns the current updated quaternion
  3684. */
  3685. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3686. /**
  3687. * Creates a new quaternion from a rotation matrix
  3688. * @param matrix defines the source matrix
  3689. * @returns a new quaternion created from the given rotation matrix values
  3690. */
  3691. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3692. /**
  3693. * Updates the given quaternion with the given rotation matrix values
  3694. * @param matrix defines the source matrix
  3695. * @param result defines the target quaternion
  3696. */
  3697. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3698. /**
  3699. * Returns the dot product (float) between the quaternions "left" and "right"
  3700. * @param left defines the left operand
  3701. * @param right defines the right operand
  3702. * @returns the dot product
  3703. */
  3704. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3705. /**
  3706. * Checks if the two quaternions are close to each other
  3707. * @param quat0 defines the first quaternion to check
  3708. * @param quat1 defines the second quaternion to check
  3709. * @returns true if the two quaternions are close to each other
  3710. */
  3711. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3712. /**
  3713. * Creates an empty quaternion
  3714. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3715. */
  3716. static Zero(): Quaternion;
  3717. /**
  3718. * Inverse a given quaternion
  3719. * @param q defines the source quaternion
  3720. * @returns a new quaternion as the inverted current quaternion
  3721. */
  3722. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Inverse a given quaternion
  3725. * @param q defines the source quaternion
  3726. * @param result the quaternion the result will be stored in
  3727. * @returns the result quaternion
  3728. */
  3729. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3730. /**
  3731. * Creates an identity quaternion
  3732. * @returns the identity quaternion
  3733. */
  3734. static Identity(): Quaternion;
  3735. /**
  3736. * Gets a boolean indicating if the given quaternion is identity
  3737. * @param quaternion defines the quaternion to check
  3738. * @returns true if the quaternion is identity
  3739. */
  3740. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3741. /**
  3742. * Creates a quaternion from a rotation around an axis
  3743. * @param axis defines the axis to use
  3744. * @param angle defines the angle to use
  3745. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3746. */
  3747. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3748. /**
  3749. * Creates a rotation around an axis and stores it into the given quaternion
  3750. * @param axis defines the axis to use
  3751. * @param angle defines the angle to use
  3752. * @param result defines the target quaternion
  3753. * @returns the target quaternion
  3754. */
  3755. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3756. /**
  3757. * Creates a new quaternion from data stored into an array
  3758. * @param array defines the data source
  3759. * @param offset defines the offset in the source array where the data starts
  3760. * @returns a new quaternion
  3761. */
  3762. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation angles
  3765. * @param x Pitch
  3766. * @param y Yaw
  3767. * @param z Roll
  3768. * @returns the new Quaternion
  3769. */
  3770. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3771. /**
  3772. * Updates a quaternion from Euler rotation angles
  3773. * @param x Pitch
  3774. * @param y Yaw
  3775. * @param z Roll
  3776. * @param result the quaternion to store the result
  3777. * @returns the updated quaternion
  3778. */
  3779. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3780. /**
  3781. * Create a quaternion from Euler rotation vector
  3782. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3783. * @returns the new Quaternion
  3784. */
  3785. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3786. /**
  3787. * Updates a quaternion from Euler rotation vector
  3788. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3789. * @param result the quaternion to store the result
  3790. * @returns the updated quaternion
  3791. */
  3792. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3793. /**
  3794. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3795. * @param yaw defines the rotation around Y axis
  3796. * @param pitch defines the rotation around X axis
  3797. * @param roll defines the rotation around Z axis
  3798. * @returns the new quaternion
  3799. */
  3800. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3801. /**
  3802. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3803. * @param yaw defines the rotation around Y axis
  3804. * @param pitch defines the rotation around X axis
  3805. * @param roll defines the rotation around Z axis
  3806. * @param result defines the target quaternion
  3807. */
  3808. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3811. * @param alpha defines the rotation around first axis
  3812. * @param beta defines the rotation around second axis
  3813. * @param gamma defines the rotation around third axis
  3814. * @returns the new quaternion
  3815. */
  3816. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3817. /**
  3818. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3819. * @param alpha defines the rotation around first axis
  3820. * @param beta defines the rotation around second axis
  3821. * @param gamma defines the rotation around third axis
  3822. * @param result defines the target quaternion
  3823. */
  3824. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3825. /**
  3826. * 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)
  3827. * @param axis1 defines the first axis
  3828. * @param axis2 defines the second axis
  3829. * @param axis3 defines the third axis
  3830. * @returns the new quaternion
  3831. */
  3832. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3833. /**
  3834. * 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
  3835. * @param axis1 defines the first axis
  3836. * @param axis2 defines the second axis
  3837. * @param axis3 defines the third axis
  3838. * @param ref defines the target quaternion
  3839. */
  3840. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3841. /**
  3842. * Interpolates between two quaternions
  3843. * @param left defines first quaternion
  3844. * @param right defines second quaternion
  3845. * @param amount defines the gradient to use
  3846. * @returns the new interpolated quaternion
  3847. */
  3848. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3849. /**
  3850. * Interpolates between two quaternions and stores it into a target quaternion
  3851. * @param left defines first quaternion
  3852. * @param right defines second quaternion
  3853. * @param amount defines the gradient to use
  3854. * @param result defines the target quaternion
  3855. */
  3856. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3857. /**
  3858. * Interpolate between two quaternions using Hermite interpolation
  3859. * @param value1 defines first quaternion
  3860. * @param tangent1 defines the incoming tangent
  3861. * @param value2 defines second quaternion
  3862. * @param tangent2 defines the outgoing tangent
  3863. * @param amount defines the target quaternion
  3864. * @returns the new interpolated quaternion
  3865. */
  3866. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3867. }
  3868. /**
  3869. * Class used to store matrix data (4x4)
  3870. */
  3871. export class Matrix {
  3872. private static _updateFlagSeed;
  3873. private static _identityReadOnly;
  3874. private _isIdentity;
  3875. private _isIdentityDirty;
  3876. private _isIdentity3x2;
  3877. private _isIdentity3x2Dirty;
  3878. /**
  3879. * Gets the update flag of the matrix which is an unique number for the matrix.
  3880. * It will be incremented every time the matrix data change.
  3881. * You can use it to speed the comparison between two versions of the same matrix.
  3882. */
  3883. updateFlag: number;
  3884. private readonly _m;
  3885. /**
  3886. * Gets the internal data of the matrix
  3887. */
  3888. get m(): DeepImmutable<Float32Array>;
  3889. /** @hidden */
  3890. _markAsUpdated(): void;
  3891. /** @hidden */
  3892. private _updateIdentityStatus;
  3893. /**
  3894. * Creates an empty matrix (filled with zeros)
  3895. */
  3896. constructor();
  3897. /**
  3898. * Check if the current matrix is identity
  3899. * @returns true is the matrix is the identity matrix
  3900. */
  3901. isIdentity(): boolean;
  3902. /**
  3903. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3904. * @returns true is the matrix is the identity matrix
  3905. */
  3906. isIdentityAs3x2(): boolean;
  3907. /**
  3908. * Gets the determinant of the matrix
  3909. * @returns the matrix determinant
  3910. */
  3911. determinant(): number;
  3912. /**
  3913. * Returns the matrix as a Float32Array
  3914. * @returns the matrix underlying array
  3915. */
  3916. toArray(): DeepImmutable<Float32Array>;
  3917. /**
  3918. * Returns the matrix as a Float32Array
  3919. * @returns the matrix underlying array.
  3920. */
  3921. asArray(): DeepImmutable<Float32Array>;
  3922. /**
  3923. * Inverts the current matrix in place
  3924. * @returns the current inverted matrix
  3925. */
  3926. invert(): Matrix;
  3927. /**
  3928. * Sets all the matrix elements to zero
  3929. * @returns the current matrix
  3930. */
  3931. reset(): Matrix;
  3932. /**
  3933. * Adds the current matrix with a second one
  3934. * @param other defines the matrix to add
  3935. * @returns a new matrix as the addition of the current matrix and the given one
  3936. */
  3937. add(other: DeepImmutable<Matrix>): Matrix;
  3938. /**
  3939. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3940. * @param other defines the matrix to add
  3941. * @param result defines the target matrix
  3942. * @returns the current matrix
  3943. */
  3944. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3945. /**
  3946. * Adds in place the given matrix to the current matrix
  3947. * @param other defines the second operand
  3948. * @returns the current updated matrix
  3949. */
  3950. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3951. /**
  3952. * Sets the given matrix to the current inverted Matrix
  3953. * @param other defines the target matrix
  3954. * @returns the unmodified current matrix
  3955. */
  3956. invertToRef(other: Matrix): Matrix;
  3957. /**
  3958. * add a value at the specified position in the current Matrix
  3959. * @param index the index of the value within the matrix. between 0 and 15.
  3960. * @param value the value to be added
  3961. * @returns the current updated matrix
  3962. */
  3963. addAtIndex(index: number, value: number): Matrix;
  3964. /**
  3965. * mutiply the specified position in the current Matrix by a value
  3966. * @param index the index of the value within the matrix. between 0 and 15.
  3967. * @param value the value to be added
  3968. * @returns the current updated matrix
  3969. */
  3970. multiplyAtIndex(index: number, value: number): Matrix;
  3971. /**
  3972. * Inserts the translation vector (using 3 floats) in the current matrix
  3973. * @param x defines the 1st component of the translation
  3974. * @param y defines the 2nd component of the translation
  3975. * @param z defines the 3rd component of the translation
  3976. * @returns the current updated matrix
  3977. */
  3978. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3979. /**
  3980. * Adds the translation vector (using 3 floats) in the current matrix
  3981. * @param x defines the 1st component of the translation
  3982. * @param y defines the 2nd component of the translation
  3983. * @param z defines the 3rd component of the translation
  3984. * @returns the current updated matrix
  3985. */
  3986. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3987. /**
  3988. * Inserts the translation vector in the current matrix
  3989. * @param vector3 defines the translation to insert
  3990. * @returns the current updated matrix
  3991. */
  3992. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3993. /**
  3994. * Gets the translation value of the current matrix
  3995. * @returns a new Vector3 as the extracted translation from the matrix
  3996. */
  3997. getTranslation(): Vector3;
  3998. /**
  3999. * Fill a Vector3 with the extracted translation from the matrix
  4000. * @param result defines the Vector3 where to store the translation
  4001. * @returns the current matrix
  4002. */
  4003. getTranslationToRef(result: Vector3): Matrix;
  4004. /**
  4005. * Remove rotation and scaling part from the matrix
  4006. * @returns the updated matrix
  4007. */
  4008. removeRotationAndScaling(): Matrix;
  4009. /**
  4010. * Multiply two matrices
  4011. * @param other defines the second operand
  4012. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4013. */
  4014. multiply(other: DeepImmutable<Matrix>): Matrix;
  4015. /**
  4016. * Copy the current matrix from the given one
  4017. * @param other defines the source matrix
  4018. * @returns the current updated matrix
  4019. */
  4020. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4021. /**
  4022. * Populates the given array from the starting index with the current matrix values
  4023. * @param array defines the target array
  4024. * @param offset defines the offset in the target array where to start storing values
  4025. * @returns the current matrix
  4026. */
  4027. copyToArray(array: Float32Array, offset?: number): Matrix;
  4028. /**
  4029. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4030. * @param other defines the second operand
  4031. * @param result defines the matrix where to store the multiplication
  4032. * @returns the current matrix
  4033. */
  4034. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4035. /**
  4036. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4037. * @param other defines the second operand
  4038. * @param result defines the array where to store the multiplication
  4039. * @param offset defines the offset in the target array where to start storing values
  4040. * @returns the current matrix
  4041. */
  4042. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4043. /**
  4044. * Check equality between this matrix and a second one
  4045. * @param value defines the second matrix to compare
  4046. * @returns true is the current matrix and the given one values are strictly equal
  4047. */
  4048. equals(value: DeepImmutable<Matrix>): boolean;
  4049. /**
  4050. * Clone the current matrix
  4051. * @returns a new matrix from the current matrix
  4052. */
  4053. clone(): Matrix;
  4054. /**
  4055. * Returns the name of the current matrix class
  4056. * @returns the string "Matrix"
  4057. */
  4058. getClassName(): string;
  4059. /**
  4060. * Gets the hash code of the current matrix
  4061. * @returns the hash code
  4062. */
  4063. getHashCode(): number;
  4064. /**
  4065. * Decomposes the current Matrix into a translation, rotation and scaling components
  4066. * @param scale defines the scale vector3 given as a reference to update
  4067. * @param rotation defines the rotation quaternion given as a reference to update
  4068. * @param translation defines the translation vector3 given as a reference to update
  4069. * @returns true if operation was successful
  4070. */
  4071. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4072. /**
  4073. * Gets specific row of the matrix
  4074. * @param index defines the number of the row to get
  4075. * @returns the index-th row of the current matrix as a new Vector4
  4076. */
  4077. getRow(index: number): Nullable<Vector4>;
  4078. /**
  4079. * Sets the index-th row of the current matrix to the vector4 values
  4080. * @param index defines the number of the row to set
  4081. * @param row defines the target vector4
  4082. * @returns the updated current matrix
  4083. */
  4084. setRow(index: number, row: Vector4): Matrix;
  4085. /**
  4086. * Compute the transpose of the matrix
  4087. * @returns the new transposed matrix
  4088. */
  4089. transpose(): Matrix;
  4090. /**
  4091. * Compute the transpose of the matrix and store it in a given matrix
  4092. * @param result defines the target matrix
  4093. * @returns the current matrix
  4094. */
  4095. transposeToRef(result: Matrix): Matrix;
  4096. /**
  4097. * Sets the index-th row of the current matrix with the given 4 x float values
  4098. * @param index defines the row index
  4099. * @param x defines the x component to set
  4100. * @param y defines the y component to set
  4101. * @param z defines the z component to set
  4102. * @param w defines the w component to set
  4103. * @returns the updated current matrix
  4104. */
  4105. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4106. /**
  4107. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4108. * @param scale defines the scale factor
  4109. * @returns a new matrix
  4110. */
  4111. scale(scale: number): Matrix;
  4112. /**
  4113. * Scale the current matrix values by a factor to a given result matrix
  4114. * @param scale defines the scale factor
  4115. * @param result defines the matrix to store the result
  4116. * @returns the current matrix
  4117. */
  4118. scaleToRef(scale: number, result: Matrix): Matrix;
  4119. /**
  4120. * Scale the current matrix values by a factor and add the result to a given matrix
  4121. * @param scale defines the scale factor
  4122. * @param result defines the Matrix to store the result
  4123. * @returns the current matrix
  4124. */
  4125. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4126. /**
  4127. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4128. * @param ref matrix to store the result
  4129. */
  4130. toNormalMatrix(ref: Matrix): void;
  4131. /**
  4132. * Gets only rotation part of the current matrix
  4133. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4134. */
  4135. getRotationMatrix(): Matrix;
  4136. /**
  4137. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4138. * @param result defines the target matrix to store data to
  4139. * @returns the current matrix
  4140. */
  4141. getRotationMatrixToRef(result: Matrix): Matrix;
  4142. /**
  4143. * Toggles model matrix from being right handed to left handed in place and vice versa
  4144. */
  4145. toggleModelMatrixHandInPlace(): void;
  4146. /**
  4147. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4148. */
  4149. toggleProjectionMatrixHandInPlace(): void;
  4150. /**
  4151. * Creates a matrix from an array
  4152. * @param array defines the source array
  4153. * @param offset defines an offset in the source array
  4154. * @returns a new Matrix set from the starting index of the given array
  4155. */
  4156. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4157. /**
  4158. * Copy the content of an array into a given matrix
  4159. * @param array defines the source array
  4160. * @param offset defines an offset in the source array
  4161. * @param result defines the target matrix
  4162. */
  4163. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4164. /**
  4165. * Stores an array into a matrix after having multiplied each component by a given factor
  4166. * @param array defines the source array
  4167. * @param offset defines the offset in the source array
  4168. * @param scale defines the scaling factor
  4169. * @param result defines the target matrix
  4170. */
  4171. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4172. /**
  4173. * Gets an identity matrix that must not be updated
  4174. */
  4175. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4176. /**
  4177. * Stores a list of values (16) inside a given matrix
  4178. * @param initialM11 defines 1st value of 1st row
  4179. * @param initialM12 defines 2nd value of 1st row
  4180. * @param initialM13 defines 3rd value of 1st row
  4181. * @param initialM14 defines 4th value of 1st row
  4182. * @param initialM21 defines 1st value of 2nd row
  4183. * @param initialM22 defines 2nd value of 2nd row
  4184. * @param initialM23 defines 3rd value of 2nd row
  4185. * @param initialM24 defines 4th value of 2nd row
  4186. * @param initialM31 defines 1st value of 3rd row
  4187. * @param initialM32 defines 2nd value of 3rd row
  4188. * @param initialM33 defines 3rd value of 3rd row
  4189. * @param initialM34 defines 4th value of 3rd row
  4190. * @param initialM41 defines 1st value of 4th row
  4191. * @param initialM42 defines 2nd value of 4th row
  4192. * @param initialM43 defines 3rd value of 4th row
  4193. * @param initialM44 defines 4th value of 4th row
  4194. * @param result defines the target matrix
  4195. */
  4196. 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;
  4197. /**
  4198. * Creates new matrix from a list of values (16)
  4199. * @param initialM11 defines 1st value of 1st row
  4200. * @param initialM12 defines 2nd value of 1st row
  4201. * @param initialM13 defines 3rd value of 1st row
  4202. * @param initialM14 defines 4th value of 1st row
  4203. * @param initialM21 defines 1st value of 2nd row
  4204. * @param initialM22 defines 2nd value of 2nd row
  4205. * @param initialM23 defines 3rd value of 2nd row
  4206. * @param initialM24 defines 4th value of 2nd row
  4207. * @param initialM31 defines 1st value of 3rd row
  4208. * @param initialM32 defines 2nd value of 3rd row
  4209. * @param initialM33 defines 3rd value of 3rd row
  4210. * @param initialM34 defines 4th value of 3rd row
  4211. * @param initialM41 defines 1st value of 4th row
  4212. * @param initialM42 defines 2nd value of 4th row
  4213. * @param initialM43 defines 3rd value of 4th row
  4214. * @param initialM44 defines 4th value of 4th row
  4215. * @returns the new matrix
  4216. */
  4217. 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;
  4218. /**
  4219. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4220. * @param scale defines the scale vector3
  4221. * @param rotation defines the rotation quaternion
  4222. * @param translation defines the translation vector3
  4223. * @returns a new matrix
  4224. */
  4225. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4226. /**
  4227. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4228. * @param scale defines the scale vector3
  4229. * @param rotation defines the rotation quaternion
  4230. * @param translation defines the translation vector3
  4231. * @param result defines the target matrix
  4232. */
  4233. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4234. /**
  4235. * Creates a new identity matrix
  4236. * @returns a new identity matrix
  4237. */
  4238. static Identity(): Matrix;
  4239. /**
  4240. * Creates a new identity matrix and stores the result in a given matrix
  4241. * @param result defines the target matrix
  4242. */
  4243. static IdentityToRef(result: Matrix): void;
  4244. /**
  4245. * Creates a new zero matrix
  4246. * @returns a new zero matrix
  4247. */
  4248. static Zero(): Matrix;
  4249. /**
  4250. * Creates a new rotation matrix for "angle" radians around the X axis
  4251. * @param angle defines the angle (in radians) to use
  4252. * @return the new matrix
  4253. */
  4254. static RotationX(angle: number): Matrix;
  4255. /**
  4256. * Creates a new matrix as the invert of a given matrix
  4257. * @param source defines the source matrix
  4258. * @returns the new matrix
  4259. */
  4260. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4261. /**
  4262. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4263. * @param angle defines the angle (in radians) to use
  4264. * @param result defines the target matrix
  4265. */
  4266. static RotationXToRef(angle: number, result: Matrix): void;
  4267. /**
  4268. * Creates a new rotation matrix for "angle" radians around the Y axis
  4269. * @param angle defines the angle (in radians) to use
  4270. * @return the new matrix
  4271. */
  4272. static RotationY(angle: number): Matrix;
  4273. /**
  4274. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4275. * @param angle defines the angle (in radians) to use
  4276. * @param result defines the target matrix
  4277. */
  4278. static RotationYToRef(angle: number, result: Matrix): void;
  4279. /**
  4280. * Creates a new rotation matrix for "angle" radians around the Z axis
  4281. * @param angle defines the angle (in radians) to use
  4282. * @return the new matrix
  4283. */
  4284. static RotationZ(angle: number): Matrix;
  4285. /**
  4286. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4287. * @param angle defines the angle (in radians) to use
  4288. * @param result defines the target matrix
  4289. */
  4290. static RotationZToRef(angle: number, result: Matrix): void;
  4291. /**
  4292. * Creates a new rotation matrix for "angle" radians around the given axis
  4293. * @param axis defines the axis to use
  4294. * @param angle defines the angle (in radians) to use
  4295. * @return the new matrix
  4296. */
  4297. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4298. /**
  4299. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4300. * @param axis defines the axis to use
  4301. * @param angle defines the angle (in radians) to use
  4302. * @param result defines the target matrix
  4303. */
  4304. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4305. /**
  4306. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4307. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4308. * @param from defines the vector to align
  4309. * @param to defines the vector to align to
  4310. * @param result defines the target matrix
  4311. */
  4312. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4313. /**
  4314. * Creates a rotation matrix
  4315. * @param yaw defines the yaw angle in radians (Y axis)
  4316. * @param pitch defines the pitch angle in radians (X axis)
  4317. * @param roll defines the roll angle in radians (X axis)
  4318. * @returns the new rotation matrix
  4319. */
  4320. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4321. /**
  4322. * Creates a rotation matrix and stores it in a given matrix
  4323. * @param yaw defines the yaw angle in radians (Y axis)
  4324. * @param pitch defines the pitch angle in radians (X axis)
  4325. * @param roll defines the roll angle in radians (X axis)
  4326. * @param result defines the target matrix
  4327. */
  4328. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4329. /**
  4330. * Creates a scaling matrix
  4331. * @param x defines the scale factor on X axis
  4332. * @param y defines the scale factor on Y axis
  4333. * @param z defines the scale factor on Z axis
  4334. * @returns the new matrix
  4335. */
  4336. static Scaling(x: number, y: number, z: number): Matrix;
  4337. /**
  4338. * Creates a scaling matrix and stores it in a given matrix
  4339. * @param x defines the scale factor on X axis
  4340. * @param y defines the scale factor on Y axis
  4341. * @param z defines the scale factor on Z axis
  4342. * @param result defines the target matrix
  4343. */
  4344. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4345. /**
  4346. * Creates a translation matrix
  4347. * @param x defines the translation on X axis
  4348. * @param y defines the translation on Y axis
  4349. * @param z defines the translationon Z axis
  4350. * @returns the new matrix
  4351. */
  4352. static Translation(x: number, y: number, z: number): Matrix;
  4353. /**
  4354. * Creates a translation matrix and stores it in a given matrix
  4355. * @param x defines the translation on X axis
  4356. * @param y defines the translation on Y axis
  4357. * @param z defines the translationon Z axis
  4358. * @param result defines the target matrix
  4359. */
  4360. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4361. /**
  4362. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4363. * @param startValue defines the start value
  4364. * @param endValue defines the end value
  4365. * @param gradient defines the gradient factor
  4366. * @returns the new matrix
  4367. */
  4368. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4369. /**
  4370. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4371. * @param startValue defines the start value
  4372. * @param endValue defines the end value
  4373. * @param gradient defines the gradient factor
  4374. * @param result defines the Matrix object where to store data
  4375. */
  4376. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4377. /**
  4378. * Builds a new matrix whose values are computed by:
  4379. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4380. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4381. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4382. * @param startValue defines the first matrix
  4383. * @param endValue defines the second matrix
  4384. * @param gradient defines the gradient between the two matrices
  4385. * @returns the new matrix
  4386. */
  4387. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4388. /**
  4389. * Update a matrix to values which are computed by:
  4390. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4391. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4392. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4393. * @param startValue defines the first matrix
  4394. * @param endValue defines the second matrix
  4395. * @param gradient defines the gradient between the two matrices
  4396. * @param result defines the target matrix
  4397. */
  4398. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4399. /**
  4400. * 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"
  4401. * This function works in left handed mode
  4402. * @param eye defines the final position of the entity
  4403. * @param target defines where the entity should look at
  4404. * @param up defines the up vector for the entity
  4405. * @returns the new matrix
  4406. */
  4407. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4408. /**
  4409. * 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".
  4410. * This function works in left handed mode
  4411. * @param eye defines the final position of the entity
  4412. * @param target defines where the entity should look at
  4413. * @param up defines the up vector for the entity
  4414. * @param result defines the target matrix
  4415. */
  4416. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4417. /**
  4418. * 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"
  4419. * This function works in right handed mode
  4420. * @param eye defines the final position of the entity
  4421. * @param target defines where the entity should look at
  4422. * @param up defines the up vector for the entity
  4423. * @returns the new matrix
  4424. */
  4425. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4426. /**
  4427. * 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".
  4428. * This function works in right handed mode
  4429. * @param eye defines the final position of the entity
  4430. * @param target defines where the entity should look at
  4431. * @param up defines the up vector for the entity
  4432. * @param result defines the target matrix
  4433. */
  4434. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4435. /**
  4436. * Create a left-handed orthographic projection matrix
  4437. * @param width defines the viewport width
  4438. * @param height defines the viewport height
  4439. * @param znear defines the near clip plane
  4440. * @param zfar defines the far clip plane
  4441. * @returns a new matrix as a left-handed orthographic projection matrix
  4442. */
  4443. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4444. /**
  4445. * Store a left-handed orthographic projection to a given matrix
  4446. * @param width defines the viewport width
  4447. * @param height defines the viewport height
  4448. * @param znear defines the near clip plane
  4449. * @param zfar defines the far clip plane
  4450. * @param result defines the target matrix
  4451. */
  4452. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4453. /**
  4454. * Create a left-handed orthographic projection matrix
  4455. * @param left defines the viewport left coordinate
  4456. * @param right defines the viewport right coordinate
  4457. * @param bottom defines the viewport bottom coordinate
  4458. * @param top defines the viewport top coordinate
  4459. * @param znear defines the near clip plane
  4460. * @param zfar defines the far clip plane
  4461. * @returns a new matrix as a left-handed orthographic projection matrix
  4462. */
  4463. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4464. /**
  4465. * Stores a left-handed orthographic projection into a given matrix
  4466. * @param left defines the viewport left coordinate
  4467. * @param right defines the viewport right coordinate
  4468. * @param bottom defines the viewport bottom coordinate
  4469. * @param top defines the viewport top coordinate
  4470. * @param znear defines the near clip plane
  4471. * @param zfar defines the far clip plane
  4472. * @param result defines the target matrix
  4473. */
  4474. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4475. /**
  4476. * Creates a right-handed orthographic projection matrix
  4477. * @param left defines the viewport left coordinate
  4478. * @param right defines the viewport right coordinate
  4479. * @param bottom defines the viewport bottom coordinate
  4480. * @param top defines the viewport top coordinate
  4481. * @param znear defines the near clip plane
  4482. * @param zfar defines the far clip plane
  4483. * @returns a new matrix as a right-handed orthographic projection matrix
  4484. */
  4485. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4486. /**
  4487. * Stores a right-handed orthographic projection into a given matrix
  4488. * @param left defines the viewport left coordinate
  4489. * @param right defines the viewport right coordinate
  4490. * @param bottom defines the viewport bottom coordinate
  4491. * @param top defines the viewport top coordinate
  4492. * @param znear defines the near clip plane
  4493. * @param zfar defines the far clip plane
  4494. * @param result defines the target matrix
  4495. */
  4496. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4497. /**
  4498. * Creates a left-handed perspective projection matrix
  4499. * @param width defines the viewport width
  4500. * @param height defines the viewport height
  4501. * @param znear defines the near clip plane
  4502. * @param zfar defines the far clip plane
  4503. * @returns a new matrix as a left-handed perspective projection matrix
  4504. */
  4505. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4506. /**
  4507. * Creates a left-handed perspective projection matrix
  4508. * @param fov defines the horizontal field of view
  4509. * @param aspect defines the aspect ratio
  4510. * @param znear defines the near clip plane
  4511. * @param zfar defines the far clip plane
  4512. * @returns a new matrix as a left-handed perspective projection matrix
  4513. */
  4514. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4515. /**
  4516. * Stores a left-handed perspective projection into a given matrix
  4517. * @param fov defines the horizontal field of view
  4518. * @param aspect defines the aspect ratio
  4519. * @param znear defines the near clip plane
  4520. * @param zfar defines the far clip plane
  4521. * @param result defines the target matrix
  4522. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4523. */
  4524. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4525. /**
  4526. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4527. * @param fov defines the horizontal field of view
  4528. * @param aspect defines the aspect ratio
  4529. * @param znear defines the near clip plane
  4530. * @param zfar not used as infinity is used as far clip
  4531. * @param result defines the target matrix
  4532. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4533. */
  4534. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4535. /**
  4536. * Creates a right-handed perspective projection matrix
  4537. * @param fov defines the horizontal field of view
  4538. * @param aspect defines the aspect ratio
  4539. * @param znear defines the near clip plane
  4540. * @param zfar defines the far clip plane
  4541. * @returns a new matrix as a right-handed perspective projection matrix
  4542. */
  4543. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4544. /**
  4545. * Stores a right-handed perspective projection into a given matrix
  4546. * @param fov defines the horizontal field of view
  4547. * @param aspect defines the aspect ratio
  4548. * @param znear defines the near clip plane
  4549. * @param zfar defines the far clip plane
  4550. * @param result defines the target matrix
  4551. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4552. */
  4553. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4554. /**
  4555. * Stores a right-handed perspective projection into a given matrix
  4556. * @param fov defines the horizontal field of view
  4557. * @param aspect defines the aspect ratio
  4558. * @param znear defines the near clip plane
  4559. * @param zfar not used as infinity is used as far clip
  4560. * @param result defines the target matrix
  4561. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4562. */
  4563. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4564. /**
  4565. * Stores a perspective projection for WebVR info a given matrix
  4566. * @param fov defines the field of view
  4567. * @param znear defines the near clip plane
  4568. * @param zfar defines the far clip plane
  4569. * @param result defines the target matrix
  4570. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4571. */
  4572. static PerspectiveFovWebVRToRef(fov: {
  4573. upDegrees: number;
  4574. downDegrees: number;
  4575. leftDegrees: number;
  4576. rightDegrees: number;
  4577. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4578. /**
  4579. * Computes a complete transformation matrix
  4580. * @param viewport defines the viewport to use
  4581. * @param world defines the world matrix
  4582. * @param view defines the view matrix
  4583. * @param projection defines the projection matrix
  4584. * @param zmin defines the near clip plane
  4585. * @param zmax defines the far clip plane
  4586. * @returns the transformation matrix
  4587. */
  4588. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4589. /**
  4590. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4591. * @param matrix defines the matrix to use
  4592. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4593. */
  4594. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4595. /**
  4596. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4597. * @param matrix defines the matrix to use
  4598. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4599. */
  4600. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4601. /**
  4602. * Compute the transpose of a given matrix
  4603. * @param matrix defines the matrix to transpose
  4604. * @returns the new matrix
  4605. */
  4606. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4607. /**
  4608. * Compute the transpose of a matrix and store it in a target matrix
  4609. * @param matrix defines the matrix to transpose
  4610. * @param result defines the target matrix
  4611. */
  4612. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4613. /**
  4614. * Computes a reflection matrix from a plane
  4615. * @param plane defines the reflection plane
  4616. * @returns a new matrix
  4617. */
  4618. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4619. /**
  4620. * Computes a reflection matrix from a plane
  4621. * @param plane defines the reflection plane
  4622. * @param result defines the target matrix
  4623. */
  4624. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4625. /**
  4626. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4627. * @param xaxis defines the value of the 1st axis
  4628. * @param yaxis defines the value of the 2nd axis
  4629. * @param zaxis defines the value of the 3rd axis
  4630. * @param result defines the target matrix
  4631. */
  4632. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4633. /**
  4634. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4635. * @param quat defines the quaternion to use
  4636. * @param result defines the target matrix
  4637. */
  4638. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4639. }
  4640. /**
  4641. * @hidden
  4642. */
  4643. export class TmpVectors {
  4644. static Vector2: Vector2[];
  4645. static Vector3: Vector3[];
  4646. static Vector4: Vector4[];
  4647. static Quaternion: Quaternion[];
  4648. static Matrix: Matrix[];
  4649. }
  4650. }
  4651. declare module "babylonjs/Maths/math.path" {
  4652. import { DeepImmutable, Nullable } from "babylonjs/types";
  4653. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4654. /**
  4655. * Defines potential orientation for back face culling
  4656. */
  4657. export enum Orientation {
  4658. /**
  4659. * Clockwise
  4660. */
  4661. CW = 0,
  4662. /** Counter clockwise */
  4663. CCW = 1
  4664. }
  4665. /** Class used to represent a Bezier curve */
  4666. export class BezierCurve {
  4667. /**
  4668. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4669. * @param t defines the time
  4670. * @param x1 defines the left coordinate on X axis
  4671. * @param y1 defines the left coordinate on Y axis
  4672. * @param x2 defines the right coordinate on X axis
  4673. * @param y2 defines the right coordinate on Y axis
  4674. * @returns the interpolated value
  4675. */
  4676. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4677. }
  4678. /**
  4679. * Defines angle representation
  4680. */
  4681. export class Angle {
  4682. private _radians;
  4683. /**
  4684. * Creates an Angle object of "radians" radians (float).
  4685. * @param radians the angle in radians
  4686. */
  4687. constructor(radians: number);
  4688. /**
  4689. * Get value in degrees
  4690. * @returns the Angle value in degrees (float)
  4691. */
  4692. degrees(): number;
  4693. /**
  4694. * Get value in radians
  4695. * @returns the Angle value in radians (float)
  4696. */
  4697. radians(): number;
  4698. /**
  4699. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4700. * @param a defines first vector
  4701. * @param b defines second vector
  4702. * @returns a new Angle
  4703. */
  4704. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4705. /**
  4706. * Gets a new Angle object from the given float in radians
  4707. * @param radians defines the angle value in radians
  4708. * @returns a new Angle
  4709. */
  4710. static FromRadians(radians: number): Angle;
  4711. /**
  4712. * Gets a new Angle object from the given float in degrees
  4713. * @param degrees defines the angle value in degrees
  4714. * @returns a new Angle
  4715. */
  4716. static FromDegrees(degrees: number): Angle;
  4717. }
  4718. /**
  4719. * This represents an arc in a 2d space.
  4720. */
  4721. export class Arc2 {
  4722. /** Defines the start point of the arc */
  4723. startPoint: Vector2;
  4724. /** Defines the mid point of the arc */
  4725. midPoint: Vector2;
  4726. /** Defines the end point of the arc */
  4727. endPoint: Vector2;
  4728. /**
  4729. * Defines the center point of the arc.
  4730. */
  4731. centerPoint: Vector2;
  4732. /**
  4733. * Defines the radius of the arc.
  4734. */
  4735. radius: number;
  4736. /**
  4737. * Defines the angle of the arc (from mid point to end point).
  4738. */
  4739. angle: Angle;
  4740. /**
  4741. * Defines the start angle of the arc (from start point to middle point).
  4742. */
  4743. startAngle: Angle;
  4744. /**
  4745. * Defines the orientation of the arc (clock wise/counter clock wise).
  4746. */
  4747. orientation: Orientation;
  4748. /**
  4749. * Creates an Arc object from the three given points : start, middle and end.
  4750. * @param startPoint Defines the start point of the arc
  4751. * @param midPoint Defines the midlle point of the arc
  4752. * @param endPoint Defines the end point of the arc
  4753. */
  4754. constructor(
  4755. /** Defines the start point of the arc */
  4756. startPoint: Vector2,
  4757. /** Defines the mid point of the arc */
  4758. midPoint: Vector2,
  4759. /** Defines the end point of the arc */
  4760. endPoint: Vector2);
  4761. }
  4762. /**
  4763. * Represents a 2D path made up of multiple 2D points
  4764. */
  4765. export class Path2 {
  4766. private _points;
  4767. private _length;
  4768. /**
  4769. * If the path start and end point are the same
  4770. */
  4771. closed: boolean;
  4772. /**
  4773. * Creates a Path2 object from the starting 2D coordinates x and y.
  4774. * @param x the starting points x value
  4775. * @param y the starting points y value
  4776. */
  4777. constructor(x: number, y: number);
  4778. /**
  4779. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4780. * @param x the added points x value
  4781. * @param y the added points y value
  4782. * @returns the updated Path2.
  4783. */
  4784. addLineTo(x: number, y: number): Path2;
  4785. /**
  4786. * 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.
  4787. * @param midX middle point x value
  4788. * @param midY middle point y value
  4789. * @param endX end point x value
  4790. * @param endY end point y value
  4791. * @param numberOfSegments (default: 36)
  4792. * @returns the updated Path2.
  4793. */
  4794. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4795. /**
  4796. * Closes the Path2.
  4797. * @returns the Path2.
  4798. */
  4799. close(): Path2;
  4800. /**
  4801. * Gets the sum of the distance between each sequential point in the path
  4802. * @returns the Path2 total length (float).
  4803. */
  4804. length(): number;
  4805. /**
  4806. * Gets the points which construct the path
  4807. * @returns the Path2 internal array of points.
  4808. */
  4809. getPoints(): Vector2[];
  4810. /**
  4811. * Retreives the point at the distance aways from the starting point
  4812. * @param normalizedLengthPosition the length along the path to retreive the point from
  4813. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4814. */
  4815. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4816. /**
  4817. * Creates a new path starting from an x and y position
  4818. * @param x starting x value
  4819. * @param y starting y value
  4820. * @returns a new Path2 starting at the coordinates (x, y).
  4821. */
  4822. static StartingAt(x: number, y: number): Path2;
  4823. }
  4824. /**
  4825. * Represents a 3D path made up of multiple 3D points
  4826. */
  4827. export class Path3D {
  4828. /**
  4829. * an array of Vector3, the curve axis of the Path3D
  4830. */
  4831. path: Vector3[];
  4832. private _curve;
  4833. private _distances;
  4834. private _tangents;
  4835. private _normals;
  4836. private _binormals;
  4837. private _raw;
  4838. private _alignTangentsWithPath;
  4839. private readonly _pointAtData;
  4840. /**
  4841. * new Path3D(path, normal, raw)
  4842. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4843. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4844. * @param path an array of Vector3, the curve axis of the Path3D
  4845. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4846. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4847. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4848. */
  4849. constructor(
  4850. /**
  4851. * an array of Vector3, the curve axis of the Path3D
  4852. */
  4853. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4854. /**
  4855. * Returns the Path3D array of successive Vector3 designing its curve.
  4856. * @returns the Path3D array of successive Vector3 designing its curve.
  4857. */
  4858. getCurve(): Vector3[];
  4859. /**
  4860. * Returns the Path3D array of successive Vector3 designing its curve.
  4861. * @returns the Path3D array of successive Vector3 designing its curve.
  4862. */
  4863. getPoints(): Vector3[];
  4864. /**
  4865. * @returns the computed length (float) of the path.
  4866. */
  4867. length(): number;
  4868. /**
  4869. * Returns an array populated with tangent vectors on each Path3D curve point.
  4870. * @returns an array populated with tangent vectors on each Path3D curve point.
  4871. */
  4872. getTangents(): Vector3[];
  4873. /**
  4874. * Returns an array populated with normal vectors on each Path3D curve point.
  4875. * @returns an array populated with normal vectors on each Path3D curve point.
  4876. */
  4877. getNormals(): Vector3[];
  4878. /**
  4879. * Returns an array populated with binormal vectors on each Path3D curve point.
  4880. * @returns an array populated with binormal vectors on each Path3D curve point.
  4881. */
  4882. getBinormals(): Vector3[];
  4883. /**
  4884. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4885. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4886. */
  4887. getDistances(): number[];
  4888. /**
  4889. * Returns an interpolated point along this path
  4890. * @param position the position of the point along this path, from 0.0 to 1.0
  4891. * @returns a new Vector3 as the point
  4892. */
  4893. getPointAt(position: number): Vector3;
  4894. /**
  4895. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4896. * @param position the position of the point along this path, from 0.0 to 1.0
  4897. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4898. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4899. */
  4900. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4901. /**
  4902. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4903. * @param position the position of the point along this path, from 0.0 to 1.0
  4904. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4905. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4906. */
  4907. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4908. /**
  4909. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4910. * @param position the position of the point along this path, from 0.0 to 1.0
  4911. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4912. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4913. */
  4914. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4915. /**
  4916. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4917. * @param position the position of the point along this path, from 0.0 to 1.0
  4918. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4919. */
  4920. getDistanceAt(position: number): number;
  4921. /**
  4922. * Returns the array index of the previous point of an interpolated point along this path
  4923. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4924. * @returns the array index
  4925. */
  4926. getPreviousPointIndexAt(position: number): number;
  4927. /**
  4928. * 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)
  4929. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4930. * @returns the sub position
  4931. */
  4932. getSubPositionAt(position: number): number;
  4933. /**
  4934. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4935. * @param target the vector of which to get the closest position to
  4936. * @returns the position of the closest virtual point on this path to the target vector
  4937. */
  4938. getClosestPositionTo(target: Vector3): number;
  4939. /**
  4940. * Returns a sub path (slice) of this path
  4941. * @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
  4942. * @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
  4943. * @returns a sub path (slice) of this path
  4944. */
  4945. slice(start?: number, end?: number): Path3D;
  4946. /**
  4947. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4948. * @param path path which all values are copied into the curves points
  4949. * @param firstNormal which should be projected onto the curve
  4950. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4951. * @returns the same object updated.
  4952. */
  4953. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4954. private _compute;
  4955. private _getFirstNonNullVector;
  4956. private _getLastNonNullVector;
  4957. private _normalVector;
  4958. /**
  4959. * Updates the point at data for an interpolated point along this curve
  4960. * @param position the position of the point along this curve, from 0.0 to 1.0
  4961. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4962. * @returns the (updated) point at data
  4963. */
  4964. private _updatePointAtData;
  4965. /**
  4966. * Updates the point at data from the specified parameters
  4967. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4968. * @param point the interpolated point
  4969. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4970. */
  4971. private _setPointAtData;
  4972. /**
  4973. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4974. */
  4975. private _updateInterpolationMatrix;
  4976. }
  4977. /**
  4978. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4979. * A Curve3 is designed from a series of successive Vector3.
  4980. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4981. */
  4982. export class Curve3 {
  4983. private _points;
  4984. private _length;
  4985. /**
  4986. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4987. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4988. * @param v1 (Vector3) the control point
  4989. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4990. * @param nbPoints (integer) the wanted number of points in the curve
  4991. * @returns the created Curve3
  4992. */
  4993. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4994. /**
  4995. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4996. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4997. * @param v1 (Vector3) the first control point
  4998. * @param v2 (Vector3) the second control point
  4999. * @param v3 (Vector3) the end point of the Cubic Bezier
  5000. * @param nbPoints (integer) the wanted number of points in the curve
  5001. * @returns the created Curve3
  5002. */
  5003. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5004. /**
  5005. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5006. * @param p1 (Vector3) the origin point of the Hermite Spline
  5007. * @param t1 (Vector3) the tangent vector at the origin point
  5008. * @param p2 (Vector3) the end point of the Hermite Spline
  5009. * @param t2 (Vector3) the tangent vector at the end point
  5010. * @param nbPoints (integer) the wanted number of points in the curve
  5011. * @returns the created Curve3
  5012. */
  5013. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5014. /**
  5015. * Returns a Curve3 object along a CatmullRom Spline curve :
  5016. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5017. * @param nbPoints (integer) the wanted number of points between each curve control points
  5018. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5019. * @returns the created Curve3
  5020. */
  5021. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5022. /**
  5023. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5024. * A Curve3 is designed from a series of successive Vector3.
  5025. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5026. * @param points points which make up the curve
  5027. */
  5028. constructor(points: Vector3[]);
  5029. /**
  5030. * @returns the Curve3 stored array of successive Vector3
  5031. */
  5032. getPoints(): Vector3[];
  5033. /**
  5034. * @returns the computed length (float) of the curve.
  5035. */
  5036. length(): number;
  5037. /**
  5038. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5039. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5040. * curveA and curveB keep unchanged.
  5041. * @param curve the curve to continue from this curve
  5042. * @returns the newly constructed curve
  5043. */
  5044. continue(curve: DeepImmutable<Curve3>): Curve3;
  5045. private _computeLength;
  5046. }
  5047. }
  5048. declare module "babylonjs/Animations/easing" {
  5049. /**
  5050. * This represents the main contract an easing function should follow.
  5051. * Easing functions are used throughout the animation system.
  5052. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5053. */
  5054. export interface IEasingFunction {
  5055. /**
  5056. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5057. * of the easing function.
  5058. * The link below provides some of the most common examples of easing functions.
  5059. * @see https://easings.net/
  5060. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5061. * @returns the corresponding value on the curve defined by the easing function
  5062. */
  5063. ease(gradient: number): number;
  5064. }
  5065. /**
  5066. * Base class used for every default easing function.
  5067. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5068. */
  5069. export class EasingFunction implements IEasingFunction {
  5070. /**
  5071. * Interpolation follows the mathematical formula associated with the easing function.
  5072. */
  5073. static readonly EASINGMODE_EASEIN: number;
  5074. /**
  5075. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5076. */
  5077. static readonly EASINGMODE_EASEOUT: number;
  5078. /**
  5079. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5080. */
  5081. static readonly EASINGMODE_EASEINOUT: number;
  5082. private _easingMode;
  5083. /**
  5084. * Sets the easing mode of the current function.
  5085. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5086. */
  5087. setEasingMode(easingMode: number): void;
  5088. /**
  5089. * Gets the current easing mode.
  5090. * @returns the easing mode
  5091. */
  5092. getEasingMode(): number;
  5093. /**
  5094. * @hidden
  5095. */
  5096. easeInCore(gradient: number): number;
  5097. /**
  5098. * Given an input gradient between 0 and 1, this returns the corresponding value
  5099. * of the easing function.
  5100. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5101. * @returns the corresponding value on the curve defined by the easing function
  5102. */
  5103. ease(gradient: number): number;
  5104. }
  5105. /**
  5106. * Easing function with a circle shape (see link below).
  5107. * @see https://easings.net/#easeInCirc
  5108. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5109. */
  5110. export class CircleEase extends EasingFunction implements IEasingFunction {
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a ease back shape (see link below).
  5116. * @see https://easings.net/#easeInBack
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BackEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the amplitude of the function */
  5121. amplitude: number;
  5122. /**
  5123. * Instantiates a back ease easing
  5124. * @see https://easings.net/#easeInBack
  5125. * @param amplitude Defines the amplitude of the function
  5126. */
  5127. constructor(
  5128. /** Defines the amplitude of the function */
  5129. amplitude?: number);
  5130. /** @hidden */
  5131. easeInCore(gradient: number): number;
  5132. }
  5133. /**
  5134. * Easing function with a bouncing shape (see link below).
  5135. * @see https://easings.net/#easeInBounce
  5136. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5137. */
  5138. export class BounceEase extends EasingFunction implements IEasingFunction {
  5139. /** Defines the number of bounces */
  5140. bounces: number;
  5141. /** Defines the amplitude of the bounce */
  5142. bounciness: number;
  5143. /**
  5144. * Instantiates a bounce easing
  5145. * @see https://easings.net/#easeInBounce
  5146. * @param bounces Defines the number of bounces
  5147. * @param bounciness Defines the amplitude of the bounce
  5148. */
  5149. constructor(
  5150. /** Defines the number of bounces */
  5151. bounces?: number,
  5152. /** Defines the amplitude of the bounce */
  5153. bounciness?: number);
  5154. /** @hidden */
  5155. easeInCore(gradient: number): number;
  5156. }
  5157. /**
  5158. * Easing function with a power of 3 shape (see link below).
  5159. * @see https://easings.net/#easeInCubic
  5160. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5161. */
  5162. export class CubicEase extends EasingFunction implements IEasingFunction {
  5163. /** @hidden */
  5164. easeInCore(gradient: number): number;
  5165. }
  5166. /**
  5167. * Easing function with an elastic shape (see link below).
  5168. * @see https://easings.net/#easeInElastic
  5169. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5170. */
  5171. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5172. /** Defines the number of oscillations*/
  5173. oscillations: number;
  5174. /** Defines the amplitude of the oscillations*/
  5175. springiness: number;
  5176. /**
  5177. * Instantiates an elastic easing function
  5178. * @see https://easings.net/#easeInElastic
  5179. * @param oscillations Defines the number of oscillations
  5180. * @param springiness Defines the amplitude of the oscillations
  5181. */
  5182. constructor(
  5183. /** Defines the number of oscillations*/
  5184. oscillations?: number,
  5185. /** Defines the amplitude of the oscillations*/
  5186. springiness?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with an exponential shape (see link below).
  5192. * @see https://easings.net/#easeInExpo
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the exponent of the function */
  5197. exponent: number;
  5198. /**
  5199. * Instantiates an exponential easing function
  5200. * @see https://easings.net/#easeInExpo
  5201. * @param exponent Defines the exponent of the function
  5202. */
  5203. constructor(
  5204. /** Defines the exponent of the function */
  5205. exponent?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class PowerEase extends EasingFunction implements IEasingFunction {
  5215. /** Defines the power of the function */
  5216. power: number;
  5217. /**
  5218. * Instantiates an power base easing function
  5219. * @see https://easings.net/#easeInQuad
  5220. * @param power Defines the power of the function
  5221. */
  5222. constructor(
  5223. /** Defines the power of the function */
  5224. power?: number);
  5225. /** @hidden */
  5226. easeInCore(gradient: number): number;
  5227. }
  5228. /**
  5229. * Easing function with a power of 2 shape (see link below).
  5230. * @see https://easings.net/#easeInQuad
  5231. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5232. */
  5233. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5234. /** @hidden */
  5235. easeInCore(gradient: number): number;
  5236. }
  5237. /**
  5238. * Easing function with a power of 4 shape (see link below).
  5239. * @see https://easings.net/#easeInQuart
  5240. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5241. */
  5242. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5243. /** @hidden */
  5244. easeInCore(gradient: number): number;
  5245. }
  5246. /**
  5247. * Easing function with a power of 5 shape (see link below).
  5248. * @see https://easings.net/#easeInQuint
  5249. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5250. */
  5251. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5252. /** @hidden */
  5253. easeInCore(gradient: number): number;
  5254. }
  5255. /**
  5256. * Easing function with a sin shape (see link below).
  5257. * @see https://easings.net/#easeInSine
  5258. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export class SineEase extends EasingFunction implements IEasingFunction {
  5261. /** @hidden */
  5262. easeInCore(gradient: number): number;
  5263. }
  5264. /**
  5265. * Easing function with a bezier shape (see link below).
  5266. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5267. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5268. */
  5269. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5270. /** Defines the x component of the start tangent in the bezier curve */
  5271. x1: number;
  5272. /** Defines the y component of the start tangent in the bezier curve */
  5273. y1: number;
  5274. /** Defines the x component of the end tangent in the bezier curve */
  5275. x2: number;
  5276. /** Defines the y component of the end tangent in the bezier curve */
  5277. y2: number;
  5278. /**
  5279. * Instantiates a bezier function
  5280. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5281. * @param x1 Defines the x component of the start tangent in the bezier curve
  5282. * @param y1 Defines the y component of the start tangent in the bezier curve
  5283. * @param x2 Defines the x component of the end tangent in the bezier curve
  5284. * @param y2 Defines the y component of the end tangent in the bezier curve
  5285. */
  5286. constructor(
  5287. /** Defines the x component of the start tangent in the bezier curve */
  5288. x1?: number,
  5289. /** Defines the y component of the start tangent in the bezier curve */
  5290. y1?: number,
  5291. /** Defines the x component of the end tangent in the bezier curve */
  5292. x2?: number,
  5293. /** Defines the y component of the end tangent in the bezier curve */
  5294. y2?: number);
  5295. /** @hidden */
  5296. easeInCore(gradient: number): number;
  5297. }
  5298. }
  5299. declare module "babylonjs/Maths/math.color" {
  5300. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5301. /**
  5302. * Class used to hold a RBG color
  5303. */
  5304. export class Color3 {
  5305. /**
  5306. * Defines the red component (between 0 and 1, default is 0)
  5307. */
  5308. r: number;
  5309. /**
  5310. * Defines the green component (between 0 and 1, default is 0)
  5311. */
  5312. g: number;
  5313. /**
  5314. * Defines the blue component (between 0 and 1, default is 0)
  5315. */
  5316. b: number;
  5317. /**
  5318. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5319. * @param r defines the red component (between 0 and 1, default is 0)
  5320. * @param g defines the green component (between 0 and 1, default is 0)
  5321. * @param b defines the blue component (between 0 and 1, default is 0)
  5322. */
  5323. constructor(
  5324. /**
  5325. * Defines the red component (between 0 and 1, default is 0)
  5326. */
  5327. r?: number,
  5328. /**
  5329. * Defines the green component (between 0 and 1, default is 0)
  5330. */
  5331. g?: number,
  5332. /**
  5333. * Defines the blue component (between 0 and 1, default is 0)
  5334. */
  5335. b?: number);
  5336. /**
  5337. * Creates a string with the Color3 current values
  5338. * @returns the string representation of the Color3 object
  5339. */
  5340. toString(): string;
  5341. /**
  5342. * Returns the string "Color3"
  5343. * @returns "Color3"
  5344. */
  5345. getClassName(): string;
  5346. /**
  5347. * Compute the Color3 hash code
  5348. * @returns an unique number that can be used to hash Color3 objects
  5349. */
  5350. getHashCode(): number;
  5351. /**
  5352. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5353. * @param array defines the array where to store the r,g,b components
  5354. * @param index defines an optional index in the target array to define where to start storing values
  5355. * @returns the current Color3 object
  5356. */
  5357. toArray(array: FloatArray, index?: number): Color3;
  5358. /**
  5359. * Returns a new Color4 object from the current Color3 and the given alpha
  5360. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5361. * @returns a new Color4 object
  5362. */
  5363. toColor4(alpha?: number): Color4;
  5364. /**
  5365. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5366. * @returns the new array
  5367. */
  5368. asArray(): number[];
  5369. /**
  5370. * Returns the luminance value
  5371. * @returns a float value
  5372. */
  5373. toLuminance(): number;
  5374. /**
  5375. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5376. * @param otherColor defines the second operand
  5377. * @returns the new Color3 object
  5378. */
  5379. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5380. /**
  5381. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5382. * @param otherColor defines the second operand
  5383. * @param result defines the Color3 object where to store the result
  5384. * @returns the current Color3
  5385. */
  5386. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5387. /**
  5388. * Determines equality between Color3 objects
  5389. * @param otherColor defines the second operand
  5390. * @returns true if the rgb values are equal to the given ones
  5391. */
  5392. equals(otherColor: DeepImmutable<Color3>): boolean;
  5393. /**
  5394. * Determines equality between the current Color3 object and a set of r,b,g values
  5395. * @param r defines the red component to check
  5396. * @param g defines the green component to check
  5397. * @param b defines the blue component to check
  5398. * @returns true if the rgb values are equal to the given ones
  5399. */
  5400. equalsFloats(r: number, g: number, b: number): boolean;
  5401. /**
  5402. * Multiplies in place each rgb value by scale
  5403. * @param scale defines the scaling factor
  5404. * @returns the updated Color3
  5405. */
  5406. scale(scale: number): Color3;
  5407. /**
  5408. * Multiplies the rgb values by scale and stores the result into "result"
  5409. * @param scale defines the scaling factor
  5410. * @param result defines the Color3 object where to store the result
  5411. * @returns the unmodified current Color3
  5412. */
  5413. scaleToRef(scale: number, result: Color3): Color3;
  5414. /**
  5415. * Scale the current Color3 values by a factor and add the result to a given Color3
  5416. * @param scale defines the scale factor
  5417. * @param result defines color to store the result into
  5418. * @returns the unmodified current Color3
  5419. */
  5420. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5421. /**
  5422. * Clamps the rgb values by the min and max values and stores the result into "result"
  5423. * @param min defines minimum clamping value (default is 0)
  5424. * @param max defines maximum clamping value (default is 1)
  5425. * @param result defines color to store the result into
  5426. * @returns the original Color3
  5427. */
  5428. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5429. /**
  5430. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5431. * @param otherColor defines the second operand
  5432. * @returns the new Color3
  5433. */
  5434. add(otherColor: DeepImmutable<Color3>): Color3;
  5435. /**
  5436. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5437. * @param otherColor defines the second operand
  5438. * @param result defines Color3 object to store the result into
  5439. * @returns the unmodified current Color3
  5440. */
  5441. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5442. /**
  5443. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5444. * @param otherColor defines the second operand
  5445. * @returns the new Color3
  5446. */
  5447. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5448. /**
  5449. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5450. * @param otherColor defines the second operand
  5451. * @param result defines Color3 object to store the result into
  5452. * @returns the unmodified current Color3
  5453. */
  5454. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5455. /**
  5456. * Copy the current object
  5457. * @returns a new Color3 copied the current one
  5458. */
  5459. clone(): Color3;
  5460. /**
  5461. * Copies the rgb values from the source in the current Color3
  5462. * @param source defines the source Color3 object
  5463. * @returns the updated Color3 object
  5464. */
  5465. copyFrom(source: DeepImmutable<Color3>): Color3;
  5466. /**
  5467. * Updates the Color3 rgb values from the given floats
  5468. * @param r defines the red component to read from
  5469. * @param g defines the green component to read from
  5470. * @param b defines the blue component to read from
  5471. * @returns the current Color3 object
  5472. */
  5473. copyFromFloats(r: number, g: number, b: number): Color3;
  5474. /**
  5475. * Updates the Color3 rgb values from the given floats
  5476. * @param r defines the red component to read from
  5477. * @param g defines the green component to read from
  5478. * @param b defines the blue component to read from
  5479. * @returns the current Color3 object
  5480. */
  5481. set(r: number, g: number, b: number): Color3;
  5482. /**
  5483. * Compute the Color3 hexadecimal code as a string
  5484. * @returns a string containing the hexadecimal representation of the Color3 object
  5485. */
  5486. toHexString(): string;
  5487. /**
  5488. * Computes a new Color3 converted from the current one to linear space
  5489. * @returns a new Color3 object
  5490. */
  5491. toLinearSpace(): Color3;
  5492. /**
  5493. * Converts current color in rgb space to HSV values
  5494. * @returns a new color3 representing the HSV values
  5495. */
  5496. toHSV(): Color3;
  5497. /**
  5498. * Converts current color in rgb space to HSV values
  5499. * @param result defines the Color3 where to store the HSV values
  5500. */
  5501. toHSVToRef(result: Color3): void;
  5502. /**
  5503. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5504. * @param convertedColor defines the Color3 object where to store the linear space version
  5505. * @returns the unmodified Color3
  5506. */
  5507. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5508. /**
  5509. * Computes a new Color3 converted from the current one to gamma space
  5510. * @returns a new Color3 object
  5511. */
  5512. toGammaSpace(): Color3;
  5513. /**
  5514. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5515. * @param convertedColor defines the Color3 object where to store the gamma space version
  5516. * @returns the unmodified Color3
  5517. */
  5518. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5519. private static _BlackReadOnly;
  5520. /**
  5521. * Convert Hue, saturation and value to a Color3 (RGB)
  5522. * @param hue defines the hue
  5523. * @param saturation defines the saturation
  5524. * @param value defines the value
  5525. * @param result defines the Color3 where to store the RGB values
  5526. */
  5527. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5528. /**
  5529. * Creates a new Color3 from the string containing valid hexadecimal values
  5530. * @param hex defines a string containing valid hexadecimal values
  5531. * @returns a new Color3 object
  5532. */
  5533. static FromHexString(hex: string): Color3;
  5534. /**
  5535. * Creates a new Color3 from the starting index of the given array
  5536. * @param array defines the source array
  5537. * @param offset defines an offset in the source array
  5538. * @returns a new Color3 object
  5539. */
  5540. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5541. /**
  5542. * Creates a new Color3 from integer values (< 256)
  5543. * @param r defines the red component to read from (value between 0 and 255)
  5544. * @param g defines the green component to read from (value between 0 and 255)
  5545. * @param b defines the blue component to read from (value between 0 and 255)
  5546. * @returns a new Color3 object
  5547. */
  5548. static FromInts(r: number, g: number, b: number): Color3;
  5549. /**
  5550. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5551. * @param start defines the start Color3 value
  5552. * @param end defines the end Color3 value
  5553. * @param amount defines the gradient value between start and end
  5554. * @returns a new Color3 object
  5555. */
  5556. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5557. /**
  5558. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5559. * @param left defines the start value
  5560. * @param right defines the end value
  5561. * @param amount defines the gradient factor
  5562. * @param result defines the Color3 object where to store the result
  5563. */
  5564. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5565. /**
  5566. * Returns a Color3 value containing a red color
  5567. * @returns a new Color3 object
  5568. */
  5569. static Red(): Color3;
  5570. /**
  5571. * Returns a Color3 value containing a green color
  5572. * @returns a new Color3 object
  5573. */
  5574. static Green(): Color3;
  5575. /**
  5576. * Returns a Color3 value containing a blue color
  5577. * @returns a new Color3 object
  5578. */
  5579. static Blue(): Color3;
  5580. /**
  5581. * Returns a Color3 value containing a black color
  5582. * @returns a new Color3 object
  5583. */
  5584. static Black(): Color3;
  5585. /**
  5586. * Gets a Color3 value containing a black color that must not be updated
  5587. */
  5588. static get BlackReadOnly(): DeepImmutable<Color3>;
  5589. /**
  5590. * Returns a Color3 value containing a white color
  5591. * @returns a new Color3 object
  5592. */
  5593. static White(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a purple color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Purple(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a magenta color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Magenta(): Color3;
  5604. /**
  5605. * Returns a Color3 value containing a yellow color
  5606. * @returns a new Color3 object
  5607. */
  5608. static Yellow(): Color3;
  5609. /**
  5610. * Returns a Color3 value containing a gray color
  5611. * @returns a new Color3 object
  5612. */
  5613. static Gray(): Color3;
  5614. /**
  5615. * Returns a Color3 value containing a teal color
  5616. * @returns a new Color3 object
  5617. */
  5618. static Teal(): Color3;
  5619. /**
  5620. * Returns a Color3 value containing a random color
  5621. * @returns a new Color3 object
  5622. */
  5623. static Random(): Color3;
  5624. }
  5625. /**
  5626. * Class used to hold a RBGA color
  5627. */
  5628. export class Color4 {
  5629. /**
  5630. * Defines the red component (between 0 and 1, default is 0)
  5631. */
  5632. r: number;
  5633. /**
  5634. * Defines the green component (between 0 and 1, default is 0)
  5635. */
  5636. g: number;
  5637. /**
  5638. * Defines the blue component (between 0 and 1, default is 0)
  5639. */
  5640. b: number;
  5641. /**
  5642. * Defines the alpha component (between 0 and 1, default is 1)
  5643. */
  5644. a: number;
  5645. /**
  5646. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5647. * @param r defines the red component (between 0 and 1, default is 0)
  5648. * @param g defines the green component (between 0 and 1, default is 0)
  5649. * @param b defines the blue component (between 0 and 1, default is 0)
  5650. * @param a defines the alpha component (between 0 and 1, default is 1)
  5651. */
  5652. constructor(
  5653. /**
  5654. * Defines the red component (between 0 and 1, default is 0)
  5655. */
  5656. r?: number,
  5657. /**
  5658. * Defines the green component (between 0 and 1, default is 0)
  5659. */
  5660. g?: number,
  5661. /**
  5662. * Defines the blue component (between 0 and 1, default is 0)
  5663. */
  5664. b?: number,
  5665. /**
  5666. * Defines the alpha component (between 0 and 1, default is 1)
  5667. */
  5668. a?: number);
  5669. /**
  5670. * Adds in place the given Color4 values to the current Color4 object
  5671. * @param right defines the second operand
  5672. * @returns the current updated Color4 object
  5673. */
  5674. addInPlace(right: DeepImmutable<Color4>): Color4;
  5675. /**
  5676. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5677. * @returns the new array
  5678. */
  5679. asArray(): number[];
  5680. /**
  5681. * Stores from the starting index in the given array the Color4 successive values
  5682. * @param array defines the array where to store the r,g,b components
  5683. * @param index defines an optional index in the target array to define where to start storing values
  5684. * @returns the current Color4 object
  5685. */
  5686. toArray(array: number[], index?: number): Color4;
  5687. /**
  5688. * Determines equality between Color4 objects
  5689. * @param otherColor defines the second operand
  5690. * @returns true if the rgba values are equal to the given ones
  5691. */
  5692. equals(otherColor: DeepImmutable<Color4>): boolean;
  5693. /**
  5694. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5695. * @param right defines the second operand
  5696. * @returns a new Color4 object
  5697. */
  5698. add(right: DeepImmutable<Color4>): Color4;
  5699. /**
  5700. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5701. * @param right defines the second operand
  5702. * @returns a new Color4 object
  5703. */
  5704. subtract(right: DeepImmutable<Color4>): Color4;
  5705. /**
  5706. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5707. * @param right defines the second operand
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the current Color4 object
  5710. */
  5711. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5712. /**
  5713. * Creates a new Color4 with the current Color4 values multiplied by scale
  5714. * @param scale defines the scaling factor to apply
  5715. * @returns a new Color4 object
  5716. */
  5717. scale(scale: number): Color4;
  5718. /**
  5719. * Multiplies the current Color4 values by scale and stores the result in "result"
  5720. * @param scale defines the scaling factor to apply
  5721. * @param result defines the Color4 object where to store the result
  5722. * @returns the current unmodified Color4
  5723. */
  5724. scaleToRef(scale: number, result: Color4): Color4;
  5725. /**
  5726. * Scale the current Color4 values by a factor and add the result to a given Color4
  5727. * @param scale defines the scale factor
  5728. * @param result defines the Color4 object where to store the result
  5729. * @returns the unmodified current Color4
  5730. */
  5731. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5732. /**
  5733. * Clamps the rgb values by the min and max values and stores the result into "result"
  5734. * @param min defines minimum clamping value (default is 0)
  5735. * @param max defines maximum clamping value (default is 1)
  5736. * @param result defines color to store the result into.
  5737. * @returns the cuurent Color4
  5738. */
  5739. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5740. /**
  5741. * Multipy an Color4 value by another and return a new Color4 object
  5742. * @param color defines the Color4 value to multiply by
  5743. * @returns a new Color4 object
  5744. */
  5745. multiply(color: Color4): Color4;
  5746. /**
  5747. * Multipy a Color4 value by another and push the result in a reference value
  5748. * @param color defines the Color4 value to multiply by
  5749. * @param result defines the Color4 to fill the result in
  5750. * @returns the result Color4
  5751. */
  5752. multiplyToRef(color: Color4, result: Color4): Color4;
  5753. /**
  5754. * Creates a string with the Color4 current values
  5755. * @returns the string representation of the Color4 object
  5756. */
  5757. toString(): string;
  5758. /**
  5759. * Returns the string "Color4"
  5760. * @returns "Color4"
  5761. */
  5762. getClassName(): string;
  5763. /**
  5764. * Compute the Color4 hash code
  5765. * @returns an unique number that can be used to hash Color4 objects
  5766. */
  5767. getHashCode(): number;
  5768. /**
  5769. * Creates a new Color4 copied from the current one
  5770. * @returns a new Color4 object
  5771. */
  5772. clone(): Color4;
  5773. /**
  5774. * Copies the given Color4 values into the current one
  5775. * @param source defines the source Color4 object
  5776. * @returns the current updated Color4 object
  5777. */
  5778. copyFrom(source: Color4): Color4;
  5779. /**
  5780. * Copies the given float values into the current one
  5781. * @param r defines the red component to read from
  5782. * @param g defines the green component to read from
  5783. * @param b defines the blue component to read from
  5784. * @param a defines the alpha component to read from
  5785. * @returns the current updated Color4 object
  5786. */
  5787. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5788. /**
  5789. * Copies the given float values into the current one
  5790. * @param r defines the red component to read from
  5791. * @param g defines the green component to read from
  5792. * @param b defines the blue component to read from
  5793. * @param a defines the alpha component to read from
  5794. * @returns the current updated Color4 object
  5795. */
  5796. set(r: number, g: number, b: number, a: number): Color4;
  5797. /**
  5798. * Compute the Color4 hexadecimal code as a string
  5799. * @returns a string containing the hexadecimal representation of the Color4 object
  5800. */
  5801. toHexString(): string;
  5802. /**
  5803. * Computes a new Color4 converted from the current one to linear space
  5804. * @returns a new Color4 object
  5805. */
  5806. toLinearSpace(): Color4;
  5807. /**
  5808. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5809. * @param convertedColor defines the Color4 object where to store the linear space version
  5810. * @returns the unmodified Color4
  5811. */
  5812. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5813. /**
  5814. * Computes a new Color4 converted from the current one to gamma space
  5815. * @returns a new Color4 object
  5816. */
  5817. toGammaSpace(): Color4;
  5818. /**
  5819. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5820. * @param convertedColor defines the Color4 object where to store the gamma space version
  5821. * @returns the unmodified Color4
  5822. */
  5823. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5824. /**
  5825. * Creates a new Color4 from the string containing valid hexadecimal values
  5826. * @param hex defines a string containing valid hexadecimal values
  5827. * @returns a new Color4 object
  5828. */
  5829. static FromHexString(hex: string): Color4;
  5830. /**
  5831. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5832. * @param left defines the start value
  5833. * @param right defines the end value
  5834. * @param amount defines the gradient factor
  5835. * @returns a new Color4 object
  5836. */
  5837. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5838. /**
  5839. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5840. * @param left defines the start value
  5841. * @param right defines the end value
  5842. * @param amount defines the gradient factor
  5843. * @param result defines the Color4 object where to store data
  5844. */
  5845. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5846. /**
  5847. * Creates a new Color4 from a Color3 and an alpha value
  5848. * @param color3 defines the source Color3 to read from
  5849. * @param alpha defines the alpha component (1.0 by default)
  5850. * @returns a new Color4 object
  5851. */
  5852. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5853. /**
  5854. * Creates a new Color4 from the starting index element of the given array
  5855. * @param array defines the source array to read from
  5856. * @param offset defines the offset in the source array
  5857. * @returns a new Color4 object
  5858. */
  5859. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5860. /**
  5861. * Creates a new Color3 from integer values (< 256)
  5862. * @param r defines the red component to read from (value between 0 and 255)
  5863. * @param g defines the green component to read from (value between 0 and 255)
  5864. * @param b defines the blue component to read from (value between 0 and 255)
  5865. * @param a defines the alpha component to read from (value between 0 and 255)
  5866. * @returns a new Color3 object
  5867. */
  5868. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5869. /**
  5870. * Check the content of a given array and convert it to an array containing RGBA data
  5871. * If the original array was already containing count * 4 values then it is returned directly
  5872. * @param colors defines the array to check
  5873. * @param count defines the number of RGBA data to expect
  5874. * @returns an array containing count * 4 values (RGBA)
  5875. */
  5876. static CheckColors4(colors: number[], count: number): number[];
  5877. }
  5878. /**
  5879. * @hidden
  5880. */
  5881. export class TmpColors {
  5882. static Color3: Color3[];
  5883. static Color4: Color4[];
  5884. }
  5885. }
  5886. declare module "babylonjs/Animations/animationKey" {
  5887. /**
  5888. * Defines an interface which represents an animation key frame
  5889. */
  5890. export interface IAnimationKey {
  5891. /**
  5892. * Frame of the key frame
  5893. */
  5894. frame: number;
  5895. /**
  5896. * Value at the specifies key frame
  5897. */
  5898. value: any;
  5899. /**
  5900. * The input tangent for the cubic hermite spline
  5901. */
  5902. inTangent?: any;
  5903. /**
  5904. * The output tangent for the cubic hermite spline
  5905. */
  5906. outTangent?: any;
  5907. /**
  5908. * The animation interpolation type
  5909. */
  5910. interpolation?: AnimationKeyInterpolation;
  5911. }
  5912. /**
  5913. * Enum for the animation key frame interpolation type
  5914. */
  5915. export enum AnimationKeyInterpolation {
  5916. /**
  5917. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5918. */
  5919. STEP = 1
  5920. }
  5921. }
  5922. declare module "babylonjs/Animations/animationRange" {
  5923. /**
  5924. * Represents the range of an animation
  5925. */
  5926. export class AnimationRange {
  5927. /**The name of the animation range**/
  5928. name: string;
  5929. /**The starting frame of the animation */
  5930. from: number;
  5931. /**The ending frame of the animation*/
  5932. to: number;
  5933. /**
  5934. * Initializes the range of an animation
  5935. * @param name The name of the animation range
  5936. * @param from The starting frame of the animation
  5937. * @param to The ending frame of the animation
  5938. */
  5939. constructor(
  5940. /**The name of the animation range**/
  5941. name: string,
  5942. /**The starting frame of the animation */
  5943. from: number,
  5944. /**The ending frame of the animation*/
  5945. to: number);
  5946. /**
  5947. * Makes a copy of the animation range
  5948. * @returns A copy of the animation range
  5949. */
  5950. clone(): AnimationRange;
  5951. }
  5952. }
  5953. declare module "babylonjs/Animations/animationEvent" {
  5954. /**
  5955. * Composed of a frame, and an action function
  5956. */
  5957. export class AnimationEvent {
  5958. /** The frame for which the event is triggered **/
  5959. frame: number;
  5960. /** The event to perform when triggered **/
  5961. action: (currentFrame: number) => void;
  5962. /** Specifies if the event should be triggered only once**/
  5963. onlyOnce?: boolean | undefined;
  5964. /**
  5965. * Specifies if the animation event is done
  5966. */
  5967. isDone: boolean;
  5968. /**
  5969. * Initializes the animation event
  5970. * @param frame The frame for which the event is triggered
  5971. * @param action The event to perform when triggered
  5972. * @param onlyOnce Specifies if the event should be triggered only once
  5973. */
  5974. constructor(
  5975. /** The frame for which the event is triggered **/
  5976. frame: number,
  5977. /** The event to perform when triggered **/
  5978. action: (currentFrame: number) => void,
  5979. /** Specifies if the event should be triggered only once**/
  5980. onlyOnce?: boolean | undefined);
  5981. /** @hidden */
  5982. _clone(): AnimationEvent;
  5983. }
  5984. }
  5985. declare module "babylonjs/Behaviors/behavior" {
  5986. import { Nullable } from "babylonjs/types";
  5987. /**
  5988. * Interface used to define a behavior
  5989. */
  5990. export interface Behavior<T> {
  5991. /** gets or sets behavior's name */
  5992. name: string;
  5993. /**
  5994. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5995. */
  5996. init(): void;
  5997. /**
  5998. * Called when the behavior is attached to a target
  5999. * @param target defines the target where the behavior is attached to
  6000. */
  6001. attach(target: T): void;
  6002. /**
  6003. * Called when the behavior is detached from its target
  6004. */
  6005. detach(): void;
  6006. }
  6007. /**
  6008. * Interface implemented by classes supporting behaviors
  6009. */
  6010. export interface IBehaviorAware<T> {
  6011. /**
  6012. * Attach a behavior
  6013. * @param behavior defines the behavior to attach
  6014. * @returns the current host
  6015. */
  6016. addBehavior(behavior: Behavior<T>): T;
  6017. /**
  6018. * Remove a behavior from the current object
  6019. * @param behavior defines the behavior to detach
  6020. * @returns the current host
  6021. */
  6022. removeBehavior(behavior: Behavior<T>): T;
  6023. /**
  6024. * Gets a behavior using its name to search
  6025. * @param name defines the name to search
  6026. * @returns the behavior or null if not found
  6027. */
  6028. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6029. }
  6030. }
  6031. declare module "babylonjs/Misc/smartArray" {
  6032. /**
  6033. * Defines an array and its length.
  6034. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6035. */
  6036. export interface ISmartArrayLike<T> {
  6037. /**
  6038. * The data of the array.
  6039. */
  6040. data: Array<T>;
  6041. /**
  6042. * The active length of the array.
  6043. */
  6044. length: number;
  6045. }
  6046. /**
  6047. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6048. */
  6049. export class SmartArray<T> implements ISmartArrayLike<T> {
  6050. /**
  6051. * The full set of data from the array.
  6052. */
  6053. data: Array<T>;
  6054. /**
  6055. * The active length of the array.
  6056. */
  6057. length: number;
  6058. protected _id: number;
  6059. /**
  6060. * Instantiates a Smart Array.
  6061. * @param capacity defines the default capacity of the array.
  6062. */
  6063. constructor(capacity: number);
  6064. /**
  6065. * Pushes a value at the end of the active data.
  6066. * @param value defines the object to push in the array.
  6067. */
  6068. push(value: T): void;
  6069. /**
  6070. * Iterates over the active data and apply the lambda to them.
  6071. * @param func defines the action to apply on each value.
  6072. */
  6073. forEach(func: (content: T) => void): void;
  6074. /**
  6075. * Sorts the full sets of data.
  6076. * @param compareFn defines the comparison function to apply.
  6077. */
  6078. sort(compareFn: (a: T, b: T) => number): void;
  6079. /**
  6080. * Resets the active data to an empty array.
  6081. */
  6082. reset(): void;
  6083. /**
  6084. * Releases all the data from the array as well as the array.
  6085. */
  6086. dispose(): void;
  6087. /**
  6088. * Concats the active data with a given array.
  6089. * @param array defines the data to concatenate with.
  6090. */
  6091. concat(array: any): void;
  6092. /**
  6093. * Returns the position of a value in the active data.
  6094. * @param value defines the value to find the index for
  6095. * @returns the index if found in the active data otherwise -1
  6096. */
  6097. indexOf(value: T): number;
  6098. /**
  6099. * Returns whether an element is part of the active data.
  6100. * @param value defines the value to look for
  6101. * @returns true if found in the active data otherwise false
  6102. */
  6103. contains(value: T): boolean;
  6104. private static _GlobalId;
  6105. }
  6106. /**
  6107. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6108. * The data in this array can only be present once
  6109. */
  6110. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6111. private _duplicateId;
  6112. /**
  6113. * Pushes a value at the end of the active data.
  6114. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6115. * @param value defines the object to push in the array.
  6116. */
  6117. push(value: T): void;
  6118. /**
  6119. * Pushes a value at the end of the active data.
  6120. * If the data is already present, it won t be added again
  6121. * @param value defines the object to push in the array.
  6122. * @returns true if added false if it was already present
  6123. */
  6124. pushNoDuplicate(value: T): boolean;
  6125. /**
  6126. * Resets the active data to an empty array.
  6127. */
  6128. reset(): void;
  6129. /**
  6130. * Concats the active data with a given array.
  6131. * This ensures no dupplicate will be present in the result.
  6132. * @param array defines the data to concatenate with.
  6133. */
  6134. concatWithNoDuplicate(array: any): void;
  6135. }
  6136. }
  6137. declare module "babylonjs/Cameras/cameraInputsManager" {
  6138. import { Nullable } from "babylonjs/types";
  6139. import { Camera } from "babylonjs/Cameras/camera";
  6140. /**
  6141. * @ignore
  6142. * This is a list of all the different input types that are available in the application.
  6143. * Fo instance: ArcRotateCameraGamepadInput...
  6144. */
  6145. export var CameraInputTypes: {};
  6146. /**
  6147. * This is the contract to implement in order to create a new input class.
  6148. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6149. */
  6150. export interface ICameraInput<TCamera extends Camera> {
  6151. /**
  6152. * Defines the camera the input is attached to.
  6153. */
  6154. camera: Nullable<TCamera>;
  6155. /**
  6156. * Gets the class name of the current intput.
  6157. * @returns the class name
  6158. */
  6159. getClassName(): string;
  6160. /**
  6161. * Get the friendly name associated with the input class.
  6162. * @returns the input friendly name
  6163. */
  6164. getSimpleName(): string;
  6165. /**
  6166. * Attach the input controls to a specific dom element to get the input from.
  6167. * @param element Defines the element the controls should be listened from
  6168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6169. */
  6170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6171. /**
  6172. * Detach the current controls from the specified dom element.
  6173. * @param element Defines the element to stop listening the inputs from
  6174. */
  6175. detachControl(element: Nullable<HTMLElement>): void;
  6176. /**
  6177. * Update the current camera state depending on the inputs that have been used this frame.
  6178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6179. */
  6180. checkInputs?: () => void;
  6181. }
  6182. /**
  6183. * Represents a map of input types to input instance or input index to input instance.
  6184. */
  6185. export interface CameraInputsMap<TCamera extends Camera> {
  6186. /**
  6187. * Accessor to the input by input type.
  6188. */
  6189. [name: string]: ICameraInput<TCamera>;
  6190. /**
  6191. * Accessor to the input by input index.
  6192. */
  6193. [idx: number]: ICameraInput<TCamera>;
  6194. }
  6195. /**
  6196. * This represents the input manager used within a camera.
  6197. * It helps dealing with all the different kind of input attached to a camera.
  6198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6199. */
  6200. export class CameraInputsManager<TCamera extends Camera> {
  6201. /**
  6202. * Defines the list of inputs attahed to the camera.
  6203. */
  6204. attached: CameraInputsMap<TCamera>;
  6205. /**
  6206. * Defines the dom element the camera is collecting inputs from.
  6207. * This is null if the controls have not been attached.
  6208. */
  6209. attachedElement: Nullable<HTMLElement>;
  6210. /**
  6211. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6212. */
  6213. noPreventDefault: boolean;
  6214. /**
  6215. * Defined the camera the input manager belongs to.
  6216. */
  6217. camera: TCamera;
  6218. /**
  6219. * Update the current camera state depending on the inputs that have been used this frame.
  6220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6221. */
  6222. checkInputs: () => void;
  6223. /**
  6224. * Instantiate a new Camera Input Manager.
  6225. * @param camera Defines the camera the input manager blongs to
  6226. */
  6227. constructor(camera: TCamera);
  6228. /**
  6229. * Add an input method to a camera
  6230. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6231. * @param input camera input method
  6232. */
  6233. add(input: ICameraInput<TCamera>): void;
  6234. /**
  6235. * Remove a specific input method from a camera
  6236. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6237. * @param inputToRemove camera input method
  6238. */
  6239. remove(inputToRemove: ICameraInput<TCamera>): void;
  6240. /**
  6241. * Remove a specific input type from a camera
  6242. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6243. * @param inputType the type of the input to remove
  6244. */
  6245. removeByType(inputType: string): void;
  6246. private _addCheckInputs;
  6247. /**
  6248. * Attach the input controls to the currently attached dom element to listen the events from.
  6249. * @param input Defines the input to attach
  6250. */
  6251. attachInput(input: ICameraInput<TCamera>): void;
  6252. /**
  6253. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6254. * @param element Defines the dom element to collect the events from
  6255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6256. */
  6257. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6258. /**
  6259. * Detach the current manager inputs controls from a specific dom element.
  6260. * @param element Defines the dom element to collect the events from
  6261. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6262. */
  6263. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6264. /**
  6265. * Rebuild the dynamic inputCheck function from the current list of
  6266. * defined inputs in the manager.
  6267. */
  6268. rebuildInputCheck(): void;
  6269. /**
  6270. * Remove all attached input methods from a camera
  6271. */
  6272. clear(): void;
  6273. /**
  6274. * Serialize the current input manager attached to a camera.
  6275. * This ensures than once parsed,
  6276. * the input associated to the camera will be identical to the current ones
  6277. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6278. */
  6279. serialize(serializedCamera: any): void;
  6280. /**
  6281. * Parses an input manager serialized JSON to restore the previous list of inputs
  6282. * and states associated to a camera.
  6283. * @param parsedCamera Defines the JSON to parse
  6284. */
  6285. parse(parsedCamera: any): void;
  6286. }
  6287. }
  6288. declare module "babylonjs/Meshes/buffer" {
  6289. import { Nullable, DataArray } from "babylonjs/types";
  6290. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6291. /**
  6292. * Class used to store data that will be store in GPU memory
  6293. */
  6294. export class Buffer {
  6295. private _engine;
  6296. private _buffer;
  6297. /** @hidden */
  6298. _data: Nullable<DataArray>;
  6299. private _updatable;
  6300. private _instanced;
  6301. private _divisor;
  6302. /**
  6303. * Gets the byte stride.
  6304. */
  6305. readonly byteStride: number;
  6306. /**
  6307. * Constructor
  6308. * @param engine the engine
  6309. * @param data the data to use for this buffer
  6310. * @param updatable whether the data is updatable
  6311. * @param stride the stride (optional)
  6312. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6313. * @param instanced whether the buffer is instanced (optional)
  6314. * @param useBytes set to true if the stride in in bytes (optional)
  6315. * @param divisor sets an optional divisor for instances (1 by default)
  6316. */
  6317. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6318. /**
  6319. * Create a new VertexBuffer based on the current buffer
  6320. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6321. * @param offset defines offset in the buffer (0 by default)
  6322. * @param size defines the size in floats of attributes (position is 3 for instance)
  6323. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6324. * @param instanced defines if the vertex buffer contains indexed data
  6325. * @param useBytes defines if the offset and stride are in bytes *
  6326. * @param divisor sets an optional divisor for instances (1 by default)
  6327. * @returns the new vertex buffer
  6328. */
  6329. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6330. /**
  6331. * Gets a boolean indicating if the Buffer is updatable?
  6332. * @returns true if the buffer is updatable
  6333. */
  6334. isUpdatable(): boolean;
  6335. /**
  6336. * Gets current buffer's data
  6337. * @returns a DataArray or null
  6338. */
  6339. getData(): Nullable<DataArray>;
  6340. /**
  6341. * Gets underlying native buffer
  6342. * @returns underlying native buffer
  6343. */
  6344. getBuffer(): Nullable<DataBuffer>;
  6345. /**
  6346. * Gets the stride in float32 units (i.e. byte stride / 4).
  6347. * May not be an integer if the byte stride is not divisible by 4.
  6348. * @returns the stride in float32 units
  6349. * @deprecated Please use byteStride instead.
  6350. */
  6351. getStrideSize(): number;
  6352. /**
  6353. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6354. * @param data defines the data to store
  6355. */
  6356. create(data?: Nullable<DataArray>): void;
  6357. /** @hidden */
  6358. _rebuild(): void;
  6359. /**
  6360. * Update current buffer data
  6361. * @param data defines the data to store
  6362. */
  6363. update(data: DataArray): void;
  6364. /**
  6365. * Updates the data directly.
  6366. * @param data the new data
  6367. * @param offset the new offset
  6368. * @param vertexCount the vertex count (optional)
  6369. * @param useBytes set to true if the offset is in bytes
  6370. */
  6371. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6372. /**
  6373. * Release all resources
  6374. */
  6375. dispose(): void;
  6376. }
  6377. /**
  6378. * Specialized buffer used to store vertex data
  6379. */
  6380. export class VertexBuffer {
  6381. /** @hidden */
  6382. _buffer: Buffer;
  6383. private _kind;
  6384. private _size;
  6385. private _ownsBuffer;
  6386. private _instanced;
  6387. private _instanceDivisor;
  6388. /**
  6389. * The byte type.
  6390. */
  6391. static readonly BYTE: number;
  6392. /**
  6393. * The unsigned byte type.
  6394. */
  6395. static readonly UNSIGNED_BYTE: number;
  6396. /**
  6397. * The short type.
  6398. */
  6399. static readonly SHORT: number;
  6400. /**
  6401. * The unsigned short type.
  6402. */
  6403. static readonly UNSIGNED_SHORT: number;
  6404. /**
  6405. * The integer type.
  6406. */
  6407. static readonly INT: number;
  6408. /**
  6409. * The unsigned integer type.
  6410. */
  6411. static readonly UNSIGNED_INT: number;
  6412. /**
  6413. * The float type.
  6414. */
  6415. static readonly FLOAT: number;
  6416. /**
  6417. * Gets or sets the instance divisor when in instanced mode
  6418. */
  6419. get instanceDivisor(): number;
  6420. set instanceDivisor(value: number);
  6421. /**
  6422. * Gets the byte stride.
  6423. */
  6424. readonly byteStride: number;
  6425. /**
  6426. * Gets the byte offset.
  6427. */
  6428. readonly byteOffset: number;
  6429. /**
  6430. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6431. */
  6432. readonly normalized: boolean;
  6433. /**
  6434. * Gets the data type of each component in the array.
  6435. */
  6436. readonly type: number;
  6437. /**
  6438. * Constructor
  6439. * @param engine the engine
  6440. * @param data the data to use for this vertex buffer
  6441. * @param kind the vertex buffer kind
  6442. * @param updatable whether the data is updatable
  6443. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6444. * @param stride the stride (optional)
  6445. * @param instanced whether the buffer is instanced (optional)
  6446. * @param offset the offset of the data (optional)
  6447. * @param size the number of components (optional)
  6448. * @param type the type of the component (optional)
  6449. * @param normalized whether the data contains normalized data (optional)
  6450. * @param useBytes set to true if stride and offset are in bytes (optional)
  6451. * @param divisor defines the instance divisor to use (1 by default)
  6452. */
  6453. 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);
  6454. /** @hidden */
  6455. _rebuild(): void;
  6456. /**
  6457. * Returns the kind of the VertexBuffer (string)
  6458. * @returns a string
  6459. */
  6460. getKind(): string;
  6461. /**
  6462. * Gets a boolean indicating if the VertexBuffer is updatable?
  6463. * @returns true if the buffer is updatable
  6464. */
  6465. isUpdatable(): boolean;
  6466. /**
  6467. * Gets current buffer's data
  6468. * @returns a DataArray or null
  6469. */
  6470. getData(): Nullable<DataArray>;
  6471. /**
  6472. * Gets underlying native buffer
  6473. * @returns underlying native buffer
  6474. */
  6475. getBuffer(): Nullable<DataBuffer>;
  6476. /**
  6477. * Gets the stride in float32 units (i.e. byte stride / 4).
  6478. * May not be an integer if the byte stride is not divisible by 4.
  6479. * @returns the stride in float32 units
  6480. * @deprecated Please use byteStride instead.
  6481. */
  6482. getStrideSize(): number;
  6483. /**
  6484. * Returns the offset as a multiple of the type byte length.
  6485. * @returns the offset in bytes
  6486. * @deprecated Please use byteOffset instead.
  6487. */
  6488. getOffset(): number;
  6489. /**
  6490. * Returns the number of components per vertex attribute (integer)
  6491. * @returns the size in float
  6492. */
  6493. getSize(): number;
  6494. /**
  6495. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6496. * @returns true if this buffer is instanced
  6497. */
  6498. getIsInstanced(): boolean;
  6499. /**
  6500. * Returns the instancing divisor, zero for non-instanced (integer).
  6501. * @returns a number
  6502. */
  6503. getInstanceDivisor(): number;
  6504. /**
  6505. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6506. * @param data defines the data to store
  6507. */
  6508. create(data?: DataArray): void;
  6509. /**
  6510. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6511. * This function will create a new buffer if the current one is not updatable
  6512. * @param data defines the data to store
  6513. */
  6514. update(data: DataArray): void;
  6515. /**
  6516. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6517. * Returns the directly updated WebGLBuffer.
  6518. * @param data the new data
  6519. * @param offset the new offset
  6520. * @param useBytes set to true if the offset is in bytes
  6521. */
  6522. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6523. /**
  6524. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6525. */
  6526. dispose(): void;
  6527. /**
  6528. * Enumerates each value of this vertex buffer as numbers.
  6529. * @param count the number of values to enumerate
  6530. * @param callback the callback function called for each value
  6531. */
  6532. forEach(count: number, callback: (value: number, index: number) => void): void;
  6533. /**
  6534. * Positions
  6535. */
  6536. static readonly PositionKind: string;
  6537. /**
  6538. * Normals
  6539. */
  6540. static readonly NormalKind: string;
  6541. /**
  6542. * Tangents
  6543. */
  6544. static readonly TangentKind: string;
  6545. /**
  6546. * Texture coordinates
  6547. */
  6548. static readonly UVKind: string;
  6549. /**
  6550. * Texture coordinates 2
  6551. */
  6552. static readonly UV2Kind: string;
  6553. /**
  6554. * Texture coordinates 3
  6555. */
  6556. static readonly UV3Kind: string;
  6557. /**
  6558. * Texture coordinates 4
  6559. */
  6560. static readonly UV4Kind: string;
  6561. /**
  6562. * Texture coordinates 5
  6563. */
  6564. static readonly UV5Kind: string;
  6565. /**
  6566. * Texture coordinates 6
  6567. */
  6568. static readonly UV6Kind: string;
  6569. /**
  6570. * Colors
  6571. */
  6572. static readonly ColorKind: string;
  6573. /**
  6574. * Matrix indices (for bones)
  6575. */
  6576. static readonly MatricesIndicesKind: string;
  6577. /**
  6578. * Matrix weights (for bones)
  6579. */
  6580. static readonly MatricesWeightsKind: string;
  6581. /**
  6582. * Additional matrix indices (for bones)
  6583. */
  6584. static readonly MatricesIndicesExtraKind: string;
  6585. /**
  6586. * Additional matrix weights (for bones)
  6587. */
  6588. static readonly MatricesWeightsExtraKind: string;
  6589. /**
  6590. * Deduces the stride given a kind.
  6591. * @param kind The kind string to deduce
  6592. * @returns The deduced stride
  6593. */
  6594. static DeduceStride(kind: string): number;
  6595. /**
  6596. * Gets the byte length of the given type.
  6597. * @param type the type
  6598. * @returns the number of bytes
  6599. */
  6600. static GetTypeByteLength(type: number): number;
  6601. /**
  6602. * Enumerates each value of the given parameters as numbers.
  6603. * @param data the data to enumerate
  6604. * @param byteOffset the byte offset of the data
  6605. * @param byteStride the byte stride of the data
  6606. * @param componentCount the number of components per element
  6607. * @param componentType the type of the component
  6608. * @param count the number of values to enumerate
  6609. * @param normalized whether the data is normalized
  6610. * @param callback the callback function called for each value
  6611. */
  6612. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6613. private static _GetFloatValue;
  6614. }
  6615. }
  6616. declare module "babylonjs/Collisions/intersectionInfo" {
  6617. import { Nullable } from "babylonjs/types";
  6618. /**
  6619. * @hidden
  6620. */
  6621. export class IntersectionInfo {
  6622. bu: Nullable<number>;
  6623. bv: Nullable<number>;
  6624. distance: number;
  6625. faceId: number;
  6626. subMeshId: number;
  6627. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6628. }
  6629. }
  6630. declare module "babylonjs/Maths/math.plane" {
  6631. import { DeepImmutable } from "babylonjs/types";
  6632. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6633. /**
  6634. * Represens a plane by the equation ax + by + cz + d = 0
  6635. */
  6636. export class Plane {
  6637. private static _TmpMatrix;
  6638. /**
  6639. * Normal of the plane (a,b,c)
  6640. */
  6641. normal: Vector3;
  6642. /**
  6643. * d component of the plane
  6644. */
  6645. d: number;
  6646. /**
  6647. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6648. * @param a a component of the plane
  6649. * @param b b component of the plane
  6650. * @param c c component of the plane
  6651. * @param d d component of the plane
  6652. */
  6653. constructor(a: number, b: number, c: number, d: number);
  6654. /**
  6655. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6656. */
  6657. asArray(): number[];
  6658. /**
  6659. * @returns a new plane copied from the current Plane.
  6660. */
  6661. clone(): Plane;
  6662. /**
  6663. * @returns the string "Plane".
  6664. */
  6665. getClassName(): string;
  6666. /**
  6667. * @returns the Plane hash code.
  6668. */
  6669. getHashCode(): number;
  6670. /**
  6671. * Normalize the current Plane in place.
  6672. * @returns the updated Plane.
  6673. */
  6674. normalize(): Plane;
  6675. /**
  6676. * Applies a transformation the plane and returns the result
  6677. * @param transformation the transformation matrix to be applied to the plane
  6678. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6679. */
  6680. transform(transformation: DeepImmutable<Matrix>): Plane;
  6681. /**
  6682. * Calcualtte the dot product between the point and the plane normal
  6683. * @param point point to calculate the dot product with
  6684. * @returns the dot product (float) of the point coordinates and the plane normal.
  6685. */
  6686. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6687. /**
  6688. * Updates the current Plane from the plane defined by the three given points.
  6689. * @param point1 one of the points used to contruct the plane
  6690. * @param point2 one of the points used to contruct the plane
  6691. * @param point3 one of the points used to contruct the plane
  6692. * @returns the updated Plane.
  6693. */
  6694. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6695. /**
  6696. * Checks if the plane is facing a given direction
  6697. * @param direction the direction to check if the plane is facing
  6698. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6699. * @returns True is the vector "direction" is the same side than the plane normal.
  6700. */
  6701. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6702. /**
  6703. * Calculates the distance to a point
  6704. * @param point point to calculate distance to
  6705. * @returns the signed distance (float) from the given point to the Plane.
  6706. */
  6707. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6708. /**
  6709. * Creates a plane from an array
  6710. * @param array the array to create a plane from
  6711. * @returns a new Plane from the given array.
  6712. */
  6713. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6714. /**
  6715. * Creates a plane from three points
  6716. * @param point1 point used to create the plane
  6717. * @param point2 point used to create the plane
  6718. * @param point3 point used to create the plane
  6719. * @returns a new Plane defined by the three given points.
  6720. */
  6721. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6722. /**
  6723. * Creates a plane from an origin point and a normal
  6724. * @param origin origin of the plane to be constructed
  6725. * @param normal normal of the plane to be constructed
  6726. * @returns a new Plane the normal vector to this plane at the given origin point.
  6727. * Note : the vector "normal" is updated because normalized.
  6728. */
  6729. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6730. /**
  6731. * Calculates the distance from a plane and a point
  6732. * @param origin origin of the plane to be constructed
  6733. * @param normal normal of the plane to be constructed
  6734. * @param point point to calculate distance to
  6735. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6736. */
  6737. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6738. }
  6739. }
  6740. declare module "babylonjs/Culling/boundingSphere" {
  6741. import { DeepImmutable } from "babylonjs/types";
  6742. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6743. import { Plane } from "babylonjs/Maths/math.plane";
  6744. /**
  6745. * Class used to store bounding sphere information
  6746. */
  6747. export class BoundingSphere {
  6748. /**
  6749. * Gets the center of the bounding sphere in local space
  6750. */
  6751. readonly center: Vector3;
  6752. /**
  6753. * Radius of the bounding sphere in local space
  6754. */
  6755. radius: number;
  6756. /**
  6757. * Gets the center of the bounding sphere in world space
  6758. */
  6759. readonly centerWorld: Vector3;
  6760. /**
  6761. * Radius of the bounding sphere in world space
  6762. */
  6763. radiusWorld: number;
  6764. /**
  6765. * Gets the minimum vector in local space
  6766. */
  6767. readonly minimum: Vector3;
  6768. /**
  6769. * Gets the maximum vector in local space
  6770. */
  6771. readonly maximum: Vector3;
  6772. private _worldMatrix;
  6773. private static readonly TmpVector3;
  6774. /**
  6775. * Creates a new bounding sphere
  6776. * @param min defines the minimum vector (in local space)
  6777. * @param max defines the maximum vector (in local space)
  6778. * @param worldMatrix defines the new world matrix
  6779. */
  6780. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6781. /**
  6782. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6783. * @param min defines the new minimum vector (in local space)
  6784. * @param max defines the new maximum vector (in local space)
  6785. * @param worldMatrix defines the new world matrix
  6786. */
  6787. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6788. /**
  6789. * Scale the current bounding sphere by applying a scale factor
  6790. * @param factor defines the scale factor to apply
  6791. * @returns the current bounding box
  6792. */
  6793. scale(factor: number): BoundingSphere;
  6794. /**
  6795. * Gets the world matrix of the bounding box
  6796. * @returns a matrix
  6797. */
  6798. getWorldMatrix(): DeepImmutable<Matrix>;
  6799. /** @hidden */
  6800. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6801. /**
  6802. * Tests if the bounding sphere is intersecting the frustum planes
  6803. * @param frustumPlanes defines the frustum planes to test
  6804. * @returns true if there is an intersection
  6805. */
  6806. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6807. /**
  6808. * Tests if the bounding sphere center is in between the frustum planes.
  6809. * Used for optimistic fast inclusion.
  6810. * @param frustumPlanes defines the frustum planes to test
  6811. * @returns true if the sphere center is in between the frustum planes
  6812. */
  6813. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6814. /**
  6815. * Tests if a point is inside the bounding sphere
  6816. * @param point defines the point to test
  6817. * @returns true if the point is inside the bounding sphere
  6818. */
  6819. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6820. /**
  6821. * Checks if two sphere intersct
  6822. * @param sphere0 sphere 0
  6823. * @param sphere1 sphere 1
  6824. * @returns true if the speres intersect
  6825. */
  6826. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6827. }
  6828. }
  6829. declare module "babylonjs/Culling/boundingBox" {
  6830. import { DeepImmutable } from "babylonjs/types";
  6831. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6832. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6833. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6834. import { Plane } from "babylonjs/Maths/math.plane";
  6835. /**
  6836. * Class used to store bounding box information
  6837. */
  6838. export class BoundingBox implements ICullable {
  6839. /**
  6840. * Gets the 8 vectors representing the bounding box in local space
  6841. */
  6842. readonly vectors: Vector3[];
  6843. /**
  6844. * Gets the center of the bounding box in local space
  6845. */
  6846. readonly center: Vector3;
  6847. /**
  6848. * Gets the center of the bounding box in world space
  6849. */
  6850. readonly centerWorld: Vector3;
  6851. /**
  6852. * Gets the extend size in local space
  6853. */
  6854. readonly extendSize: Vector3;
  6855. /**
  6856. * Gets the extend size in world space
  6857. */
  6858. readonly extendSizeWorld: Vector3;
  6859. /**
  6860. * Gets the OBB (object bounding box) directions
  6861. */
  6862. readonly directions: Vector3[];
  6863. /**
  6864. * Gets the 8 vectors representing the bounding box in world space
  6865. */
  6866. readonly vectorsWorld: Vector3[];
  6867. /**
  6868. * Gets the minimum vector in world space
  6869. */
  6870. readonly minimumWorld: Vector3;
  6871. /**
  6872. * Gets the maximum vector in world space
  6873. */
  6874. readonly maximumWorld: Vector3;
  6875. /**
  6876. * Gets the minimum vector in local space
  6877. */
  6878. readonly minimum: Vector3;
  6879. /**
  6880. * Gets the maximum vector in local space
  6881. */
  6882. readonly maximum: Vector3;
  6883. private _worldMatrix;
  6884. private static readonly TmpVector3;
  6885. /**
  6886. * @hidden
  6887. */
  6888. _tag: number;
  6889. /**
  6890. * Creates a new bounding box
  6891. * @param min defines the minimum vector (in local space)
  6892. * @param max defines the maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6896. /**
  6897. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6898. * @param min defines the new minimum vector (in local space)
  6899. * @param max defines the new maximum vector (in local space)
  6900. * @param worldMatrix defines the new world matrix
  6901. */
  6902. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6903. /**
  6904. * Scale the current bounding box by applying a scale factor
  6905. * @param factor defines the scale factor to apply
  6906. * @returns the current bounding box
  6907. */
  6908. scale(factor: number): BoundingBox;
  6909. /**
  6910. * Gets the world matrix of the bounding box
  6911. * @returns a matrix
  6912. */
  6913. getWorldMatrix(): DeepImmutable<Matrix>;
  6914. /** @hidden */
  6915. _update(world: DeepImmutable<Matrix>): void;
  6916. /**
  6917. * Tests if the bounding box is intersecting the frustum planes
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if there is an intersection
  6920. */
  6921. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if the bounding box is entirely inside the frustum planes
  6924. * @param frustumPlanes defines the frustum planes to test
  6925. * @returns true if there is an inclusion
  6926. */
  6927. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6928. /**
  6929. * Tests if a point is inside the bounding box
  6930. * @param point defines the point to test
  6931. * @returns true if the point is inside the bounding box
  6932. */
  6933. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6934. /**
  6935. * Tests if the bounding box intersects with a bounding sphere
  6936. * @param sphere defines the sphere to test
  6937. * @returns true if there is an intersection
  6938. */
  6939. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6940. /**
  6941. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6942. * @param min defines the min vector to use
  6943. * @param max defines the max vector to use
  6944. * @returns true if there is an intersection
  6945. */
  6946. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6947. /**
  6948. * Tests if two bounding boxes are intersections
  6949. * @param box0 defines the first box to test
  6950. * @param box1 defines the second box to test
  6951. * @returns true if there is an intersection
  6952. */
  6953. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6954. /**
  6955. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6956. * @param minPoint defines the minimum vector of the bounding box
  6957. * @param maxPoint defines the maximum vector of the bounding box
  6958. * @param sphereCenter defines the sphere center
  6959. * @param sphereRadius defines the sphere radius
  6960. * @returns true if there is an intersection
  6961. */
  6962. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6963. /**
  6964. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6965. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6966. * @param frustumPlanes defines the frustum planes to test
  6967. * @return true if there is an inclusion
  6968. */
  6969. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6970. /**
  6971. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6972. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6973. * @param frustumPlanes defines the frustum planes to test
  6974. * @return true if there is an intersection
  6975. */
  6976. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6977. }
  6978. }
  6979. declare module "babylonjs/Collisions/collider" {
  6980. import { Nullable, IndicesArray } from "babylonjs/types";
  6981. import { Vector3 } from "babylonjs/Maths/math.vector";
  6982. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6983. import { Plane } from "babylonjs/Maths/math.plane";
  6984. /** @hidden */
  6985. export class Collider {
  6986. /** Define if a collision was found */
  6987. collisionFound: boolean;
  6988. /**
  6989. * Define last intersection point in local space
  6990. */
  6991. intersectionPoint: Vector3;
  6992. /**
  6993. * Define last collided mesh
  6994. */
  6995. collidedMesh: Nullable<AbstractMesh>;
  6996. private _collisionPoint;
  6997. private _planeIntersectionPoint;
  6998. private _tempVector;
  6999. private _tempVector2;
  7000. private _tempVector3;
  7001. private _tempVector4;
  7002. private _edge;
  7003. private _baseToVertex;
  7004. private _destinationPoint;
  7005. private _slidePlaneNormal;
  7006. private _displacementVector;
  7007. /** @hidden */
  7008. _radius: Vector3;
  7009. /** @hidden */
  7010. _retry: number;
  7011. private _velocity;
  7012. private _basePoint;
  7013. private _epsilon;
  7014. /** @hidden */
  7015. _velocityWorldLength: number;
  7016. /** @hidden */
  7017. _basePointWorld: Vector3;
  7018. private _velocityWorld;
  7019. private _normalizedVelocity;
  7020. /** @hidden */
  7021. _initialVelocity: Vector3;
  7022. /** @hidden */
  7023. _initialPosition: Vector3;
  7024. private _nearestDistance;
  7025. private _collisionMask;
  7026. get collisionMask(): number;
  7027. set collisionMask(mask: number);
  7028. /**
  7029. * Gets the plane normal used to compute the sliding response (in local space)
  7030. */
  7031. get slidePlaneNormal(): Vector3;
  7032. /** @hidden */
  7033. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7034. /** @hidden */
  7035. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7036. /** @hidden */
  7037. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7038. /** @hidden */
  7039. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7040. /** @hidden */
  7041. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7042. /** @hidden */
  7043. _getResponse(pos: Vector3, vel: Vector3): void;
  7044. }
  7045. }
  7046. declare module "babylonjs/Culling/boundingInfo" {
  7047. import { DeepImmutable } from "babylonjs/types";
  7048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7049. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7050. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7051. import { Plane } from "babylonjs/Maths/math.plane";
  7052. import { Collider } from "babylonjs/Collisions/collider";
  7053. /**
  7054. * Interface for cullable objects
  7055. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7056. */
  7057. export interface ICullable {
  7058. /**
  7059. * Checks if the object or part of the object is in the frustum
  7060. * @param frustumPlanes Camera near/planes
  7061. * @returns true if the object is in frustum otherwise false
  7062. */
  7063. isInFrustum(frustumPlanes: Plane[]): boolean;
  7064. /**
  7065. * Checks if a cullable object (mesh...) is in the camera frustum
  7066. * Unlike isInFrustum this cheks the full bounding box
  7067. * @param frustumPlanes Camera near/planes
  7068. * @returns true if the object is in frustum otherwise false
  7069. */
  7070. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7071. }
  7072. /**
  7073. * Info for a bounding data of a mesh
  7074. */
  7075. export class BoundingInfo implements ICullable {
  7076. /**
  7077. * Bounding box for the mesh
  7078. */
  7079. readonly boundingBox: BoundingBox;
  7080. /**
  7081. * Bounding sphere for the mesh
  7082. */
  7083. readonly boundingSphere: BoundingSphere;
  7084. private _isLocked;
  7085. private static readonly TmpVector3;
  7086. /**
  7087. * Constructs bounding info
  7088. * @param minimum min vector of the bounding box/sphere
  7089. * @param maximum max vector of the bounding box/sphere
  7090. * @param worldMatrix defines the new world matrix
  7091. */
  7092. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7093. /**
  7094. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7095. * @param min defines the new minimum vector (in local space)
  7096. * @param max defines the new maximum vector (in local space)
  7097. * @param worldMatrix defines the new world matrix
  7098. */
  7099. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7100. /**
  7101. * min vector of the bounding box/sphere
  7102. */
  7103. get minimum(): Vector3;
  7104. /**
  7105. * max vector of the bounding box/sphere
  7106. */
  7107. get maximum(): Vector3;
  7108. /**
  7109. * If the info is locked and won't be updated to avoid perf overhead
  7110. */
  7111. get isLocked(): boolean;
  7112. set isLocked(value: boolean);
  7113. /**
  7114. * Updates the bounding sphere and box
  7115. * @param world world matrix to be used to update
  7116. */
  7117. update(world: DeepImmutable<Matrix>): void;
  7118. /**
  7119. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7120. * @param center New center of the bounding info
  7121. * @param extend New extend of the bounding info
  7122. * @returns the current bounding info
  7123. */
  7124. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7125. /**
  7126. * Scale the current bounding info by applying a scale factor
  7127. * @param factor defines the scale factor to apply
  7128. * @returns the current bounding info
  7129. */
  7130. scale(factor: number): BoundingInfo;
  7131. /**
  7132. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7133. * @param frustumPlanes defines the frustum to test
  7134. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7135. * @returns true if the bounding info is in the frustum planes
  7136. */
  7137. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7138. /**
  7139. * Gets the world distance between the min and max points of the bounding box
  7140. */
  7141. get diagonalLength(): number;
  7142. /**
  7143. * Checks if a cullable object (mesh...) is in the camera frustum
  7144. * Unlike isInFrustum this cheks the full bounding box
  7145. * @param frustumPlanes Camera near/planes
  7146. * @returns true if the object is in frustum otherwise false
  7147. */
  7148. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7149. /** @hidden */
  7150. _checkCollision(collider: Collider): boolean;
  7151. /**
  7152. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7153. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7154. * @param point the point to check intersection with
  7155. * @returns if the point intersects
  7156. */
  7157. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7158. /**
  7159. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7160. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7161. * @param boundingInfo the bounding info to check intersection with
  7162. * @param precise if the intersection should be done using OBB
  7163. * @returns if the bounding info intersects
  7164. */
  7165. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7166. }
  7167. }
  7168. declare module "babylonjs/Maths/math.functions" {
  7169. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7170. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7171. /**
  7172. * Extracts minimum and maximum values from a list of indexed positions
  7173. * @param positions defines the positions to use
  7174. * @param indices defines the indices to the positions
  7175. * @param indexStart defines the start index
  7176. * @param indexCount defines the end index
  7177. * @param bias defines bias value to add to the result
  7178. * @return minimum and maximum values
  7179. */
  7180. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7181. minimum: Vector3;
  7182. maximum: Vector3;
  7183. };
  7184. /**
  7185. * Extracts minimum and maximum values from a list of positions
  7186. * @param positions defines the positions to use
  7187. * @param start defines the start index in the positions array
  7188. * @param count defines the number of positions to handle
  7189. * @param bias defines bias value to add to the result
  7190. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7191. * @return minimum and maximum values
  7192. */
  7193. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7194. minimum: Vector3;
  7195. maximum: Vector3;
  7196. };
  7197. }
  7198. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7199. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7200. /** @hidden */
  7201. export class WebGLDataBuffer extends DataBuffer {
  7202. private _buffer;
  7203. constructor(resource: WebGLBuffer);
  7204. get underlyingResource(): any;
  7205. }
  7206. }
  7207. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7208. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7209. import { Nullable } from "babylonjs/types";
  7210. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7211. /** @hidden */
  7212. export class WebGLPipelineContext implements IPipelineContext {
  7213. engine: ThinEngine;
  7214. program: Nullable<WebGLProgram>;
  7215. context?: WebGLRenderingContext;
  7216. vertexShader?: WebGLShader;
  7217. fragmentShader?: WebGLShader;
  7218. isParallelCompiled: boolean;
  7219. onCompiled?: () => void;
  7220. transformFeedback?: WebGLTransformFeedback | null;
  7221. vertexCompilationError: Nullable<string>;
  7222. fragmentCompilationError: Nullable<string>;
  7223. programLinkError: Nullable<string>;
  7224. programValidationError: Nullable<string>;
  7225. get isAsync(): boolean;
  7226. get isReady(): boolean;
  7227. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7228. }
  7229. }
  7230. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7231. import { FloatArray, Nullable } from "babylonjs/types";
  7232. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7233. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7234. module "babylonjs/Engines/thinEngine" {
  7235. interface ThinEngine {
  7236. /**
  7237. * Create an uniform buffer
  7238. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7239. * @param elements defines the content of the uniform buffer
  7240. * @returns the webGL uniform buffer
  7241. */
  7242. createUniformBuffer(elements: FloatArray): DataBuffer;
  7243. /**
  7244. * Create a dynamic uniform buffer
  7245. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7246. * @param elements defines the content of the uniform buffer
  7247. * @returns the webGL uniform buffer
  7248. */
  7249. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7250. /**
  7251. * Update an existing uniform buffer
  7252. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7253. * @param uniformBuffer defines the target uniform buffer
  7254. * @param elements defines the content to update
  7255. * @param offset defines the offset in the uniform buffer where update should start
  7256. * @param count defines the size of the data to update
  7257. */
  7258. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7259. /**
  7260. * Bind an uniform buffer to the current webGL context
  7261. * @param buffer defines the buffer to bind
  7262. */
  7263. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7264. /**
  7265. * Bind a buffer to the current webGL context at a given location
  7266. * @param buffer defines the buffer to bind
  7267. * @param location defines the index where to bind the buffer
  7268. */
  7269. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7270. /**
  7271. * Bind a specific block at a given index in a specific shader program
  7272. * @param pipelineContext defines the pipeline context to use
  7273. * @param blockName defines the block name
  7274. * @param index defines the index where to bind the block
  7275. */
  7276. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7277. }
  7278. }
  7279. }
  7280. declare module "babylonjs/Materials/uniformBuffer" {
  7281. import { Nullable, FloatArray } from "babylonjs/types";
  7282. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7283. import { Engine } from "babylonjs/Engines/engine";
  7284. import { Effect } from "babylonjs/Materials/effect";
  7285. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7286. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7287. import { Color3 } from "babylonjs/Maths/math.color";
  7288. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7289. /**
  7290. * Uniform buffer objects.
  7291. *
  7292. * Handles blocks of uniform on the GPU.
  7293. *
  7294. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7295. *
  7296. * For more information, please refer to :
  7297. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7298. */
  7299. export class UniformBuffer {
  7300. private _engine;
  7301. private _buffer;
  7302. private _data;
  7303. private _bufferData;
  7304. private _dynamic?;
  7305. private _uniformLocations;
  7306. private _uniformSizes;
  7307. private _uniformLocationPointer;
  7308. private _needSync;
  7309. private _noUBO;
  7310. private _currentEffect;
  7311. /** @hidden */
  7312. _alreadyBound: boolean;
  7313. private static _MAX_UNIFORM_SIZE;
  7314. private static _tempBuffer;
  7315. /**
  7316. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7321. /**
  7322. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7327. /**
  7328. * Lambda to Update a single float in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateFloat: (name: string, x: number) => void;
  7333. /**
  7334. * Lambda to Update a vec2 of float in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7339. /**
  7340. * Lambda to Update a vec3 of float in a uniform buffer.
  7341. * This is dynamic to allow compat with webgl 1 and 2.
  7342. * You will need to pass the name of the uniform as well as the value.
  7343. */
  7344. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7345. /**
  7346. * Lambda to Update a vec4 of float in a uniform buffer.
  7347. * This is dynamic to allow compat with webgl 1 and 2.
  7348. * You will need to pass the name of the uniform as well as the value.
  7349. */
  7350. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7351. /**
  7352. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7353. * This is dynamic to allow compat with webgl 1 and 2.
  7354. * You will need to pass the name of the uniform as well as the value.
  7355. */
  7356. updateMatrix: (name: string, mat: Matrix) => void;
  7357. /**
  7358. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7359. * This is dynamic to allow compat with webgl 1 and 2.
  7360. * You will need to pass the name of the uniform as well as the value.
  7361. */
  7362. updateVector3: (name: string, vector: Vector3) => void;
  7363. /**
  7364. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7365. * This is dynamic to allow compat with webgl 1 and 2.
  7366. * You will need to pass the name of the uniform as well as the value.
  7367. */
  7368. updateVector4: (name: string, vector: Vector4) => void;
  7369. /**
  7370. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7371. * This is dynamic to allow compat with webgl 1 and 2.
  7372. * You will need to pass the name of the uniform as well as the value.
  7373. */
  7374. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7375. /**
  7376. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7377. * This is dynamic to allow compat with webgl 1 and 2.
  7378. * You will need to pass the name of the uniform as well as the value.
  7379. */
  7380. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7381. /**
  7382. * Instantiates a new Uniform buffer objects.
  7383. *
  7384. * Handles blocks of uniform on the GPU.
  7385. *
  7386. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7387. *
  7388. * For more information, please refer to :
  7389. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7390. * @param engine Define the engine the buffer is associated with
  7391. * @param data Define the data contained in the buffer
  7392. * @param dynamic Define if the buffer is updatable
  7393. */
  7394. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7395. /**
  7396. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7397. * or just falling back on setUniformXXX calls.
  7398. */
  7399. get useUbo(): boolean;
  7400. /**
  7401. * Indicates if the WebGL underlying uniform buffer is in sync
  7402. * with the javascript cache data.
  7403. */
  7404. get isSync(): boolean;
  7405. /**
  7406. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7407. * Also, a dynamic UniformBuffer will disable cache verification and always
  7408. * update the underlying WebGL uniform buffer to the GPU.
  7409. * @returns if Dynamic, otherwise false
  7410. */
  7411. isDynamic(): boolean;
  7412. /**
  7413. * The data cache on JS side.
  7414. * @returns the underlying data as a float array
  7415. */
  7416. getData(): Float32Array;
  7417. /**
  7418. * The underlying WebGL Uniform buffer.
  7419. * @returns the webgl buffer
  7420. */
  7421. getBuffer(): Nullable<DataBuffer>;
  7422. /**
  7423. * std140 layout specifies how to align data within an UBO structure.
  7424. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7425. * for specs.
  7426. */
  7427. private _fillAlignment;
  7428. /**
  7429. * Adds an uniform in the buffer.
  7430. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7431. * for the layout to be correct !
  7432. * @param name Name of the uniform, as used in the uniform block in the shader.
  7433. * @param size Data size, or data directly.
  7434. */
  7435. addUniform(name: string, size: number | number[]): void;
  7436. /**
  7437. * Adds a Matrix 4x4 to the uniform buffer.
  7438. * @param name Name of the uniform, as used in the uniform block in the shader.
  7439. * @param mat A 4x4 matrix.
  7440. */
  7441. addMatrix(name: string, mat: Matrix): void;
  7442. /**
  7443. * Adds a vec2 to the uniform buffer.
  7444. * @param name Name of the uniform, as used in the uniform block in the shader.
  7445. * @param x Define the x component value of the vec2
  7446. * @param y Define the y component value of the vec2
  7447. */
  7448. addFloat2(name: string, x: number, y: number): void;
  7449. /**
  7450. * Adds a vec3 to the uniform buffer.
  7451. * @param name Name of the uniform, as used in the uniform block in the shader.
  7452. * @param x Define the x component value of the vec3
  7453. * @param y Define the y component value of the vec3
  7454. * @param z Define the z component value of the vec3
  7455. */
  7456. addFloat3(name: string, x: number, y: number, z: number): void;
  7457. /**
  7458. * Adds a vec3 to the uniform buffer.
  7459. * @param name Name of the uniform, as used in the uniform block in the shader.
  7460. * @param color Define the vec3 from a Color
  7461. */
  7462. addColor3(name: string, color: Color3): void;
  7463. /**
  7464. * Adds a vec4 to the uniform buffer.
  7465. * @param name Name of the uniform, as used in the uniform block in the shader.
  7466. * @param color Define the rgb components from a Color
  7467. * @param alpha Define the a component of the vec4
  7468. */
  7469. addColor4(name: string, color: Color3, alpha: number): void;
  7470. /**
  7471. * Adds a vec3 to the uniform buffer.
  7472. * @param name Name of the uniform, as used in the uniform block in the shader.
  7473. * @param vector Define the vec3 components from a Vector
  7474. */
  7475. addVector3(name: string, vector: Vector3): void;
  7476. /**
  7477. * Adds a Matrix 3x3 to the uniform buffer.
  7478. * @param name Name of the uniform, as used in the uniform block in the shader.
  7479. */
  7480. addMatrix3x3(name: string): void;
  7481. /**
  7482. * Adds a Matrix 2x2 to the uniform buffer.
  7483. * @param name Name of the uniform, as used in the uniform block in the shader.
  7484. */
  7485. addMatrix2x2(name: string): void;
  7486. /**
  7487. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7488. */
  7489. create(): void;
  7490. /** @hidden */
  7491. _rebuild(): void;
  7492. /**
  7493. * Updates the WebGL Uniform Buffer on the GPU.
  7494. * If the `dynamic` flag is set to true, no cache comparison is done.
  7495. * Otherwise, the buffer will be updated only if the cache differs.
  7496. */
  7497. update(): void;
  7498. /**
  7499. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7500. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7501. * @param data Define the flattened data
  7502. * @param size Define the size of the data.
  7503. */
  7504. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7505. private _valueCache;
  7506. private _cacheMatrix;
  7507. private _updateMatrix3x3ForUniform;
  7508. private _updateMatrix3x3ForEffect;
  7509. private _updateMatrix2x2ForEffect;
  7510. private _updateMatrix2x2ForUniform;
  7511. private _updateFloatForEffect;
  7512. private _updateFloatForUniform;
  7513. private _updateFloat2ForEffect;
  7514. private _updateFloat2ForUniform;
  7515. private _updateFloat3ForEffect;
  7516. private _updateFloat3ForUniform;
  7517. private _updateFloat4ForEffect;
  7518. private _updateFloat4ForUniform;
  7519. private _updateMatrixForEffect;
  7520. private _updateMatrixForUniform;
  7521. private _updateVector3ForEffect;
  7522. private _updateVector3ForUniform;
  7523. private _updateVector4ForEffect;
  7524. private _updateVector4ForUniform;
  7525. private _updateColor3ForEffect;
  7526. private _updateColor3ForUniform;
  7527. private _updateColor4ForEffect;
  7528. private _updateColor4ForUniform;
  7529. /**
  7530. * Sets a sampler uniform on the effect.
  7531. * @param name Define the name of the sampler.
  7532. * @param texture Define the texture to set in the sampler
  7533. */
  7534. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7535. /**
  7536. * Directly updates the value of the uniform in the cache AND on the GPU.
  7537. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7538. * @param data Define the flattened data
  7539. */
  7540. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7541. /**
  7542. * Binds this uniform buffer to an effect.
  7543. * @param effect Define the effect to bind the buffer to
  7544. * @param name Name of the uniform block in the shader.
  7545. */
  7546. bindToEffect(effect: Effect, name: string): void;
  7547. /**
  7548. * Disposes the uniform buffer.
  7549. */
  7550. dispose(): void;
  7551. }
  7552. }
  7553. declare module "babylonjs/Misc/iInspectable" {
  7554. /**
  7555. * Enum that determines the text-wrapping mode to use.
  7556. */
  7557. export enum InspectableType {
  7558. /**
  7559. * Checkbox for booleans
  7560. */
  7561. Checkbox = 0,
  7562. /**
  7563. * Sliders for numbers
  7564. */
  7565. Slider = 1,
  7566. /**
  7567. * Vector3
  7568. */
  7569. Vector3 = 2,
  7570. /**
  7571. * Quaternions
  7572. */
  7573. Quaternion = 3,
  7574. /**
  7575. * Color3
  7576. */
  7577. Color3 = 4,
  7578. /**
  7579. * String
  7580. */
  7581. String = 5
  7582. }
  7583. /**
  7584. * Interface used to define custom inspectable properties.
  7585. * This interface is used by the inspector to display custom property grids
  7586. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7587. */
  7588. export interface IInspectable {
  7589. /**
  7590. * Gets the label to display
  7591. */
  7592. label: string;
  7593. /**
  7594. * Gets the name of the property to edit
  7595. */
  7596. propertyName: string;
  7597. /**
  7598. * Gets the type of the editor to use
  7599. */
  7600. type: InspectableType;
  7601. /**
  7602. * Gets the minimum value of the property when using in "slider" mode
  7603. */
  7604. min?: number;
  7605. /**
  7606. * Gets the maximum value of the property when using in "slider" mode
  7607. */
  7608. max?: number;
  7609. /**
  7610. * Gets the setp to use when using in "slider" mode
  7611. */
  7612. step?: number;
  7613. }
  7614. }
  7615. declare module "babylonjs/Misc/timingTools" {
  7616. /**
  7617. * Class used to provide helper for timing
  7618. */
  7619. export class TimingTools {
  7620. /**
  7621. * Polyfill for setImmediate
  7622. * @param action defines the action to execute after the current execution block
  7623. */
  7624. static SetImmediate(action: () => void): void;
  7625. }
  7626. }
  7627. declare module "babylonjs/Misc/instantiationTools" {
  7628. /**
  7629. * Class used to enable instatition of objects by class name
  7630. */
  7631. export class InstantiationTools {
  7632. /**
  7633. * Use this object to register external classes like custom textures or material
  7634. * to allow the laoders to instantiate them
  7635. */
  7636. static RegisteredExternalClasses: {
  7637. [key: string]: Object;
  7638. };
  7639. /**
  7640. * Tries to instantiate a new object from a given class name
  7641. * @param className defines the class name to instantiate
  7642. * @returns the new object or null if the system was not able to do the instantiation
  7643. */
  7644. static Instantiate(className: string): any;
  7645. }
  7646. }
  7647. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7648. /**
  7649. * Define options used to create a depth texture
  7650. */
  7651. export class DepthTextureCreationOptions {
  7652. /** Specifies whether or not a stencil should be allocated in the texture */
  7653. generateStencil?: boolean;
  7654. /** Specifies whether or not bilinear filtering is enable on the texture */
  7655. bilinearFiltering?: boolean;
  7656. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7657. comparisonFunction?: number;
  7658. /** Specifies if the created texture is a cube texture */
  7659. isCube?: boolean;
  7660. }
  7661. }
  7662. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7663. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7664. import { Nullable } from "babylonjs/types";
  7665. import { Scene } from "babylonjs/scene";
  7666. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7667. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7668. module "babylonjs/Engines/thinEngine" {
  7669. interface ThinEngine {
  7670. /**
  7671. * Creates a depth stencil cube texture.
  7672. * This is only available in WebGL 2.
  7673. * @param size The size of face edge in the cube texture.
  7674. * @param options The options defining the cube texture.
  7675. * @returns The cube texture
  7676. */
  7677. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7678. /**
  7679. * Creates a cube texture
  7680. * @param rootUrl defines the url where the files to load is located
  7681. * @param scene defines the current scene
  7682. * @param files defines the list of files to load (1 per face)
  7683. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7684. * @param onLoad defines an optional callback raised when the texture is loaded
  7685. * @param onError defines an optional callback raised if there is an issue to load the texture
  7686. * @param format defines the format of the data
  7687. * @param forcedExtension defines the extension to use to pick the right loader
  7688. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7689. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7690. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7691. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7692. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7693. * @returns the cube texture as an InternalTexture
  7694. */
  7695. 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>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7696. /**
  7697. * Creates a cube texture
  7698. * @param rootUrl defines the url where the files to load is located
  7699. * @param scene defines the current scene
  7700. * @param files defines the list of files to load (1 per face)
  7701. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7702. * @param onLoad defines an optional callback raised when the texture is loaded
  7703. * @param onError defines an optional callback raised if there is an issue to load the texture
  7704. * @param format defines the format of the data
  7705. * @param forcedExtension defines the extension to use to pick the right loader
  7706. * @returns the cube texture as an InternalTexture
  7707. */
  7708. 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;
  7709. /**
  7710. * Creates a cube texture
  7711. * @param rootUrl defines the url where the files to load is located
  7712. * @param scene defines the current scene
  7713. * @param files defines the list of files to load (1 per face)
  7714. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7715. * @param onLoad defines an optional callback raised when the texture is loaded
  7716. * @param onError defines an optional callback raised if there is an issue to load the texture
  7717. * @param format defines the format of the data
  7718. * @param forcedExtension defines the extension to use to pick the right loader
  7719. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7720. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7721. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7722. * @returns the cube texture as an InternalTexture
  7723. */
  7724. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7725. /** @hidden */
  7726. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7727. /** @hidden */
  7728. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7729. /** @hidden */
  7730. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7731. /** @hidden */
  7732. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7733. /**
  7734. * @hidden
  7735. */
  7736. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7737. }
  7738. }
  7739. }
  7740. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7741. import { Nullable } from "babylonjs/types";
  7742. import { Scene } from "babylonjs/scene";
  7743. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7745. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7746. /**
  7747. * Class for creating a cube texture
  7748. */
  7749. export class CubeTexture extends BaseTexture {
  7750. private _delayedOnLoad;
  7751. /**
  7752. * The url of the texture
  7753. */
  7754. url: string;
  7755. /**
  7756. * Gets or sets the center of the bounding box associated with the cube texture.
  7757. * It must define where the camera used to render the texture was set
  7758. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7759. */
  7760. boundingBoxPosition: Vector3;
  7761. private _boundingBoxSize;
  7762. /**
  7763. * Gets or sets the size of the bounding box associated with the cube texture
  7764. * When defined, the cubemap will switch to local mode
  7765. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7766. * @example https://www.babylonjs-playground.com/#RNASML
  7767. */
  7768. set boundingBoxSize(value: Vector3);
  7769. /**
  7770. * Returns the bounding box size
  7771. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7772. */
  7773. get boundingBoxSize(): Vector3;
  7774. protected _rotationY: number;
  7775. /**
  7776. * Sets texture matrix rotation angle around Y axis in radians.
  7777. */
  7778. set rotationY(value: number);
  7779. /**
  7780. * Gets texture matrix rotation angle around Y axis radians.
  7781. */
  7782. get rotationY(): number;
  7783. /**
  7784. * Are mip maps generated for this texture or not.
  7785. */
  7786. get noMipmap(): boolean;
  7787. private _noMipmap;
  7788. private _files;
  7789. protected _forcedExtension: Nullable<string>;
  7790. private _extensions;
  7791. private _textureMatrix;
  7792. private _format;
  7793. private _createPolynomials;
  7794. /** @hidden */
  7795. _prefiltered: boolean;
  7796. /**
  7797. * Creates a cube texture from an array of image urls
  7798. * @param files defines an array of image urls
  7799. * @param scene defines the hosting scene
  7800. * @param noMipmap specifies if mip maps are not used
  7801. * @returns a cube texture
  7802. */
  7803. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7804. /**
  7805. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7806. * @param url defines the url of the prefiltered texture
  7807. * @param scene defines the scene the texture is attached to
  7808. * @param forcedExtension defines the extension of the file if different from the url
  7809. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7810. * @return the prefiltered texture
  7811. */
  7812. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7813. /**
  7814. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7815. * as prefiltered data.
  7816. * @param rootUrl defines the url of the texture or the root name of the six images
  7817. * @param scene defines the scene the texture is attached to
  7818. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7819. * @param noMipmap defines if mipmaps should be created or not
  7820. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7821. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7822. * @param onError defines a callback triggered in case of error during load
  7823. * @param format defines the internal format to use for the texture once loaded
  7824. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7825. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7826. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7827. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7828. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7829. * @return the cube texture
  7830. */
  7831. 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);
  7832. /**
  7833. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7834. */
  7835. get isPrefiltered(): boolean;
  7836. /**
  7837. * Get the current class name of the texture useful for serialization or dynamic coding.
  7838. * @returns "CubeTexture"
  7839. */
  7840. getClassName(): string;
  7841. /**
  7842. * Update the url (and optional buffer) of this texture if url was null during construction.
  7843. * @param url the url of the texture
  7844. * @param forcedExtension defines the extension to use
  7845. * @param onLoad callback called when the texture is loaded (defaults to null)
  7846. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7847. */
  7848. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7849. /**
  7850. * Delays loading of the cube texture
  7851. * @param forcedExtension defines the extension to use
  7852. */
  7853. delayLoad(forcedExtension?: string): void;
  7854. /**
  7855. * Returns the reflection texture matrix
  7856. * @returns the reflection texture matrix
  7857. */
  7858. getReflectionTextureMatrix(): Matrix;
  7859. /**
  7860. * Sets the reflection texture matrix
  7861. * @param value Reflection texture matrix
  7862. */
  7863. setReflectionTextureMatrix(value: Matrix): void;
  7864. /**
  7865. * Parses text to create a cube texture
  7866. * @param parsedTexture define the serialized text to read from
  7867. * @param scene defines the hosting scene
  7868. * @param rootUrl defines the root url of the cube texture
  7869. * @returns a cube texture
  7870. */
  7871. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7872. /**
  7873. * Makes a clone, or deep copy, of the cube texture
  7874. * @returns a new cube texture
  7875. */
  7876. clone(): CubeTexture;
  7877. }
  7878. }
  7879. declare module "babylonjs/Materials/materialDefines" {
  7880. /**
  7881. * Manages the defines for the Material
  7882. */
  7883. export class MaterialDefines {
  7884. /** @hidden */
  7885. protected _keys: string[];
  7886. private _isDirty;
  7887. /** @hidden */
  7888. _renderId: number;
  7889. /** @hidden */
  7890. _areLightsDirty: boolean;
  7891. /** @hidden */
  7892. _areLightsDisposed: boolean;
  7893. /** @hidden */
  7894. _areAttributesDirty: boolean;
  7895. /** @hidden */
  7896. _areTexturesDirty: boolean;
  7897. /** @hidden */
  7898. _areFresnelDirty: boolean;
  7899. /** @hidden */
  7900. _areMiscDirty: boolean;
  7901. /** @hidden */
  7902. _areImageProcessingDirty: boolean;
  7903. /** @hidden */
  7904. _normals: boolean;
  7905. /** @hidden */
  7906. _uvs: boolean;
  7907. /** @hidden */
  7908. _needNormals: boolean;
  7909. /** @hidden */
  7910. _needUVs: boolean;
  7911. [id: string]: any;
  7912. /**
  7913. * Specifies if the material needs to be re-calculated
  7914. */
  7915. get isDirty(): boolean;
  7916. /**
  7917. * Marks the material to indicate that it has been re-calculated
  7918. */
  7919. markAsProcessed(): void;
  7920. /**
  7921. * Marks the material to indicate that it needs to be re-calculated
  7922. */
  7923. markAsUnprocessed(): void;
  7924. /**
  7925. * Marks the material to indicate all of its defines need to be re-calculated
  7926. */
  7927. markAllAsDirty(): void;
  7928. /**
  7929. * Marks the material to indicate that image processing needs to be re-calculated
  7930. */
  7931. markAsImageProcessingDirty(): void;
  7932. /**
  7933. * Marks the material to indicate the lights need to be re-calculated
  7934. * @param disposed Defines whether the light is dirty due to dispose or not
  7935. */
  7936. markAsLightDirty(disposed?: boolean): void;
  7937. /**
  7938. * Marks the attribute state as changed
  7939. */
  7940. markAsAttributesDirty(): void;
  7941. /**
  7942. * Marks the texture state as changed
  7943. */
  7944. markAsTexturesDirty(): void;
  7945. /**
  7946. * Marks the fresnel state as changed
  7947. */
  7948. markAsFresnelDirty(): void;
  7949. /**
  7950. * Marks the misc state as changed
  7951. */
  7952. markAsMiscDirty(): void;
  7953. /**
  7954. * Rebuilds the material defines
  7955. */
  7956. rebuild(): void;
  7957. /**
  7958. * Specifies if two material defines are equal
  7959. * @param other - A material define instance to compare to
  7960. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7961. */
  7962. isEqual(other: MaterialDefines): boolean;
  7963. /**
  7964. * Clones this instance's defines to another instance
  7965. * @param other - material defines to clone values to
  7966. */
  7967. cloneTo(other: MaterialDefines): void;
  7968. /**
  7969. * Resets the material define values
  7970. */
  7971. reset(): void;
  7972. /**
  7973. * Converts the material define values to a string
  7974. * @returns - String of material define information
  7975. */
  7976. toString(): string;
  7977. }
  7978. }
  7979. declare module "babylonjs/Materials/colorCurves" {
  7980. import { Effect } from "babylonjs/Materials/effect";
  7981. /**
  7982. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7983. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7984. * 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;
  7985. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7986. */
  7987. export class ColorCurves {
  7988. private _dirty;
  7989. private _tempColor;
  7990. private _globalCurve;
  7991. private _highlightsCurve;
  7992. private _midtonesCurve;
  7993. private _shadowsCurve;
  7994. private _positiveCurve;
  7995. private _negativeCurve;
  7996. private _globalHue;
  7997. private _globalDensity;
  7998. private _globalSaturation;
  7999. private _globalExposure;
  8000. /**
  8001. * Gets the global Hue value.
  8002. * 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).
  8003. */
  8004. get globalHue(): number;
  8005. /**
  8006. * Sets the global Hue value.
  8007. * 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).
  8008. */
  8009. set globalHue(value: number);
  8010. /**
  8011. * Gets the global Density value.
  8012. * 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.
  8013. * Values less than zero provide a filter of opposite hue.
  8014. */
  8015. get globalDensity(): number;
  8016. /**
  8017. * Sets the global Density value.
  8018. * 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.
  8019. * Values less than zero provide a filter of opposite hue.
  8020. */
  8021. set globalDensity(value: number);
  8022. /**
  8023. * Gets the global Saturation value.
  8024. * 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.
  8025. */
  8026. get globalSaturation(): number;
  8027. /**
  8028. * Sets the global Saturation value.
  8029. * 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.
  8030. */
  8031. set globalSaturation(value: number);
  8032. /**
  8033. * Gets the global Exposure value.
  8034. * 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.
  8035. */
  8036. get globalExposure(): number;
  8037. /**
  8038. * Sets the global Exposure value.
  8039. * 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.
  8040. */
  8041. set globalExposure(value: number);
  8042. private _highlightsHue;
  8043. private _highlightsDensity;
  8044. private _highlightsSaturation;
  8045. private _highlightsExposure;
  8046. /**
  8047. * Gets the highlights Hue value.
  8048. * 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).
  8049. */
  8050. get highlightsHue(): number;
  8051. /**
  8052. * Sets the highlights Hue value.
  8053. * 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).
  8054. */
  8055. set highlightsHue(value: number);
  8056. /**
  8057. * Gets the highlights Density value.
  8058. * 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.
  8059. * Values less than zero provide a filter of opposite hue.
  8060. */
  8061. get highlightsDensity(): number;
  8062. /**
  8063. * Sets the highlights Density value.
  8064. * 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.
  8065. * Values less than zero provide a filter of opposite hue.
  8066. */
  8067. set highlightsDensity(value: number);
  8068. /**
  8069. * Gets the highlights Saturation value.
  8070. * 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.
  8071. */
  8072. get highlightsSaturation(): number;
  8073. /**
  8074. * Sets the highlights Saturation value.
  8075. * 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.
  8076. */
  8077. set highlightsSaturation(value: number);
  8078. /**
  8079. * Gets the highlights Exposure value.
  8080. * 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.
  8081. */
  8082. get highlightsExposure(): number;
  8083. /**
  8084. * Sets the highlights Exposure value.
  8085. * 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.
  8086. */
  8087. set highlightsExposure(value: number);
  8088. private _midtonesHue;
  8089. private _midtonesDensity;
  8090. private _midtonesSaturation;
  8091. private _midtonesExposure;
  8092. /**
  8093. * Gets the midtones Hue value.
  8094. * 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).
  8095. */
  8096. get midtonesHue(): number;
  8097. /**
  8098. * Sets the midtones Hue value.
  8099. * 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).
  8100. */
  8101. set midtonesHue(value: number);
  8102. /**
  8103. * Gets the midtones Density value.
  8104. * 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.
  8105. * Values less than zero provide a filter of opposite hue.
  8106. */
  8107. get midtonesDensity(): number;
  8108. /**
  8109. * Sets the midtones Density value.
  8110. * 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.
  8111. * Values less than zero provide a filter of opposite hue.
  8112. */
  8113. set midtonesDensity(value: number);
  8114. /**
  8115. * Gets the midtones Saturation value.
  8116. * 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.
  8117. */
  8118. get midtonesSaturation(): number;
  8119. /**
  8120. * Sets the midtones Saturation value.
  8121. * 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.
  8122. */
  8123. set midtonesSaturation(value: number);
  8124. /**
  8125. * Gets the midtones Exposure value.
  8126. * 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.
  8127. */
  8128. get midtonesExposure(): number;
  8129. /**
  8130. * Sets the midtones Exposure value.
  8131. * 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.
  8132. */
  8133. set midtonesExposure(value: number);
  8134. private _shadowsHue;
  8135. private _shadowsDensity;
  8136. private _shadowsSaturation;
  8137. private _shadowsExposure;
  8138. /**
  8139. * Gets the shadows Hue value.
  8140. * 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).
  8141. */
  8142. get shadowsHue(): number;
  8143. /**
  8144. * Sets the shadows Hue value.
  8145. * 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).
  8146. */
  8147. set shadowsHue(value: number);
  8148. /**
  8149. * Gets the shadows Density value.
  8150. * 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.
  8151. * Values less than zero provide a filter of opposite hue.
  8152. */
  8153. get shadowsDensity(): number;
  8154. /**
  8155. * Sets the shadows Density value.
  8156. * 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.
  8157. * Values less than zero provide a filter of opposite hue.
  8158. */
  8159. set shadowsDensity(value: number);
  8160. /**
  8161. * Gets the shadows Saturation value.
  8162. * 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.
  8163. */
  8164. get shadowsSaturation(): number;
  8165. /**
  8166. * Sets the shadows Saturation value.
  8167. * 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.
  8168. */
  8169. set shadowsSaturation(value: number);
  8170. /**
  8171. * Gets the shadows Exposure value.
  8172. * 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.
  8173. */
  8174. get shadowsExposure(): number;
  8175. /**
  8176. * Sets the shadows Exposure value.
  8177. * 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.
  8178. */
  8179. set shadowsExposure(value: number);
  8180. /**
  8181. * Returns the class name
  8182. * @returns The class name
  8183. */
  8184. getClassName(): string;
  8185. /**
  8186. * Binds the color curves to the shader.
  8187. * @param colorCurves The color curve to bind
  8188. * @param effect The effect to bind to
  8189. * @param positiveUniform The positive uniform shader parameter
  8190. * @param neutralUniform The neutral uniform shader parameter
  8191. * @param negativeUniform The negative uniform shader parameter
  8192. */
  8193. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8194. /**
  8195. * Prepare the list of uniforms associated with the ColorCurves effects.
  8196. * @param uniformsList The list of uniforms used in the effect
  8197. */
  8198. static PrepareUniforms(uniformsList: string[]): void;
  8199. /**
  8200. * Returns color grading data based on a hue, density, saturation and exposure value.
  8201. * @param filterHue The hue of the color filter.
  8202. * @param filterDensity The density of the color filter.
  8203. * @param saturation The saturation.
  8204. * @param exposure The exposure.
  8205. * @param result The result data container.
  8206. */
  8207. private getColorGradingDataToRef;
  8208. /**
  8209. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8210. * @param value The input slider value in range [-100,100].
  8211. * @returns Adjusted value.
  8212. */
  8213. private static applyColorGradingSliderNonlinear;
  8214. /**
  8215. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8216. * @param hue The hue (H) input.
  8217. * @param saturation The saturation (S) input.
  8218. * @param brightness The brightness (B) input.
  8219. * @result An RGBA color represented as Vector4.
  8220. */
  8221. private static fromHSBToRef;
  8222. /**
  8223. * Returns a value clamped between min and max
  8224. * @param value The value to clamp
  8225. * @param min The minimum of value
  8226. * @param max The maximum of value
  8227. * @returns The clamped value.
  8228. */
  8229. private static clamp;
  8230. /**
  8231. * Clones the current color curve instance.
  8232. * @return The cloned curves
  8233. */
  8234. clone(): ColorCurves;
  8235. /**
  8236. * Serializes the current color curve instance to a json representation.
  8237. * @return a JSON representation
  8238. */
  8239. serialize(): any;
  8240. /**
  8241. * Parses the color curve from a json representation.
  8242. * @param source the JSON source to parse
  8243. * @return The parsed curves
  8244. */
  8245. static Parse(source: any): ColorCurves;
  8246. }
  8247. }
  8248. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8249. import { Observable } from "babylonjs/Misc/observable";
  8250. import { Nullable } from "babylonjs/types";
  8251. import { Color4 } from "babylonjs/Maths/math.color";
  8252. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8253. import { Effect } from "babylonjs/Materials/effect";
  8254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8255. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8256. /**
  8257. * Interface to follow in your material defines to integrate easily the
  8258. * Image proccessing functions.
  8259. * @hidden
  8260. */
  8261. export interface IImageProcessingConfigurationDefines {
  8262. IMAGEPROCESSING: boolean;
  8263. VIGNETTE: boolean;
  8264. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8265. VIGNETTEBLENDMODEOPAQUE: boolean;
  8266. TONEMAPPING: boolean;
  8267. TONEMAPPING_ACES: boolean;
  8268. CONTRAST: boolean;
  8269. EXPOSURE: boolean;
  8270. COLORCURVES: boolean;
  8271. COLORGRADING: boolean;
  8272. COLORGRADING3D: boolean;
  8273. SAMPLER3DGREENDEPTH: boolean;
  8274. SAMPLER3DBGRMAP: boolean;
  8275. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8276. }
  8277. /**
  8278. * @hidden
  8279. */
  8280. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8281. IMAGEPROCESSING: boolean;
  8282. VIGNETTE: boolean;
  8283. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8284. VIGNETTEBLENDMODEOPAQUE: boolean;
  8285. TONEMAPPING: boolean;
  8286. TONEMAPPING_ACES: boolean;
  8287. CONTRAST: boolean;
  8288. COLORCURVES: boolean;
  8289. COLORGRADING: boolean;
  8290. COLORGRADING3D: boolean;
  8291. SAMPLER3DGREENDEPTH: boolean;
  8292. SAMPLER3DBGRMAP: boolean;
  8293. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8294. EXPOSURE: boolean;
  8295. constructor();
  8296. }
  8297. /**
  8298. * This groups together the common properties used for image processing either in direct forward pass
  8299. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8300. * or not.
  8301. */
  8302. export class ImageProcessingConfiguration {
  8303. /**
  8304. * Default tone mapping applied in BabylonJS.
  8305. */
  8306. static readonly TONEMAPPING_STANDARD: number;
  8307. /**
  8308. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8309. * to other engines rendering to increase portability.
  8310. */
  8311. static readonly TONEMAPPING_ACES: number;
  8312. /**
  8313. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8314. */
  8315. colorCurves: Nullable<ColorCurves>;
  8316. private _colorCurvesEnabled;
  8317. /**
  8318. * Gets wether the color curves effect is enabled.
  8319. */
  8320. get colorCurvesEnabled(): boolean;
  8321. /**
  8322. * Sets wether the color curves effect is enabled.
  8323. */
  8324. set colorCurvesEnabled(value: boolean);
  8325. private _colorGradingTexture;
  8326. /**
  8327. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8328. */
  8329. get colorGradingTexture(): Nullable<BaseTexture>;
  8330. /**
  8331. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8332. */
  8333. set colorGradingTexture(value: Nullable<BaseTexture>);
  8334. private _colorGradingEnabled;
  8335. /**
  8336. * Gets wether the color grading effect is enabled.
  8337. */
  8338. get colorGradingEnabled(): boolean;
  8339. /**
  8340. * Sets wether the color grading effect is enabled.
  8341. */
  8342. set colorGradingEnabled(value: boolean);
  8343. private _colorGradingWithGreenDepth;
  8344. /**
  8345. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8346. */
  8347. get colorGradingWithGreenDepth(): boolean;
  8348. /**
  8349. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8350. */
  8351. set colorGradingWithGreenDepth(value: boolean);
  8352. private _colorGradingBGR;
  8353. /**
  8354. * Gets wether the color grading texture contains BGR values.
  8355. */
  8356. get colorGradingBGR(): boolean;
  8357. /**
  8358. * Sets wether the color grading texture contains BGR values.
  8359. */
  8360. set colorGradingBGR(value: boolean);
  8361. /** @hidden */
  8362. _exposure: number;
  8363. /**
  8364. * Gets the Exposure used in the effect.
  8365. */
  8366. get exposure(): number;
  8367. /**
  8368. * Sets the Exposure used in the effect.
  8369. */
  8370. set exposure(value: number);
  8371. private _toneMappingEnabled;
  8372. /**
  8373. * Gets wether the tone mapping effect is enabled.
  8374. */
  8375. get toneMappingEnabled(): boolean;
  8376. /**
  8377. * Sets wether the tone mapping effect is enabled.
  8378. */
  8379. set toneMappingEnabled(value: boolean);
  8380. private _toneMappingType;
  8381. /**
  8382. * Gets the type of tone mapping effect.
  8383. */
  8384. get toneMappingType(): number;
  8385. /**
  8386. * Sets the type of tone mapping effect used in BabylonJS.
  8387. */
  8388. set toneMappingType(value: number);
  8389. protected _contrast: number;
  8390. /**
  8391. * Gets the contrast used in the effect.
  8392. */
  8393. get contrast(): number;
  8394. /**
  8395. * Sets the contrast used in the effect.
  8396. */
  8397. set contrast(value: number);
  8398. /**
  8399. * Vignette stretch size.
  8400. */
  8401. vignetteStretch: number;
  8402. /**
  8403. * Vignette centre X Offset.
  8404. */
  8405. vignetteCentreX: number;
  8406. /**
  8407. * Vignette centre Y Offset.
  8408. */
  8409. vignetteCentreY: number;
  8410. /**
  8411. * Vignette weight or intensity of the vignette effect.
  8412. */
  8413. vignetteWeight: number;
  8414. /**
  8415. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8416. * if vignetteEnabled is set to true.
  8417. */
  8418. vignetteColor: Color4;
  8419. /**
  8420. * Camera field of view used by the Vignette effect.
  8421. */
  8422. vignetteCameraFov: number;
  8423. private _vignetteBlendMode;
  8424. /**
  8425. * Gets the vignette blend mode allowing different kind of effect.
  8426. */
  8427. get vignetteBlendMode(): number;
  8428. /**
  8429. * Sets the vignette blend mode allowing different kind of effect.
  8430. */
  8431. set vignetteBlendMode(value: number);
  8432. private _vignetteEnabled;
  8433. /**
  8434. * Gets wether the vignette effect is enabled.
  8435. */
  8436. get vignetteEnabled(): boolean;
  8437. /**
  8438. * Sets wether the vignette effect is enabled.
  8439. */
  8440. set vignetteEnabled(value: boolean);
  8441. private _applyByPostProcess;
  8442. /**
  8443. * Gets wether the image processing is applied through a post process or not.
  8444. */
  8445. get applyByPostProcess(): boolean;
  8446. /**
  8447. * Sets wether the image processing is applied through a post process or not.
  8448. */
  8449. set applyByPostProcess(value: boolean);
  8450. private _isEnabled;
  8451. /**
  8452. * Gets wether the image processing is enabled or not.
  8453. */
  8454. get isEnabled(): boolean;
  8455. /**
  8456. * Sets wether the image processing is enabled or not.
  8457. */
  8458. set isEnabled(value: boolean);
  8459. /**
  8460. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8461. */
  8462. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8463. /**
  8464. * Method called each time the image processing information changes requires to recompile the effect.
  8465. */
  8466. protected _updateParameters(): void;
  8467. /**
  8468. * Gets the current class name.
  8469. * @return "ImageProcessingConfiguration"
  8470. */
  8471. getClassName(): string;
  8472. /**
  8473. * Prepare the list of uniforms associated with the Image Processing effects.
  8474. * @param uniforms The list of uniforms used in the effect
  8475. * @param defines the list of defines currently in use
  8476. */
  8477. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8478. /**
  8479. * Prepare the list of samplers associated with the Image Processing effects.
  8480. * @param samplersList The list of uniforms used in the effect
  8481. * @param defines the list of defines currently in use
  8482. */
  8483. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8484. /**
  8485. * Prepare the list of defines associated to the shader.
  8486. * @param defines the list of defines to complete
  8487. * @param forPostProcess Define if we are currently in post process mode or not
  8488. */
  8489. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8490. /**
  8491. * Returns true if all the image processing information are ready.
  8492. * @returns True if ready, otherwise, false
  8493. */
  8494. isReady(): boolean;
  8495. /**
  8496. * Binds the image processing to the shader.
  8497. * @param effect The effect to bind to
  8498. * @param overrideAspectRatio Override the aspect ratio of the effect
  8499. */
  8500. bind(effect: Effect, overrideAspectRatio?: number): void;
  8501. /**
  8502. * Clones the current image processing instance.
  8503. * @return The cloned image processing
  8504. */
  8505. clone(): ImageProcessingConfiguration;
  8506. /**
  8507. * Serializes the current image processing instance to a json representation.
  8508. * @return a JSON representation
  8509. */
  8510. serialize(): any;
  8511. /**
  8512. * Parses the image processing from a json representation.
  8513. * @param source the JSON source to parse
  8514. * @return The parsed image processing
  8515. */
  8516. static Parse(source: any): ImageProcessingConfiguration;
  8517. private static _VIGNETTEMODE_MULTIPLY;
  8518. private static _VIGNETTEMODE_OPAQUE;
  8519. /**
  8520. * Used to apply the vignette as a mix with the pixel color.
  8521. */
  8522. static get VIGNETTEMODE_MULTIPLY(): number;
  8523. /**
  8524. * Used to apply the vignette as a replacement of the pixel color.
  8525. */
  8526. static get VIGNETTEMODE_OPAQUE(): number;
  8527. }
  8528. }
  8529. declare module "babylonjs/Shaders/postprocess.vertex" {
  8530. /** @hidden */
  8531. export var postprocessVertexShader: {
  8532. name: string;
  8533. shader: string;
  8534. };
  8535. }
  8536. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8537. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8538. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8539. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8540. module "babylonjs/Engines/thinEngine" {
  8541. interface ThinEngine {
  8542. /**
  8543. * Creates a new render target texture
  8544. * @param size defines the size of the texture
  8545. * @param options defines the options used to create the texture
  8546. * @returns a new render target texture stored in an InternalTexture
  8547. */
  8548. createRenderTargetTexture(size: number | {
  8549. width: number;
  8550. height: number;
  8551. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8552. /**
  8553. * Creates a depth stencil texture.
  8554. * This is only available in WebGL 2 or with the depth texture extension available.
  8555. * @param size The size of face edge in the texture.
  8556. * @param options The options defining the texture.
  8557. * @returns The texture
  8558. */
  8559. createDepthStencilTexture(size: number | {
  8560. width: number;
  8561. height: number;
  8562. }, options: DepthTextureCreationOptions): InternalTexture;
  8563. /** @hidden */
  8564. _createDepthStencilTexture(size: number | {
  8565. width: number;
  8566. height: number;
  8567. }, options: DepthTextureCreationOptions): InternalTexture;
  8568. }
  8569. }
  8570. }
  8571. declare module "babylonjs/Maths/math.axis" {
  8572. import { Vector3 } from "babylonjs/Maths/math.vector";
  8573. /** Defines supported spaces */
  8574. export enum Space {
  8575. /** Local (object) space */
  8576. LOCAL = 0,
  8577. /** World space */
  8578. WORLD = 1,
  8579. /** Bone space */
  8580. BONE = 2
  8581. }
  8582. /** Defines the 3 main axes */
  8583. export class Axis {
  8584. /** X axis */
  8585. static X: Vector3;
  8586. /** Y axis */
  8587. static Y: Vector3;
  8588. /** Z axis */
  8589. static Z: Vector3;
  8590. }
  8591. }
  8592. declare module "babylonjs/Cameras/targetCamera" {
  8593. import { Nullable } from "babylonjs/types";
  8594. import { Camera } from "babylonjs/Cameras/camera";
  8595. import { Scene } from "babylonjs/scene";
  8596. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8597. /**
  8598. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8599. * This is the base of the follow, arc rotate cameras and Free camera
  8600. * @see http://doc.babylonjs.com/features/cameras
  8601. */
  8602. export class TargetCamera extends Camera {
  8603. private static _RigCamTransformMatrix;
  8604. private static _TargetTransformMatrix;
  8605. private static _TargetFocalPoint;
  8606. /**
  8607. * Define the current direction the camera is moving to
  8608. */
  8609. cameraDirection: Vector3;
  8610. /**
  8611. * Define the current rotation the camera is rotating to
  8612. */
  8613. cameraRotation: Vector2;
  8614. /**
  8615. * When set, the up vector of the camera will be updated by the rotation of the camera
  8616. */
  8617. updateUpVectorFromRotation: boolean;
  8618. private _tmpQuaternion;
  8619. /**
  8620. * Define the current rotation of the camera
  8621. */
  8622. rotation: Vector3;
  8623. /**
  8624. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8625. */
  8626. rotationQuaternion: Quaternion;
  8627. /**
  8628. * Define the current speed of the camera
  8629. */
  8630. speed: number;
  8631. /**
  8632. * Add constraint to the camera to prevent it to move freely in all directions and
  8633. * around all axis.
  8634. */
  8635. noRotationConstraint: boolean;
  8636. /**
  8637. * Define the current target of the camera as an object or a position.
  8638. */
  8639. lockedTarget: any;
  8640. /** @hidden */
  8641. _currentTarget: Vector3;
  8642. /** @hidden */
  8643. _initialFocalDistance: number;
  8644. /** @hidden */
  8645. _viewMatrix: Matrix;
  8646. /** @hidden */
  8647. _camMatrix: Matrix;
  8648. /** @hidden */
  8649. _cameraTransformMatrix: Matrix;
  8650. /** @hidden */
  8651. _cameraRotationMatrix: Matrix;
  8652. /** @hidden */
  8653. _referencePoint: Vector3;
  8654. /** @hidden */
  8655. _transformedReferencePoint: Vector3;
  8656. protected _globalCurrentTarget: Vector3;
  8657. protected _globalCurrentUpVector: Vector3;
  8658. /** @hidden */
  8659. _reset: () => void;
  8660. private _defaultUp;
  8661. /**
  8662. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8663. * This is the base of the follow, arc rotate cameras and Free camera
  8664. * @see http://doc.babylonjs.com/features/cameras
  8665. * @param name Defines the name of the camera in the scene
  8666. * @param position Defines the start position of the camera in the scene
  8667. * @param scene Defines the scene the camera belongs to
  8668. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8669. */
  8670. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8671. /**
  8672. * Gets the position in front of the camera at a given distance.
  8673. * @param distance The distance from the camera we want the position to be
  8674. * @returns the position
  8675. */
  8676. getFrontPosition(distance: number): Vector3;
  8677. /** @hidden */
  8678. _getLockedTargetPosition(): Nullable<Vector3>;
  8679. private _storedPosition;
  8680. private _storedRotation;
  8681. private _storedRotationQuaternion;
  8682. /**
  8683. * Store current camera state of the camera (fov, position, rotation, etc..)
  8684. * @returns the camera
  8685. */
  8686. storeState(): Camera;
  8687. /**
  8688. * Restored camera state. You must call storeState() first
  8689. * @returns whether it was successful or not
  8690. * @hidden
  8691. */
  8692. _restoreStateValues(): boolean;
  8693. /** @hidden */
  8694. _initCache(): void;
  8695. /** @hidden */
  8696. _updateCache(ignoreParentClass?: boolean): void;
  8697. /** @hidden */
  8698. _isSynchronizedViewMatrix(): boolean;
  8699. /** @hidden */
  8700. _computeLocalCameraSpeed(): number;
  8701. /**
  8702. * Defines the target the camera should look at.
  8703. * @param target Defines the new target as a Vector or a mesh
  8704. */
  8705. setTarget(target: Vector3): void;
  8706. /**
  8707. * Return the current target position of the camera. This value is expressed in local space.
  8708. * @returns the target position
  8709. */
  8710. getTarget(): Vector3;
  8711. /** @hidden */
  8712. _decideIfNeedsToMove(): boolean;
  8713. /** @hidden */
  8714. _updatePosition(): void;
  8715. /** @hidden */
  8716. _checkInputs(): void;
  8717. protected _updateCameraRotationMatrix(): void;
  8718. /**
  8719. * 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)
  8720. * @returns the current camera
  8721. */
  8722. private _rotateUpVectorWithCameraRotationMatrix;
  8723. private _cachedRotationZ;
  8724. private _cachedQuaternionRotationZ;
  8725. /** @hidden */
  8726. _getViewMatrix(): Matrix;
  8727. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8728. /**
  8729. * @hidden
  8730. */
  8731. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8732. /**
  8733. * @hidden
  8734. */
  8735. _updateRigCameras(): void;
  8736. private _getRigCamPositionAndTarget;
  8737. /**
  8738. * Gets the current object class name.
  8739. * @return the class name
  8740. */
  8741. getClassName(): string;
  8742. }
  8743. }
  8744. declare module "babylonjs/Events/keyboardEvents" {
  8745. /**
  8746. * Gather the list of keyboard event types as constants.
  8747. */
  8748. export class KeyboardEventTypes {
  8749. /**
  8750. * The keydown event is fired when a key becomes active (pressed).
  8751. */
  8752. static readonly KEYDOWN: number;
  8753. /**
  8754. * The keyup event is fired when a key has been released.
  8755. */
  8756. static readonly KEYUP: number;
  8757. }
  8758. /**
  8759. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8760. */
  8761. export class KeyboardInfo {
  8762. /**
  8763. * Defines the type of event (KeyboardEventTypes)
  8764. */
  8765. type: number;
  8766. /**
  8767. * Defines the related dom event
  8768. */
  8769. event: KeyboardEvent;
  8770. /**
  8771. * Instantiates a new keyboard info.
  8772. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8773. * @param type Defines the type of event (KeyboardEventTypes)
  8774. * @param event Defines the related dom event
  8775. */
  8776. constructor(
  8777. /**
  8778. * Defines the type of event (KeyboardEventTypes)
  8779. */
  8780. type: number,
  8781. /**
  8782. * Defines the related dom event
  8783. */
  8784. event: KeyboardEvent);
  8785. }
  8786. /**
  8787. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8788. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8789. */
  8790. export class KeyboardInfoPre extends KeyboardInfo {
  8791. /**
  8792. * Defines the type of event (KeyboardEventTypes)
  8793. */
  8794. type: number;
  8795. /**
  8796. * Defines the related dom event
  8797. */
  8798. event: KeyboardEvent;
  8799. /**
  8800. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8801. */
  8802. skipOnPointerObservable: boolean;
  8803. /**
  8804. * Instantiates a new keyboard pre info.
  8805. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8806. * @param type Defines the type of event (KeyboardEventTypes)
  8807. * @param event Defines the related dom event
  8808. */
  8809. constructor(
  8810. /**
  8811. * Defines the type of event (KeyboardEventTypes)
  8812. */
  8813. type: number,
  8814. /**
  8815. * Defines the related dom event
  8816. */
  8817. event: KeyboardEvent);
  8818. }
  8819. }
  8820. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8821. import { Nullable } from "babylonjs/types";
  8822. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8823. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8824. /**
  8825. * Manage the keyboard inputs to control the movement of a free camera.
  8826. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8827. */
  8828. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8829. /**
  8830. * Defines the camera the input is attached to.
  8831. */
  8832. camera: FreeCamera;
  8833. /**
  8834. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8835. */
  8836. keysUp: number[];
  8837. /**
  8838. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8839. */
  8840. keysDown: number[];
  8841. /**
  8842. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8843. */
  8844. keysLeft: number[];
  8845. /**
  8846. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8847. */
  8848. keysRight: number[];
  8849. private _keys;
  8850. private _onCanvasBlurObserver;
  8851. private _onKeyboardObserver;
  8852. private _engine;
  8853. private _scene;
  8854. /**
  8855. * Attach the input controls to a specific dom element to get the input from.
  8856. * @param element Defines the element the controls should be listened from
  8857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8858. */
  8859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8860. /**
  8861. * Detach the current controls from the specified dom element.
  8862. * @param element Defines the element to stop listening the inputs from
  8863. */
  8864. detachControl(element: Nullable<HTMLElement>): void;
  8865. /**
  8866. * Update the current camera state depending on the inputs that have been used this frame.
  8867. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8868. */
  8869. checkInputs(): void;
  8870. /**
  8871. * Gets the class name of the current intput.
  8872. * @returns the class name
  8873. */
  8874. getClassName(): string;
  8875. /** @hidden */
  8876. _onLostFocus(): void;
  8877. /**
  8878. * Get the friendly name associated with the input class.
  8879. * @returns the input friendly name
  8880. */
  8881. getSimpleName(): string;
  8882. }
  8883. }
  8884. declare module "babylonjs/Lights/shadowLight" {
  8885. import { Camera } from "babylonjs/Cameras/camera";
  8886. import { Scene } from "babylonjs/scene";
  8887. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8889. import { Light } from "babylonjs/Lights/light";
  8890. /**
  8891. * Interface describing all the common properties and methods a shadow light needs to implement.
  8892. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8893. * as well as binding the different shadow properties to the effects.
  8894. */
  8895. export interface IShadowLight extends Light {
  8896. /**
  8897. * The light id in the scene (used in scene.findLighById for instance)
  8898. */
  8899. id: string;
  8900. /**
  8901. * The position the shdow will be casted from.
  8902. */
  8903. position: Vector3;
  8904. /**
  8905. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8906. */
  8907. direction: Vector3;
  8908. /**
  8909. * The transformed position. Position of the light in world space taking parenting in account.
  8910. */
  8911. transformedPosition: Vector3;
  8912. /**
  8913. * The transformed direction. Direction of the light in world space taking parenting in account.
  8914. */
  8915. transformedDirection: Vector3;
  8916. /**
  8917. * The friendly name of the light in the scene.
  8918. */
  8919. name: string;
  8920. /**
  8921. * Defines the shadow projection clipping minimum z value.
  8922. */
  8923. shadowMinZ: number;
  8924. /**
  8925. * Defines the shadow projection clipping maximum z value.
  8926. */
  8927. shadowMaxZ: number;
  8928. /**
  8929. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8930. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8931. */
  8932. computeTransformedInformation(): boolean;
  8933. /**
  8934. * Gets the scene the light belongs to.
  8935. * @returns The scene
  8936. */
  8937. getScene(): Scene;
  8938. /**
  8939. * Callback defining a custom Projection Matrix Builder.
  8940. * This can be used to override the default projection matrix computation.
  8941. */
  8942. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8943. /**
  8944. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8945. * @param matrix The materix to updated with the projection information
  8946. * @param viewMatrix The transform matrix of the light
  8947. * @param renderList The list of mesh to render in the map
  8948. * @returns The current light
  8949. */
  8950. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8951. /**
  8952. * Gets the current depth scale used in ESM.
  8953. * @returns The scale
  8954. */
  8955. getDepthScale(): number;
  8956. /**
  8957. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8958. * @returns true if a cube texture needs to be use
  8959. */
  8960. needCube(): boolean;
  8961. /**
  8962. * Detects if the projection matrix requires to be recomputed this frame.
  8963. * @returns true if it requires to be recomputed otherwise, false.
  8964. */
  8965. needProjectionMatrixCompute(): boolean;
  8966. /**
  8967. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8968. */
  8969. forceProjectionMatrixCompute(): void;
  8970. /**
  8971. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8972. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8973. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8974. */
  8975. getShadowDirection(faceIndex?: number): Vector3;
  8976. /**
  8977. * Gets the minZ used for shadow according to both the scene and the light.
  8978. * @param activeCamera The camera we are returning the min for
  8979. * @returns the depth min z
  8980. */
  8981. getDepthMinZ(activeCamera: Camera): number;
  8982. /**
  8983. * Gets the maxZ used for shadow according to both the scene and the light.
  8984. * @param activeCamera The camera we are returning the max for
  8985. * @returns the depth max z
  8986. */
  8987. getDepthMaxZ(activeCamera: Camera): number;
  8988. }
  8989. /**
  8990. * Base implementation IShadowLight
  8991. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8992. */
  8993. export abstract class ShadowLight extends Light implements IShadowLight {
  8994. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8995. protected _position: Vector3;
  8996. protected _setPosition(value: Vector3): void;
  8997. /**
  8998. * Sets the position the shadow will be casted from. Also use as the light position for both
  8999. * point and spot lights.
  9000. */
  9001. get position(): Vector3;
  9002. /**
  9003. * Sets the position the shadow will be casted from. Also use as the light position for both
  9004. * point and spot lights.
  9005. */
  9006. set position(value: Vector3);
  9007. protected _direction: Vector3;
  9008. protected _setDirection(value: Vector3): void;
  9009. /**
  9010. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9011. * Also use as the light direction on spot and directional lights.
  9012. */
  9013. get direction(): Vector3;
  9014. /**
  9015. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9016. * Also use as the light direction on spot and directional lights.
  9017. */
  9018. set direction(value: Vector3);
  9019. protected _shadowMinZ: number;
  9020. /**
  9021. * Gets the shadow projection clipping minimum z value.
  9022. */
  9023. get shadowMinZ(): number;
  9024. /**
  9025. * Sets the shadow projection clipping minimum z value.
  9026. */
  9027. set shadowMinZ(value: number);
  9028. protected _shadowMaxZ: number;
  9029. /**
  9030. * Sets the shadow projection clipping maximum z value.
  9031. */
  9032. get shadowMaxZ(): number;
  9033. /**
  9034. * Gets the shadow projection clipping maximum z value.
  9035. */
  9036. set shadowMaxZ(value: number);
  9037. /**
  9038. * Callback defining a custom Projection Matrix Builder.
  9039. * This can be used to override the default projection matrix computation.
  9040. */
  9041. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9042. /**
  9043. * The transformed position. Position of the light in world space taking parenting in account.
  9044. */
  9045. transformedPosition: Vector3;
  9046. /**
  9047. * The transformed direction. Direction of the light in world space taking parenting in account.
  9048. */
  9049. transformedDirection: Vector3;
  9050. private _needProjectionMatrixCompute;
  9051. /**
  9052. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9053. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9054. */
  9055. computeTransformedInformation(): boolean;
  9056. /**
  9057. * Return the depth scale used for the shadow map.
  9058. * @returns the depth scale.
  9059. */
  9060. getDepthScale(): number;
  9061. /**
  9062. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9063. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9064. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9065. */
  9066. getShadowDirection(faceIndex?: number): Vector3;
  9067. /**
  9068. * Returns the ShadowLight absolute position in the World.
  9069. * @returns the position vector in world space
  9070. */
  9071. getAbsolutePosition(): Vector3;
  9072. /**
  9073. * Sets the ShadowLight direction toward the passed target.
  9074. * @param target The point to target in local space
  9075. * @returns the updated ShadowLight direction
  9076. */
  9077. setDirectionToTarget(target: Vector3): Vector3;
  9078. /**
  9079. * Returns the light rotation in euler definition.
  9080. * @returns the x y z rotation in local space.
  9081. */
  9082. getRotation(): Vector3;
  9083. /**
  9084. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9085. * @returns true if a cube texture needs to be use
  9086. */
  9087. needCube(): boolean;
  9088. /**
  9089. * Detects if the projection matrix requires to be recomputed this frame.
  9090. * @returns true if it requires to be recomputed otherwise, false.
  9091. */
  9092. needProjectionMatrixCompute(): boolean;
  9093. /**
  9094. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9095. */
  9096. forceProjectionMatrixCompute(): void;
  9097. /** @hidden */
  9098. _initCache(): void;
  9099. /** @hidden */
  9100. _isSynchronized(): boolean;
  9101. /**
  9102. * Computes the world matrix of the node
  9103. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9104. * @returns the world matrix
  9105. */
  9106. computeWorldMatrix(force?: boolean): Matrix;
  9107. /**
  9108. * Gets the minZ used for shadow according to both the scene and the light.
  9109. * @param activeCamera The camera we are returning the min for
  9110. * @returns the depth min z
  9111. */
  9112. getDepthMinZ(activeCamera: Camera): number;
  9113. /**
  9114. * Gets the maxZ used for shadow according to both the scene and the light.
  9115. * @param activeCamera The camera we are returning the max for
  9116. * @returns the depth max z
  9117. */
  9118. getDepthMaxZ(activeCamera: Camera): number;
  9119. /**
  9120. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9121. * @param matrix The materix to updated with the projection information
  9122. * @param viewMatrix The transform matrix of the light
  9123. * @param renderList The list of mesh to render in the map
  9124. * @returns The current light
  9125. */
  9126. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9127. }
  9128. }
  9129. declare module "babylonjs/Materials/effectFallbacks" {
  9130. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9131. import { Effect } from "babylonjs/Materials/effect";
  9132. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9133. /**
  9134. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9135. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9136. */
  9137. export class EffectFallbacks implements IEffectFallbacks {
  9138. private _defines;
  9139. private _currentRank;
  9140. private _maxRank;
  9141. private _mesh;
  9142. /**
  9143. * Removes the fallback from the bound mesh.
  9144. */
  9145. unBindMesh(): void;
  9146. /**
  9147. * Adds a fallback on the specified property.
  9148. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9149. * @param define The name of the define in the shader
  9150. */
  9151. addFallback(rank: number, define: string): void;
  9152. /**
  9153. * Sets the mesh to use CPU skinning when needing to fallback.
  9154. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9155. * @param mesh The mesh to use the fallbacks.
  9156. */
  9157. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9158. /**
  9159. * Checks to see if more fallbacks are still availible.
  9160. */
  9161. get hasMoreFallbacks(): boolean;
  9162. /**
  9163. * Removes the defines that should be removed when falling back.
  9164. * @param currentDefines defines the current define statements for the shader.
  9165. * @param effect defines the current effect we try to compile
  9166. * @returns The resulting defines with defines of the current rank removed.
  9167. */
  9168. reduce(currentDefines: string, effect: Effect): string;
  9169. }
  9170. }
  9171. declare module "babylonjs/Materials/materialHelper" {
  9172. import { Nullable } from "babylonjs/types";
  9173. import { Scene } from "babylonjs/scene";
  9174. import { Engine } from "babylonjs/Engines/engine";
  9175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9176. import { Light } from "babylonjs/Lights/light";
  9177. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9178. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9179. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9180. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9181. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9182. /**
  9183. * "Static Class" containing the most commonly used helper while dealing with material for
  9184. * rendering purpose.
  9185. *
  9186. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9187. *
  9188. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9189. */
  9190. export class MaterialHelper {
  9191. /**
  9192. * Bind the current view position to an effect.
  9193. * @param effect The effect to be bound
  9194. * @param scene The scene the eyes position is used from
  9195. */
  9196. static BindEyePosition(effect: Effect, scene: Scene): void;
  9197. /**
  9198. * Helps preparing the defines values about the UVs in used in the effect.
  9199. * UVs are shared as much as we can accross channels in the shaders.
  9200. * @param texture The texture we are preparing the UVs for
  9201. * @param defines The defines to update
  9202. * @param key The channel key "diffuse", "specular"... used in the shader
  9203. */
  9204. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9205. /**
  9206. * Binds a texture matrix value to its corrsponding uniform
  9207. * @param texture The texture to bind the matrix for
  9208. * @param uniformBuffer The uniform buffer receivin the data
  9209. * @param key The channel key "diffuse", "specular"... used in the shader
  9210. */
  9211. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9212. /**
  9213. * Gets the current status of the fog (should it be enabled?)
  9214. * @param mesh defines the mesh to evaluate for fog support
  9215. * @param scene defines the hosting scene
  9216. * @returns true if fog must be enabled
  9217. */
  9218. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9219. /**
  9220. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9221. * @param mesh defines the current mesh
  9222. * @param scene defines the current scene
  9223. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9224. * @param pointsCloud defines if point cloud rendering has to be turned on
  9225. * @param fogEnabled defines if fog has to be turned on
  9226. * @param alphaTest defines if alpha testing has to be turned on
  9227. * @param defines defines the current list of defines
  9228. */
  9229. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9230. /**
  9231. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9232. * @param scene defines the current scene
  9233. * @param engine defines the current engine
  9234. * @param defines specifies the list of active defines
  9235. * @param useInstances defines if instances have to be turned on
  9236. * @param useClipPlane defines if clip plane have to be turned on
  9237. */
  9238. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9239. /**
  9240. * Prepares the defines for bones
  9241. * @param mesh The mesh containing the geometry data we will draw
  9242. * @param defines The defines to update
  9243. */
  9244. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9245. /**
  9246. * Prepares the defines for morph targets
  9247. * @param mesh The mesh containing the geometry data we will draw
  9248. * @param defines The defines to update
  9249. */
  9250. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9251. /**
  9252. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9253. * @param mesh The mesh containing the geometry data we will draw
  9254. * @param defines The defines to update
  9255. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9256. * @param useBones Precise whether bones should be used or not (override mesh info)
  9257. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9258. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9259. * @returns false if defines are considered not dirty and have not been checked
  9260. */
  9261. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9262. /**
  9263. * Prepares the defines related to multiview
  9264. * @param scene The scene we are intending to draw
  9265. * @param defines The defines to update
  9266. */
  9267. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9268. /**
  9269. * Prepares the defines related to the light information passed in parameter
  9270. * @param scene The scene we are intending to draw
  9271. * @param mesh The mesh the effect is compiling for
  9272. * @param light The light the effect is compiling for
  9273. * @param lightIndex The index of the light
  9274. * @param defines The defines to update
  9275. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9276. * @param state Defines the current state regarding what is needed (normals, etc...)
  9277. */
  9278. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9279. needNormals: boolean;
  9280. needRebuild: boolean;
  9281. shadowEnabled: boolean;
  9282. specularEnabled: boolean;
  9283. lightmapMode: boolean;
  9284. }): void;
  9285. /**
  9286. * Prepares the defines related to the light information passed in parameter
  9287. * @param scene The scene we are intending to draw
  9288. * @param mesh The mesh the effect is compiling for
  9289. * @param defines The defines to update
  9290. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9291. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9292. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9293. * @returns true if normals will be required for the rest of the effect
  9294. */
  9295. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9296. /**
  9297. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9298. * @param lightIndex defines the light index
  9299. * @param uniformsList The uniform list
  9300. * @param samplersList The sampler list
  9301. * @param projectedLightTexture defines if projected texture must be used
  9302. * @param uniformBuffersList defines an optional list of uniform buffers
  9303. */
  9304. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9305. /**
  9306. * Prepares the uniforms and samplers list to be used in the effect
  9307. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9308. * @param samplersList The sampler list
  9309. * @param defines The defines helping in the list generation
  9310. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9311. */
  9312. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9313. /**
  9314. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9315. * @param defines The defines to update while falling back
  9316. * @param fallbacks The authorized effect fallbacks
  9317. * @param maxSimultaneousLights The maximum number of lights allowed
  9318. * @param rank the current rank of the Effect
  9319. * @returns The newly affected rank
  9320. */
  9321. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9322. private static _TmpMorphInfluencers;
  9323. /**
  9324. * Prepares the list of attributes required for morph targets according to the effect defines.
  9325. * @param attribs The current list of supported attribs
  9326. * @param mesh The mesh to prepare the morph targets attributes for
  9327. * @param influencers The number of influencers
  9328. */
  9329. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9330. /**
  9331. * Prepares the list of attributes required for morph targets according to the effect defines.
  9332. * @param attribs The current list of supported attribs
  9333. * @param mesh The mesh to prepare the morph targets attributes for
  9334. * @param defines The current Defines of the effect
  9335. */
  9336. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9337. /**
  9338. * Prepares the list of attributes required for bones according to the effect defines.
  9339. * @param attribs The current list of supported attribs
  9340. * @param mesh The mesh to prepare the bones attributes for
  9341. * @param defines The current Defines of the effect
  9342. * @param fallbacks The current efffect fallback strategy
  9343. */
  9344. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9345. /**
  9346. * Check and prepare the list of attributes required for instances according to the effect defines.
  9347. * @param attribs The current list of supported attribs
  9348. * @param defines The current MaterialDefines of the effect
  9349. */
  9350. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9351. /**
  9352. * Add the list of attributes required for instances to the attribs array.
  9353. * @param attribs The current list of supported attribs
  9354. */
  9355. static PushAttributesForInstances(attribs: string[]): void;
  9356. /**
  9357. * Binds the light information to the effect.
  9358. * @param light The light containing the generator
  9359. * @param effect The effect we are binding the data to
  9360. * @param lightIndex The light index in the effect used to render
  9361. */
  9362. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9363. /**
  9364. * Binds the lights information from the scene to the effect for the given mesh.
  9365. * @param light Light to bind
  9366. * @param lightIndex Light index
  9367. * @param scene The scene where the light belongs to
  9368. * @param effect The effect we are binding the data to
  9369. * @param useSpecular Defines if specular is supported
  9370. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9371. */
  9372. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9373. /**
  9374. * Binds the lights information from the scene to the effect for the given mesh.
  9375. * @param scene The scene the lights belongs to
  9376. * @param mesh The mesh we are binding the information to render
  9377. * @param effect The effect we are binding the data to
  9378. * @param defines The generated defines for the effect
  9379. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9380. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9381. */
  9382. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9383. private static _tempFogColor;
  9384. /**
  9385. * Binds the fog information from the scene to the effect for the given mesh.
  9386. * @param scene The scene the lights belongs to
  9387. * @param mesh The mesh we are binding the information to render
  9388. * @param effect The effect we are binding the data to
  9389. * @param linearSpace Defines if the fog effect is applied in linear space
  9390. */
  9391. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9392. /**
  9393. * Binds the bones information from the mesh to the effect.
  9394. * @param mesh The mesh we are binding the information to render
  9395. * @param effect The effect we are binding the data to
  9396. */
  9397. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9398. /**
  9399. * Binds the morph targets information from the mesh to the effect.
  9400. * @param abstractMesh The mesh we are binding the information to render
  9401. * @param effect The effect we are binding the data to
  9402. */
  9403. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9404. /**
  9405. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9406. * @param defines The generated defines used in the effect
  9407. * @param effect The effect we are binding the data to
  9408. * @param scene The scene we are willing to render with logarithmic scale for
  9409. */
  9410. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9411. /**
  9412. * Binds the clip plane information from the scene to the effect.
  9413. * @param scene The scene the clip plane information are extracted from
  9414. * @param effect The effect we are binding the data to
  9415. */
  9416. static BindClipPlane(effect: Effect, scene: Scene): void;
  9417. }
  9418. }
  9419. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9420. /** @hidden */
  9421. export var packingFunctions: {
  9422. name: string;
  9423. shader: string;
  9424. };
  9425. }
  9426. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9427. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9428. /** @hidden */
  9429. export var shadowMapPixelShader: {
  9430. name: string;
  9431. shader: string;
  9432. };
  9433. }
  9434. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9435. /** @hidden */
  9436. export var bonesDeclaration: {
  9437. name: string;
  9438. shader: string;
  9439. };
  9440. }
  9441. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9442. /** @hidden */
  9443. export var morphTargetsVertexGlobalDeclaration: {
  9444. name: string;
  9445. shader: string;
  9446. };
  9447. }
  9448. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9449. /** @hidden */
  9450. export var morphTargetsVertexDeclaration: {
  9451. name: string;
  9452. shader: string;
  9453. };
  9454. }
  9455. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9456. /** @hidden */
  9457. export var instancesDeclaration: {
  9458. name: string;
  9459. shader: string;
  9460. };
  9461. }
  9462. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9463. /** @hidden */
  9464. export var helperFunctions: {
  9465. name: string;
  9466. shader: string;
  9467. };
  9468. }
  9469. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9470. /** @hidden */
  9471. export var morphTargetsVertex: {
  9472. name: string;
  9473. shader: string;
  9474. };
  9475. }
  9476. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9477. /** @hidden */
  9478. export var instancesVertex: {
  9479. name: string;
  9480. shader: string;
  9481. };
  9482. }
  9483. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9484. /** @hidden */
  9485. export var bonesVertex: {
  9486. name: string;
  9487. shader: string;
  9488. };
  9489. }
  9490. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9491. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9492. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9493. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9494. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9495. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9496. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9497. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9498. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9499. /** @hidden */
  9500. export var shadowMapVertexShader: {
  9501. name: string;
  9502. shader: string;
  9503. };
  9504. }
  9505. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9506. /** @hidden */
  9507. export var depthBoxBlurPixelShader: {
  9508. name: string;
  9509. shader: string;
  9510. };
  9511. }
  9512. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9513. import { Nullable } from "babylonjs/types";
  9514. import { Scene } from "babylonjs/scene";
  9515. import { Matrix } from "babylonjs/Maths/math.vector";
  9516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9518. import { Mesh } from "babylonjs/Meshes/mesh";
  9519. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9520. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9521. import { Effect } from "babylonjs/Materials/effect";
  9522. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9523. import "babylonjs/Shaders/shadowMap.fragment";
  9524. import "babylonjs/Shaders/shadowMap.vertex";
  9525. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9526. import { Observable } from "babylonjs/Misc/observable";
  9527. /**
  9528. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9529. */
  9530. export interface ICustomShaderOptions {
  9531. /**
  9532. * Gets or sets the custom shader name to use
  9533. */
  9534. shaderName: string;
  9535. /**
  9536. * The list of attribute names used in the shader
  9537. */
  9538. attributes?: string[];
  9539. /**
  9540. * The list of unifrom names used in the shader
  9541. */
  9542. uniforms?: string[];
  9543. /**
  9544. * The list of sampler names used in the shader
  9545. */
  9546. samplers?: string[];
  9547. /**
  9548. * The list of defines used in the shader
  9549. */
  9550. defines?: string[];
  9551. }
  9552. /**
  9553. * Interface to implement to create a shadow generator compatible with BJS.
  9554. */
  9555. export interface IShadowGenerator {
  9556. /**
  9557. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9558. * @returns The render target texture if present otherwise, null
  9559. */
  9560. getShadowMap(): Nullable<RenderTargetTexture>;
  9561. /**
  9562. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9563. * @returns The render target texture if the shadow map is present otherwise, null
  9564. */
  9565. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9566. /**
  9567. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9568. * @param subMesh The submesh we want to render in the shadow map
  9569. * @param useInstances Defines wether will draw in the map using instances
  9570. * @returns true if ready otherwise, false
  9571. */
  9572. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9573. /**
  9574. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9575. * @param defines Defines of the material we want to update
  9576. * @param lightIndex Index of the light in the enabled light list of the material
  9577. */
  9578. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9579. /**
  9580. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9581. * defined in the generator but impacting the effect).
  9582. * It implies the unifroms available on the materials are the standard BJS ones.
  9583. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9584. * @param effect The effect we are binfing the information for
  9585. */
  9586. bindShadowLight(lightIndex: string, effect: Effect): void;
  9587. /**
  9588. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9589. * (eq to shadow prjection matrix * light transform matrix)
  9590. * @returns The transform matrix used to create the shadow map
  9591. */
  9592. getTransformMatrix(): Matrix;
  9593. /**
  9594. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9595. * Cube and 2D textures for instance.
  9596. */
  9597. recreateShadowMap(): void;
  9598. /**
  9599. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9600. * @param onCompiled Callback triggered at the and of the effects compilation
  9601. * @param options Sets of optional options forcing the compilation with different modes
  9602. */
  9603. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9604. useInstances: boolean;
  9605. }>): void;
  9606. /**
  9607. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9608. * @param options Sets of optional options forcing the compilation with different modes
  9609. * @returns A promise that resolves when the compilation completes
  9610. */
  9611. forceCompilationAsync(options?: Partial<{
  9612. useInstances: boolean;
  9613. }>): Promise<void>;
  9614. /**
  9615. * Serializes the shadow generator setup to a json object.
  9616. * @returns The serialized JSON object
  9617. */
  9618. serialize(): any;
  9619. /**
  9620. * Disposes the Shadow map and related Textures and effects.
  9621. */
  9622. dispose(): void;
  9623. }
  9624. /**
  9625. * Default implementation IShadowGenerator.
  9626. * This is the main object responsible of generating shadows in the framework.
  9627. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9628. */
  9629. export class ShadowGenerator implements IShadowGenerator {
  9630. /**
  9631. * Shadow generator mode None: no filtering applied.
  9632. */
  9633. static readonly FILTER_NONE: number;
  9634. /**
  9635. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9636. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9637. */
  9638. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9639. /**
  9640. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9641. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9642. */
  9643. static readonly FILTER_POISSONSAMPLING: number;
  9644. /**
  9645. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9646. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9647. */
  9648. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9649. /**
  9650. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9651. * edge artifacts on steep falloff.
  9652. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9653. */
  9654. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9655. /**
  9656. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9657. * edge artifacts on steep falloff.
  9658. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9659. */
  9660. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9661. /**
  9662. * Shadow generator mode PCF: Percentage Closer Filtering
  9663. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9664. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9665. */
  9666. static readonly FILTER_PCF: number;
  9667. /**
  9668. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9669. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9670. * Contact Hardening
  9671. */
  9672. static readonly FILTER_PCSS: number;
  9673. /**
  9674. * Reserved for PCF and PCSS
  9675. * Highest Quality.
  9676. *
  9677. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9678. *
  9679. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9680. */
  9681. static readonly QUALITY_HIGH: number;
  9682. /**
  9683. * Reserved for PCF and PCSS
  9684. * Good tradeoff for quality/perf cross devices
  9685. *
  9686. * Execute PCF on a 3*3 kernel.
  9687. *
  9688. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9689. */
  9690. static readonly QUALITY_MEDIUM: number;
  9691. /**
  9692. * Reserved for PCF and PCSS
  9693. * The lowest quality but the fastest.
  9694. *
  9695. * Execute PCF on a 1*1 kernel.
  9696. *
  9697. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9698. */
  9699. static readonly QUALITY_LOW: number;
  9700. /** Gets or sets the custom shader name to use */
  9701. customShaderOptions: ICustomShaderOptions;
  9702. /**
  9703. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9704. */
  9705. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9706. /**
  9707. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9708. */
  9709. onAfterShadowMapRenderObservable: Observable<Effect>;
  9710. /**
  9711. * Observable triggered before a mesh is rendered in the shadow map.
  9712. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9713. */
  9714. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9715. /**
  9716. * Observable triggered after a mesh is rendered in the shadow map.
  9717. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9718. */
  9719. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9720. private _bias;
  9721. /**
  9722. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9723. */
  9724. get bias(): number;
  9725. /**
  9726. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9727. */
  9728. set bias(bias: number);
  9729. private _normalBias;
  9730. /**
  9731. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9732. */
  9733. get normalBias(): number;
  9734. /**
  9735. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9736. */
  9737. set normalBias(normalBias: number);
  9738. private _blurBoxOffset;
  9739. /**
  9740. * Gets the blur box offset: offset applied during the blur pass.
  9741. * Only useful if useKernelBlur = false
  9742. */
  9743. get blurBoxOffset(): number;
  9744. /**
  9745. * Sets the blur box offset: offset applied during the blur pass.
  9746. * Only useful if useKernelBlur = false
  9747. */
  9748. set blurBoxOffset(value: number);
  9749. private _blurScale;
  9750. /**
  9751. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9752. * 2 means half of the size.
  9753. */
  9754. get blurScale(): number;
  9755. /**
  9756. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9757. * 2 means half of the size.
  9758. */
  9759. set blurScale(value: number);
  9760. private _blurKernel;
  9761. /**
  9762. * Gets the blur kernel: kernel size of the blur pass.
  9763. * Only useful if useKernelBlur = true
  9764. */
  9765. get blurKernel(): number;
  9766. /**
  9767. * Sets the blur kernel: kernel size of the blur pass.
  9768. * Only useful if useKernelBlur = true
  9769. */
  9770. set blurKernel(value: number);
  9771. private _useKernelBlur;
  9772. /**
  9773. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9774. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9775. */
  9776. get useKernelBlur(): boolean;
  9777. /**
  9778. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9779. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9780. */
  9781. set useKernelBlur(value: boolean);
  9782. private _depthScale;
  9783. /**
  9784. * Gets the depth scale used in ESM mode.
  9785. */
  9786. get depthScale(): number;
  9787. /**
  9788. * Sets the depth scale used in ESM mode.
  9789. * This can override the scale stored on the light.
  9790. */
  9791. set depthScale(value: number);
  9792. private _filter;
  9793. /**
  9794. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9795. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9796. */
  9797. get filter(): number;
  9798. /**
  9799. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9800. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9801. */
  9802. set filter(value: number);
  9803. /**
  9804. * Gets if the current filter is set to Poisson Sampling.
  9805. */
  9806. get usePoissonSampling(): boolean;
  9807. /**
  9808. * Sets the current filter to Poisson Sampling.
  9809. */
  9810. set usePoissonSampling(value: boolean);
  9811. /**
  9812. * Gets if the current filter is set to ESM.
  9813. */
  9814. get useExponentialShadowMap(): boolean;
  9815. /**
  9816. * Sets the current filter is to ESM.
  9817. */
  9818. set useExponentialShadowMap(value: boolean);
  9819. /**
  9820. * Gets if the current filter is set to filtered ESM.
  9821. */
  9822. get useBlurExponentialShadowMap(): boolean;
  9823. /**
  9824. * Gets if the current filter is set to filtered ESM.
  9825. */
  9826. set useBlurExponentialShadowMap(value: boolean);
  9827. /**
  9828. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9829. * exponential to prevent steep falloff artifacts).
  9830. */
  9831. get useCloseExponentialShadowMap(): boolean;
  9832. /**
  9833. * Sets the current filter to "close ESM" (using the inverse of the
  9834. * exponential to prevent steep falloff artifacts).
  9835. */
  9836. set useCloseExponentialShadowMap(value: boolean);
  9837. /**
  9838. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9839. * exponential to prevent steep falloff artifacts).
  9840. */
  9841. get useBlurCloseExponentialShadowMap(): boolean;
  9842. /**
  9843. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9844. * exponential to prevent steep falloff artifacts).
  9845. */
  9846. set useBlurCloseExponentialShadowMap(value: boolean);
  9847. /**
  9848. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9849. */
  9850. get usePercentageCloserFiltering(): boolean;
  9851. /**
  9852. * Sets the current filter to "PCF" (percentage closer filtering).
  9853. */
  9854. set usePercentageCloserFiltering(value: boolean);
  9855. private _filteringQuality;
  9856. /**
  9857. * Gets the PCF or PCSS Quality.
  9858. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9859. */
  9860. get filteringQuality(): number;
  9861. /**
  9862. * Sets the PCF or PCSS Quality.
  9863. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9864. */
  9865. set filteringQuality(filteringQuality: number);
  9866. /**
  9867. * Gets if the current filter is set to "PCSS" (contact hardening).
  9868. */
  9869. get useContactHardeningShadow(): boolean;
  9870. /**
  9871. * Sets the current filter to "PCSS" (contact hardening).
  9872. */
  9873. set useContactHardeningShadow(value: boolean);
  9874. private _contactHardeningLightSizeUVRatio;
  9875. /**
  9876. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9877. * Using a ratio helps keeping shape stability independently of the map size.
  9878. *
  9879. * It does not account for the light projection as it was having too much
  9880. * instability during the light setup or during light position changes.
  9881. *
  9882. * Only valid if useContactHardeningShadow is true.
  9883. */
  9884. get contactHardeningLightSizeUVRatio(): number;
  9885. /**
  9886. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9887. * Using a ratio helps keeping shape stability independently of the map size.
  9888. *
  9889. * It does not account for the light projection as it was having too much
  9890. * instability during the light setup or during light position changes.
  9891. *
  9892. * Only valid if useContactHardeningShadow is true.
  9893. */
  9894. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  9895. private _darkness;
  9896. /** Gets or sets the actual darkness of a shadow */
  9897. get darkness(): number;
  9898. set darkness(value: number);
  9899. /**
  9900. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9901. * 0 means strongest and 1 would means no shadow.
  9902. * @returns the darkness.
  9903. */
  9904. getDarkness(): number;
  9905. /**
  9906. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9907. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9908. * @returns the shadow generator allowing fluent coding.
  9909. */
  9910. setDarkness(darkness: number): ShadowGenerator;
  9911. private _transparencyShadow;
  9912. /** Gets or sets the ability to have transparent shadow */
  9913. get transparencyShadow(): boolean;
  9914. set transparencyShadow(value: boolean);
  9915. /**
  9916. * Sets the ability to have transparent shadow (boolean).
  9917. * @param transparent True if transparent else False
  9918. * @returns the shadow generator allowing fluent coding
  9919. */
  9920. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9921. private _shadowMap;
  9922. private _shadowMap2;
  9923. /**
  9924. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9925. * @returns The render target texture if present otherwise, null
  9926. */
  9927. getShadowMap(): Nullable<RenderTargetTexture>;
  9928. /**
  9929. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9930. * @returns The render target texture if the shadow map is present otherwise, null
  9931. */
  9932. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9933. /**
  9934. * Gets the class name of that object
  9935. * @returns "ShadowGenerator"
  9936. */
  9937. getClassName(): string;
  9938. /**
  9939. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9940. * @param mesh Mesh to add
  9941. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9942. * @returns the Shadow Generator itself
  9943. */
  9944. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9945. /**
  9946. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9947. * @param mesh Mesh to remove
  9948. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9949. * @returns the Shadow Generator itself
  9950. */
  9951. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9952. /**
  9953. * Controls the extent to which the shadows fade out at the edge of the frustum
  9954. * Used only by directionals and spots
  9955. */
  9956. frustumEdgeFalloff: number;
  9957. private _light;
  9958. /**
  9959. * Returns the associated light object.
  9960. * @returns the light generating the shadow
  9961. */
  9962. getLight(): IShadowLight;
  9963. /**
  9964. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9965. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9966. * It might on the other hand introduce peter panning.
  9967. */
  9968. forceBackFacesOnly: boolean;
  9969. private _scene;
  9970. private _lightDirection;
  9971. private _effect;
  9972. private _viewMatrix;
  9973. private _projectionMatrix;
  9974. private _transformMatrix;
  9975. private _cachedPosition;
  9976. private _cachedDirection;
  9977. private _cachedDefines;
  9978. private _currentRenderID;
  9979. private _boxBlurPostprocess;
  9980. private _kernelBlurXPostprocess;
  9981. private _kernelBlurYPostprocess;
  9982. private _blurPostProcesses;
  9983. private _mapSize;
  9984. private _currentFaceIndex;
  9985. private _currentFaceIndexCache;
  9986. private _textureType;
  9987. private _defaultTextureMatrix;
  9988. private _storedUniqueId;
  9989. /** @hidden */
  9990. static _SceneComponentInitialization: (scene: Scene) => void;
  9991. /**
  9992. * Creates a ShadowGenerator object.
  9993. * A ShadowGenerator is the required tool to use the shadows.
  9994. * Each light casting shadows needs to use its own ShadowGenerator.
  9995. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9996. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9997. * @param light The light object generating the shadows.
  9998. * @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.
  9999. */
  10000. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10001. private _initializeGenerator;
  10002. private _initializeShadowMap;
  10003. private _initializeBlurRTTAndPostProcesses;
  10004. private _renderForShadowMap;
  10005. private _renderSubMeshForShadowMap;
  10006. private _applyFilterValues;
  10007. /**
  10008. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10009. * @param onCompiled Callback triggered at the and of the effects compilation
  10010. * @param options Sets of optional options forcing the compilation with different modes
  10011. */
  10012. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10013. useInstances: boolean;
  10014. }>): void;
  10015. /**
  10016. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10017. * @param options Sets of optional options forcing the compilation with different modes
  10018. * @returns A promise that resolves when the compilation completes
  10019. */
  10020. forceCompilationAsync(options?: Partial<{
  10021. useInstances: boolean;
  10022. }>): Promise<void>;
  10023. /**
  10024. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10025. * @param subMesh The submesh we want to render in the shadow map
  10026. * @param useInstances Defines wether will draw in the map using instances
  10027. * @returns true if ready otherwise, false
  10028. */
  10029. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10030. /**
  10031. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10032. * @param defines Defines of the material we want to update
  10033. * @param lightIndex Index of the light in the enabled light list of the material
  10034. */
  10035. prepareDefines(defines: any, lightIndex: number): void;
  10036. /**
  10037. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10038. * defined in the generator but impacting the effect).
  10039. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10040. * @param effect The effect we are binfing the information for
  10041. */
  10042. bindShadowLight(lightIndex: string, effect: Effect): void;
  10043. /**
  10044. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10045. * (eq to shadow prjection matrix * light transform matrix)
  10046. * @returns The transform matrix used to create the shadow map
  10047. */
  10048. getTransformMatrix(): Matrix;
  10049. /**
  10050. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10051. * Cube and 2D textures for instance.
  10052. */
  10053. recreateShadowMap(): void;
  10054. private _disposeBlurPostProcesses;
  10055. private _disposeRTTandPostProcesses;
  10056. /**
  10057. * Disposes the ShadowGenerator.
  10058. * Returns nothing.
  10059. */
  10060. dispose(): void;
  10061. /**
  10062. * Serializes the shadow generator setup to a json object.
  10063. * @returns The serialized JSON object
  10064. */
  10065. serialize(): any;
  10066. /**
  10067. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10068. * @param parsedShadowGenerator The JSON object to parse
  10069. * @param scene The scene to create the shadow map for
  10070. * @returns The parsed shadow generator
  10071. */
  10072. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10073. }
  10074. }
  10075. declare module "babylonjs/Lights/light" {
  10076. import { Nullable } from "babylonjs/types";
  10077. import { Scene } from "babylonjs/scene";
  10078. import { Vector3 } from "babylonjs/Maths/math.vector";
  10079. import { Color3 } from "babylonjs/Maths/math.color";
  10080. import { Node } from "babylonjs/node";
  10081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10082. import { Effect } from "babylonjs/Materials/effect";
  10083. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10084. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10085. /**
  10086. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10087. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10088. * 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.
  10089. */
  10090. export abstract class Light extends Node {
  10091. /**
  10092. * Falloff Default: light is falling off following the material specification:
  10093. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10094. */
  10095. static readonly FALLOFF_DEFAULT: number;
  10096. /**
  10097. * Falloff Physical: light is falling off following the inverse squared distance law.
  10098. */
  10099. static readonly FALLOFF_PHYSICAL: number;
  10100. /**
  10101. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10102. * to enhance interoperability with other engines.
  10103. */
  10104. static readonly FALLOFF_GLTF: number;
  10105. /**
  10106. * Falloff Standard: light is falling off like in the standard material
  10107. * to enhance interoperability with other materials.
  10108. */
  10109. static readonly FALLOFF_STANDARD: number;
  10110. /**
  10111. * If every light affecting the material is in this lightmapMode,
  10112. * material.lightmapTexture adds or multiplies
  10113. * (depends on material.useLightmapAsShadowmap)
  10114. * after every other light calculations.
  10115. */
  10116. static readonly LIGHTMAP_DEFAULT: number;
  10117. /**
  10118. * material.lightmapTexture as only diffuse lighting from this light
  10119. * adds only specular lighting from this light
  10120. * adds dynamic shadows
  10121. */
  10122. static readonly LIGHTMAP_SPECULAR: number;
  10123. /**
  10124. * material.lightmapTexture as only lighting
  10125. * no light calculation from this light
  10126. * only adds dynamic shadows from this light
  10127. */
  10128. static readonly LIGHTMAP_SHADOWSONLY: number;
  10129. /**
  10130. * Each light type uses the default quantity according to its type:
  10131. * point/spot lights use luminous intensity
  10132. * directional lights use illuminance
  10133. */
  10134. static readonly INTENSITYMODE_AUTOMATIC: number;
  10135. /**
  10136. * lumen (lm)
  10137. */
  10138. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10139. /**
  10140. * candela (lm/sr)
  10141. */
  10142. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10143. /**
  10144. * lux (lm/m^2)
  10145. */
  10146. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10147. /**
  10148. * nit (cd/m^2)
  10149. */
  10150. static readonly INTENSITYMODE_LUMINANCE: number;
  10151. /**
  10152. * Light type const id of the point light.
  10153. */
  10154. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10155. /**
  10156. * Light type const id of the directional light.
  10157. */
  10158. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10159. /**
  10160. * Light type const id of the spot light.
  10161. */
  10162. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10163. /**
  10164. * Light type const id of the hemispheric light.
  10165. */
  10166. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10167. /**
  10168. * Diffuse gives the basic color to an object.
  10169. */
  10170. diffuse: Color3;
  10171. /**
  10172. * Specular produces a highlight color on an object.
  10173. * Note: This is note affecting PBR materials.
  10174. */
  10175. specular: Color3;
  10176. /**
  10177. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10178. * falling off base on range or angle.
  10179. * This can be set to any values in Light.FALLOFF_x.
  10180. *
  10181. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10182. * other types of materials.
  10183. */
  10184. falloffType: number;
  10185. /**
  10186. * Strength of the light.
  10187. * Note: By default it is define in the framework own unit.
  10188. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10189. */
  10190. intensity: number;
  10191. private _range;
  10192. protected _inverseSquaredRange: number;
  10193. /**
  10194. * Defines how far from the source the light is impacting in scene units.
  10195. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10196. */
  10197. get range(): number;
  10198. /**
  10199. * Defines how far from the source the light is impacting in scene units.
  10200. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10201. */
  10202. set range(value: number);
  10203. /**
  10204. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10205. * of light.
  10206. */
  10207. private _photometricScale;
  10208. private _intensityMode;
  10209. /**
  10210. * Gets the photometric scale used to interpret the intensity.
  10211. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10212. */
  10213. get intensityMode(): number;
  10214. /**
  10215. * Sets the photometric scale used to interpret the intensity.
  10216. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10217. */
  10218. set intensityMode(value: number);
  10219. private _radius;
  10220. /**
  10221. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10222. */
  10223. get radius(): number;
  10224. /**
  10225. * sets the light radius used by PBR Materials to simulate soft area lights.
  10226. */
  10227. set radius(value: number);
  10228. private _renderPriority;
  10229. /**
  10230. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10231. * exceeding the number allowed of the materials.
  10232. */
  10233. renderPriority: number;
  10234. private _shadowEnabled;
  10235. /**
  10236. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10237. * the current shadow generator.
  10238. */
  10239. get shadowEnabled(): boolean;
  10240. /**
  10241. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10242. * the current shadow generator.
  10243. */
  10244. set shadowEnabled(value: boolean);
  10245. private _includedOnlyMeshes;
  10246. /**
  10247. * Gets the only meshes impacted by this light.
  10248. */
  10249. get includedOnlyMeshes(): AbstractMesh[];
  10250. /**
  10251. * Sets the only meshes impacted by this light.
  10252. */
  10253. set includedOnlyMeshes(value: AbstractMesh[]);
  10254. private _excludedMeshes;
  10255. /**
  10256. * Gets the meshes not impacted by this light.
  10257. */
  10258. get excludedMeshes(): AbstractMesh[];
  10259. /**
  10260. * Sets the meshes not impacted by this light.
  10261. */
  10262. set excludedMeshes(value: AbstractMesh[]);
  10263. private _excludeWithLayerMask;
  10264. /**
  10265. * Gets the layer id use to find what meshes are not impacted by the light.
  10266. * Inactive if 0
  10267. */
  10268. get excludeWithLayerMask(): number;
  10269. /**
  10270. * Sets the layer id use to find what meshes are not impacted by the light.
  10271. * Inactive if 0
  10272. */
  10273. set excludeWithLayerMask(value: number);
  10274. private _includeOnlyWithLayerMask;
  10275. /**
  10276. * Gets the layer id use to find what meshes are impacted by the light.
  10277. * Inactive if 0
  10278. */
  10279. get includeOnlyWithLayerMask(): number;
  10280. /**
  10281. * Sets the layer id use to find what meshes are impacted by the light.
  10282. * Inactive if 0
  10283. */
  10284. set includeOnlyWithLayerMask(value: number);
  10285. private _lightmapMode;
  10286. /**
  10287. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10288. */
  10289. get lightmapMode(): number;
  10290. /**
  10291. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10292. */
  10293. set lightmapMode(value: number);
  10294. /**
  10295. * Shadow generator associted to the light.
  10296. * @hidden Internal use only.
  10297. */
  10298. _shadowGenerator: Nullable<IShadowGenerator>;
  10299. /**
  10300. * @hidden Internal use only.
  10301. */
  10302. _excludedMeshesIds: string[];
  10303. /**
  10304. * @hidden Internal use only.
  10305. */
  10306. _includedOnlyMeshesIds: string[];
  10307. /**
  10308. * The current light unifom buffer.
  10309. * @hidden Internal use only.
  10310. */
  10311. _uniformBuffer: UniformBuffer;
  10312. /** @hidden */
  10313. _renderId: number;
  10314. /**
  10315. * Creates a Light object in the scene.
  10316. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10317. * @param name The firendly name of the light
  10318. * @param scene The scene the light belongs too
  10319. */
  10320. constructor(name: string, scene: Scene);
  10321. protected abstract _buildUniformLayout(): void;
  10322. /**
  10323. * Sets the passed Effect "effect" with the Light information.
  10324. * @param effect The effect to update
  10325. * @param lightIndex The index of the light in the effect to update
  10326. * @returns The light
  10327. */
  10328. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10329. /**
  10330. * Sets the passed Effect "effect" with the Light textures.
  10331. * @param effect The effect to update
  10332. * @param lightIndex The index of the light in the effect to update
  10333. * @returns The light
  10334. */
  10335. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  10336. /**
  10337. * Binds the lights information from the scene to the effect for the given mesh.
  10338. * @param lightIndex Light index
  10339. * @param scene The scene where the light belongs to
  10340. * @param effect The effect we are binding the data to
  10341. * @param useSpecular Defines if specular is supported
  10342. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  10343. */
  10344. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  10345. /**
  10346. * Sets the passed Effect "effect" with the Light information.
  10347. * @param effect The effect to update
  10348. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10349. * @returns The light
  10350. */
  10351. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10352. /**
  10353. * Returns the string "Light".
  10354. * @returns the class name
  10355. */
  10356. getClassName(): string;
  10357. /** @hidden */
  10358. readonly _isLight: boolean;
  10359. /**
  10360. * Converts the light information to a readable string for debug purpose.
  10361. * @param fullDetails Supports for multiple levels of logging within scene loading
  10362. * @returns the human readable light info
  10363. */
  10364. toString(fullDetails?: boolean): string;
  10365. /** @hidden */
  10366. protected _syncParentEnabledState(): void;
  10367. /**
  10368. * Set the enabled state of this node.
  10369. * @param value - the new enabled state
  10370. */
  10371. setEnabled(value: boolean): void;
  10372. /**
  10373. * Returns the Light associated shadow generator if any.
  10374. * @return the associated shadow generator.
  10375. */
  10376. getShadowGenerator(): Nullable<IShadowGenerator>;
  10377. /**
  10378. * Returns a Vector3, the absolute light position in the World.
  10379. * @returns the world space position of the light
  10380. */
  10381. getAbsolutePosition(): Vector3;
  10382. /**
  10383. * Specifies if the light will affect the passed mesh.
  10384. * @param mesh The mesh to test against the light
  10385. * @return true the mesh is affected otherwise, false.
  10386. */
  10387. canAffectMesh(mesh: AbstractMesh): boolean;
  10388. /**
  10389. * Sort function to order lights for rendering.
  10390. * @param a First Light object to compare to second.
  10391. * @param b Second Light object to compare first.
  10392. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10393. */
  10394. static CompareLightsPriority(a: Light, b: Light): number;
  10395. /**
  10396. * Releases resources associated with this node.
  10397. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10398. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10399. */
  10400. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10401. /**
  10402. * Returns the light type ID (integer).
  10403. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10404. */
  10405. getTypeID(): number;
  10406. /**
  10407. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10408. * @returns the scaled intensity in intensity mode unit
  10409. */
  10410. getScaledIntensity(): number;
  10411. /**
  10412. * Returns a new Light object, named "name", from the current one.
  10413. * @param name The name of the cloned light
  10414. * @returns the new created light
  10415. */
  10416. clone(name: string): Nullable<Light>;
  10417. /**
  10418. * Serializes the current light into a Serialization object.
  10419. * @returns the serialized object.
  10420. */
  10421. serialize(): any;
  10422. /**
  10423. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10424. * This new light is named "name" and added to the passed scene.
  10425. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10426. * @param name The friendly name of the light
  10427. * @param scene The scene the new light will belong to
  10428. * @returns the constructor function
  10429. */
  10430. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10431. /**
  10432. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10433. * @param parsedLight The JSON representation of the light
  10434. * @param scene The scene to create the parsed light in
  10435. * @returns the created light after parsing
  10436. */
  10437. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10438. private _hookArrayForExcluded;
  10439. private _hookArrayForIncludedOnly;
  10440. private _resyncMeshes;
  10441. /**
  10442. * Forces the meshes to update their light related information in their rendering used effects
  10443. * @hidden Internal Use Only
  10444. */
  10445. _markMeshesAsLightDirty(): void;
  10446. /**
  10447. * Recomputes the cached photometric scale if needed.
  10448. */
  10449. private _computePhotometricScale;
  10450. /**
  10451. * Returns the Photometric Scale according to the light type and intensity mode.
  10452. */
  10453. private _getPhotometricScale;
  10454. /**
  10455. * Reorder the light in the scene according to their defined priority.
  10456. * @hidden Internal Use Only
  10457. */
  10458. _reorderLightsInScene(): void;
  10459. /**
  10460. * Prepares the list of defines specific to the light type.
  10461. * @param defines the list of defines
  10462. * @param lightIndex defines the index of the light for the effect
  10463. */
  10464. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10465. }
  10466. }
  10467. declare module "babylonjs/Actions/action" {
  10468. import { Observable } from "babylonjs/Misc/observable";
  10469. import { Condition } from "babylonjs/Actions/condition";
  10470. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10471. import { ActionManager } from "babylonjs/Actions/actionManager";
  10472. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10473. /**
  10474. * Interface used to define Action
  10475. */
  10476. export interface IAction {
  10477. /**
  10478. * Trigger for the action
  10479. */
  10480. trigger: number;
  10481. /** Options of the trigger */
  10482. triggerOptions: any;
  10483. /**
  10484. * Gets the trigger parameters
  10485. * @returns the trigger parameters
  10486. */
  10487. getTriggerParameter(): any;
  10488. /**
  10489. * Internal only - executes current action event
  10490. * @hidden
  10491. */
  10492. _executeCurrent(evt?: ActionEvent): void;
  10493. /**
  10494. * Serialize placeholder for child classes
  10495. * @param parent of child
  10496. * @returns the serialized object
  10497. */
  10498. serialize(parent: any): any;
  10499. /**
  10500. * Internal only
  10501. * @hidden
  10502. */
  10503. _prepare(): void;
  10504. /**
  10505. * Internal only - manager for action
  10506. * @hidden
  10507. */
  10508. _actionManager: AbstractActionManager;
  10509. /**
  10510. * Adds action to chain of actions, may be a DoNothingAction
  10511. * @param action defines the next action to execute
  10512. * @returns The action passed in
  10513. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10514. */
  10515. then(action: IAction): IAction;
  10516. }
  10517. /**
  10518. * The action to be carried out following a trigger
  10519. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10520. */
  10521. export class Action implements IAction {
  10522. /** the trigger, with or without parameters, for the action */
  10523. triggerOptions: any;
  10524. /**
  10525. * Trigger for the action
  10526. */
  10527. trigger: number;
  10528. /**
  10529. * Internal only - manager for action
  10530. * @hidden
  10531. */
  10532. _actionManager: ActionManager;
  10533. private _nextActiveAction;
  10534. private _child;
  10535. private _condition?;
  10536. private _triggerParameter;
  10537. /**
  10538. * An event triggered prior to action being executed.
  10539. */
  10540. onBeforeExecuteObservable: Observable<Action>;
  10541. /**
  10542. * Creates a new Action
  10543. * @param triggerOptions the trigger, with or without parameters, for the action
  10544. * @param condition an optional determinant of action
  10545. */
  10546. constructor(
  10547. /** the trigger, with or without parameters, for the action */
  10548. triggerOptions: any, condition?: Condition);
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */
  10553. _prepare(): void;
  10554. /**
  10555. * Gets the trigger parameters
  10556. * @returns the trigger parameters
  10557. */
  10558. getTriggerParameter(): any;
  10559. /**
  10560. * Internal only - executes current action event
  10561. * @hidden
  10562. */
  10563. _executeCurrent(evt?: ActionEvent): void;
  10564. /**
  10565. * Execute placeholder for child classes
  10566. * @param evt optional action event
  10567. */
  10568. execute(evt?: ActionEvent): void;
  10569. /**
  10570. * Skips to next active action
  10571. */
  10572. skipToNextActiveAction(): void;
  10573. /**
  10574. * Adds action to chain of actions, may be a DoNothingAction
  10575. * @param action defines the next action to execute
  10576. * @returns The action passed in
  10577. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10578. */
  10579. then(action: Action): Action;
  10580. /**
  10581. * Internal only
  10582. * @hidden
  10583. */
  10584. _getProperty(propertyPath: string): string;
  10585. /**
  10586. * Internal only
  10587. * @hidden
  10588. */
  10589. _getEffectiveTarget(target: any, propertyPath: string): any;
  10590. /**
  10591. * Serialize placeholder for child classes
  10592. * @param parent of child
  10593. * @returns the serialized object
  10594. */
  10595. serialize(parent: any): any;
  10596. /**
  10597. * Internal only called by serialize
  10598. * @hidden
  10599. */
  10600. protected _serialize(serializedAction: any, parent?: any): any;
  10601. /**
  10602. * Internal only
  10603. * @hidden
  10604. */
  10605. static _SerializeValueAsString: (value: any) => string;
  10606. /**
  10607. * Internal only
  10608. * @hidden
  10609. */
  10610. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10611. name: string;
  10612. targetType: string;
  10613. value: string;
  10614. };
  10615. }
  10616. }
  10617. declare module "babylonjs/Actions/condition" {
  10618. import { ActionManager } from "babylonjs/Actions/actionManager";
  10619. /**
  10620. * A Condition applied to an Action
  10621. */
  10622. export class Condition {
  10623. /**
  10624. * Internal only - manager for action
  10625. * @hidden
  10626. */
  10627. _actionManager: ActionManager;
  10628. /**
  10629. * Internal only
  10630. * @hidden
  10631. */
  10632. _evaluationId: number;
  10633. /**
  10634. * Internal only
  10635. * @hidden
  10636. */
  10637. _currentResult: boolean;
  10638. /**
  10639. * Creates a new Condition
  10640. * @param actionManager the manager of the action the condition is applied to
  10641. */
  10642. constructor(actionManager: ActionManager);
  10643. /**
  10644. * Check if the current condition is valid
  10645. * @returns a boolean
  10646. */
  10647. isValid(): boolean;
  10648. /**
  10649. * Internal only
  10650. * @hidden
  10651. */
  10652. _getProperty(propertyPath: string): string;
  10653. /**
  10654. * Internal only
  10655. * @hidden
  10656. */
  10657. _getEffectiveTarget(target: any, propertyPath: string): any;
  10658. /**
  10659. * Serialize placeholder for child classes
  10660. * @returns the serialized object
  10661. */
  10662. serialize(): any;
  10663. /**
  10664. * Internal only
  10665. * @hidden
  10666. */
  10667. protected _serialize(serializedCondition: any): any;
  10668. }
  10669. /**
  10670. * Defines specific conditional operators as extensions of Condition
  10671. */
  10672. export class ValueCondition extends Condition {
  10673. /** path to specify the property of the target the conditional operator uses */
  10674. propertyPath: string;
  10675. /** the value compared by the conditional operator against the current value of the property */
  10676. value: any;
  10677. /** the conditional operator, default ValueCondition.IsEqual */
  10678. operator: number;
  10679. /**
  10680. * Internal only
  10681. * @hidden
  10682. */
  10683. private static _IsEqual;
  10684. /**
  10685. * Internal only
  10686. * @hidden
  10687. */
  10688. private static _IsDifferent;
  10689. /**
  10690. * Internal only
  10691. * @hidden
  10692. */
  10693. private static _IsGreater;
  10694. /**
  10695. * Internal only
  10696. * @hidden
  10697. */
  10698. private static _IsLesser;
  10699. /**
  10700. * returns the number for IsEqual
  10701. */
  10702. static get IsEqual(): number;
  10703. /**
  10704. * Returns the number for IsDifferent
  10705. */
  10706. static get IsDifferent(): number;
  10707. /**
  10708. * Returns the number for IsGreater
  10709. */
  10710. static get IsGreater(): number;
  10711. /**
  10712. * Returns the number for IsLesser
  10713. */
  10714. static get IsLesser(): number;
  10715. /**
  10716. * Internal only The action manager for the condition
  10717. * @hidden
  10718. */
  10719. _actionManager: ActionManager;
  10720. /**
  10721. * Internal only
  10722. * @hidden
  10723. */
  10724. private _target;
  10725. /**
  10726. * Internal only
  10727. * @hidden
  10728. */
  10729. private _effectiveTarget;
  10730. /**
  10731. * Internal only
  10732. * @hidden
  10733. */
  10734. private _property;
  10735. /**
  10736. * Creates a new ValueCondition
  10737. * @param actionManager manager for the action the condition applies to
  10738. * @param target for the action
  10739. * @param propertyPath path to specify the property of the target the conditional operator uses
  10740. * @param value the value compared by the conditional operator against the current value of the property
  10741. * @param operator the conditional operator, default ValueCondition.IsEqual
  10742. */
  10743. constructor(actionManager: ActionManager, target: any,
  10744. /** path to specify the property of the target the conditional operator uses */
  10745. propertyPath: string,
  10746. /** the value compared by the conditional operator against the current value of the property */
  10747. value: any,
  10748. /** the conditional operator, default ValueCondition.IsEqual */
  10749. operator?: number);
  10750. /**
  10751. * Compares the given value with the property value for the specified conditional operator
  10752. * @returns the result of the comparison
  10753. */
  10754. isValid(): boolean;
  10755. /**
  10756. * Serialize the ValueCondition into a JSON compatible object
  10757. * @returns serialization object
  10758. */
  10759. serialize(): any;
  10760. /**
  10761. * Gets the name of the conditional operator for the ValueCondition
  10762. * @param operator the conditional operator
  10763. * @returns the name
  10764. */
  10765. static GetOperatorName(operator: number): string;
  10766. }
  10767. /**
  10768. * Defines a predicate condition as an extension of Condition
  10769. */
  10770. export class PredicateCondition extends Condition {
  10771. /** defines the predicate function used to validate the condition */
  10772. predicate: () => boolean;
  10773. /**
  10774. * Internal only - manager for action
  10775. * @hidden
  10776. */
  10777. _actionManager: ActionManager;
  10778. /**
  10779. * Creates a new PredicateCondition
  10780. * @param actionManager manager for the action the condition applies to
  10781. * @param predicate defines the predicate function used to validate the condition
  10782. */
  10783. constructor(actionManager: ActionManager,
  10784. /** defines the predicate function used to validate the condition */
  10785. predicate: () => boolean);
  10786. /**
  10787. * @returns the validity of the predicate condition
  10788. */
  10789. isValid(): boolean;
  10790. }
  10791. /**
  10792. * Defines a state condition as an extension of Condition
  10793. */
  10794. export class StateCondition extends Condition {
  10795. /** Value to compare with target state */
  10796. value: string;
  10797. /**
  10798. * Internal only - manager for action
  10799. * @hidden
  10800. */
  10801. _actionManager: ActionManager;
  10802. /**
  10803. * Internal only
  10804. * @hidden
  10805. */
  10806. private _target;
  10807. /**
  10808. * Creates a new StateCondition
  10809. * @param actionManager manager for the action the condition applies to
  10810. * @param target of the condition
  10811. * @param value to compare with target state
  10812. */
  10813. constructor(actionManager: ActionManager, target: any,
  10814. /** Value to compare with target state */
  10815. value: string);
  10816. /**
  10817. * Gets a boolean indicating if the current condition is met
  10818. * @returns the validity of the state
  10819. */
  10820. isValid(): boolean;
  10821. /**
  10822. * Serialize the StateCondition into a JSON compatible object
  10823. * @returns serialization object
  10824. */
  10825. serialize(): any;
  10826. }
  10827. }
  10828. declare module "babylonjs/Actions/directActions" {
  10829. import { Action } from "babylonjs/Actions/action";
  10830. import { Condition } from "babylonjs/Actions/condition";
  10831. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10832. /**
  10833. * This defines an action responsible to toggle a boolean once triggered.
  10834. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10835. */
  10836. export class SwitchBooleanAction extends Action {
  10837. /**
  10838. * The path to the boolean property in the target object
  10839. */
  10840. propertyPath: string;
  10841. private _target;
  10842. private _effectiveTarget;
  10843. private _property;
  10844. /**
  10845. * Instantiate the action
  10846. * @param triggerOptions defines the trigger options
  10847. * @param target defines the object containing the boolean
  10848. * @param propertyPath defines the path to the boolean property in the target object
  10849. * @param condition defines the trigger related conditions
  10850. */
  10851. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10852. /** @hidden */
  10853. _prepare(): void;
  10854. /**
  10855. * Execute the action toggle the boolean value.
  10856. */
  10857. execute(): void;
  10858. /**
  10859. * Serializes the actions and its related information.
  10860. * @param parent defines the object to serialize in
  10861. * @returns the serialized object
  10862. */
  10863. serialize(parent: any): any;
  10864. }
  10865. /**
  10866. * This defines an action responsible to set a the state field of the target
  10867. * to a desired value once triggered.
  10868. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10869. */
  10870. export class SetStateAction extends Action {
  10871. /**
  10872. * The value to store in the state field.
  10873. */
  10874. value: string;
  10875. private _target;
  10876. /**
  10877. * Instantiate the action
  10878. * @param triggerOptions defines the trigger options
  10879. * @param target defines the object containing the state property
  10880. * @param value defines the value to store in the state field
  10881. * @param condition defines the trigger related conditions
  10882. */
  10883. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10884. /**
  10885. * Execute the action and store the value on the target state property.
  10886. */
  10887. execute(): void;
  10888. /**
  10889. * Serializes the actions and its related information.
  10890. * @param parent defines the object to serialize in
  10891. * @returns the serialized object
  10892. */
  10893. serialize(parent: any): any;
  10894. }
  10895. /**
  10896. * This defines an action responsible to set a property of the target
  10897. * to a desired value once triggered.
  10898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10899. */
  10900. export class SetValueAction extends Action {
  10901. /**
  10902. * The path of the property to set in the target.
  10903. */
  10904. propertyPath: string;
  10905. /**
  10906. * The value to set in the property
  10907. */
  10908. value: any;
  10909. private _target;
  10910. private _effectiveTarget;
  10911. private _property;
  10912. /**
  10913. * Instantiate the action
  10914. * @param triggerOptions defines the trigger options
  10915. * @param target defines the object containing the property
  10916. * @param propertyPath defines the path of the property to set in the target
  10917. * @param value defines the value to set in the property
  10918. * @param condition defines the trigger related conditions
  10919. */
  10920. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10921. /** @hidden */
  10922. _prepare(): void;
  10923. /**
  10924. * Execute the action and set the targetted property to the desired value.
  10925. */
  10926. execute(): void;
  10927. /**
  10928. * Serializes the actions and its related information.
  10929. * @param parent defines the object to serialize in
  10930. * @returns the serialized object
  10931. */
  10932. serialize(parent: any): any;
  10933. }
  10934. /**
  10935. * This defines an action responsible to increment the target value
  10936. * to a desired value once triggered.
  10937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10938. */
  10939. export class IncrementValueAction extends Action {
  10940. /**
  10941. * The path of the property to increment in the target.
  10942. */
  10943. propertyPath: string;
  10944. /**
  10945. * The value we should increment the property by.
  10946. */
  10947. value: any;
  10948. private _target;
  10949. private _effectiveTarget;
  10950. private _property;
  10951. /**
  10952. * Instantiate the action
  10953. * @param triggerOptions defines the trigger options
  10954. * @param target defines the object containing the property
  10955. * @param propertyPath defines the path of the property to increment in the target
  10956. * @param value defines the value value we should increment the property by
  10957. * @param condition defines the trigger related conditions
  10958. */
  10959. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10960. /** @hidden */
  10961. _prepare(): void;
  10962. /**
  10963. * Execute the action and increment the target of the value amount.
  10964. */
  10965. execute(): void;
  10966. /**
  10967. * Serializes the actions and its related information.
  10968. * @param parent defines the object to serialize in
  10969. * @returns the serialized object
  10970. */
  10971. serialize(parent: any): any;
  10972. }
  10973. /**
  10974. * This defines an action responsible to start an animation once triggered.
  10975. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10976. */
  10977. export class PlayAnimationAction extends Action {
  10978. /**
  10979. * Where the animation should start (animation frame)
  10980. */
  10981. from: number;
  10982. /**
  10983. * Where the animation should stop (animation frame)
  10984. */
  10985. to: number;
  10986. /**
  10987. * Define if the animation should loop or stop after the first play.
  10988. */
  10989. loop?: boolean;
  10990. private _target;
  10991. /**
  10992. * Instantiate the action
  10993. * @param triggerOptions defines the trigger options
  10994. * @param target defines the target animation or animation name
  10995. * @param from defines from where the animation should start (animation frame)
  10996. * @param end defines where the animation should stop (animation frame)
  10997. * @param loop defines if the animation should loop or stop after the first play
  10998. * @param condition defines the trigger related conditions
  10999. */
  11000. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11001. /** @hidden */
  11002. _prepare(): void;
  11003. /**
  11004. * Execute the action and play the animation.
  11005. */
  11006. execute(): void;
  11007. /**
  11008. * Serializes the actions and its related information.
  11009. * @param parent defines the object to serialize in
  11010. * @returns the serialized object
  11011. */
  11012. serialize(parent: any): any;
  11013. }
  11014. /**
  11015. * This defines an action responsible to stop an animation once triggered.
  11016. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11017. */
  11018. export class StopAnimationAction extends Action {
  11019. private _target;
  11020. /**
  11021. * Instantiate the action
  11022. * @param triggerOptions defines the trigger options
  11023. * @param target defines the target animation or animation name
  11024. * @param condition defines the trigger related conditions
  11025. */
  11026. constructor(triggerOptions: any, target: any, condition?: Condition);
  11027. /** @hidden */
  11028. _prepare(): void;
  11029. /**
  11030. * Execute the action and stop the animation.
  11031. */
  11032. execute(): void;
  11033. /**
  11034. * Serializes the actions and its related information.
  11035. * @param parent defines the object to serialize in
  11036. * @returns the serialized object
  11037. */
  11038. serialize(parent: any): any;
  11039. }
  11040. /**
  11041. * This defines an action responsible that does nothing once triggered.
  11042. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11043. */
  11044. export class DoNothingAction extends Action {
  11045. /**
  11046. * Instantiate the action
  11047. * @param triggerOptions defines the trigger options
  11048. * @param condition defines the trigger related conditions
  11049. */
  11050. constructor(triggerOptions?: any, condition?: Condition);
  11051. /**
  11052. * Execute the action and do nothing.
  11053. */
  11054. execute(): void;
  11055. /**
  11056. * Serializes the actions and its related information.
  11057. * @param parent defines the object to serialize in
  11058. * @returns the serialized object
  11059. */
  11060. serialize(parent: any): any;
  11061. }
  11062. /**
  11063. * This defines an action responsible to trigger several actions once triggered.
  11064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11065. */
  11066. export class CombineAction extends Action {
  11067. /**
  11068. * The list of aggregated animations to run.
  11069. */
  11070. children: Action[];
  11071. /**
  11072. * Instantiate the action
  11073. * @param triggerOptions defines the trigger options
  11074. * @param children defines the list of aggregated animations to run
  11075. * @param condition defines the trigger related conditions
  11076. */
  11077. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11078. /** @hidden */
  11079. _prepare(): void;
  11080. /**
  11081. * Execute the action and executes all the aggregated actions.
  11082. */
  11083. execute(evt: ActionEvent): void;
  11084. /**
  11085. * Serializes the actions and its related information.
  11086. * @param parent defines the object to serialize in
  11087. * @returns the serialized object
  11088. */
  11089. serialize(parent: any): any;
  11090. }
  11091. /**
  11092. * This defines an action responsible to run code (external event) once triggered.
  11093. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11094. */
  11095. export class ExecuteCodeAction extends Action {
  11096. /**
  11097. * The callback function to run.
  11098. */
  11099. func: (evt: ActionEvent) => void;
  11100. /**
  11101. * Instantiate the action
  11102. * @param triggerOptions defines the trigger options
  11103. * @param func defines the callback function to run
  11104. * @param condition defines the trigger related conditions
  11105. */
  11106. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11107. /**
  11108. * Execute the action and run the attached code.
  11109. */
  11110. execute(evt: ActionEvent): void;
  11111. }
  11112. /**
  11113. * This defines an action responsible to set the parent property of the target once triggered.
  11114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11115. */
  11116. export class SetParentAction extends Action {
  11117. private _parent;
  11118. private _target;
  11119. /**
  11120. * Instantiate the action
  11121. * @param triggerOptions defines the trigger options
  11122. * @param target defines the target containing the parent property
  11123. * @param parent defines from where the animation should start (animation frame)
  11124. * @param condition defines the trigger related conditions
  11125. */
  11126. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11127. /** @hidden */
  11128. _prepare(): void;
  11129. /**
  11130. * Execute the action and set the parent property.
  11131. */
  11132. execute(): void;
  11133. /**
  11134. * Serializes the actions and its related information.
  11135. * @param parent defines the object to serialize in
  11136. * @returns the serialized object
  11137. */
  11138. serialize(parent: any): any;
  11139. }
  11140. }
  11141. declare module "babylonjs/Actions/actionManager" {
  11142. import { Nullable } from "babylonjs/types";
  11143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11144. import { Scene } from "babylonjs/scene";
  11145. import { IAction } from "babylonjs/Actions/action";
  11146. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11147. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11148. /**
  11149. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11150. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11152. */
  11153. export class ActionManager extends AbstractActionManager {
  11154. /**
  11155. * Nothing
  11156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11157. */
  11158. static readonly NothingTrigger: number;
  11159. /**
  11160. * On pick
  11161. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11162. */
  11163. static readonly OnPickTrigger: number;
  11164. /**
  11165. * On left pick
  11166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11167. */
  11168. static readonly OnLeftPickTrigger: number;
  11169. /**
  11170. * On right pick
  11171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11172. */
  11173. static readonly OnRightPickTrigger: number;
  11174. /**
  11175. * On center pick
  11176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11177. */
  11178. static readonly OnCenterPickTrigger: number;
  11179. /**
  11180. * On pick down
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11182. */
  11183. static readonly OnPickDownTrigger: number;
  11184. /**
  11185. * On double pick
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11187. */
  11188. static readonly OnDoublePickTrigger: number;
  11189. /**
  11190. * On pick up
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11192. */
  11193. static readonly OnPickUpTrigger: number;
  11194. /**
  11195. * On pick out.
  11196. * This trigger will only be raised if you also declared a OnPickDown
  11197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11198. */
  11199. static readonly OnPickOutTrigger: number;
  11200. /**
  11201. * On long press
  11202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11203. */
  11204. static readonly OnLongPressTrigger: number;
  11205. /**
  11206. * On pointer over
  11207. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11208. */
  11209. static readonly OnPointerOverTrigger: number;
  11210. /**
  11211. * On pointer out
  11212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11213. */
  11214. static readonly OnPointerOutTrigger: number;
  11215. /**
  11216. * On every frame
  11217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11218. */
  11219. static readonly OnEveryFrameTrigger: number;
  11220. /**
  11221. * On intersection enter
  11222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11223. */
  11224. static readonly OnIntersectionEnterTrigger: number;
  11225. /**
  11226. * On intersection exit
  11227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11228. */
  11229. static readonly OnIntersectionExitTrigger: number;
  11230. /**
  11231. * On key down
  11232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11233. */
  11234. static readonly OnKeyDownTrigger: number;
  11235. /**
  11236. * On key up
  11237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11238. */
  11239. static readonly OnKeyUpTrigger: number;
  11240. private _scene;
  11241. /**
  11242. * Creates a new action manager
  11243. * @param scene defines the hosting scene
  11244. */
  11245. constructor(scene: Scene);
  11246. /**
  11247. * Releases all associated resources
  11248. */
  11249. dispose(): void;
  11250. /**
  11251. * Gets hosting scene
  11252. * @returns the hosting scene
  11253. */
  11254. getScene(): Scene;
  11255. /**
  11256. * Does this action manager handles actions of any of the given triggers
  11257. * @param triggers defines the triggers to be tested
  11258. * @return a boolean indicating whether one (or more) of the triggers is handled
  11259. */
  11260. hasSpecificTriggers(triggers: number[]): boolean;
  11261. /**
  11262. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11263. * speed.
  11264. * @param triggerA defines the trigger to be tested
  11265. * @param triggerB defines the trigger to be tested
  11266. * @return a boolean indicating whether one (or more) of the triggers is handled
  11267. */
  11268. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11269. /**
  11270. * Does this action manager handles actions of a given trigger
  11271. * @param trigger defines the trigger to be tested
  11272. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11273. * @return whether the trigger is handled
  11274. */
  11275. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11276. /**
  11277. * Does this action manager has pointer triggers
  11278. */
  11279. get hasPointerTriggers(): boolean;
  11280. /**
  11281. * Does this action manager has pick triggers
  11282. */
  11283. get hasPickTriggers(): boolean;
  11284. /**
  11285. * Registers an action to this action manager
  11286. * @param action defines the action to be registered
  11287. * @return the action amended (prepared) after registration
  11288. */
  11289. registerAction(action: IAction): Nullable<IAction>;
  11290. /**
  11291. * Unregisters an action to this action manager
  11292. * @param action defines the action to be unregistered
  11293. * @return a boolean indicating whether the action has been unregistered
  11294. */
  11295. unregisterAction(action: IAction): Boolean;
  11296. /**
  11297. * Process a specific trigger
  11298. * @param trigger defines the trigger to process
  11299. * @param evt defines the event details to be processed
  11300. */
  11301. processTrigger(trigger: number, evt?: IActionEvent): void;
  11302. /** @hidden */
  11303. _getEffectiveTarget(target: any, propertyPath: string): any;
  11304. /** @hidden */
  11305. _getProperty(propertyPath: string): string;
  11306. /**
  11307. * Serialize this manager to a JSON object
  11308. * @param name defines the property name to store this manager
  11309. * @returns a JSON representation of this manager
  11310. */
  11311. serialize(name: string): any;
  11312. /**
  11313. * Creates a new ActionManager from a JSON data
  11314. * @param parsedActions defines the JSON data to read from
  11315. * @param object defines the hosting mesh
  11316. * @param scene defines the hosting scene
  11317. */
  11318. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11319. /**
  11320. * Get a trigger name by index
  11321. * @param trigger defines the trigger index
  11322. * @returns a trigger name
  11323. */
  11324. static GetTriggerName(trigger: number): string;
  11325. }
  11326. }
  11327. declare module "babylonjs/Culling/ray" {
  11328. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11329. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11330. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11331. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11332. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11333. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11334. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11335. import { Plane } from "babylonjs/Maths/math.plane";
  11336. /**
  11337. * Class representing a ray with position and direction
  11338. */
  11339. export class Ray {
  11340. /** origin point */
  11341. origin: Vector3;
  11342. /** direction */
  11343. direction: Vector3;
  11344. /** length of the ray */
  11345. length: number;
  11346. private static readonly TmpVector3;
  11347. private _tmpRay;
  11348. /**
  11349. * Creates a new ray
  11350. * @param origin origin point
  11351. * @param direction direction
  11352. * @param length length of the ray
  11353. */
  11354. constructor(
  11355. /** origin point */
  11356. origin: Vector3,
  11357. /** direction */
  11358. direction: Vector3,
  11359. /** length of the ray */
  11360. length?: number);
  11361. /**
  11362. * Checks if the ray intersects a box
  11363. * @param minimum bound of the box
  11364. * @param maximum bound of the box
  11365. * @param intersectionTreshold extra extend to be added to the box in all direction
  11366. * @returns if the box was hit
  11367. */
  11368. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11369. /**
  11370. * Checks if the ray intersects a box
  11371. * @param box the bounding box to check
  11372. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11373. * @returns if the box was hit
  11374. */
  11375. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11376. /**
  11377. * If the ray hits a sphere
  11378. * @param sphere the bounding sphere to check
  11379. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11380. * @returns true if it hits the sphere
  11381. */
  11382. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11383. /**
  11384. * If the ray hits a triange
  11385. * @param vertex0 triangle vertex
  11386. * @param vertex1 triangle vertex
  11387. * @param vertex2 triangle vertex
  11388. * @returns intersection information if hit
  11389. */
  11390. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11391. /**
  11392. * Checks if ray intersects a plane
  11393. * @param plane the plane to check
  11394. * @returns the distance away it was hit
  11395. */
  11396. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11397. /**
  11398. * Calculate the intercept of a ray on a given axis
  11399. * @param axis to check 'x' | 'y' | 'z'
  11400. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11401. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11402. */
  11403. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11404. /**
  11405. * Checks if ray intersects a mesh
  11406. * @param mesh the mesh to check
  11407. * @param fastCheck if only the bounding box should checked
  11408. * @returns picking info of the intersecton
  11409. */
  11410. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11411. /**
  11412. * Checks if ray intersects a mesh
  11413. * @param meshes the meshes to check
  11414. * @param fastCheck if only the bounding box should checked
  11415. * @param results array to store result in
  11416. * @returns Array of picking infos
  11417. */
  11418. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11419. private _comparePickingInfo;
  11420. private static smallnum;
  11421. private static rayl;
  11422. /**
  11423. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11424. * @param sega the first point of the segment to test the intersection against
  11425. * @param segb the second point of the segment to test the intersection against
  11426. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11427. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11428. */
  11429. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11430. /**
  11431. * Update the ray from viewport position
  11432. * @param x position
  11433. * @param y y position
  11434. * @param viewportWidth viewport width
  11435. * @param viewportHeight viewport height
  11436. * @param world world matrix
  11437. * @param view view matrix
  11438. * @param projection projection matrix
  11439. * @returns this ray updated
  11440. */
  11441. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11442. /**
  11443. * Creates a ray with origin and direction of 0,0,0
  11444. * @returns the new ray
  11445. */
  11446. static Zero(): Ray;
  11447. /**
  11448. * Creates a new ray from screen space and viewport
  11449. * @param x position
  11450. * @param y y position
  11451. * @param viewportWidth viewport width
  11452. * @param viewportHeight viewport height
  11453. * @param world world matrix
  11454. * @param view view matrix
  11455. * @param projection projection matrix
  11456. * @returns new ray
  11457. */
  11458. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11459. /**
  11460. * 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
  11461. * transformed to the given world matrix.
  11462. * @param origin The origin point
  11463. * @param end The end point
  11464. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11465. * @returns the new ray
  11466. */
  11467. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11468. /**
  11469. * Transforms a ray by a matrix
  11470. * @param ray ray to transform
  11471. * @param matrix matrix to apply
  11472. * @returns the resulting new ray
  11473. */
  11474. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11475. /**
  11476. * Transforms a ray by a matrix
  11477. * @param ray ray to transform
  11478. * @param matrix matrix to apply
  11479. * @param result ray to store result in
  11480. */
  11481. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11482. /**
  11483. * Unproject a ray from screen space to object space
  11484. * @param sourceX defines the screen space x coordinate to use
  11485. * @param sourceY defines the screen space y coordinate to use
  11486. * @param viewportWidth defines the current width of the viewport
  11487. * @param viewportHeight defines the current height of the viewport
  11488. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11489. * @param view defines the view matrix to use
  11490. * @param projection defines the projection matrix to use
  11491. */
  11492. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11493. }
  11494. /**
  11495. * Type used to define predicate used to select faces when a mesh intersection is detected
  11496. */
  11497. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11498. module "babylonjs/scene" {
  11499. interface Scene {
  11500. /** @hidden */
  11501. _tempPickingRay: Nullable<Ray>;
  11502. /** @hidden */
  11503. _cachedRayForTransform: Ray;
  11504. /** @hidden */
  11505. _pickWithRayInverseMatrix: Matrix;
  11506. /** @hidden */
  11507. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11508. /** @hidden */
  11509. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11510. }
  11511. }
  11512. }
  11513. declare module "babylonjs/sceneComponent" {
  11514. import { Scene } from "babylonjs/scene";
  11515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11517. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11518. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11519. import { Nullable } from "babylonjs/types";
  11520. import { Camera } from "babylonjs/Cameras/camera";
  11521. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11522. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11523. import { AbstractScene } from "babylonjs/abstractScene";
  11524. import { Mesh } from "babylonjs/Meshes/mesh";
  11525. /**
  11526. * Groups all the scene component constants in one place to ease maintenance.
  11527. * @hidden
  11528. */
  11529. export class SceneComponentConstants {
  11530. static readonly NAME_EFFECTLAYER: string;
  11531. static readonly NAME_LAYER: string;
  11532. static readonly NAME_LENSFLARESYSTEM: string;
  11533. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11534. static readonly NAME_PARTICLESYSTEM: string;
  11535. static readonly NAME_GAMEPAD: string;
  11536. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11537. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11538. static readonly NAME_DEPTHRENDERER: string;
  11539. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11540. static readonly NAME_SPRITE: string;
  11541. static readonly NAME_OUTLINERENDERER: string;
  11542. static readonly NAME_PROCEDURALTEXTURE: string;
  11543. static readonly NAME_SHADOWGENERATOR: string;
  11544. static readonly NAME_OCTREE: string;
  11545. static readonly NAME_PHYSICSENGINE: string;
  11546. static readonly NAME_AUDIO: string;
  11547. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11548. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11549. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11550. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11551. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11552. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11553. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11554. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11555. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11556. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11557. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11558. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11559. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11560. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11561. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11562. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11563. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11564. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11565. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11566. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11567. static readonly STEP_AFTERRENDER_AUDIO: number;
  11568. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11569. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11570. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11571. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11572. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11573. static readonly STEP_POINTERMOVE_SPRITE: number;
  11574. static readonly STEP_POINTERDOWN_SPRITE: number;
  11575. static readonly STEP_POINTERUP_SPRITE: number;
  11576. }
  11577. /**
  11578. * This represents a scene component.
  11579. *
  11580. * This is used to decouple the dependency the scene is having on the different workloads like
  11581. * layers, post processes...
  11582. */
  11583. export interface ISceneComponent {
  11584. /**
  11585. * The name of the component. Each component must have a unique name.
  11586. */
  11587. name: string;
  11588. /**
  11589. * The scene the component belongs to.
  11590. */
  11591. scene: Scene;
  11592. /**
  11593. * Register the component to one instance of a scene.
  11594. */
  11595. register(): void;
  11596. /**
  11597. * Rebuilds the elements related to this component in case of
  11598. * context lost for instance.
  11599. */
  11600. rebuild(): void;
  11601. /**
  11602. * Disposes the component and the associated ressources.
  11603. */
  11604. dispose(): void;
  11605. }
  11606. /**
  11607. * This represents a SERIALIZABLE scene component.
  11608. *
  11609. * This extends Scene Component to add Serialization methods on top.
  11610. */
  11611. export interface ISceneSerializableComponent extends ISceneComponent {
  11612. /**
  11613. * Adds all the elements from the container to the scene
  11614. * @param container the container holding the elements
  11615. */
  11616. addFromContainer(container: AbstractScene): void;
  11617. /**
  11618. * Removes all the elements in the container from the scene
  11619. * @param container contains the elements to remove
  11620. * @param dispose if the removed element should be disposed (default: false)
  11621. */
  11622. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11623. /**
  11624. * Serializes the component data to the specified json object
  11625. * @param serializationObject The object to serialize to
  11626. */
  11627. serialize(serializationObject: any): void;
  11628. }
  11629. /**
  11630. * Strong typing of a Mesh related stage step action
  11631. */
  11632. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11633. /**
  11634. * Strong typing of a Evaluate Sub Mesh related stage step action
  11635. */
  11636. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11637. /**
  11638. * Strong typing of a Active Mesh related stage step action
  11639. */
  11640. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11641. /**
  11642. * Strong typing of a Camera related stage step action
  11643. */
  11644. export type CameraStageAction = (camera: Camera) => void;
  11645. /**
  11646. * Strong typing of a Camera Frame buffer related stage step action
  11647. */
  11648. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11649. /**
  11650. * Strong typing of a Render Target related stage step action
  11651. */
  11652. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11653. /**
  11654. * Strong typing of a RenderingGroup related stage step action
  11655. */
  11656. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11657. /**
  11658. * Strong typing of a Mesh Render related stage step action
  11659. */
  11660. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11661. /**
  11662. * Strong typing of a simple stage step action
  11663. */
  11664. export type SimpleStageAction = () => void;
  11665. /**
  11666. * Strong typing of a render target action.
  11667. */
  11668. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11669. /**
  11670. * Strong typing of a pointer move action.
  11671. */
  11672. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11673. /**
  11674. * Strong typing of a pointer up/down action.
  11675. */
  11676. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11677. /**
  11678. * Representation of a stage in the scene (Basically a list of ordered steps)
  11679. * @hidden
  11680. */
  11681. export class Stage<T extends Function> extends Array<{
  11682. index: number;
  11683. component: ISceneComponent;
  11684. action: T;
  11685. }> {
  11686. /**
  11687. * Hide ctor from the rest of the world.
  11688. * @param items The items to add.
  11689. */
  11690. private constructor();
  11691. /**
  11692. * Creates a new Stage.
  11693. * @returns A new instance of a Stage
  11694. */
  11695. static Create<T extends Function>(): Stage<T>;
  11696. /**
  11697. * Registers a step in an ordered way in the targeted stage.
  11698. * @param index Defines the position to register the step in
  11699. * @param component Defines the component attached to the step
  11700. * @param action Defines the action to launch during the step
  11701. */
  11702. registerStep(index: number, component: ISceneComponent, action: T): void;
  11703. /**
  11704. * Clears all the steps from the stage.
  11705. */
  11706. clear(): void;
  11707. }
  11708. }
  11709. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11710. import { Nullable } from "babylonjs/types";
  11711. import { Observable } from "babylonjs/Misc/observable";
  11712. import { Scene } from "babylonjs/scene";
  11713. import { Sprite } from "babylonjs/Sprites/sprite";
  11714. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11715. import { Ray } from "babylonjs/Culling/ray";
  11716. import { Camera } from "babylonjs/Cameras/camera";
  11717. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11718. import { ISceneComponent } from "babylonjs/sceneComponent";
  11719. module "babylonjs/scene" {
  11720. interface Scene {
  11721. /** @hidden */
  11722. _pointerOverSprite: Nullable<Sprite>;
  11723. /** @hidden */
  11724. _pickedDownSprite: Nullable<Sprite>;
  11725. /** @hidden */
  11726. _tempSpritePickingRay: Nullable<Ray>;
  11727. /**
  11728. * All of the sprite managers added to this scene
  11729. * @see http://doc.babylonjs.com/babylon101/sprites
  11730. */
  11731. spriteManagers: Array<ISpriteManager>;
  11732. /**
  11733. * An event triggered when sprites rendering is about to start
  11734. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11735. */
  11736. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11737. /**
  11738. * An event triggered when sprites rendering is done
  11739. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11740. */
  11741. onAfterSpritesRenderingObservable: Observable<Scene>;
  11742. /** @hidden */
  11743. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11744. /** Launch a ray to try to pick a sprite in the scene
  11745. * @param x position on screen
  11746. * @param y position on screen
  11747. * @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
  11748. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11749. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11750. * @returns a PickingInfo
  11751. */
  11752. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11753. /** Use the given ray to pick a sprite in the scene
  11754. * @param ray The ray (in world space) to use to pick meshes
  11755. * @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
  11756. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11757. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11758. * @returns a PickingInfo
  11759. */
  11760. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11761. /** @hidden */
  11762. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11763. /** Launch a ray to try to pick sprites in the scene
  11764. * @param x position on screen
  11765. * @param y position on screen
  11766. * @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
  11767. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11768. * @returns a PickingInfo array
  11769. */
  11770. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11771. /** Use the given ray to pick sprites in the scene
  11772. * @param ray The ray (in world space) to use to pick meshes
  11773. * @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
  11774. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11775. * @returns a PickingInfo array
  11776. */
  11777. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11778. /**
  11779. * Force the sprite under the pointer
  11780. * @param sprite defines the sprite to use
  11781. */
  11782. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11783. /**
  11784. * Gets the sprite under the pointer
  11785. * @returns a Sprite or null if no sprite is under the pointer
  11786. */
  11787. getPointerOverSprite(): Nullable<Sprite>;
  11788. }
  11789. }
  11790. /**
  11791. * Defines the sprite scene component responsible to manage sprites
  11792. * in a given scene.
  11793. */
  11794. export class SpriteSceneComponent implements ISceneComponent {
  11795. /**
  11796. * The component name helpfull to identify the component in the list of scene components.
  11797. */
  11798. readonly name: string;
  11799. /**
  11800. * The scene the component belongs to.
  11801. */
  11802. scene: Scene;
  11803. /** @hidden */
  11804. private _spritePredicate;
  11805. /**
  11806. * Creates a new instance of the component for the given scene
  11807. * @param scene Defines the scene to register the component in
  11808. */
  11809. constructor(scene: Scene);
  11810. /**
  11811. * Registers the component in a given scene
  11812. */
  11813. register(): void;
  11814. /**
  11815. * Rebuilds the elements related to this component in case of
  11816. * context lost for instance.
  11817. */
  11818. rebuild(): void;
  11819. /**
  11820. * Disposes the component and the associated ressources.
  11821. */
  11822. dispose(): void;
  11823. private _pickSpriteButKeepRay;
  11824. private _pointerMove;
  11825. private _pointerDown;
  11826. private _pointerUp;
  11827. }
  11828. }
  11829. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11830. /** @hidden */
  11831. export var fogFragmentDeclaration: {
  11832. name: string;
  11833. shader: string;
  11834. };
  11835. }
  11836. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11837. /** @hidden */
  11838. export var fogFragment: {
  11839. name: string;
  11840. shader: string;
  11841. };
  11842. }
  11843. declare module "babylonjs/Shaders/sprites.fragment" {
  11844. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11845. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11846. /** @hidden */
  11847. export var spritesPixelShader: {
  11848. name: string;
  11849. shader: string;
  11850. };
  11851. }
  11852. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11853. /** @hidden */
  11854. export var fogVertexDeclaration: {
  11855. name: string;
  11856. shader: string;
  11857. };
  11858. }
  11859. declare module "babylonjs/Shaders/sprites.vertex" {
  11860. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11861. /** @hidden */
  11862. export var spritesVertexShader: {
  11863. name: string;
  11864. shader: string;
  11865. };
  11866. }
  11867. declare module "babylonjs/Sprites/spriteManager" {
  11868. import { IDisposable, Scene } from "babylonjs/scene";
  11869. import { Nullable } from "babylonjs/types";
  11870. import { Observable } from "babylonjs/Misc/observable";
  11871. import { Sprite } from "babylonjs/Sprites/sprite";
  11872. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11873. import { Camera } from "babylonjs/Cameras/camera";
  11874. import { Texture } from "babylonjs/Materials/Textures/texture";
  11875. import "babylonjs/Shaders/sprites.fragment";
  11876. import "babylonjs/Shaders/sprites.vertex";
  11877. import { Ray } from "babylonjs/Culling/ray";
  11878. /**
  11879. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11880. */
  11881. export interface ISpriteManager extends IDisposable {
  11882. /**
  11883. * Restricts the camera to viewing objects with the same layerMask.
  11884. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11885. */
  11886. layerMask: number;
  11887. /**
  11888. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11889. */
  11890. isPickable: boolean;
  11891. /**
  11892. * Specifies the rendering group id for this mesh (0 by default)
  11893. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11894. */
  11895. renderingGroupId: number;
  11896. /**
  11897. * Defines the list of sprites managed by the manager.
  11898. */
  11899. sprites: Array<Sprite>;
  11900. /**
  11901. * Tests the intersection of a sprite with a specific ray.
  11902. * @param ray The ray we are sending to test the collision
  11903. * @param camera The camera space we are sending rays in
  11904. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11905. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11906. * @returns picking info or null.
  11907. */
  11908. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11909. /**
  11910. * Intersects the sprites with a ray
  11911. * @param ray defines the ray to intersect with
  11912. * @param camera defines the current active camera
  11913. * @param predicate defines a predicate used to select candidate sprites
  11914. * @returns null if no hit or a PickingInfo array
  11915. */
  11916. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11917. /**
  11918. * Renders the list of sprites on screen.
  11919. */
  11920. render(): void;
  11921. }
  11922. /**
  11923. * Class used to manage multiple sprites on the same spritesheet
  11924. * @see http://doc.babylonjs.com/babylon101/sprites
  11925. */
  11926. export class SpriteManager implements ISpriteManager {
  11927. /** defines the manager's name */
  11928. name: string;
  11929. /** Gets the list of sprites */
  11930. sprites: Sprite[];
  11931. /** Gets or sets the rendering group id (0 by default) */
  11932. renderingGroupId: number;
  11933. /** Gets or sets camera layer mask */
  11934. layerMask: number;
  11935. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11936. fogEnabled: boolean;
  11937. /** Gets or sets a boolean indicating if the sprites are pickable */
  11938. isPickable: boolean;
  11939. /** Defines the default width of a cell in the spritesheet */
  11940. cellWidth: number;
  11941. /** Defines the default height of a cell in the spritesheet */
  11942. cellHeight: number;
  11943. /** Associative array from JSON sprite data file */
  11944. private _cellData;
  11945. /** Array of sprite names from JSON sprite data file */
  11946. private _spriteMap;
  11947. /** True when packed cell data from JSON file is ready*/
  11948. private _packedAndReady;
  11949. /**
  11950. * An event triggered when the manager is disposed.
  11951. */
  11952. onDisposeObservable: Observable<SpriteManager>;
  11953. private _onDisposeObserver;
  11954. /**
  11955. * Callback called when the manager is disposed
  11956. */
  11957. set onDispose(callback: () => void);
  11958. private _capacity;
  11959. private _fromPacked;
  11960. private _spriteTexture;
  11961. private _epsilon;
  11962. private _scene;
  11963. private _vertexData;
  11964. private _buffer;
  11965. private _vertexBuffers;
  11966. private _indexBuffer;
  11967. private _effectBase;
  11968. private _effectFog;
  11969. /**
  11970. * Gets or sets the spritesheet texture
  11971. */
  11972. get texture(): Texture;
  11973. set texture(value: Texture);
  11974. /**
  11975. * Creates a new sprite manager
  11976. * @param name defines the manager's name
  11977. * @param imgUrl defines the sprite sheet url
  11978. * @param capacity defines the maximum allowed number of sprites
  11979. * @param cellSize defines the size of a sprite cell
  11980. * @param scene defines the hosting scene
  11981. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11982. * @param samplingMode defines the smapling mode to use with spritesheet
  11983. * @param fromPacked set to false; do not alter
  11984. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11985. */
  11986. constructor(
  11987. /** defines the manager's name */
  11988. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11989. private _makePacked;
  11990. private _appendSpriteVertex;
  11991. /**
  11992. * Intersects the sprites with a ray
  11993. * @param ray defines the ray to intersect with
  11994. * @param camera defines the current active camera
  11995. * @param predicate defines a predicate used to select candidate sprites
  11996. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11997. * @returns null if no hit or a PickingInfo
  11998. */
  11999. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12000. /**
  12001. * Intersects the sprites with a ray
  12002. * @param ray defines the ray to intersect with
  12003. * @param camera defines the current active camera
  12004. * @param predicate defines a predicate used to select candidate sprites
  12005. * @returns null if no hit or a PickingInfo array
  12006. */
  12007. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  12008. /**
  12009. * Render all child sprites
  12010. */
  12011. render(): void;
  12012. /**
  12013. * Release associated resources
  12014. */
  12015. dispose(): void;
  12016. }
  12017. }
  12018. declare module "babylonjs/Sprites/sprite" {
  12019. import { Vector3 } from "babylonjs/Maths/math.vector";
  12020. import { Nullable } from "babylonjs/types";
  12021. import { ActionManager } from "babylonjs/Actions/actionManager";
  12022. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12023. import { Color4 } from "babylonjs/Maths/math.color";
  12024. /**
  12025. * Class used to represent a sprite
  12026. * @see http://doc.babylonjs.com/babylon101/sprites
  12027. */
  12028. export class Sprite {
  12029. /** defines the name */
  12030. name: string;
  12031. /** Gets or sets the current world position */
  12032. position: Vector3;
  12033. /** Gets or sets the main color */
  12034. color: Color4;
  12035. /** Gets or sets the width */
  12036. width: number;
  12037. /** Gets or sets the height */
  12038. height: number;
  12039. /** Gets or sets rotation angle */
  12040. angle: number;
  12041. /** Gets or sets the cell index in the sprite sheet */
  12042. cellIndex: number;
  12043. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  12044. cellRef: string;
  12045. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12046. invertU: number;
  12047. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12048. invertV: number;
  12049. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12050. disposeWhenFinishedAnimating: boolean;
  12051. /** Gets the list of attached animations */
  12052. animations: Animation[];
  12053. /** Gets or sets a boolean indicating if the sprite can be picked */
  12054. isPickable: boolean;
  12055. /**
  12056. * Gets or sets the associated action manager
  12057. */
  12058. actionManager: Nullable<ActionManager>;
  12059. private _animationStarted;
  12060. private _loopAnimation;
  12061. private _fromIndex;
  12062. private _toIndex;
  12063. private _delay;
  12064. private _direction;
  12065. private _manager;
  12066. private _time;
  12067. private _onAnimationEnd;
  12068. /**
  12069. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12070. */
  12071. isVisible: boolean;
  12072. /**
  12073. * Gets or sets the sprite size
  12074. */
  12075. get size(): number;
  12076. set size(value: number);
  12077. /**
  12078. * Creates a new Sprite
  12079. * @param name defines the name
  12080. * @param manager defines the manager
  12081. */
  12082. constructor(
  12083. /** defines the name */
  12084. name: string, manager: ISpriteManager);
  12085. /**
  12086. * Starts an animation
  12087. * @param from defines the initial key
  12088. * @param to defines the end key
  12089. * @param loop defines if the animation must loop
  12090. * @param delay defines the start delay (in ms)
  12091. * @param onAnimationEnd defines a callback to call when animation ends
  12092. */
  12093. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12094. /** Stops current animation (if any) */
  12095. stopAnimation(): void;
  12096. /** @hidden */
  12097. _animate(deltaTime: number): void;
  12098. /** Release associated resources */
  12099. dispose(): void;
  12100. }
  12101. }
  12102. declare module "babylonjs/Collisions/pickingInfo" {
  12103. import { Nullable } from "babylonjs/types";
  12104. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12106. import { Sprite } from "babylonjs/Sprites/sprite";
  12107. import { Ray } from "babylonjs/Culling/ray";
  12108. /**
  12109. * Information about the result of picking within a scene
  12110. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12111. */
  12112. export class PickingInfo {
  12113. /** @hidden */
  12114. _pickingUnavailable: boolean;
  12115. /**
  12116. * If the pick collided with an object
  12117. */
  12118. hit: boolean;
  12119. /**
  12120. * Distance away where the pick collided
  12121. */
  12122. distance: number;
  12123. /**
  12124. * The location of pick collision
  12125. */
  12126. pickedPoint: Nullable<Vector3>;
  12127. /**
  12128. * The mesh corresponding the the pick collision
  12129. */
  12130. pickedMesh: Nullable<AbstractMesh>;
  12131. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  12132. bu: number;
  12133. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  12134. bv: number;
  12135. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12136. faceId: number;
  12137. /** Id of the the submesh that was picked */
  12138. subMeshId: number;
  12139. /** If a sprite was picked, this will be the sprite the pick collided with */
  12140. pickedSprite: Nullable<Sprite>;
  12141. /**
  12142. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12143. */
  12144. originMesh: Nullable<AbstractMesh>;
  12145. /**
  12146. * The ray that was used to perform the picking.
  12147. */
  12148. ray: Nullable<Ray>;
  12149. /**
  12150. * Gets the normal correspodning to the face the pick collided with
  12151. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12152. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12153. * @returns The normal correspodning to the face the pick collided with
  12154. */
  12155. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12156. /**
  12157. * Gets the texture coordinates of where the pick occured
  12158. * @returns the vector containing the coordnates of the texture
  12159. */
  12160. getTextureCoordinates(): Nullable<Vector2>;
  12161. }
  12162. }
  12163. declare module "babylonjs/Events/pointerEvents" {
  12164. import { Nullable } from "babylonjs/types";
  12165. import { Vector2 } from "babylonjs/Maths/math.vector";
  12166. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12167. import { Ray } from "babylonjs/Culling/ray";
  12168. /**
  12169. * Gather the list of pointer event types as constants.
  12170. */
  12171. export class PointerEventTypes {
  12172. /**
  12173. * 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.
  12174. */
  12175. static readonly POINTERDOWN: number;
  12176. /**
  12177. * The pointerup event is fired when a pointer is no longer active.
  12178. */
  12179. static readonly POINTERUP: number;
  12180. /**
  12181. * The pointermove event is fired when a pointer changes coordinates.
  12182. */
  12183. static readonly POINTERMOVE: number;
  12184. /**
  12185. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12186. */
  12187. static readonly POINTERWHEEL: number;
  12188. /**
  12189. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12190. */
  12191. static readonly POINTERPICK: number;
  12192. /**
  12193. * The pointertap event is fired when a the object has been touched and released without drag.
  12194. */
  12195. static readonly POINTERTAP: number;
  12196. /**
  12197. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12198. */
  12199. static readonly POINTERDOUBLETAP: number;
  12200. }
  12201. /**
  12202. * Base class of pointer info types.
  12203. */
  12204. export class PointerInfoBase {
  12205. /**
  12206. * Defines the type of event (PointerEventTypes)
  12207. */
  12208. type: number;
  12209. /**
  12210. * Defines the related dom event
  12211. */
  12212. event: PointerEvent | MouseWheelEvent;
  12213. /**
  12214. * Instantiates the base class of pointers info.
  12215. * @param type Defines the type of event (PointerEventTypes)
  12216. * @param event Defines the related dom event
  12217. */
  12218. constructor(
  12219. /**
  12220. * Defines the type of event (PointerEventTypes)
  12221. */
  12222. type: number,
  12223. /**
  12224. * Defines the related dom event
  12225. */
  12226. event: PointerEvent | MouseWheelEvent);
  12227. }
  12228. /**
  12229. * This class is used to store pointer related info for the onPrePointerObservable event.
  12230. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12231. */
  12232. export class PointerInfoPre extends PointerInfoBase {
  12233. /**
  12234. * Ray from a pointer if availible (eg. 6dof controller)
  12235. */
  12236. ray: Nullable<Ray>;
  12237. /**
  12238. * Defines the local position of the pointer on the canvas.
  12239. */
  12240. localPosition: Vector2;
  12241. /**
  12242. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12243. */
  12244. skipOnPointerObservable: boolean;
  12245. /**
  12246. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12247. * @param type Defines the type of event (PointerEventTypes)
  12248. * @param event Defines the related dom event
  12249. * @param localX Defines the local x coordinates of the pointer when the event occured
  12250. * @param localY Defines the local y coordinates of the pointer when the event occured
  12251. */
  12252. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12253. }
  12254. /**
  12255. * This type contains all the data related to a pointer event in Babylon.js.
  12256. * 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.
  12257. */
  12258. export class PointerInfo extends PointerInfoBase {
  12259. /**
  12260. * Defines the picking info associated to the info (if any)\
  12261. */
  12262. pickInfo: Nullable<PickingInfo>;
  12263. /**
  12264. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12265. * @param type Defines the type of event (PointerEventTypes)
  12266. * @param event Defines the related dom event
  12267. * @param pickInfo Defines the picking info associated to the info (if any)\
  12268. */
  12269. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12270. /**
  12271. * Defines the picking info associated to the info (if any)\
  12272. */
  12273. pickInfo: Nullable<PickingInfo>);
  12274. }
  12275. /**
  12276. * Data relating to a touch event on the screen.
  12277. */
  12278. export interface PointerTouch {
  12279. /**
  12280. * X coordinate of touch.
  12281. */
  12282. x: number;
  12283. /**
  12284. * Y coordinate of touch.
  12285. */
  12286. y: number;
  12287. /**
  12288. * Id of touch. Unique for each finger.
  12289. */
  12290. pointerId: number;
  12291. /**
  12292. * Event type passed from DOM.
  12293. */
  12294. type: any;
  12295. }
  12296. }
  12297. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12298. import { Observable } from "babylonjs/Misc/observable";
  12299. import { Nullable } from "babylonjs/types";
  12300. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12301. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12302. /**
  12303. * Manage the mouse inputs to control the movement of a free camera.
  12304. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12305. */
  12306. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12307. /**
  12308. * Define if touch is enabled in the mouse input
  12309. */
  12310. touchEnabled: boolean;
  12311. /**
  12312. * Defines the camera the input is attached to.
  12313. */
  12314. camera: FreeCamera;
  12315. /**
  12316. * Defines the buttons associated with the input to handle camera move.
  12317. */
  12318. buttons: number[];
  12319. /**
  12320. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12321. */
  12322. angularSensibility: number;
  12323. private _pointerInput;
  12324. private _onMouseMove;
  12325. private _observer;
  12326. private previousPosition;
  12327. /**
  12328. * Observable for when a pointer move event occurs containing the move offset
  12329. */
  12330. onPointerMovedObservable: Observable<{
  12331. offsetX: number;
  12332. offsetY: number;
  12333. }>;
  12334. /**
  12335. * @hidden
  12336. * If the camera should be rotated automatically based on pointer movement
  12337. */
  12338. _allowCameraRotation: boolean;
  12339. /**
  12340. * Manage the mouse inputs to control the movement of a free camera.
  12341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12342. * @param touchEnabled Defines if touch is enabled or not
  12343. */
  12344. constructor(
  12345. /**
  12346. * Define if touch is enabled in the mouse input
  12347. */
  12348. touchEnabled?: boolean);
  12349. /**
  12350. * Attach the input controls to a specific dom element to get the input from.
  12351. * @param element Defines the element the controls should be listened from
  12352. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12353. */
  12354. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12355. /**
  12356. * Called on JS contextmenu event.
  12357. * Override this method to provide functionality.
  12358. */
  12359. protected onContextMenu(evt: PointerEvent): void;
  12360. /**
  12361. * Detach the current controls from the specified dom element.
  12362. * @param element Defines the element to stop listening the inputs from
  12363. */
  12364. detachControl(element: Nullable<HTMLElement>): void;
  12365. /**
  12366. * Gets the class name of the current intput.
  12367. * @returns the class name
  12368. */
  12369. getClassName(): string;
  12370. /**
  12371. * Get the friendly name associated with the input class.
  12372. * @returns the input friendly name
  12373. */
  12374. getSimpleName(): string;
  12375. }
  12376. }
  12377. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12378. import { Nullable } from "babylonjs/types";
  12379. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12380. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12381. /**
  12382. * Manage the touch inputs to control the movement of a free camera.
  12383. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12384. */
  12385. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12386. /**
  12387. * Defines the camera the input is attached to.
  12388. */
  12389. camera: FreeCamera;
  12390. /**
  12391. * Defines the touch sensibility for rotation.
  12392. * The higher the faster.
  12393. */
  12394. touchAngularSensibility: number;
  12395. /**
  12396. * Defines the touch sensibility for move.
  12397. * The higher the faster.
  12398. */
  12399. touchMoveSensibility: number;
  12400. private _offsetX;
  12401. private _offsetY;
  12402. private _pointerPressed;
  12403. private _pointerInput;
  12404. private _observer;
  12405. private _onLostFocus;
  12406. /**
  12407. * Attach the input controls to a specific dom element to get the input from.
  12408. * @param element Defines the element the controls should be listened from
  12409. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12410. */
  12411. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12412. /**
  12413. * Detach the current controls from the specified dom element.
  12414. * @param element Defines the element to stop listening the inputs from
  12415. */
  12416. detachControl(element: Nullable<HTMLElement>): void;
  12417. /**
  12418. * Update the current camera state depending on the inputs that have been used this frame.
  12419. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12420. */
  12421. checkInputs(): void;
  12422. /**
  12423. * Gets the class name of the current intput.
  12424. * @returns the class name
  12425. */
  12426. getClassName(): string;
  12427. /**
  12428. * Get the friendly name associated with the input class.
  12429. * @returns the input friendly name
  12430. */
  12431. getSimpleName(): string;
  12432. }
  12433. }
  12434. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12435. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12436. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12437. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12438. import { Nullable } from "babylonjs/types";
  12439. /**
  12440. * Default Inputs manager for the FreeCamera.
  12441. * It groups all the default supported inputs for ease of use.
  12442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12443. */
  12444. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12445. /**
  12446. * @hidden
  12447. */
  12448. _mouseInput: Nullable<FreeCameraMouseInput>;
  12449. /**
  12450. * Instantiates a new FreeCameraInputsManager.
  12451. * @param camera Defines the camera the inputs belong to
  12452. */
  12453. constructor(camera: FreeCamera);
  12454. /**
  12455. * Add keyboard input support to the input manager.
  12456. * @returns the current input manager
  12457. */
  12458. addKeyboard(): FreeCameraInputsManager;
  12459. /**
  12460. * Add mouse input support to the input manager.
  12461. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12462. * @returns the current input manager
  12463. */
  12464. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12465. /**
  12466. * Removes the mouse input support from the manager
  12467. * @returns the current input manager
  12468. */
  12469. removeMouse(): FreeCameraInputsManager;
  12470. /**
  12471. * Add touch input support to the input manager.
  12472. * @returns the current input manager
  12473. */
  12474. addTouch(): FreeCameraInputsManager;
  12475. /**
  12476. * Remove all attached input methods from a camera
  12477. */
  12478. clear(): void;
  12479. }
  12480. }
  12481. declare module "babylonjs/Cameras/freeCamera" {
  12482. import { Vector3 } from "babylonjs/Maths/math.vector";
  12483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12484. import { Scene } from "babylonjs/scene";
  12485. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12486. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12487. /**
  12488. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12489. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12490. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12491. */
  12492. export class FreeCamera extends TargetCamera {
  12493. /**
  12494. * Define the collision ellipsoid of the camera.
  12495. * This is helpful to simulate a camera body like the player body around the camera
  12496. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12497. */
  12498. ellipsoid: Vector3;
  12499. /**
  12500. * Define an offset for the position of the ellipsoid around the camera.
  12501. * This can be helpful to determine the center of the body near the gravity center of the body
  12502. * instead of its head.
  12503. */
  12504. ellipsoidOffset: Vector3;
  12505. /**
  12506. * Enable or disable collisions of the camera with the rest of the scene objects.
  12507. */
  12508. checkCollisions: boolean;
  12509. /**
  12510. * Enable or disable gravity on the camera.
  12511. */
  12512. applyGravity: boolean;
  12513. /**
  12514. * Define the input manager associated to the camera.
  12515. */
  12516. inputs: FreeCameraInputsManager;
  12517. /**
  12518. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12519. * Higher values reduce sensitivity.
  12520. */
  12521. get angularSensibility(): number;
  12522. /**
  12523. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12524. * Higher values reduce sensitivity.
  12525. */
  12526. set angularSensibility(value: number);
  12527. /**
  12528. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12529. */
  12530. get keysUp(): number[];
  12531. set keysUp(value: number[]);
  12532. /**
  12533. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12534. */
  12535. get keysDown(): number[];
  12536. set keysDown(value: number[]);
  12537. /**
  12538. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12539. */
  12540. get keysLeft(): number[];
  12541. set keysLeft(value: number[]);
  12542. /**
  12543. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12544. */
  12545. get keysRight(): number[];
  12546. set keysRight(value: number[]);
  12547. /**
  12548. * Event raised when the camera collide with a mesh in the scene.
  12549. */
  12550. onCollide: (collidedMesh: AbstractMesh) => void;
  12551. private _collider;
  12552. private _needMoveForGravity;
  12553. private _oldPosition;
  12554. private _diffPosition;
  12555. private _newPosition;
  12556. /** @hidden */
  12557. _localDirection: Vector3;
  12558. /** @hidden */
  12559. _transformedDirection: Vector3;
  12560. /**
  12561. * Instantiates a Free Camera.
  12562. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12563. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12564. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12565. * @param name Define the name of the camera in the scene
  12566. * @param position Define the start position of the camera in the scene
  12567. * @param scene Define the scene the camera belongs to
  12568. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12569. */
  12570. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12571. /**
  12572. * Attached controls to the current camera.
  12573. * @param element Defines the element the controls should be listened from
  12574. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12575. */
  12576. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12577. /**
  12578. * Detach the current controls from the camera.
  12579. * The camera will stop reacting to inputs.
  12580. * @param element Defines the element to stop listening the inputs from
  12581. */
  12582. detachControl(element: HTMLElement): void;
  12583. private _collisionMask;
  12584. /**
  12585. * Define a collision mask to limit the list of object the camera can collide with
  12586. */
  12587. get collisionMask(): number;
  12588. set collisionMask(mask: number);
  12589. /** @hidden */
  12590. _collideWithWorld(displacement: Vector3): void;
  12591. private _onCollisionPositionChange;
  12592. /** @hidden */
  12593. _checkInputs(): void;
  12594. /** @hidden */
  12595. _decideIfNeedsToMove(): boolean;
  12596. /** @hidden */
  12597. _updatePosition(): void;
  12598. /**
  12599. * Destroy the camera and release the current resources hold by it.
  12600. */
  12601. dispose(): void;
  12602. /**
  12603. * Gets the current object class name.
  12604. * @return the class name
  12605. */
  12606. getClassName(): string;
  12607. }
  12608. }
  12609. declare module "babylonjs/Gamepads/gamepad" {
  12610. import { Observable } from "babylonjs/Misc/observable";
  12611. /**
  12612. * Represents a gamepad control stick position
  12613. */
  12614. export class StickValues {
  12615. /**
  12616. * The x component of the control stick
  12617. */
  12618. x: number;
  12619. /**
  12620. * The y component of the control stick
  12621. */
  12622. y: number;
  12623. /**
  12624. * Initializes the gamepad x and y control stick values
  12625. * @param x The x component of the gamepad control stick value
  12626. * @param y The y component of the gamepad control stick value
  12627. */
  12628. constructor(
  12629. /**
  12630. * The x component of the control stick
  12631. */
  12632. x: number,
  12633. /**
  12634. * The y component of the control stick
  12635. */
  12636. y: number);
  12637. }
  12638. /**
  12639. * An interface which manages callbacks for gamepad button changes
  12640. */
  12641. export interface GamepadButtonChanges {
  12642. /**
  12643. * Called when a gamepad has been changed
  12644. */
  12645. changed: boolean;
  12646. /**
  12647. * Called when a gamepad press event has been triggered
  12648. */
  12649. pressChanged: boolean;
  12650. /**
  12651. * Called when a touch event has been triggered
  12652. */
  12653. touchChanged: boolean;
  12654. /**
  12655. * Called when a value has changed
  12656. */
  12657. valueChanged: boolean;
  12658. }
  12659. /**
  12660. * Represents a gamepad
  12661. */
  12662. export class Gamepad {
  12663. /**
  12664. * The id of the gamepad
  12665. */
  12666. id: string;
  12667. /**
  12668. * The index of the gamepad
  12669. */
  12670. index: number;
  12671. /**
  12672. * The browser gamepad
  12673. */
  12674. browserGamepad: any;
  12675. /**
  12676. * Specifies what type of gamepad this represents
  12677. */
  12678. type: number;
  12679. private _leftStick;
  12680. private _rightStick;
  12681. /** @hidden */
  12682. _isConnected: boolean;
  12683. private _leftStickAxisX;
  12684. private _leftStickAxisY;
  12685. private _rightStickAxisX;
  12686. private _rightStickAxisY;
  12687. /**
  12688. * Triggered when the left control stick has been changed
  12689. */
  12690. private _onleftstickchanged;
  12691. /**
  12692. * Triggered when the right control stick has been changed
  12693. */
  12694. private _onrightstickchanged;
  12695. /**
  12696. * Represents a gamepad controller
  12697. */
  12698. static GAMEPAD: number;
  12699. /**
  12700. * Represents a generic controller
  12701. */
  12702. static GENERIC: number;
  12703. /**
  12704. * Represents an XBox controller
  12705. */
  12706. static XBOX: number;
  12707. /**
  12708. * Represents a pose-enabled controller
  12709. */
  12710. static POSE_ENABLED: number;
  12711. /**
  12712. * Represents an Dual Shock controller
  12713. */
  12714. static DUALSHOCK: number;
  12715. /**
  12716. * Specifies whether the left control stick should be Y-inverted
  12717. */
  12718. protected _invertLeftStickY: boolean;
  12719. /**
  12720. * Specifies if the gamepad has been connected
  12721. */
  12722. get isConnected(): boolean;
  12723. /**
  12724. * Initializes the gamepad
  12725. * @param id The id of the gamepad
  12726. * @param index The index of the gamepad
  12727. * @param browserGamepad The browser gamepad
  12728. * @param leftStickX The x component of the left joystick
  12729. * @param leftStickY The y component of the left joystick
  12730. * @param rightStickX The x component of the right joystick
  12731. * @param rightStickY The y component of the right joystick
  12732. */
  12733. constructor(
  12734. /**
  12735. * The id of the gamepad
  12736. */
  12737. id: string,
  12738. /**
  12739. * The index of the gamepad
  12740. */
  12741. index: number,
  12742. /**
  12743. * The browser gamepad
  12744. */
  12745. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12746. /**
  12747. * Callback triggered when the left joystick has changed
  12748. * @param callback
  12749. */
  12750. onleftstickchanged(callback: (values: StickValues) => void): void;
  12751. /**
  12752. * Callback triggered when the right joystick has changed
  12753. * @param callback
  12754. */
  12755. onrightstickchanged(callback: (values: StickValues) => void): void;
  12756. /**
  12757. * Gets the left joystick
  12758. */
  12759. get leftStick(): StickValues;
  12760. /**
  12761. * Sets the left joystick values
  12762. */
  12763. set leftStick(newValues: StickValues);
  12764. /**
  12765. * Gets the right joystick
  12766. */
  12767. get rightStick(): StickValues;
  12768. /**
  12769. * Sets the right joystick value
  12770. */
  12771. set rightStick(newValues: StickValues);
  12772. /**
  12773. * Updates the gamepad joystick positions
  12774. */
  12775. update(): void;
  12776. /**
  12777. * Disposes the gamepad
  12778. */
  12779. dispose(): void;
  12780. }
  12781. /**
  12782. * Represents a generic gamepad
  12783. */
  12784. export class GenericPad extends Gamepad {
  12785. private _buttons;
  12786. private _onbuttondown;
  12787. private _onbuttonup;
  12788. /**
  12789. * Observable triggered when a button has been pressed
  12790. */
  12791. onButtonDownObservable: Observable<number>;
  12792. /**
  12793. * Observable triggered when a button has been released
  12794. */
  12795. onButtonUpObservable: Observable<number>;
  12796. /**
  12797. * Callback triggered when a button has been pressed
  12798. * @param callback Called when a button has been pressed
  12799. */
  12800. onbuttondown(callback: (buttonPressed: number) => void): void;
  12801. /**
  12802. * Callback triggered when a button has been released
  12803. * @param callback Called when a button has been released
  12804. */
  12805. onbuttonup(callback: (buttonReleased: number) => void): void;
  12806. /**
  12807. * Initializes the generic gamepad
  12808. * @param id The id of the generic gamepad
  12809. * @param index The index of the generic gamepad
  12810. * @param browserGamepad The browser gamepad
  12811. */
  12812. constructor(id: string, index: number, browserGamepad: any);
  12813. private _setButtonValue;
  12814. /**
  12815. * Updates the generic gamepad
  12816. */
  12817. update(): void;
  12818. /**
  12819. * Disposes the generic gamepad
  12820. */
  12821. dispose(): void;
  12822. }
  12823. }
  12824. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12825. import { Nullable } from "babylonjs/types";
  12826. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12827. import { Scene } from "babylonjs/scene";
  12828. module "babylonjs/Engines/engine" {
  12829. interface Engine {
  12830. /**
  12831. * Creates a raw texture
  12832. * @param data defines the data to store in the texture
  12833. * @param width defines the width of the texture
  12834. * @param height defines the height of the texture
  12835. * @param format defines the format of the data
  12836. * @param generateMipMaps defines if the engine should generate the mip levels
  12837. * @param invertY defines if data must be stored with Y axis inverted
  12838. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12839. * @param compression defines the compression used (null by default)
  12840. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12841. * @returns the raw texture inside an InternalTexture
  12842. */
  12843. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12844. /**
  12845. * Update a raw texture
  12846. * @param texture defines the texture to update
  12847. * @param data defines the data to store in the texture
  12848. * @param format defines the format of the data
  12849. * @param invertY defines if data must be stored with Y axis inverted
  12850. */
  12851. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12852. /**
  12853. * Update a raw texture
  12854. * @param texture defines the texture to update
  12855. * @param data defines the data to store in the texture
  12856. * @param format defines the format of the data
  12857. * @param invertY defines if data must be stored with Y axis inverted
  12858. * @param compression defines the compression used (null by default)
  12859. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12860. */
  12861. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12862. /**
  12863. * Creates a new raw cube texture
  12864. * @param data defines the array of data to use to create each face
  12865. * @param size defines the size of the textures
  12866. * @param format defines the format of the data
  12867. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12868. * @param generateMipMaps defines if the engine should generate the mip levels
  12869. * @param invertY defines if data must be stored with Y axis inverted
  12870. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12871. * @param compression defines the compression used (null by default)
  12872. * @returns the cube texture as an InternalTexture
  12873. */
  12874. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12875. /**
  12876. * Update a raw cube texture
  12877. * @param texture defines the texture to udpdate
  12878. * @param data defines the data to store
  12879. * @param format defines the data format
  12880. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12881. * @param invertY defines if data must be stored with Y axis inverted
  12882. */
  12883. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12884. /**
  12885. * Update a raw cube texture
  12886. * @param texture defines the texture to udpdate
  12887. * @param data defines the data to store
  12888. * @param format defines the data format
  12889. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12890. * @param invertY defines if data must be stored with Y axis inverted
  12891. * @param compression defines the compression used (null by default)
  12892. */
  12893. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12894. /**
  12895. * Update a raw cube texture
  12896. * @param texture defines the texture to udpdate
  12897. * @param data defines the data to store
  12898. * @param format defines the data format
  12899. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12900. * @param invertY defines if data must be stored with Y axis inverted
  12901. * @param compression defines the compression used (null by default)
  12902. * @param level defines which level of the texture to update
  12903. */
  12904. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12905. /**
  12906. * Creates a new raw cube texture from a specified url
  12907. * @param url defines the url where the data is located
  12908. * @param scene defines the current scene
  12909. * @param size defines the size of the textures
  12910. * @param format defines the format of the data
  12911. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12912. * @param noMipmap defines if the engine should avoid generating the mip levels
  12913. * @param callback defines a callback used to extract texture data from loaded data
  12914. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12915. * @param onLoad defines a callback called when texture is loaded
  12916. * @param onError defines a callback called if there is an error
  12917. * @returns the cube texture as an InternalTexture
  12918. */
  12919. 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;
  12920. /**
  12921. * Creates a new raw cube texture from a specified url
  12922. * @param url defines the url where the data is located
  12923. * @param scene defines the current scene
  12924. * @param size defines the size of the textures
  12925. * @param format defines the format of the data
  12926. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12927. * @param noMipmap defines if the engine should avoid generating the mip levels
  12928. * @param callback defines a callback used to extract texture data from loaded data
  12929. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12930. * @param onLoad defines a callback called when texture is loaded
  12931. * @param onError defines a callback called if there is an error
  12932. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12933. * @param invertY defines if data must be stored with Y axis inverted
  12934. * @returns the cube texture as an InternalTexture
  12935. */
  12936. 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;
  12937. /**
  12938. * Creates a new raw 3D texture
  12939. * @param data defines the data used to create the texture
  12940. * @param width defines the width of the texture
  12941. * @param height defines the height of the texture
  12942. * @param depth defines the depth of the texture
  12943. * @param format defines the format of the texture
  12944. * @param generateMipMaps defines if the engine must generate mip levels
  12945. * @param invertY defines if data must be stored with Y axis inverted
  12946. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12947. * @param compression defines the compressed used (can be null)
  12948. * @param textureType defines the compressed used (can be null)
  12949. * @returns a new raw 3D texture (stored in an InternalTexture)
  12950. */
  12951. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12952. /**
  12953. * Update a raw 3D texture
  12954. * @param texture defines the texture to update
  12955. * @param data defines the data to store
  12956. * @param format defines the data format
  12957. * @param invertY defines if data must be stored with Y axis inverted
  12958. */
  12959. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12960. /**
  12961. * Update a raw 3D texture
  12962. * @param texture defines the texture to update
  12963. * @param data defines the data to store
  12964. * @param format defines the data format
  12965. * @param invertY defines if data must be stored with Y axis inverted
  12966. * @param compression defines the used compression (can be null)
  12967. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12968. */
  12969. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12970. /**
  12971. * Creates a new raw 2D array texture
  12972. * @param data defines the data used to create the texture
  12973. * @param width defines the width of the texture
  12974. * @param height defines the height of the texture
  12975. * @param depth defines the number of layers of the texture
  12976. * @param format defines the format of the texture
  12977. * @param generateMipMaps defines if the engine must generate mip levels
  12978. * @param invertY defines if data must be stored with Y axis inverted
  12979. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12980. * @param compression defines the compressed used (can be null)
  12981. * @param textureType defines the compressed used (can be null)
  12982. * @returns a new raw 2D array texture (stored in an InternalTexture)
  12983. */
  12984. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12985. /**
  12986. * Update a raw 2D array texture
  12987. * @param texture defines the texture to update
  12988. * @param data defines the data to store
  12989. * @param format defines the data format
  12990. * @param invertY defines if data must be stored with Y axis inverted
  12991. */
  12992. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12993. /**
  12994. * Update a raw 2D array texture
  12995. * @param texture defines the texture to update
  12996. * @param data defines the data to store
  12997. * @param format defines the data format
  12998. * @param invertY defines if data must be stored with Y axis inverted
  12999. * @param compression defines the used compression (can be null)
  13000. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  13001. */
  13002. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  13003. }
  13004. }
  13005. }
  13006. declare module "babylonjs/Materials/Textures/rawTexture" {
  13007. import { Scene } from "babylonjs/scene";
  13008. import { Texture } from "babylonjs/Materials/Textures/texture";
  13009. import "babylonjs/Engines/Extensions/engine.rawTexture";
  13010. /**
  13011. * Raw texture can help creating a texture directly from an array of data.
  13012. * This can be super useful if you either get the data from an uncompressed source or
  13013. * if you wish to create your texture pixel by pixel.
  13014. */
  13015. export class RawTexture extends Texture {
  13016. /**
  13017. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13018. */
  13019. format: number;
  13020. private _engine;
  13021. /**
  13022. * Instantiates a new RawTexture.
  13023. * Raw texture can help creating a texture directly from an array of data.
  13024. * This can be super useful if you either get the data from an uncompressed source or
  13025. * if you wish to create your texture pixel by pixel.
  13026. * @param data define the array of data to use to create the texture
  13027. * @param width define the width of the texture
  13028. * @param height define the height of the texture
  13029. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13030. * @param scene define the scene the texture belongs to
  13031. * @param generateMipMaps define whether mip maps should be generated or not
  13032. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13033. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13034. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13035. */
  13036. constructor(data: ArrayBufferView, width: number, height: number,
  13037. /**
  13038. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  13039. */
  13040. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  13041. /**
  13042. * Updates the texture underlying data.
  13043. * @param data Define the new data of the texture
  13044. */
  13045. update(data: ArrayBufferView): void;
  13046. /**
  13047. * Creates a luminance texture from some data.
  13048. * @param data Define the texture data
  13049. * @param width Define the width of the texture
  13050. * @param height Define the height of the texture
  13051. * @param scene Define the scene the texture belongs to
  13052. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13053. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13054. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13055. * @returns the luminance texture
  13056. */
  13057. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13058. /**
  13059. * Creates a luminance alpha texture from some data.
  13060. * @param data Define the texture data
  13061. * @param width Define the width of the texture
  13062. * @param height Define the height of the texture
  13063. * @param scene Define the scene the texture belongs to
  13064. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13065. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13066. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13067. * @returns the luminance alpha texture
  13068. */
  13069. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13070. /**
  13071. * Creates an alpha texture from some data.
  13072. * @param data Define the texture data
  13073. * @param width Define the width of the texture
  13074. * @param height Define the height of the texture
  13075. * @param scene Define the scene the texture belongs to
  13076. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13077. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13078. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13079. * @returns the alpha texture
  13080. */
  13081. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  13082. /**
  13083. * Creates a RGB texture from some data.
  13084. * @param data Define the texture data
  13085. * @param width Define the width of the texture
  13086. * @param height Define the height of the texture
  13087. * @param scene Define the scene the texture belongs to
  13088. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13089. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13090. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13091. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13092. * @returns the RGB alpha texture
  13093. */
  13094. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13095. /**
  13096. * Creates a RGBA texture from some data.
  13097. * @param data Define the texture data
  13098. * @param width Define the width of the texture
  13099. * @param height Define the height of the texture
  13100. * @param scene Define the scene the texture belongs to
  13101. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13102. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13103. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13104. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13105. * @returns the RGBA texture
  13106. */
  13107. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13108. /**
  13109. * Creates a R texture from some data.
  13110. * @param data Define the texture data
  13111. * @param width Define the width of the texture
  13112. * @param height Define the height of the texture
  13113. * @param scene Define the scene the texture belongs to
  13114. * @param generateMipMaps Define whether or not to create mip maps for the texture
  13115. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  13116. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  13117. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  13118. * @returns the R texture
  13119. */
  13120. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  13121. }
  13122. }
  13123. declare module "babylonjs/Maths/math.size" {
  13124. /**
  13125. * Interface for the size containing width and height
  13126. */
  13127. export interface ISize {
  13128. /**
  13129. * Width
  13130. */
  13131. width: number;
  13132. /**
  13133. * Heighht
  13134. */
  13135. height: number;
  13136. }
  13137. /**
  13138. * Size containing widht and height
  13139. */
  13140. export class Size implements ISize {
  13141. /**
  13142. * Width
  13143. */
  13144. width: number;
  13145. /**
  13146. * Height
  13147. */
  13148. height: number;
  13149. /**
  13150. * Creates a Size object from the given width and height (floats).
  13151. * @param width width of the new size
  13152. * @param height height of the new size
  13153. */
  13154. constructor(width: number, height: number);
  13155. /**
  13156. * Returns a string with the Size width and height
  13157. * @returns a string with the Size width and height
  13158. */
  13159. toString(): string;
  13160. /**
  13161. * "Size"
  13162. * @returns the string "Size"
  13163. */
  13164. getClassName(): string;
  13165. /**
  13166. * Returns the Size hash code.
  13167. * @returns a hash code for a unique width and height
  13168. */
  13169. getHashCode(): number;
  13170. /**
  13171. * Updates the current size from the given one.
  13172. * @param src the given size
  13173. */
  13174. copyFrom(src: Size): void;
  13175. /**
  13176. * Updates in place the current Size from the given floats.
  13177. * @param width width of the new size
  13178. * @param height height of the new size
  13179. * @returns the updated Size.
  13180. */
  13181. copyFromFloats(width: number, height: number): Size;
  13182. /**
  13183. * Updates in place the current Size from the given floats.
  13184. * @param width width to set
  13185. * @param height height to set
  13186. * @returns the updated Size.
  13187. */
  13188. set(width: number, height: number): Size;
  13189. /**
  13190. * Multiplies the width and height by numbers
  13191. * @param w factor to multiple the width by
  13192. * @param h factor to multiple the height by
  13193. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  13194. */
  13195. multiplyByFloats(w: number, h: number): Size;
  13196. /**
  13197. * Clones the size
  13198. * @returns a new Size copied from the given one.
  13199. */
  13200. clone(): Size;
  13201. /**
  13202. * True if the current Size and the given one width and height are strictly equal.
  13203. * @param other the other size to compare against
  13204. * @returns True if the current Size and the given one width and height are strictly equal.
  13205. */
  13206. equals(other: Size): boolean;
  13207. /**
  13208. * The surface of the Size : width * height (float).
  13209. */
  13210. get surface(): number;
  13211. /**
  13212. * Create a new size of zero
  13213. * @returns a new Size set to (0.0, 0.0)
  13214. */
  13215. static Zero(): Size;
  13216. /**
  13217. * Sums the width and height of two sizes
  13218. * @param otherSize size to add to this size
  13219. * @returns a new Size set as the addition result of the current Size and the given one.
  13220. */
  13221. add(otherSize: Size): Size;
  13222. /**
  13223. * Subtracts the width and height of two
  13224. * @param otherSize size to subtract to this size
  13225. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13226. */
  13227. subtract(otherSize: Size): Size;
  13228. /**
  13229. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13230. * @param start starting size to lerp between
  13231. * @param end end size to lerp between
  13232. * @param amount amount to lerp between the start and end values
  13233. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13234. */
  13235. static Lerp(start: Size, end: Size, amount: number): Size;
  13236. }
  13237. }
  13238. declare module "babylonjs/Animations/runtimeAnimation" {
  13239. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13240. import { Animatable } from "babylonjs/Animations/animatable";
  13241. import { Scene } from "babylonjs/scene";
  13242. /**
  13243. * Defines a runtime animation
  13244. */
  13245. export class RuntimeAnimation {
  13246. private _events;
  13247. /**
  13248. * The current frame of the runtime animation
  13249. */
  13250. private _currentFrame;
  13251. /**
  13252. * The animation used by the runtime animation
  13253. */
  13254. private _animation;
  13255. /**
  13256. * The target of the runtime animation
  13257. */
  13258. private _target;
  13259. /**
  13260. * The initiating animatable
  13261. */
  13262. private _host;
  13263. /**
  13264. * The original value of the runtime animation
  13265. */
  13266. private _originalValue;
  13267. /**
  13268. * The original blend value of the runtime animation
  13269. */
  13270. private _originalBlendValue;
  13271. /**
  13272. * The offsets cache of the runtime animation
  13273. */
  13274. private _offsetsCache;
  13275. /**
  13276. * The high limits cache of the runtime animation
  13277. */
  13278. private _highLimitsCache;
  13279. /**
  13280. * Specifies if the runtime animation has been stopped
  13281. */
  13282. private _stopped;
  13283. /**
  13284. * The blending factor of the runtime animation
  13285. */
  13286. private _blendingFactor;
  13287. /**
  13288. * The BabylonJS scene
  13289. */
  13290. private _scene;
  13291. /**
  13292. * The current value of the runtime animation
  13293. */
  13294. private _currentValue;
  13295. /** @hidden */
  13296. _animationState: _IAnimationState;
  13297. /**
  13298. * The active target of the runtime animation
  13299. */
  13300. private _activeTargets;
  13301. private _currentActiveTarget;
  13302. private _directTarget;
  13303. /**
  13304. * The target path of the runtime animation
  13305. */
  13306. private _targetPath;
  13307. /**
  13308. * The weight of the runtime animation
  13309. */
  13310. private _weight;
  13311. /**
  13312. * The ratio offset of the runtime animation
  13313. */
  13314. private _ratioOffset;
  13315. /**
  13316. * The previous delay of the runtime animation
  13317. */
  13318. private _previousDelay;
  13319. /**
  13320. * The previous ratio of the runtime animation
  13321. */
  13322. private _previousRatio;
  13323. private _enableBlending;
  13324. private _keys;
  13325. private _minFrame;
  13326. private _maxFrame;
  13327. private _minValue;
  13328. private _maxValue;
  13329. private _targetIsArray;
  13330. /**
  13331. * Gets the current frame of the runtime animation
  13332. */
  13333. get currentFrame(): number;
  13334. /**
  13335. * Gets the weight of the runtime animation
  13336. */
  13337. get weight(): number;
  13338. /**
  13339. * Gets the current value of the runtime animation
  13340. */
  13341. get currentValue(): any;
  13342. /**
  13343. * Gets the target path of the runtime animation
  13344. */
  13345. get targetPath(): string;
  13346. /**
  13347. * Gets the actual target of the runtime animation
  13348. */
  13349. get target(): any;
  13350. /** @hidden */
  13351. _onLoop: () => void;
  13352. /**
  13353. * Create a new RuntimeAnimation object
  13354. * @param target defines the target of the animation
  13355. * @param animation defines the source animation object
  13356. * @param scene defines the hosting scene
  13357. * @param host defines the initiating Animatable
  13358. */
  13359. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13360. private _preparePath;
  13361. /**
  13362. * Gets the animation from the runtime animation
  13363. */
  13364. get animation(): Animation;
  13365. /**
  13366. * Resets the runtime animation to the beginning
  13367. * @param restoreOriginal defines whether to restore the target property to the original value
  13368. */
  13369. reset(restoreOriginal?: boolean): void;
  13370. /**
  13371. * Specifies if the runtime animation is stopped
  13372. * @returns Boolean specifying if the runtime animation is stopped
  13373. */
  13374. isStopped(): boolean;
  13375. /**
  13376. * Disposes of the runtime animation
  13377. */
  13378. dispose(): void;
  13379. /**
  13380. * Apply the interpolated value to the target
  13381. * @param currentValue defines the value computed by the animation
  13382. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13383. */
  13384. setValue(currentValue: any, weight: number): void;
  13385. private _getOriginalValues;
  13386. private _setValue;
  13387. /**
  13388. * Gets the loop pmode of the runtime animation
  13389. * @returns Loop Mode
  13390. */
  13391. private _getCorrectLoopMode;
  13392. /**
  13393. * Move the current animation to a given frame
  13394. * @param frame defines the frame to move to
  13395. */
  13396. goToFrame(frame: number): void;
  13397. /**
  13398. * @hidden Internal use only
  13399. */
  13400. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13401. /**
  13402. * Execute the current animation
  13403. * @param delay defines the delay to add to the current frame
  13404. * @param from defines the lower bound of the animation range
  13405. * @param to defines the upper bound of the animation range
  13406. * @param loop defines if the current animation must loop
  13407. * @param speedRatio defines the current speed ratio
  13408. * @param weight defines the weight of the animation (default is -1 so no weight)
  13409. * @param onLoop optional callback called when animation loops
  13410. * @returns a boolean indicating if the animation is running
  13411. */
  13412. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13413. }
  13414. }
  13415. declare module "babylonjs/Animations/animatable" {
  13416. import { Animation } from "babylonjs/Animations/animation";
  13417. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13418. import { Nullable } from "babylonjs/types";
  13419. import { Observable } from "babylonjs/Misc/observable";
  13420. import { Scene } from "babylonjs/scene";
  13421. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13422. import { Node } from "babylonjs/node";
  13423. /**
  13424. * Class used to store an actual running animation
  13425. */
  13426. export class Animatable {
  13427. /** defines the target object */
  13428. target: any;
  13429. /** defines the starting frame number (default is 0) */
  13430. fromFrame: number;
  13431. /** defines the ending frame number (default is 100) */
  13432. toFrame: number;
  13433. /** defines if the animation must loop (default is false) */
  13434. loopAnimation: boolean;
  13435. /** defines a callback to call when animation ends if it is not looping */
  13436. onAnimationEnd?: (() => void) | null | undefined;
  13437. /** defines a callback to call when animation loops */
  13438. onAnimationLoop?: (() => void) | null | undefined;
  13439. private _localDelayOffset;
  13440. private _pausedDelay;
  13441. private _runtimeAnimations;
  13442. private _paused;
  13443. private _scene;
  13444. private _speedRatio;
  13445. private _weight;
  13446. private _syncRoot;
  13447. /**
  13448. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13449. * This will only apply for non looping animation (default is true)
  13450. */
  13451. disposeOnEnd: boolean;
  13452. /**
  13453. * Gets a boolean indicating if the animation has started
  13454. */
  13455. animationStarted: boolean;
  13456. /**
  13457. * Observer raised when the animation ends
  13458. */
  13459. onAnimationEndObservable: Observable<Animatable>;
  13460. /**
  13461. * Observer raised when the animation loops
  13462. */
  13463. onAnimationLoopObservable: Observable<Animatable>;
  13464. /**
  13465. * Gets the root Animatable used to synchronize and normalize animations
  13466. */
  13467. get syncRoot(): Nullable<Animatable>;
  13468. /**
  13469. * Gets the current frame of the first RuntimeAnimation
  13470. * Used to synchronize Animatables
  13471. */
  13472. get masterFrame(): number;
  13473. /**
  13474. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13475. */
  13476. get weight(): number;
  13477. set weight(value: number);
  13478. /**
  13479. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13480. */
  13481. get speedRatio(): number;
  13482. set speedRatio(value: number);
  13483. /**
  13484. * Creates a new Animatable
  13485. * @param scene defines the hosting scene
  13486. * @param target defines the target object
  13487. * @param fromFrame defines the starting frame number (default is 0)
  13488. * @param toFrame defines the ending frame number (default is 100)
  13489. * @param loopAnimation defines if the animation must loop (default is false)
  13490. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13491. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13492. * @param animations defines a group of animation to add to the new Animatable
  13493. * @param onAnimationLoop defines a callback to call when animation loops
  13494. */
  13495. constructor(scene: Scene,
  13496. /** defines the target object */
  13497. target: any,
  13498. /** defines the starting frame number (default is 0) */
  13499. fromFrame?: number,
  13500. /** defines the ending frame number (default is 100) */
  13501. toFrame?: number,
  13502. /** defines if the animation must loop (default is false) */
  13503. loopAnimation?: boolean, speedRatio?: number,
  13504. /** defines a callback to call when animation ends if it is not looping */
  13505. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13506. /** defines a callback to call when animation loops */
  13507. onAnimationLoop?: (() => void) | null | undefined);
  13508. /**
  13509. * Synchronize and normalize current Animatable with a source Animatable
  13510. * This is useful when using animation weights and when animations are not of the same length
  13511. * @param root defines the root Animatable to synchronize with
  13512. * @returns the current Animatable
  13513. */
  13514. syncWith(root: Animatable): Animatable;
  13515. /**
  13516. * Gets the list of runtime animations
  13517. * @returns an array of RuntimeAnimation
  13518. */
  13519. getAnimations(): RuntimeAnimation[];
  13520. /**
  13521. * Adds more animations to the current animatable
  13522. * @param target defines the target of the animations
  13523. * @param animations defines the new animations to add
  13524. */
  13525. appendAnimations(target: any, animations: Animation[]): void;
  13526. /**
  13527. * Gets the source animation for a specific property
  13528. * @param property defines the propertyu to look for
  13529. * @returns null or the source animation for the given property
  13530. */
  13531. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13532. /**
  13533. * Gets the runtime animation for a specific property
  13534. * @param property defines the propertyu to look for
  13535. * @returns null or the runtime animation for the given property
  13536. */
  13537. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13538. /**
  13539. * Resets the animatable to its original state
  13540. */
  13541. reset(): void;
  13542. /**
  13543. * Allows the animatable to blend with current running animations
  13544. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13545. * @param blendingSpeed defines the blending speed to use
  13546. */
  13547. enableBlending(blendingSpeed: number): void;
  13548. /**
  13549. * Disable animation blending
  13550. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13551. */
  13552. disableBlending(): void;
  13553. /**
  13554. * Jump directly to a given frame
  13555. * @param frame defines the frame to jump to
  13556. */
  13557. goToFrame(frame: number): void;
  13558. /**
  13559. * Pause the animation
  13560. */
  13561. pause(): void;
  13562. /**
  13563. * Restart the animation
  13564. */
  13565. restart(): void;
  13566. private _raiseOnAnimationEnd;
  13567. /**
  13568. * Stop and delete the current animation
  13569. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13570. * @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)
  13571. */
  13572. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13573. /**
  13574. * Wait asynchronously for the animation to end
  13575. * @returns a promise which will be fullfilled when the animation ends
  13576. */
  13577. waitAsync(): Promise<Animatable>;
  13578. /** @hidden */
  13579. _animate(delay: number): boolean;
  13580. }
  13581. module "babylonjs/scene" {
  13582. interface Scene {
  13583. /** @hidden */
  13584. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13585. /** @hidden */
  13586. _processLateAnimationBindingsForMatrices(holder: {
  13587. totalWeight: number;
  13588. animations: RuntimeAnimation[];
  13589. originalValue: Matrix;
  13590. }): any;
  13591. /** @hidden */
  13592. _processLateAnimationBindingsForQuaternions(holder: {
  13593. totalWeight: number;
  13594. animations: RuntimeAnimation[];
  13595. originalValue: Quaternion;
  13596. }, refQuaternion: Quaternion): Quaternion;
  13597. /** @hidden */
  13598. _processLateAnimationBindings(): void;
  13599. /**
  13600. * Will start the animation sequence of a given target
  13601. * @param target defines the target
  13602. * @param from defines from which frame should animation start
  13603. * @param to defines until which frame should animation run.
  13604. * @param weight defines the weight to apply to the animation (1.0 by default)
  13605. * @param loop defines if the animation loops
  13606. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13607. * @param onAnimationEnd defines the function to be executed when the animation ends
  13608. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13609. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13610. * @param onAnimationLoop defines the callback to call when an animation loops
  13611. * @returns the animatable object created for this animation
  13612. */
  13613. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13614. /**
  13615. * Will start the animation sequence of a given target
  13616. * @param target defines the target
  13617. * @param from defines from which frame should animation start
  13618. * @param to defines until which frame should animation run.
  13619. * @param loop defines if the animation loops
  13620. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13621. * @param onAnimationEnd defines the function to be executed when the animation ends
  13622. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13623. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13624. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13625. * @param onAnimationLoop defines the callback to call when an animation loops
  13626. * @returns the animatable object created for this animation
  13627. */
  13628. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13629. /**
  13630. * Will start the animation sequence of a given target and its hierarchy
  13631. * @param target defines the target
  13632. * @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.
  13633. * @param from defines from which frame should animation start
  13634. * @param to defines until which frame should animation run.
  13635. * @param loop defines if the animation loops
  13636. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13637. * @param onAnimationEnd defines the function to be executed when the animation ends
  13638. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13639. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13640. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13641. * @param onAnimationLoop defines the callback to call when an animation loops
  13642. * @returns the list of created animatables
  13643. */
  13644. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13645. /**
  13646. * Begin a new animation on a given node
  13647. * @param target defines the target where the animation will take place
  13648. * @param animations defines the list of animations to start
  13649. * @param from defines the initial value
  13650. * @param to defines the final value
  13651. * @param loop defines if you want animation to loop (off by default)
  13652. * @param speedRatio defines the speed ratio to apply to all animations
  13653. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13654. * @param onAnimationLoop defines the callback to call when an animation loops
  13655. * @returns the list of created animatables
  13656. */
  13657. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13658. /**
  13659. * Begin a new animation on a given node and its hierarchy
  13660. * @param target defines the root node where the animation will take place
  13661. * @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.
  13662. * @param animations defines the list of animations to start
  13663. * @param from defines the initial value
  13664. * @param to defines the final value
  13665. * @param loop defines if you want animation to loop (off by default)
  13666. * @param speedRatio defines the speed ratio to apply to all animations
  13667. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13668. * @param onAnimationLoop defines the callback to call when an animation loops
  13669. * @returns the list of animatables created for all nodes
  13670. */
  13671. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13672. /**
  13673. * Gets the animatable associated with a specific target
  13674. * @param target defines the target of the animatable
  13675. * @returns the required animatable if found
  13676. */
  13677. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13678. /**
  13679. * Gets all animatables associated with a given target
  13680. * @param target defines the target to look animatables for
  13681. * @returns an array of Animatables
  13682. */
  13683. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13684. /**
  13685. * Stops and removes all animations that have been applied to the scene
  13686. */
  13687. stopAllAnimations(): void;
  13688. /**
  13689. * Gets the current delta time used by animation engine
  13690. */
  13691. deltaTime: number;
  13692. }
  13693. }
  13694. module "babylonjs/Bones/bone" {
  13695. interface Bone {
  13696. /**
  13697. * Copy an animation range from another bone
  13698. * @param source defines the source bone
  13699. * @param rangeName defines the range name to copy
  13700. * @param frameOffset defines the frame offset
  13701. * @param rescaleAsRequired defines if rescaling must be applied if required
  13702. * @param skelDimensionsRatio defines the scaling ratio
  13703. * @returns true if operation was successful
  13704. */
  13705. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13706. }
  13707. }
  13708. }
  13709. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13710. /**
  13711. * Class used to override all child animations of a given target
  13712. */
  13713. export class AnimationPropertiesOverride {
  13714. /**
  13715. * Gets or sets a value indicating if animation blending must be used
  13716. */
  13717. enableBlending: boolean;
  13718. /**
  13719. * Gets or sets the blending speed to use when enableBlending is true
  13720. */
  13721. blendingSpeed: number;
  13722. /**
  13723. * Gets or sets the default loop mode to use
  13724. */
  13725. loopMode: number;
  13726. }
  13727. }
  13728. declare module "babylonjs/Bones/skeleton" {
  13729. import { Bone } from "babylonjs/Bones/bone";
  13730. import { Observable } from "babylonjs/Misc/observable";
  13731. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13732. import { Scene } from "babylonjs/scene";
  13733. import { Nullable } from "babylonjs/types";
  13734. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13735. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13736. import { Animatable } from "babylonjs/Animations/animatable";
  13737. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13738. import { Animation } from "babylonjs/Animations/animation";
  13739. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13740. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13741. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13742. /**
  13743. * Class used to handle skinning animations
  13744. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13745. */
  13746. export class Skeleton implements IAnimatable {
  13747. /** defines the skeleton name */
  13748. name: string;
  13749. /** defines the skeleton Id */
  13750. id: string;
  13751. /**
  13752. * Defines the list of child bones
  13753. */
  13754. bones: Bone[];
  13755. /**
  13756. * Defines an estimate of the dimension of the skeleton at rest
  13757. */
  13758. dimensionsAtRest: Vector3;
  13759. /**
  13760. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13761. */
  13762. needInitialSkinMatrix: boolean;
  13763. /**
  13764. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13765. */
  13766. overrideMesh: Nullable<AbstractMesh>;
  13767. /**
  13768. * Gets the list of animations attached to this skeleton
  13769. */
  13770. animations: Array<Animation>;
  13771. private _scene;
  13772. private _isDirty;
  13773. private _transformMatrices;
  13774. private _transformMatrixTexture;
  13775. private _meshesWithPoseMatrix;
  13776. private _animatables;
  13777. private _identity;
  13778. private _synchronizedWithMesh;
  13779. private _ranges;
  13780. private _lastAbsoluteTransformsUpdateId;
  13781. private _canUseTextureForBones;
  13782. private _uniqueId;
  13783. /** @hidden */
  13784. _numBonesWithLinkedTransformNode: number;
  13785. /** @hidden */
  13786. _hasWaitingData: Nullable<boolean>;
  13787. /**
  13788. * Specifies if the skeleton should be serialized
  13789. */
  13790. doNotSerialize: boolean;
  13791. private _useTextureToStoreBoneMatrices;
  13792. /**
  13793. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13794. * Please note that this option is not available if the hardware does not support it
  13795. */
  13796. get useTextureToStoreBoneMatrices(): boolean;
  13797. set useTextureToStoreBoneMatrices(value: boolean);
  13798. private _animationPropertiesOverride;
  13799. /**
  13800. * Gets or sets the animation properties override
  13801. */
  13802. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  13803. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  13804. /**
  13805. * List of inspectable custom properties (used by the Inspector)
  13806. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13807. */
  13808. inspectableCustomProperties: IInspectable[];
  13809. /**
  13810. * An observable triggered before computing the skeleton's matrices
  13811. */
  13812. onBeforeComputeObservable: Observable<Skeleton>;
  13813. /**
  13814. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13815. */
  13816. get isUsingTextureForMatrices(): boolean;
  13817. /**
  13818. * Gets the unique ID of this skeleton
  13819. */
  13820. get uniqueId(): number;
  13821. /**
  13822. * Creates a new skeleton
  13823. * @param name defines the skeleton name
  13824. * @param id defines the skeleton Id
  13825. * @param scene defines the hosting scene
  13826. */
  13827. constructor(
  13828. /** defines the skeleton name */
  13829. name: string,
  13830. /** defines the skeleton Id */
  13831. id: string, scene: Scene);
  13832. /**
  13833. * Gets the current object class name.
  13834. * @return the class name
  13835. */
  13836. getClassName(): string;
  13837. /**
  13838. * Returns an array containing the root bones
  13839. * @returns an array containing the root bones
  13840. */
  13841. getChildren(): Array<Bone>;
  13842. /**
  13843. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13844. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13845. * @returns a Float32Array containing matrices data
  13846. */
  13847. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13848. /**
  13849. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13850. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13851. * @returns a raw texture containing the data
  13852. */
  13853. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13854. /**
  13855. * Gets the current hosting scene
  13856. * @returns a scene object
  13857. */
  13858. getScene(): Scene;
  13859. /**
  13860. * Gets a string representing the current skeleton data
  13861. * @param fullDetails defines a boolean indicating if we want a verbose version
  13862. * @returns a string representing the current skeleton data
  13863. */
  13864. toString(fullDetails?: boolean): string;
  13865. /**
  13866. * Get bone's index searching by name
  13867. * @param name defines bone's name to search for
  13868. * @return the indice of the bone. Returns -1 if not found
  13869. */
  13870. getBoneIndexByName(name: string): number;
  13871. /**
  13872. * Creater a new animation range
  13873. * @param name defines the name of the range
  13874. * @param from defines the start key
  13875. * @param to defines the end key
  13876. */
  13877. createAnimationRange(name: string, from: number, to: number): void;
  13878. /**
  13879. * Delete a specific animation range
  13880. * @param name defines the name of the range
  13881. * @param deleteFrames defines if frames must be removed as well
  13882. */
  13883. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13884. /**
  13885. * Gets a specific animation range
  13886. * @param name defines the name of the range to look for
  13887. * @returns the requested animation range or null if not found
  13888. */
  13889. getAnimationRange(name: string): Nullable<AnimationRange>;
  13890. /**
  13891. * Gets the list of all animation ranges defined on this skeleton
  13892. * @returns an array
  13893. */
  13894. getAnimationRanges(): Nullable<AnimationRange>[];
  13895. /**
  13896. * Copy animation range from a source skeleton.
  13897. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13898. * @param source defines the source skeleton
  13899. * @param name defines the name of the range to copy
  13900. * @param rescaleAsRequired defines if rescaling must be applied if required
  13901. * @returns true if operation was successful
  13902. */
  13903. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13904. /**
  13905. * Forces the skeleton to go to rest pose
  13906. */
  13907. returnToRest(): void;
  13908. private _getHighestAnimationFrame;
  13909. /**
  13910. * Begin a specific animation range
  13911. * @param name defines the name of the range to start
  13912. * @param loop defines if looping must be turned on (false by default)
  13913. * @param speedRatio defines the speed ratio to apply (1 by default)
  13914. * @param onAnimationEnd defines a callback which will be called when animation will end
  13915. * @returns a new animatable
  13916. */
  13917. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13918. /** @hidden */
  13919. _markAsDirty(): void;
  13920. /** @hidden */
  13921. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13922. /** @hidden */
  13923. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13924. private _computeTransformMatrices;
  13925. /**
  13926. * Build all resources required to render a skeleton
  13927. */
  13928. prepare(): void;
  13929. /**
  13930. * Gets the list of animatables currently running for this skeleton
  13931. * @returns an array of animatables
  13932. */
  13933. getAnimatables(): IAnimatable[];
  13934. /**
  13935. * Clone the current skeleton
  13936. * @param name defines the name of the new skeleton
  13937. * @param id defines the id of the new skeleton
  13938. * @returns the new skeleton
  13939. */
  13940. clone(name: string, id?: string): Skeleton;
  13941. /**
  13942. * Enable animation blending for this skeleton
  13943. * @param blendingSpeed defines the blending speed to apply
  13944. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13945. */
  13946. enableBlending(blendingSpeed?: number): void;
  13947. /**
  13948. * Releases all resources associated with the current skeleton
  13949. */
  13950. dispose(): void;
  13951. /**
  13952. * Serialize the skeleton in a JSON object
  13953. * @returns a JSON object
  13954. */
  13955. serialize(): any;
  13956. /**
  13957. * Creates a new skeleton from serialized data
  13958. * @param parsedSkeleton defines the serialized data
  13959. * @param scene defines the hosting scene
  13960. * @returns a new skeleton
  13961. */
  13962. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13963. /**
  13964. * Compute all node absolute transforms
  13965. * @param forceUpdate defines if computation must be done even if cache is up to date
  13966. */
  13967. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13968. /**
  13969. * Gets the root pose matrix
  13970. * @returns a matrix
  13971. */
  13972. getPoseMatrix(): Nullable<Matrix>;
  13973. /**
  13974. * Sorts bones per internal index
  13975. */
  13976. sortBones(): void;
  13977. private _sortBones;
  13978. }
  13979. }
  13980. declare module "babylonjs/Bones/bone" {
  13981. import { Skeleton } from "babylonjs/Bones/skeleton";
  13982. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13983. import { Nullable } from "babylonjs/types";
  13984. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13985. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13986. import { Node } from "babylonjs/node";
  13987. import { Space } from "babylonjs/Maths/math.axis";
  13988. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13989. /**
  13990. * Class used to store bone information
  13991. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13992. */
  13993. export class Bone extends Node {
  13994. /**
  13995. * defines the bone name
  13996. */
  13997. name: string;
  13998. private static _tmpVecs;
  13999. private static _tmpQuat;
  14000. private static _tmpMats;
  14001. /**
  14002. * Gets the list of child bones
  14003. */
  14004. children: Bone[];
  14005. /** Gets the animations associated with this bone */
  14006. animations: import("babylonjs/Animations/animation").Animation[];
  14007. /**
  14008. * Gets or sets bone length
  14009. */
  14010. length: number;
  14011. /**
  14012. * @hidden Internal only
  14013. * Set this value to map this bone to a different index in the transform matrices
  14014. * Set this value to -1 to exclude the bone from the transform matrices
  14015. */
  14016. _index: Nullable<number>;
  14017. private _skeleton;
  14018. private _localMatrix;
  14019. private _restPose;
  14020. private _baseMatrix;
  14021. private _absoluteTransform;
  14022. private _invertedAbsoluteTransform;
  14023. private _parent;
  14024. private _scalingDeterminant;
  14025. private _worldTransform;
  14026. private _localScaling;
  14027. private _localRotation;
  14028. private _localPosition;
  14029. private _needToDecompose;
  14030. private _needToCompose;
  14031. /** @hidden */
  14032. _linkedTransformNode: Nullable<TransformNode>;
  14033. /** @hidden */
  14034. _waitingTransformNodeId: Nullable<string>;
  14035. /** @hidden */
  14036. get _matrix(): Matrix;
  14037. /** @hidden */
  14038. set _matrix(value: Matrix);
  14039. /**
  14040. * Create a new bone
  14041. * @param name defines the bone name
  14042. * @param skeleton defines the parent skeleton
  14043. * @param parentBone defines the parent (can be null if the bone is the root)
  14044. * @param localMatrix defines the local matrix
  14045. * @param restPose defines the rest pose matrix
  14046. * @param baseMatrix defines the base matrix
  14047. * @param index defines index of the bone in the hiearchy
  14048. */
  14049. constructor(
  14050. /**
  14051. * defines the bone name
  14052. */
  14053. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14054. /**
  14055. * Gets the current object class name.
  14056. * @return the class name
  14057. */
  14058. getClassName(): string;
  14059. /**
  14060. * Gets the parent skeleton
  14061. * @returns a skeleton
  14062. */
  14063. getSkeleton(): Skeleton;
  14064. /**
  14065. * Gets parent bone
  14066. * @returns a bone or null if the bone is the root of the bone hierarchy
  14067. */
  14068. getParent(): Nullable<Bone>;
  14069. /**
  14070. * Returns an array containing the root bones
  14071. * @returns an array containing the root bones
  14072. */
  14073. getChildren(): Array<Bone>;
  14074. /**
  14075. * Gets the node index in matrix array generated for rendering
  14076. * @returns the node index
  14077. */
  14078. getIndex(): number;
  14079. /**
  14080. * Sets the parent bone
  14081. * @param parent defines the parent (can be null if the bone is the root)
  14082. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14083. */
  14084. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14085. /**
  14086. * Gets the local matrix
  14087. * @returns a matrix
  14088. */
  14089. getLocalMatrix(): Matrix;
  14090. /**
  14091. * Gets the base matrix (initial matrix which remains unchanged)
  14092. * @returns a matrix
  14093. */
  14094. getBaseMatrix(): Matrix;
  14095. /**
  14096. * Gets the rest pose matrix
  14097. * @returns a matrix
  14098. */
  14099. getRestPose(): Matrix;
  14100. /**
  14101. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14102. */
  14103. getWorldMatrix(): Matrix;
  14104. /**
  14105. * Sets the local matrix to rest pose matrix
  14106. */
  14107. returnToRest(): void;
  14108. /**
  14109. * Gets the inverse of the absolute transform matrix.
  14110. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14111. * @returns a matrix
  14112. */
  14113. getInvertedAbsoluteTransform(): Matrix;
  14114. /**
  14115. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14116. * @returns a matrix
  14117. */
  14118. getAbsoluteTransform(): Matrix;
  14119. /**
  14120. * Links with the given transform node.
  14121. * The local matrix of this bone is copied from the transform node every frame.
  14122. * @param transformNode defines the transform node to link to
  14123. */
  14124. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14125. /**
  14126. * Gets the node used to drive the bone's transformation
  14127. * @returns a transform node or null
  14128. */
  14129. getTransformNode(): Nullable<TransformNode>;
  14130. /** Gets or sets current position (in local space) */
  14131. get position(): Vector3;
  14132. set position(newPosition: Vector3);
  14133. /** Gets or sets current rotation (in local space) */
  14134. get rotation(): Vector3;
  14135. set rotation(newRotation: Vector3);
  14136. /** Gets or sets current rotation quaternion (in local space) */
  14137. get rotationQuaternion(): Quaternion;
  14138. set rotationQuaternion(newRotation: Quaternion);
  14139. /** Gets or sets current scaling (in local space) */
  14140. get scaling(): Vector3;
  14141. set scaling(newScaling: Vector3);
  14142. /**
  14143. * Gets the animation properties override
  14144. */
  14145. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14146. private _decompose;
  14147. private _compose;
  14148. /**
  14149. * Update the base and local matrices
  14150. * @param matrix defines the new base or local matrix
  14151. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14152. * @param updateLocalMatrix defines if the local matrix should be updated
  14153. */
  14154. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14155. /** @hidden */
  14156. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14157. /**
  14158. * Flag the bone as dirty (Forcing it to update everything)
  14159. */
  14160. markAsDirty(): void;
  14161. /** @hidden */
  14162. _markAsDirtyAndCompose(): void;
  14163. private _markAsDirtyAndDecompose;
  14164. /**
  14165. * Translate the bone in local or world space
  14166. * @param vec The amount to translate the bone
  14167. * @param space The space that the translation is in
  14168. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14169. */
  14170. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14171. /**
  14172. * Set the postion of the bone in local or world space
  14173. * @param position The position to set the bone
  14174. * @param space The space that the position is in
  14175. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14176. */
  14177. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14178. /**
  14179. * Set the absolute position of the bone (world space)
  14180. * @param position The position to set the bone
  14181. * @param mesh The mesh that this bone is attached to
  14182. */
  14183. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14184. /**
  14185. * Scale the bone on the x, y and z axes (in local space)
  14186. * @param x The amount to scale the bone on the x axis
  14187. * @param y The amount to scale the bone on the y axis
  14188. * @param z The amount to scale the bone on the z axis
  14189. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14190. */
  14191. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14192. /**
  14193. * Set the bone scaling in local space
  14194. * @param scale defines the scaling vector
  14195. */
  14196. setScale(scale: Vector3): void;
  14197. /**
  14198. * Gets the current scaling in local space
  14199. * @returns the current scaling vector
  14200. */
  14201. getScale(): Vector3;
  14202. /**
  14203. * Gets the current scaling in local space and stores it in a target vector
  14204. * @param result defines the target vector
  14205. */
  14206. getScaleToRef(result: Vector3): void;
  14207. /**
  14208. * Set the yaw, pitch, and roll of the bone in local or world space
  14209. * @param yaw The rotation of the bone on the y axis
  14210. * @param pitch The rotation of the bone on the x axis
  14211. * @param roll The rotation of the bone on the z axis
  14212. * @param space The space that the axes of rotation are in
  14213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14214. */
  14215. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14216. /**
  14217. * Add a rotation to the bone on an axis in local or world space
  14218. * @param axis The axis to rotate the bone on
  14219. * @param amount The amount to rotate the bone
  14220. * @param space The space that the axis is in
  14221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14222. */
  14223. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14224. /**
  14225. * Set the rotation of the bone to a particular axis angle in local or world space
  14226. * @param axis The axis to rotate the bone on
  14227. * @param angle The angle that the bone should be rotated to
  14228. * @param space The space that the axis is in
  14229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14230. */
  14231. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14232. /**
  14233. * Set the euler rotation of the bone in local of world space
  14234. * @param rotation The euler rotation that the bone should be set to
  14235. * @param space The space that the rotation is in
  14236. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14237. */
  14238. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14239. /**
  14240. * Set the quaternion rotation of the bone in local of world space
  14241. * @param quat The quaternion rotation that the bone should be set to
  14242. * @param space The space that the rotation is in
  14243. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14244. */
  14245. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14246. /**
  14247. * Set the rotation matrix of the bone in local of world space
  14248. * @param rotMat The rotation matrix that the bone should be set to
  14249. * @param space The space that the rotation is in
  14250. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14251. */
  14252. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14253. private _rotateWithMatrix;
  14254. private _getNegativeRotationToRef;
  14255. /**
  14256. * Get the position of the bone in local or world space
  14257. * @param space The space that the returned position is in
  14258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14259. * @returns The position of the bone
  14260. */
  14261. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14262. /**
  14263. * Copy the position of the bone to a vector3 in local or world space
  14264. * @param space The space that the returned position is in
  14265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14266. * @param result The vector3 to copy the position to
  14267. */
  14268. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14269. /**
  14270. * Get the absolute position of the bone (world space)
  14271. * @param mesh The mesh that this bone is attached to
  14272. * @returns The absolute position of the bone
  14273. */
  14274. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14275. /**
  14276. * Copy the absolute position of the bone (world space) to the result param
  14277. * @param mesh The mesh that this bone is attached to
  14278. * @param result The vector3 to copy the absolute position to
  14279. */
  14280. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14281. /**
  14282. * Compute the absolute transforms of this bone and its children
  14283. */
  14284. computeAbsoluteTransforms(): void;
  14285. /**
  14286. * Get the world direction from an axis that is in the local space of the bone
  14287. * @param localAxis The local direction that is used to compute the world direction
  14288. * @param mesh The mesh that this bone is attached to
  14289. * @returns The world direction
  14290. */
  14291. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14292. /**
  14293. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14294. * @param localAxis The local direction that is used to compute the world direction
  14295. * @param mesh The mesh that this bone is attached to
  14296. * @param result The vector3 that the world direction will be copied to
  14297. */
  14298. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14299. /**
  14300. * Get the euler rotation of the bone in local or world space
  14301. * @param space The space that the rotation should be in
  14302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14303. * @returns The euler rotation
  14304. */
  14305. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14306. /**
  14307. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14308. * @param space The space that the rotation should be in
  14309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14310. * @param result The vector3 that the rotation should be copied to
  14311. */
  14312. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14313. /**
  14314. * Get the quaternion rotation of the bone in either local or world space
  14315. * @param space The space that the rotation should be in
  14316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14317. * @returns The quaternion rotation
  14318. */
  14319. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14320. /**
  14321. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14322. * @param space The space that the rotation should be in
  14323. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14324. * @param result The quaternion that the rotation should be copied to
  14325. */
  14326. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14327. /**
  14328. * Get the rotation matrix of the bone in local or world space
  14329. * @param space The space that the rotation should be in
  14330. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14331. * @returns The rotation matrix
  14332. */
  14333. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14334. /**
  14335. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14336. * @param space The space that the rotation should be in
  14337. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14338. * @param result The quaternion that the rotation should be copied to
  14339. */
  14340. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14341. /**
  14342. * Get the world position of a point that is in the local space of the bone
  14343. * @param position The local position
  14344. * @param mesh The mesh that this bone is attached to
  14345. * @returns The world position
  14346. */
  14347. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14348. /**
  14349. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14350. * @param position The local position
  14351. * @param mesh The mesh that this bone is attached to
  14352. * @param result The vector3 that the world position should be copied to
  14353. */
  14354. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14355. /**
  14356. * Get the local position of a point that is in world space
  14357. * @param position The world position
  14358. * @param mesh The mesh that this bone is attached to
  14359. * @returns The local position
  14360. */
  14361. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14362. /**
  14363. * Get the local position of a point that is in world space and copy it to the result param
  14364. * @param position The world position
  14365. * @param mesh The mesh that this bone is attached to
  14366. * @param result The vector3 that the local position should be copied to
  14367. */
  14368. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14369. }
  14370. }
  14371. declare module "babylonjs/Meshes/transformNode" {
  14372. import { DeepImmutable } from "babylonjs/types";
  14373. import { Observable } from "babylonjs/Misc/observable";
  14374. import { Nullable } from "babylonjs/types";
  14375. import { Camera } from "babylonjs/Cameras/camera";
  14376. import { Scene } from "babylonjs/scene";
  14377. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14378. import { Node } from "babylonjs/node";
  14379. import { Bone } from "babylonjs/Bones/bone";
  14380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14381. import { Space } from "babylonjs/Maths/math.axis";
  14382. /**
  14383. * 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.
  14384. * @see https://doc.babylonjs.com/how_to/transformnode
  14385. */
  14386. export class TransformNode extends Node {
  14387. /**
  14388. * Object will not rotate to face the camera
  14389. */
  14390. static BILLBOARDMODE_NONE: number;
  14391. /**
  14392. * Object will rotate to face the camera but only on the x axis
  14393. */
  14394. static BILLBOARDMODE_X: number;
  14395. /**
  14396. * Object will rotate to face the camera but only on the y axis
  14397. */
  14398. static BILLBOARDMODE_Y: number;
  14399. /**
  14400. * Object will rotate to face the camera but only on the z axis
  14401. */
  14402. static BILLBOARDMODE_Z: number;
  14403. /**
  14404. * Object will rotate to face the camera
  14405. */
  14406. static BILLBOARDMODE_ALL: number;
  14407. /**
  14408. * Object will rotate to face the camera's position instead of orientation
  14409. */
  14410. static BILLBOARDMODE_USE_POSITION: number;
  14411. private _forward;
  14412. private _forwardInverted;
  14413. private _up;
  14414. private _right;
  14415. private _rightInverted;
  14416. private _position;
  14417. private _rotation;
  14418. private _rotationQuaternion;
  14419. protected _scaling: Vector3;
  14420. protected _isDirty: boolean;
  14421. private _transformToBoneReferal;
  14422. private _isAbsoluteSynced;
  14423. private _billboardMode;
  14424. /**
  14425. * Gets or sets the billboard mode. Default is 0.
  14426. *
  14427. * | Value | Type | Description |
  14428. * | --- | --- | --- |
  14429. * | 0 | BILLBOARDMODE_NONE | |
  14430. * | 1 | BILLBOARDMODE_X | |
  14431. * | 2 | BILLBOARDMODE_Y | |
  14432. * | 4 | BILLBOARDMODE_Z | |
  14433. * | 7 | BILLBOARDMODE_ALL | |
  14434. *
  14435. */
  14436. get billboardMode(): number;
  14437. set billboardMode(value: number);
  14438. private _preserveParentRotationForBillboard;
  14439. /**
  14440. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14441. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14442. */
  14443. get preserveParentRotationForBillboard(): boolean;
  14444. set preserveParentRotationForBillboard(value: boolean);
  14445. /**
  14446. * 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
  14447. */
  14448. scalingDeterminant: number;
  14449. private _infiniteDistance;
  14450. /**
  14451. * Gets or sets the distance of the object to max, often used by skybox
  14452. */
  14453. get infiniteDistance(): boolean;
  14454. set infiniteDistance(value: boolean);
  14455. /**
  14456. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14457. * By default the system will update normals to compensate
  14458. */
  14459. ignoreNonUniformScaling: boolean;
  14460. /**
  14461. * 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
  14462. */
  14463. reIntegrateRotationIntoRotationQuaternion: boolean;
  14464. /** @hidden */
  14465. _poseMatrix: Nullable<Matrix>;
  14466. /** @hidden */
  14467. _localMatrix: Matrix;
  14468. private _usePivotMatrix;
  14469. private _absolutePosition;
  14470. private _absoluteScaling;
  14471. private _absoluteRotationQuaternion;
  14472. private _pivotMatrix;
  14473. private _pivotMatrixInverse;
  14474. protected _postMultiplyPivotMatrix: boolean;
  14475. protected _isWorldMatrixFrozen: boolean;
  14476. /** @hidden */
  14477. _indexInSceneTransformNodesArray: number;
  14478. /**
  14479. * An event triggered after the world matrix is updated
  14480. */
  14481. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14482. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14483. /**
  14484. * Gets a string identifying the name of the class
  14485. * @returns "TransformNode" string
  14486. */
  14487. getClassName(): string;
  14488. /**
  14489. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14490. */
  14491. get position(): Vector3;
  14492. set position(newPosition: Vector3);
  14493. /**
  14494. * 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)).
  14495. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14496. */
  14497. get rotation(): Vector3;
  14498. set rotation(newRotation: Vector3);
  14499. /**
  14500. * 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)).
  14501. */
  14502. get scaling(): Vector3;
  14503. set scaling(newScaling: Vector3);
  14504. /**
  14505. * 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).
  14506. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14507. */
  14508. get rotationQuaternion(): Nullable<Quaternion>;
  14509. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14510. /**
  14511. * The forward direction of that transform in world space.
  14512. */
  14513. get forward(): Vector3;
  14514. /**
  14515. * The up direction of that transform in world space.
  14516. */
  14517. get up(): Vector3;
  14518. /**
  14519. * The right direction of that transform in world space.
  14520. */
  14521. get right(): Vector3;
  14522. /**
  14523. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14524. * @param matrix the matrix to copy the pose from
  14525. * @returns this TransformNode.
  14526. */
  14527. updatePoseMatrix(matrix: Matrix): TransformNode;
  14528. /**
  14529. * Returns the mesh Pose matrix.
  14530. * @returns the pose matrix
  14531. */
  14532. getPoseMatrix(): Matrix;
  14533. /** @hidden */
  14534. _isSynchronized(): boolean;
  14535. /** @hidden */
  14536. _initCache(): void;
  14537. /**
  14538. * Flag the transform node as dirty (Forcing it to update everything)
  14539. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14540. * @returns this transform node
  14541. */
  14542. markAsDirty(property: string): TransformNode;
  14543. /**
  14544. * Returns the current mesh absolute position.
  14545. * Returns a Vector3.
  14546. */
  14547. get absolutePosition(): Vector3;
  14548. /**
  14549. * Returns the current mesh absolute scaling.
  14550. * Returns a Vector3.
  14551. */
  14552. get absoluteScaling(): Vector3;
  14553. /**
  14554. * Returns the current mesh absolute rotation.
  14555. * Returns a Quaternion.
  14556. */
  14557. get absoluteRotationQuaternion(): Quaternion;
  14558. /**
  14559. * Sets a new matrix to apply before all other transformation
  14560. * @param matrix defines the transform matrix
  14561. * @returns the current TransformNode
  14562. */
  14563. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14564. /**
  14565. * Sets a new pivot matrix to the current node
  14566. * @param matrix defines the new pivot matrix to use
  14567. * @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
  14568. * @returns the current TransformNode
  14569. */
  14570. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14571. /**
  14572. * Returns the mesh pivot matrix.
  14573. * Default : Identity.
  14574. * @returns the matrix
  14575. */
  14576. getPivotMatrix(): Matrix;
  14577. /**
  14578. * Instantiate (when possible) or clone that node with its hierarchy
  14579. * @param newParent defines the new parent to use for the instance (or clone)
  14580. * @param options defines options to configure how copy is done
  14581. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14582. * @returns an instance (or a clone) of the current node with its hiearchy
  14583. */
  14584. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14585. doNotInstantiate: boolean;
  14586. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14587. /**
  14588. * Prevents the World matrix to be computed any longer
  14589. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14590. * @returns the TransformNode.
  14591. */
  14592. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14593. /**
  14594. * Allows back the World matrix computation.
  14595. * @returns the TransformNode.
  14596. */
  14597. unfreezeWorldMatrix(): this;
  14598. /**
  14599. * True if the World matrix has been frozen.
  14600. */
  14601. get isWorldMatrixFrozen(): boolean;
  14602. /**
  14603. * Retuns the mesh absolute position in the World.
  14604. * @returns a Vector3.
  14605. */
  14606. getAbsolutePosition(): Vector3;
  14607. /**
  14608. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14609. * @param absolutePosition the absolute position to set
  14610. * @returns the TransformNode.
  14611. */
  14612. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14613. /**
  14614. * Sets the mesh position in its local space.
  14615. * @param vector3 the position to set in localspace
  14616. * @returns the TransformNode.
  14617. */
  14618. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14619. /**
  14620. * Returns the mesh position in the local space from the current World matrix values.
  14621. * @returns a new Vector3.
  14622. */
  14623. getPositionExpressedInLocalSpace(): Vector3;
  14624. /**
  14625. * Translates the mesh along the passed Vector3 in its local space.
  14626. * @param vector3 the distance to translate in localspace
  14627. * @returns the TransformNode.
  14628. */
  14629. locallyTranslate(vector3: Vector3): TransformNode;
  14630. private static _lookAtVectorCache;
  14631. /**
  14632. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14633. * @param targetPoint the position (must be in same space as current mesh) to look at
  14634. * @param yawCor optional yaw (y-axis) correction in radians
  14635. * @param pitchCor optional pitch (x-axis) correction in radians
  14636. * @param rollCor optional roll (z-axis) correction in radians
  14637. * @param space the choosen space of the target
  14638. * @returns the TransformNode.
  14639. */
  14640. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14641. /**
  14642. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14643. * This Vector3 is expressed in the World space.
  14644. * @param localAxis axis to rotate
  14645. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14646. */
  14647. getDirection(localAxis: Vector3): Vector3;
  14648. /**
  14649. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14650. * localAxis is expressed in the mesh local space.
  14651. * result is computed in the Wordl space from the mesh World matrix.
  14652. * @param localAxis axis to rotate
  14653. * @param result the resulting transformnode
  14654. * @returns this TransformNode.
  14655. */
  14656. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14657. /**
  14658. * Sets this transform node rotation to the given local axis.
  14659. * @param localAxis the axis in local space
  14660. * @param yawCor optional yaw (y-axis) correction in radians
  14661. * @param pitchCor optional pitch (x-axis) correction in radians
  14662. * @param rollCor optional roll (z-axis) correction in radians
  14663. * @returns this TransformNode
  14664. */
  14665. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14666. /**
  14667. * Sets a new pivot point to the current node
  14668. * @param point defines the new pivot point to use
  14669. * @param space defines if the point is in world or local space (local by default)
  14670. * @returns the current TransformNode
  14671. */
  14672. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14673. /**
  14674. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14675. * @returns the pivot point
  14676. */
  14677. getPivotPoint(): Vector3;
  14678. /**
  14679. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14680. * @param result the vector3 to store the result
  14681. * @returns this TransformNode.
  14682. */
  14683. getPivotPointToRef(result: Vector3): TransformNode;
  14684. /**
  14685. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14686. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14687. */
  14688. getAbsolutePivotPoint(): Vector3;
  14689. /**
  14690. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14691. * @param result vector3 to store the result
  14692. * @returns this TransformNode.
  14693. */
  14694. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14695. /**
  14696. * Defines the passed node as the parent of the current node.
  14697. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14698. * @see https://doc.babylonjs.com/how_to/parenting
  14699. * @param node the node ot set as the parent
  14700. * @returns this TransformNode.
  14701. */
  14702. setParent(node: Nullable<Node>): TransformNode;
  14703. private _nonUniformScaling;
  14704. /**
  14705. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14706. */
  14707. get nonUniformScaling(): boolean;
  14708. /** @hidden */
  14709. _updateNonUniformScalingState(value: boolean): boolean;
  14710. /**
  14711. * Attach the current TransformNode to another TransformNode associated with a bone
  14712. * @param bone Bone affecting the TransformNode
  14713. * @param affectedTransformNode TransformNode associated with the bone
  14714. * @returns this object
  14715. */
  14716. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14717. /**
  14718. * Detach the transform node if its associated with a bone
  14719. * @returns this object
  14720. */
  14721. detachFromBone(): TransformNode;
  14722. private static _rotationAxisCache;
  14723. /**
  14724. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14725. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14726. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14727. * The passed axis is also normalized.
  14728. * @param axis the axis to rotate around
  14729. * @param amount the amount to rotate in radians
  14730. * @param space Space to rotate in (Default: local)
  14731. * @returns the TransformNode.
  14732. */
  14733. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14734. /**
  14735. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14736. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14737. * The passed axis is also normalized. .
  14738. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14739. * @param point the point to rotate around
  14740. * @param axis the axis to rotate around
  14741. * @param amount the amount to rotate in radians
  14742. * @returns the TransformNode
  14743. */
  14744. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14745. /**
  14746. * Translates the mesh along the axis vector for the passed distance in the given space.
  14747. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14748. * @param axis the axis to translate in
  14749. * @param distance the distance to translate
  14750. * @param space Space to rotate in (Default: local)
  14751. * @returns the TransformNode.
  14752. */
  14753. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14754. /**
  14755. * Adds a rotation step to the mesh current rotation.
  14756. * x, y, z are Euler angles expressed in radians.
  14757. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14758. * This means this rotation is made in the mesh local space only.
  14759. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14760. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14761. * ```javascript
  14762. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14763. * ```
  14764. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14765. * 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.
  14766. * @param x Rotation to add
  14767. * @param y Rotation to add
  14768. * @param z Rotation to add
  14769. * @returns the TransformNode.
  14770. */
  14771. addRotation(x: number, y: number, z: number): TransformNode;
  14772. /**
  14773. * @hidden
  14774. */
  14775. protected _getEffectiveParent(): Nullable<Node>;
  14776. /**
  14777. * Computes the world matrix of the node
  14778. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14779. * @returns the world matrix
  14780. */
  14781. computeWorldMatrix(force?: boolean): Matrix;
  14782. protected _afterComputeWorldMatrix(): void;
  14783. /**
  14784. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14785. * @param func callback function to add
  14786. *
  14787. * @returns the TransformNode.
  14788. */
  14789. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14790. /**
  14791. * Removes a registered callback function.
  14792. * @param func callback function to remove
  14793. * @returns the TransformNode.
  14794. */
  14795. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14796. /**
  14797. * Gets the position of the current mesh in camera space
  14798. * @param camera defines the camera to use
  14799. * @returns a position
  14800. */
  14801. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14802. /**
  14803. * Returns the distance from the mesh to the active camera
  14804. * @param camera defines the camera to use
  14805. * @returns the distance
  14806. */
  14807. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14808. /**
  14809. * Clone the current transform node
  14810. * @param name Name of the new clone
  14811. * @param newParent New parent for the clone
  14812. * @param doNotCloneChildren Do not clone children hierarchy
  14813. * @returns the new transform node
  14814. */
  14815. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14816. /**
  14817. * Serializes the objects information.
  14818. * @param currentSerializationObject defines the object to serialize in
  14819. * @returns the serialized object
  14820. */
  14821. serialize(currentSerializationObject?: any): any;
  14822. /**
  14823. * Returns a new TransformNode object parsed from the source provided.
  14824. * @param parsedTransformNode is the source.
  14825. * @param scene the scne the object belongs to
  14826. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14827. * @returns a new TransformNode object parsed from the source provided.
  14828. */
  14829. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14830. /**
  14831. * Get all child-transformNodes of this node
  14832. * @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
  14833. * @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
  14834. * @returns an array of TransformNode
  14835. */
  14836. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14837. /**
  14838. * Releases resources associated with this transform node.
  14839. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14840. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14841. */
  14842. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14843. /**
  14844. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14845. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14846. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14847. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14848. * @returns the current mesh
  14849. */
  14850. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14851. private _syncAbsoluteScalingAndRotation;
  14852. }
  14853. }
  14854. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14855. import { Observable } from "babylonjs/Misc/observable";
  14856. import { Nullable } from "babylonjs/types";
  14857. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14858. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14859. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14860. import { Ray } from "babylonjs/Culling/ray";
  14861. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14862. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14863. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14864. /**
  14865. * Defines the types of pose enabled controllers that are supported
  14866. */
  14867. export enum PoseEnabledControllerType {
  14868. /**
  14869. * HTC Vive
  14870. */
  14871. VIVE = 0,
  14872. /**
  14873. * Oculus Rift
  14874. */
  14875. OCULUS = 1,
  14876. /**
  14877. * Windows mixed reality
  14878. */
  14879. WINDOWS = 2,
  14880. /**
  14881. * Samsung gear VR
  14882. */
  14883. GEAR_VR = 3,
  14884. /**
  14885. * Google Daydream
  14886. */
  14887. DAYDREAM = 4,
  14888. /**
  14889. * Generic
  14890. */
  14891. GENERIC = 5
  14892. }
  14893. /**
  14894. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14895. */
  14896. export interface MutableGamepadButton {
  14897. /**
  14898. * Value of the button/trigger
  14899. */
  14900. value: number;
  14901. /**
  14902. * If the button/trigger is currently touched
  14903. */
  14904. touched: boolean;
  14905. /**
  14906. * If the button/trigger is currently pressed
  14907. */
  14908. pressed: boolean;
  14909. }
  14910. /**
  14911. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14912. * @hidden
  14913. */
  14914. export interface ExtendedGamepadButton extends GamepadButton {
  14915. /**
  14916. * If the button/trigger is currently pressed
  14917. */
  14918. readonly pressed: boolean;
  14919. /**
  14920. * If the button/trigger is currently touched
  14921. */
  14922. readonly touched: boolean;
  14923. /**
  14924. * Value of the button/trigger
  14925. */
  14926. readonly value: number;
  14927. }
  14928. /** @hidden */
  14929. export interface _GamePadFactory {
  14930. /**
  14931. * Returns wether or not the current gamepad can be created for this type of controller.
  14932. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14933. * @returns true if it can be created, otherwise false
  14934. */
  14935. canCreate(gamepadInfo: any): boolean;
  14936. /**
  14937. * Creates a new instance of the Gamepad.
  14938. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14939. * @returns the new gamepad instance
  14940. */
  14941. create(gamepadInfo: any): Gamepad;
  14942. }
  14943. /**
  14944. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14945. */
  14946. export class PoseEnabledControllerHelper {
  14947. /** @hidden */
  14948. static _ControllerFactories: _GamePadFactory[];
  14949. /** @hidden */
  14950. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14951. /**
  14952. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14953. * @param vrGamepad the gamepad to initialized
  14954. * @returns a vr controller of the type the gamepad identified as
  14955. */
  14956. static InitiateController(vrGamepad: any): Gamepad;
  14957. }
  14958. /**
  14959. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14960. */
  14961. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14962. /**
  14963. * If the controller is used in a webXR session
  14964. */
  14965. isXR: boolean;
  14966. private _deviceRoomPosition;
  14967. private _deviceRoomRotationQuaternion;
  14968. /**
  14969. * The device position in babylon space
  14970. */
  14971. devicePosition: Vector3;
  14972. /**
  14973. * The device rotation in babylon space
  14974. */
  14975. deviceRotationQuaternion: Quaternion;
  14976. /**
  14977. * The scale factor of the device in babylon space
  14978. */
  14979. deviceScaleFactor: number;
  14980. /**
  14981. * (Likely devicePosition should be used instead) The device position in its room space
  14982. */
  14983. position: Vector3;
  14984. /**
  14985. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14986. */
  14987. rotationQuaternion: Quaternion;
  14988. /**
  14989. * The type of controller (Eg. Windows mixed reality)
  14990. */
  14991. controllerType: PoseEnabledControllerType;
  14992. protected _calculatedPosition: Vector3;
  14993. private _calculatedRotation;
  14994. /**
  14995. * The raw pose from the device
  14996. */
  14997. rawPose: DevicePose;
  14998. private _trackPosition;
  14999. private _maxRotationDistFromHeadset;
  15000. private _draggedRoomRotation;
  15001. /**
  15002. * @hidden
  15003. */
  15004. _disableTrackPosition(fixedPosition: Vector3): void;
  15005. /**
  15006. * Internal, the mesh attached to the controller
  15007. * @hidden
  15008. */
  15009. _mesh: Nullable<AbstractMesh>;
  15010. private _poseControlledCamera;
  15011. private _leftHandSystemQuaternion;
  15012. /**
  15013. * Internal, matrix used to convert room space to babylon space
  15014. * @hidden
  15015. */
  15016. _deviceToWorld: Matrix;
  15017. /**
  15018. * Node to be used when casting a ray from the controller
  15019. * @hidden
  15020. */
  15021. _pointingPoseNode: Nullable<TransformNode>;
  15022. /**
  15023. * Name of the child mesh that can be used to cast a ray from the controller
  15024. */
  15025. static readonly POINTING_POSE: string;
  15026. /**
  15027. * Creates a new PoseEnabledController from a gamepad
  15028. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  15029. */
  15030. constructor(browserGamepad: any);
  15031. private _workingMatrix;
  15032. /**
  15033. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  15034. */
  15035. update(): void;
  15036. /**
  15037. * Updates only the pose device and mesh without doing any button event checking
  15038. */
  15039. protected _updatePoseAndMesh(): void;
  15040. /**
  15041. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  15042. * @param poseData raw pose fromthe device
  15043. */
  15044. updateFromDevice(poseData: DevicePose): void;
  15045. /**
  15046. * @hidden
  15047. */
  15048. _meshAttachedObservable: Observable<AbstractMesh>;
  15049. /**
  15050. * Attaches a mesh to the controller
  15051. * @param mesh the mesh to be attached
  15052. */
  15053. attachToMesh(mesh: AbstractMesh): void;
  15054. /**
  15055. * Attaches the controllers mesh to a camera
  15056. * @param camera the camera the mesh should be attached to
  15057. */
  15058. attachToPoseControlledCamera(camera: TargetCamera): void;
  15059. /**
  15060. * Disposes of the controller
  15061. */
  15062. dispose(): void;
  15063. /**
  15064. * The mesh that is attached to the controller
  15065. */
  15066. get mesh(): Nullable<AbstractMesh>;
  15067. /**
  15068. * Gets the ray of the controller in the direction the controller is pointing
  15069. * @param length the length the resulting ray should be
  15070. * @returns a ray in the direction the controller is pointing
  15071. */
  15072. getForwardRay(length?: number): Ray;
  15073. }
  15074. }
  15075. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  15076. import { Observable } from "babylonjs/Misc/observable";
  15077. import { Scene } from "babylonjs/scene";
  15078. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15079. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  15080. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  15081. import { Nullable } from "babylonjs/types";
  15082. /**
  15083. * Defines the WebVRController object that represents controllers tracked in 3D space
  15084. */
  15085. export abstract class WebVRController extends PoseEnabledController {
  15086. /**
  15087. * Internal, the default controller model for the controller
  15088. */
  15089. protected _defaultModel: Nullable<AbstractMesh>;
  15090. /**
  15091. * Fired when the trigger state has changed
  15092. */
  15093. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  15094. /**
  15095. * Fired when the main button state has changed
  15096. */
  15097. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15098. /**
  15099. * Fired when the secondary button state has changed
  15100. */
  15101. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  15102. /**
  15103. * Fired when the pad state has changed
  15104. */
  15105. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  15106. /**
  15107. * Fired when controllers stick values have changed
  15108. */
  15109. onPadValuesChangedObservable: Observable<StickValues>;
  15110. /**
  15111. * Array of button availible on the controller
  15112. */
  15113. protected _buttons: Array<MutableGamepadButton>;
  15114. private _onButtonStateChange;
  15115. /**
  15116. * Fired when a controller button's state has changed
  15117. * @param callback the callback containing the button that was modified
  15118. */
  15119. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  15120. /**
  15121. * X and Y axis corresponding to the controllers joystick
  15122. */
  15123. pad: StickValues;
  15124. /**
  15125. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  15126. */
  15127. hand: string;
  15128. /**
  15129. * The default controller model for the controller
  15130. */
  15131. get defaultModel(): Nullable<AbstractMesh>;
  15132. /**
  15133. * Creates a new WebVRController from a gamepad
  15134. * @param vrGamepad the gamepad that the WebVRController should be created from
  15135. */
  15136. constructor(vrGamepad: any);
  15137. /**
  15138. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  15139. */
  15140. update(): void;
  15141. /**
  15142. * Function to be called when a button is modified
  15143. */
  15144. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  15145. /**
  15146. * Loads a mesh and attaches it to the controller
  15147. * @param scene the scene the mesh should be added to
  15148. * @param meshLoaded callback for when the mesh has been loaded
  15149. */
  15150. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  15151. private _setButtonValue;
  15152. private _changes;
  15153. private _checkChanges;
  15154. /**
  15155. * Disposes of th webVRCOntroller
  15156. */
  15157. dispose(): void;
  15158. }
  15159. }
  15160. declare module "babylonjs/Lights/hemisphericLight" {
  15161. import { Nullable } from "babylonjs/types";
  15162. import { Scene } from "babylonjs/scene";
  15163. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15164. import { Color3 } from "babylonjs/Maths/math.color";
  15165. import { Effect } from "babylonjs/Materials/effect";
  15166. import { Light } from "babylonjs/Lights/light";
  15167. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  15168. /**
  15169. * The HemisphericLight simulates the ambient environment light,
  15170. * so the passed direction is the light reflection direction, not the incoming direction.
  15171. */
  15172. export class HemisphericLight extends Light {
  15173. /**
  15174. * The groundColor is the light in the opposite direction to the one specified during creation.
  15175. * 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.
  15176. */
  15177. groundColor: Color3;
  15178. /**
  15179. * The light reflection direction, not the incoming direction.
  15180. */
  15181. direction: Vector3;
  15182. /**
  15183. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  15184. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  15185. * The HemisphericLight can't cast shadows.
  15186. * Documentation : https://doc.babylonjs.com/babylon101/lights
  15187. * @param name The friendly name of the light
  15188. * @param direction The direction of the light reflection
  15189. * @param scene The scene the light belongs to
  15190. */
  15191. constructor(name: string, direction: Vector3, scene: Scene);
  15192. protected _buildUniformLayout(): void;
  15193. /**
  15194. * Returns the string "HemisphericLight".
  15195. * @return The class name
  15196. */
  15197. getClassName(): string;
  15198. /**
  15199. * Sets the HemisphericLight direction towards the passed target (Vector3).
  15200. * Returns the updated direction.
  15201. * @param target The target the direction should point to
  15202. * @return The computed direction
  15203. */
  15204. setDirectionToTarget(target: Vector3): Vector3;
  15205. /**
  15206. * Returns the shadow generator associated to the light.
  15207. * @returns Always null for hemispheric lights because it does not support shadows.
  15208. */
  15209. getShadowGenerator(): Nullable<IShadowGenerator>;
  15210. /**
  15211. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  15212. * @param effect The effect to update
  15213. * @param lightIndex The index of the light in the effect to update
  15214. * @returns The hemispheric light
  15215. */
  15216. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  15217. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  15218. /**
  15219. * Computes the world matrix of the node
  15220. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15221. * @param useWasUpdatedFlag defines a reserved property
  15222. * @returns the world matrix
  15223. */
  15224. computeWorldMatrix(): Matrix;
  15225. /**
  15226. * Returns the integer 3.
  15227. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15228. */
  15229. getTypeID(): number;
  15230. /**
  15231. * Prepares the list of defines specific to the light type.
  15232. * @param defines the list of defines
  15233. * @param lightIndex defines the index of the light for the effect
  15234. */
  15235. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15236. }
  15237. }
  15238. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15239. /** @hidden */
  15240. export var vrMultiviewToSingleviewPixelShader: {
  15241. name: string;
  15242. shader: string;
  15243. };
  15244. }
  15245. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15246. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15247. import { Scene } from "babylonjs/scene";
  15248. /**
  15249. * Renders to multiple views with a single draw call
  15250. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15251. */
  15252. export class MultiviewRenderTarget extends RenderTargetTexture {
  15253. /**
  15254. * Creates a multiview render target
  15255. * @param scene scene used with the render target
  15256. * @param size the size of the render target (used for each view)
  15257. */
  15258. constructor(scene: Scene, size?: number | {
  15259. width: number;
  15260. height: number;
  15261. } | {
  15262. ratio: number;
  15263. });
  15264. /**
  15265. * @hidden
  15266. * @param faceIndex the face index, if its a cube texture
  15267. */
  15268. _bindFrameBuffer(faceIndex?: number): void;
  15269. /**
  15270. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15271. * @returns the view count
  15272. */
  15273. getViewCount(): number;
  15274. }
  15275. }
  15276. declare module "babylonjs/Maths/math.frustum" {
  15277. import { Matrix } from "babylonjs/Maths/math.vector";
  15278. import { DeepImmutable } from "babylonjs/types";
  15279. import { Plane } from "babylonjs/Maths/math.plane";
  15280. /**
  15281. * Represents a camera frustum
  15282. */
  15283. export class Frustum {
  15284. /**
  15285. * Gets the planes representing the frustum
  15286. * @param transform matrix to be applied to the returned planes
  15287. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15288. */
  15289. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15290. /**
  15291. * Gets the near frustum plane transformed by the transform matrix
  15292. * @param transform transformation matrix to be applied to the resulting frustum plane
  15293. * @param frustumPlane the resuling frustum plane
  15294. */
  15295. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15296. /**
  15297. * Gets the far frustum plane transformed by the transform matrix
  15298. * @param transform transformation matrix to be applied to the resulting frustum plane
  15299. * @param frustumPlane the resuling frustum plane
  15300. */
  15301. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15302. /**
  15303. * Gets the left frustum plane transformed by the transform matrix
  15304. * @param transform transformation matrix to be applied to the resulting frustum plane
  15305. * @param frustumPlane the resuling frustum plane
  15306. */
  15307. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15308. /**
  15309. * Gets the right frustum plane transformed by the transform matrix
  15310. * @param transform transformation matrix to be applied to the resulting frustum plane
  15311. * @param frustumPlane the resuling frustum plane
  15312. */
  15313. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15314. /**
  15315. * Gets the top frustum plane transformed by the transform matrix
  15316. * @param transform transformation matrix to be applied to the resulting frustum plane
  15317. * @param frustumPlane the resuling frustum plane
  15318. */
  15319. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15320. /**
  15321. * Gets the bottom frustum plane transformed by the transform matrix
  15322. * @param transform transformation matrix to be applied to the resulting frustum plane
  15323. * @param frustumPlane the resuling frustum plane
  15324. */
  15325. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15326. /**
  15327. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15328. * @param transform transformation matrix to be applied to the resulting frustum planes
  15329. * @param frustumPlanes the resuling frustum planes
  15330. */
  15331. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15332. }
  15333. }
  15334. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15335. import { Camera } from "babylonjs/Cameras/camera";
  15336. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15337. import { Nullable } from "babylonjs/types";
  15338. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15339. import { Matrix } from "babylonjs/Maths/math.vector";
  15340. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15341. module "babylonjs/Engines/engine" {
  15342. interface Engine {
  15343. /**
  15344. * Creates a new multiview render target
  15345. * @param width defines the width of the texture
  15346. * @param height defines the height of the texture
  15347. * @returns the created multiview texture
  15348. */
  15349. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15350. /**
  15351. * Binds a multiview framebuffer to be drawn to
  15352. * @param multiviewTexture texture to bind
  15353. */
  15354. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15355. }
  15356. }
  15357. module "babylonjs/Cameras/camera" {
  15358. interface Camera {
  15359. /**
  15360. * @hidden
  15361. * 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)
  15362. */
  15363. _useMultiviewToSingleView: boolean;
  15364. /**
  15365. * @hidden
  15366. * 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)
  15367. */
  15368. _multiviewTexture: Nullable<RenderTargetTexture>;
  15369. /**
  15370. * @hidden
  15371. * ensures the multiview texture of the camera exists and has the specified width/height
  15372. * @param width height to set on the multiview texture
  15373. * @param height width to set on the multiview texture
  15374. */
  15375. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15376. }
  15377. }
  15378. module "babylonjs/scene" {
  15379. interface Scene {
  15380. /** @hidden */
  15381. _transformMatrixR: Matrix;
  15382. /** @hidden */
  15383. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15384. /** @hidden */
  15385. _createMultiviewUbo(): void;
  15386. /** @hidden */
  15387. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15388. /** @hidden */
  15389. _renderMultiviewToSingleView(camera: Camera): void;
  15390. }
  15391. }
  15392. }
  15393. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15394. import { Camera } from "babylonjs/Cameras/camera";
  15395. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15396. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15397. import "babylonjs/Engines/Extensions/engine.multiview";
  15398. /**
  15399. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15400. * This will not be used for webXR as it supports displaying texture arrays directly
  15401. */
  15402. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15403. /**
  15404. * Initializes a VRMultiviewToSingleview
  15405. * @param name name of the post process
  15406. * @param camera camera to be applied to
  15407. * @param scaleFactor scaling factor to the size of the output texture
  15408. */
  15409. constructor(name: string, camera: Camera, scaleFactor: number);
  15410. }
  15411. }
  15412. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15413. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15414. import { Nullable } from "babylonjs/types";
  15415. import { Size } from "babylonjs/Maths/math.size";
  15416. import { Observable } from "babylonjs/Misc/observable";
  15417. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  15418. /**
  15419. * Interface used to define additional presentation attributes
  15420. */
  15421. export interface IVRPresentationAttributes {
  15422. /**
  15423. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  15424. */
  15425. highRefreshRate: boolean;
  15426. /**
  15427. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  15428. */
  15429. foveationLevel: number;
  15430. }
  15431. module "babylonjs/Engines/engine" {
  15432. interface Engine {
  15433. /** @hidden */
  15434. _vrDisplay: any;
  15435. /** @hidden */
  15436. _vrSupported: boolean;
  15437. /** @hidden */
  15438. _oldSize: Size;
  15439. /** @hidden */
  15440. _oldHardwareScaleFactor: number;
  15441. /** @hidden */
  15442. _vrExclusivePointerMode: boolean;
  15443. /** @hidden */
  15444. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15445. /** @hidden */
  15446. _onVRDisplayPointerRestricted: () => void;
  15447. /** @hidden */
  15448. _onVRDisplayPointerUnrestricted: () => void;
  15449. /** @hidden */
  15450. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15451. /** @hidden */
  15452. _onVrDisplayDisconnect: Nullable<() => void>;
  15453. /** @hidden */
  15454. _onVrDisplayPresentChange: Nullable<() => void>;
  15455. /**
  15456. * Observable signaled when VR display mode changes
  15457. */
  15458. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15459. /**
  15460. * Observable signaled when VR request present is complete
  15461. */
  15462. onVRRequestPresentComplete: Observable<boolean>;
  15463. /**
  15464. * Observable signaled when VR request present starts
  15465. */
  15466. onVRRequestPresentStart: Observable<Engine>;
  15467. /**
  15468. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15469. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15470. */
  15471. isInVRExclusivePointerMode: boolean;
  15472. /**
  15473. * Gets a boolean indicating if a webVR device was detected
  15474. * @returns true if a webVR device was detected
  15475. */
  15476. isVRDevicePresent(): boolean;
  15477. /**
  15478. * Gets the current webVR device
  15479. * @returns the current webVR device (or null)
  15480. */
  15481. getVRDevice(): any;
  15482. /**
  15483. * Initializes a webVR display and starts listening to display change events
  15484. * The onVRDisplayChangedObservable will be notified upon these changes
  15485. * @returns A promise containing a VRDisplay and if vr is supported
  15486. */
  15487. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15488. /** @hidden */
  15489. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15490. /**
  15491. * Gets or sets the presentation attributes used to configure VR rendering
  15492. */
  15493. vrPresentationAttributes?: IVRPresentationAttributes;
  15494. /**
  15495. * Call this function to switch to webVR mode
  15496. * Will do nothing if webVR is not supported or if there is no webVR device
  15497. * @param options the webvr options provided to the camera. mainly used for multiview
  15498. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15499. */
  15500. enableVR(options: WebVROptions): void;
  15501. /** @hidden */
  15502. _onVRFullScreenTriggered(): void;
  15503. }
  15504. }
  15505. }
  15506. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15507. import { Nullable } from "babylonjs/types";
  15508. import { Observable } from "babylonjs/Misc/observable";
  15509. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15510. import { Scene } from "babylonjs/scene";
  15511. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15512. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15513. import { Node } from "babylonjs/node";
  15514. import { Ray } from "babylonjs/Culling/ray";
  15515. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15516. import "babylonjs/Engines/Extensions/engine.webVR";
  15517. /**
  15518. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15519. * IMPORTANT!! The data is right-hand data.
  15520. * @export
  15521. * @interface DevicePose
  15522. */
  15523. export interface DevicePose {
  15524. /**
  15525. * The position of the device, values in array are [x,y,z].
  15526. */
  15527. readonly position: Nullable<Float32Array>;
  15528. /**
  15529. * The linearVelocity of the device, values in array are [x,y,z].
  15530. */
  15531. readonly linearVelocity: Nullable<Float32Array>;
  15532. /**
  15533. * The linearAcceleration of the device, values in array are [x,y,z].
  15534. */
  15535. readonly linearAcceleration: Nullable<Float32Array>;
  15536. /**
  15537. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15538. */
  15539. readonly orientation: Nullable<Float32Array>;
  15540. /**
  15541. * The angularVelocity of the device, values in array are [x,y,z].
  15542. */
  15543. readonly angularVelocity: Nullable<Float32Array>;
  15544. /**
  15545. * The angularAcceleration of the device, values in array are [x,y,z].
  15546. */
  15547. readonly angularAcceleration: Nullable<Float32Array>;
  15548. }
  15549. /**
  15550. * Interface representing a pose controlled object in Babylon.
  15551. * A pose controlled object has both regular pose values as well as pose values
  15552. * from an external device such as a VR head mounted display
  15553. */
  15554. export interface PoseControlled {
  15555. /**
  15556. * The position of the object in babylon space.
  15557. */
  15558. position: Vector3;
  15559. /**
  15560. * The rotation quaternion of the object in babylon space.
  15561. */
  15562. rotationQuaternion: Quaternion;
  15563. /**
  15564. * The position of the device in babylon space.
  15565. */
  15566. devicePosition?: Vector3;
  15567. /**
  15568. * The rotation quaternion of the device in babylon space.
  15569. */
  15570. deviceRotationQuaternion: Quaternion;
  15571. /**
  15572. * The raw pose coming from the device.
  15573. */
  15574. rawPose: Nullable<DevicePose>;
  15575. /**
  15576. * The scale of the device to be used when translating from device space to babylon space.
  15577. */
  15578. deviceScaleFactor: number;
  15579. /**
  15580. * Updates the poseControlled values based on the input device pose.
  15581. * @param poseData the pose data to update the object with
  15582. */
  15583. updateFromDevice(poseData: DevicePose): void;
  15584. }
  15585. /**
  15586. * Set of options to customize the webVRCamera
  15587. */
  15588. export interface WebVROptions {
  15589. /**
  15590. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15591. */
  15592. trackPosition?: boolean;
  15593. /**
  15594. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15595. */
  15596. positionScale?: number;
  15597. /**
  15598. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15599. */
  15600. displayName?: string;
  15601. /**
  15602. * Should the native controller meshes be initialized. (default: true)
  15603. */
  15604. controllerMeshes?: boolean;
  15605. /**
  15606. * Creating a default HemiLight only on controllers. (default: true)
  15607. */
  15608. defaultLightingOnControllers?: boolean;
  15609. /**
  15610. * If you don't want to use the default VR button of the helper. (default: false)
  15611. */
  15612. useCustomVRButton?: boolean;
  15613. /**
  15614. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15615. */
  15616. customVRButton?: HTMLButtonElement;
  15617. /**
  15618. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15619. */
  15620. rayLength?: number;
  15621. /**
  15622. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15623. */
  15624. defaultHeight?: number;
  15625. /**
  15626. * If multiview should be used if availible (default: false)
  15627. */
  15628. useMultiview?: boolean;
  15629. }
  15630. /**
  15631. * This represents a WebVR camera.
  15632. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15633. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15634. */
  15635. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15636. private webVROptions;
  15637. /**
  15638. * @hidden
  15639. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15640. */
  15641. _vrDevice: any;
  15642. /**
  15643. * The rawPose of the vrDevice.
  15644. */
  15645. rawPose: Nullable<DevicePose>;
  15646. private _onVREnabled;
  15647. private _specsVersion;
  15648. private _attached;
  15649. private _frameData;
  15650. protected _descendants: Array<Node>;
  15651. private _deviceRoomPosition;
  15652. /** @hidden */
  15653. _deviceRoomRotationQuaternion: Quaternion;
  15654. private _standingMatrix;
  15655. /**
  15656. * Represents device position in babylon space.
  15657. */
  15658. devicePosition: Vector3;
  15659. /**
  15660. * Represents device rotation in babylon space.
  15661. */
  15662. deviceRotationQuaternion: Quaternion;
  15663. /**
  15664. * The scale of the device to be used when translating from device space to babylon space.
  15665. */
  15666. deviceScaleFactor: number;
  15667. private _deviceToWorld;
  15668. private _worldToDevice;
  15669. /**
  15670. * References to the webVR controllers for the vrDevice.
  15671. */
  15672. controllers: Array<WebVRController>;
  15673. /**
  15674. * Emits an event when a controller is attached.
  15675. */
  15676. onControllersAttachedObservable: Observable<WebVRController[]>;
  15677. /**
  15678. * Emits an event when a controller's mesh has been loaded;
  15679. */
  15680. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15681. /**
  15682. * Emits an event when the HMD's pose has been updated.
  15683. */
  15684. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15685. private _poseSet;
  15686. /**
  15687. * If the rig cameras be used as parent instead of this camera.
  15688. */
  15689. rigParenting: boolean;
  15690. private _lightOnControllers;
  15691. private _defaultHeight?;
  15692. /**
  15693. * Instantiates a WebVRFreeCamera.
  15694. * @param name The name of the WebVRFreeCamera
  15695. * @param position The starting anchor position for the camera
  15696. * @param scene The scene the camera belongs to
  15697. * @param webVROptions a set of customizable options for the webVRCamera
  15698. */
  15699. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15700. /**
  15701. * Gets the device distance from the ground in meters.
  15702. * @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.
  15703. */
  15704. deviceDistanceToRoomGround(): number;
  15705. /**
  15706. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15707. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15708. */
  15709. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15710. /**
  15711. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15712. * @returns A promise with a boolean set to if the standing matrix is supported.
  15713. */
  15714. useStandingMatrixAsync(): Promise<boolean>;
  15715. /**
  15716. * Disposes the camera
  15717. */
  15718. dispose(): void;
  15719. /**
  15720. * Gets a vrController by name.
  15721. * @param name The name of the controller to retreive
  15722. * @returns the controller matching the name specified or null if not found
  15723. */
  15724. getControllerByName(name: string): Nullable<WebVRController>;
  15725. private _leftController;
  15726. /**
  15727. * The controller corresponding to the users left hand.
  15728. */
  15729. get leftController(): Nullable<WebVRController>;
  15730. private _rightController;
  15731. /**
  15732. * The controller corresponding to the users right hand.
  15733. */
  15734. get rightController(): Nullable<WebVRController>;
  15735. /**
  15736. * Casts a ray forward from the vrCamera's gaze.
  15737. * @param length Length of the ray (default: 100)
  15738. * @returns the ray corresponding to the gaze
  15739. */
  15740. getForwardRay(length?: number): Ray;
  15741. /**
  15742. * @hidden
  15743. * Updates the camera based on device's frame data
  15744. */
  15745. _checkInputs(): void;
  15746. /**
  15747. * Updates the poseControlled values based on the input device pose.
  15748. * @param poseData Pose coming from the device
  15749. */
  15750. updateFromDevice(poseData: DevicePose): void;
  15751. private _htmlElementAttached;
  15752. private _detachIfAttached;
  15753. /**
  15754. * WebVR's attach control will start broadcasting frames to the device.
  15755. * Note that in certain browsers (chrome for example) this function must be called
  15756. * within a user-interaction callback. Example:
  15757. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15758. *
  15759. * @param element html element to attach the vrDevice to
  15760. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15761. */
  15762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15763. /**
  15764. * Detaches the camera from the html element and disables VR
  15765. *
  15766. * @param element html element to detach from
  15767. */
  15768. detachControl(element: HTMLElement): void;
  15769. /**
  15770. * @returns the name of this class
  15771. */
  15772. getClassName(): string;
  15773. /**
  15774. * Calls resetPose on the vrDisplay
  15775. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15776. */
  15777. resetToCurrentRotation(): void;
  15778. /**
  15779. * @hidden
  15780. * Updates the rig cameras (left and right eye)
  15781. */
  15782. _updateRigCameras(): void;
  15783. private _workingVector;
  15784. private _oneVector;
  15785. private _workingMatrix;
  15786. private updateCacheCalled;
  15787. private _correctPositionIfNotTrackPosition;
  15788. /**
  15789. * @hidden
  15790. * Updates the cached values of the camera
  15791. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15792. */
  15793. _updateCache(ignoreParentClass?: boolean): void;
  15794. /**
  15795. * @hidden
  15796. * Get current device position in babylon world
  15797. */
  15798. _computeDevicePosition(): void;
  15799. /**
  15800. * Updates the current device position and rotation in the babylon world
  15801. */
  15802. update(): void;
  15803. /**
  15804. * @hidden
  15805. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15806. * @returns an identity matrix
  15807. */
  15808. _getViewMatrix(): Matrix;
  15809. private _tmpMatrix;
  15810. /**
  15811. * This function is called by the two RIG cameras.
  15812. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15813. * @hidden
  15814. */
  15815. _getWebVRViewMatrix(): Matrix;
  15816. /** @hidden */
  15817. _getWebVRProjectionMatrix(): Matrix;
  15818. private _onGamepadConnectedObserver;
  15819. private _onGamepadDisconnectedObserver;
  15820. private _updateCacheWhenTrackingDisabledObserver;
  15821. /**
  15822. * Initializes the controllers and their meshes
  15823. */
  15824. initControllers(): void;
  15825. }
  15826. }
  15827. declare module "babylonjs/PostProcesses/postProcess" {
  15828. import { Nullable } from "babylonjs/types";
  15829. import { SmartArray } from "babylonjs/Misc/smartArray";
  15830. import { Observable } from "babylonjs/Misc/observable";
  15831. import { Vector2 } from "babylonjs/Maths/math.vector";
  15832. import { Camera } from "babylonjs/Cameras/camera";
  15833. import { Effect } from "babylonjs/Materials/effect";
  15834. import "babylonjs/Shaders/postprocess.vertex";
  15835. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15836. import { Engine } from "babylonjs/Engines/engine";
  15837. import { Color4 } from "babylonjs/Maths/math.color";
  15838. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15839. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15840. /**
  15841. * Size options for a post process
  15842. */
  15843. export type PostProcessOptions = {
  15844. width: number;
  15845. height: number;
  15846. };
  15847. /**
  15848. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15849. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15850. */
  15851. export class PostProcess {
  15852. /** Name of the PostProcess. */
  15853. name: string;
  15854. /**
  15855. * Gets or sets the unique id of the post process
  15856. */
  15857. uniqueId: number;
  15858. /**
  15859. * Width of the texture to apply the post process on
  15860. */
  15861. width: number;
  15862. /**
  15863. * Height of the texture to apply the post process on
  15864. */
  15865. height: number;
  15866. /**
  15867. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15868. * @hidden
  15869. */
  15870. _outputTexture: Nullable<InternalTexture>;
  15871. /**
  15872. * Sampling mode used by the shader
  15873. * See https://doc.babylonjs.com/classes/3.1/texture
  15874. */
  15875. renderTargetSamplingMode: number;
  15876. /**
  15877. * Clear color to use when screen clearing
  15878. */
  15879. clearColor: Color4;
  15880. /**
  15881. * If the buffer needs to be cleared before applying the post process. (default: true)
  15882. * Should be set to false if shader will overwrite all previous pixels.
  15883. */
  15884. autoClear: boolean;
  15885. /**
  15886. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15887. */
  15888. alphaMode: number;
  15889. /**
  15890. * Sets the setAlphaBlendConstants of the babylon engine
  15891. */
  15892. alphaConstants: Color4;
  15893. /**
  15894. * Animations to be used for the post processing
  15895. */
  15896. animations: import("babylonjs/Animations/animation").Animation[];
  15897. /**
  15898. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15899. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15900. */
  15901. enablePixelPerfectMode: boolean;
  15902. /**
  15903. * Force the postprocess to be applied without taking in account viewport
  15904. */
  15905. forceFullscreenViewport: boolean;
  15906. /**
  15907. * List of inspectable custom properties (used by the Inspector)
  15908. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15909. */
  15910. inspectableCustomProperties: IInspectable[];
  15911. /**
  15912. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15913. *
  15914. * | Value | Type | Description |
  15915. * | ----- | ----------------------------------- | ----------- |
  15916. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15917. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15918. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15919. *
  15920. */
  15921. scaleMode: number;
  15922. /**
  15923. * Force textures to be a power of two (default: false)
  15924. */
  15925. alwaysForcePOT: boolean;
  15926. private _samples;
  15927. /**
  15928. * Number of sample textures (default: 1)
  15929. */
  15930. get samples(): number;
  15931. set samples(n: number);
  15932. /**
  15933. * Modify the scale of the post process to be the same as the viewport (default: false)
  15934. */
  15935. adaptScaleToCurrentViewport: boolean;
  15936. private _camera;
  15937. private _scene;
  15938. private _engine;
  15939. private _options;
  15940. private _reusable;
  15941. private _textureType;
  15942. /**
  15943. * Smart array of input and output textures for the post process.
  15944. * @hidden
  15945. */
  15946. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15947. /**
  15948. * The index in _textures that corresponds to the output texture.
  15949. * @hidden
  15950. */
  15951. _currentRenderTextureInd: number;
  15952. private _effect;
  15953. private _samplers;
  15954. private _fragmentUrl;
  15955. private _vertexUrl;
  15956. private _parameters;
  15957. private _scaleRatio;
  15958. protected _indexParameters: any;
  15959. private _shareOutputWithPostProcess;
  15960. private _texelSize;
  15961. private _forcedOutputTexture;
  15962. /**
  15963. * Returns the fragment url or shader name used in the post process.
  15964. * @returns the fragment url or name in the shader store.
  15965. */
  15966. getEffectName(): string;
  15967. /**
  15968. * An event triggered when the postprocess is activated.
  15969. */
  15970. onActivateObservable: Observable<Camera>;
  15971. private _onActivateObserver;
  15972. /**
  15973. * A function that is added to the onActivateObservable
  15974. */
  15975. set onActivate(callback: Nullable<(camera: Camera) => void>);
  15976. /**
  15977. * An event triggered when the postprocess changes its size.
  15978. */
  15979. onSizeChangedObservable: Observable<PostProcess>;
  15980. private _onSizeChangedObserver;
  15981. /**
  15982. * A function that is added to the onSizeChangedObservable
  15983. */
  15984. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  15985. /**
  15986. * An event triggered when the postprocess applies its effect.
  15987. */
  15988. onApplyObservable: Observable<Effect>;
  15989. private _onApplyObserver;
  15990. /**
  15991. * A function that is added to the onApplyObservable
  15992. */
  15993. set onApply(callback: (effect: Effect) => void);
  15994. /**
  15995. * An event triggered before rendering the postprocess
  15996. */
  15997. onBeforeRenderObservable: Observable<Effect>;
  15998. private _onBeforeRenderObserver;
  15999. /**
  16000. * A function that is added to the onBeforeRenderObservable
  16001. */
  16002. set onBeforeRender(callback: (effect: Effect) => void);
  16003. /**
  16004. * An event triggered after rendering the postprocess
  16005. */
  16006. onAfterRenderObservable: Observable<Effect>;
  16007. private _onAfterRenderObserver;
  16008. /**
  16009. * A function that is added to the onAfterRenderObservable
  16010. */
  16011. set onAfterRender(callback: (efect: Effect) => void);
  16012. /**
  16013. * 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
  16014. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  16015. */
  16016. get inputTexture(): InternalTexture;
  16017. set inputTexture(value: InternalTexture);
  16018. /**
  16019. * Gets the camera which post process is applied to.
  16020. * @returns The camera the post process is applied to.
  16021. */
  16022. getCamera(): Camera;
  16023. /**
  16024. * Gets the texel size of the postprocess.
  16025. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  16026. */
  16027. get texelSize(): Vector2;
  16028. /**
  16029. * Creates a new instance PostProcess
  16030. * @param name The name of the PostProcess.
  16031. * @param fragmentUrl The url of the fragment shader to be used.
  16032. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  16033. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  16034. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16035. * @param camera The camera to apply the render pass to.
  16036. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16037. * @param engine The engine which the post process will be applied. (default: current engine)
  16038. * @param reusable If the post process can be reused on the same frame. (default: false)
  16039. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  16040. * @param textureType Type of textures used when performing the post process. (default: 0)
  16041. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  16042. * @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
  16043. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  16044. */
  16045. constructor(
  16046. /** Name of the PostProcess. */
  16047. 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);
  16048. /**
  16049. * Gets a string idenfifying the name of the class
  16050. * @returns "PostProcess" string
  16051. */
  16052. getClassName(): string;
  16053. /**
  16054. * Gets the engine which this post process belongs to.
  16055. * @returns The engine the post process was enabled with.
  16056. */
  16057. getEngine(): Engine;
  16058. /**
  16059. * The effect that is created when initializing the post process.
  16060. * @returns The created effect corresponding the the postprocess.
  16061. */
  16062. getEffect(): Effect;
  16063. /**
  16064. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  16065. * @param postProcess The post process to share the output with.
  16066. * @returns This post process.
  16067. */
  16068. shareOutputWith(postProcess: PostProcess): PostProcess;
  16069. /**
  16070. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  16071. * This should be called if the post process that shares output with this post process is disabled/disposed.
  16072. */
  16073. useOwnOutput(): void;
  16074. /**
  16075. * Updates the effect with the current post process compile time values and recompiles the shader.
  16076. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16077. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16078. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16079. * @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
  16080. * @param onCompiled Called when the shader has been compiled.
  16081. * @param onError Called if there is an error when compiling a shader.
  16082. */
  16083. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16084. /**
  16085. * The post process is reusable if it can be used multiple times within one frame.
  16086. * @returns If the post process is reusable
  16087. */
  16088. isReusable(): boolean;
  16089. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16090. markTextureDirty(): void;
  16091. /**
  16092. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  16093. * 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.
  16094. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  16095. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  16096. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  16097. * @returns The target texture that was bound to be written to.
  16098. */
  16099. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  16100. /**
  16101. * If the post process is supported.
  16102. */
  16103. get isSupported(): boolean;
  16104. /**
  16105. * The aspect ratio of the output texture.
  16106. */
  16107. get aspectRatio(): number;
  16108. /**
  16109. * Get a value indicating if the post-process is ready to be used
  16110. * @returns true if the post-process is ready (shader is compiled)
  16111. */
  16112. isReady(): boolean;
  16113. /**
  16114. * Binds all textures and uniforms to the shader, this will be run on every pass.
  16115. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  16116. */
  16117. apply(): Nullable<Effect>;
  16118. private _disposeTextures;
  16119. /**
  16120. * Disposes the post process.
  16121. * @param camera The camera to dispose the post process on.
  16122. */
  16123. dispose(camera?: Camera): void;
  16124. }
  16125. }
  16126. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  16127. /** @hidden */
  16128. export var kernelBlurVaryingDeclaration: {
  16129. name: string;
  16130. shader: string;
  16131. };
  16132. }
  16133. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  16134. /** @hidden */
  16135. export var kernelBlurFragment: {
  16136. name: string;
  16137. shader: string;
  16138. };
  16139. }
  16140. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  16141. /** @hidden */
  16142. export var kernelBlurFragment2: {
  16143. name: string;
  16144. shader: string;
  16145. };
  16146. }
  16147. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  16148. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16149. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  16150. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  16151. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  16152. /** @hidden */
  16153. export var kernelBlurPixelShader: {
  16154. name: string;
  16155. shader: string;
  16156. };
  16157. }
  16158. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  16159. /** @hidden */
  16160. export var kernelBlurVertex: {
  16161. name: string;
  16162. shader: string;
  16163. };
  16164. }
  16165. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  16166. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  16167. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  16168. /** @hidden */
  16169. export var kernelBlurVertexShader: {
  16170. name: string;
  16171. shader: string;
  16172. };
  16173. }
  16174. declare module "babylonjs/PostProcesses/blurPostProcess" {
  16175. import { Vector2 } from "babylonjs/Maths/math.vector";
  16176. import { Nullable } from "babylonjs/types";
  16177. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  16178. import { Camera } from "babylonjs/Cameras/camera";
  16179. import { Effect } from "babylonjs/Materials/effect";
  16180. import { Engine } from "babylonjs/Engines/engine";
  16181. import "babylonjs/Shaders/kernelBlur.fragment";
  16182. import "babylonjs/Shaders/kernelBlur.vertex";
  16183. /**
  16184. * The Blur Post Process which blurs an image based on a kernel and direction.
  16185. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  16186. */
  16187. export class BlurPostProcess extends PostProcess {
  16188. /** The direction in which to blur the image. */
  16189. direction: Vector2;
  16190. private blockCompilation;
  16191. protected _kernel: number;
  16192. protected _idealKernel: number;
  16193. protected _packedFloat: boolean;
  16194. private _staticDefines;
  16195. /**
  16196. * Sets the length in pixels of the blur sample region
  16197. */
  16198. set kernel(v: number);
  16199. /**
  16200. * Gets the length in pixels of the blur sample region
  16201. */
  16202. get kernel(): number;
  16203. /**
  16204. * Sets wether or not the blur needs to unpack/repack floats
  16205. */
  16206. set packedFloat(v: boolean);
  16207. /**
  16208. * Gets wether or not the blur is unpacking/repacking floats
  16209. */
  16210. get packedFloat(): boolean;
  16211. /**
  16212. * Creates a new instance BlurPostProcess
  16213. * @param name The name of the effect.
  16214. * @param direction The direction in which to blur the image.
  16215. * @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.
  16216. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  16217. * @param camera The camera to apply the render pass to.
  16218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  16219. * @param engine The engine which the post process will be applied. (default: current engine)
  16220. * @param reusable If the post process can be reused on the same frame. (default: false)
  16221. * @param textureType Type of textures used when performing the post process. (default: 0)
  16222. * @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)
  16223. */
  16224. constructor(name: string,
  16225. /** The direction in which to blur the image. */
  16226. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  16227. /**
  16228. * Updates the effect with the current post process compile time values and recompiles the shader.
  16229. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  16230. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  16231. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  16232. * @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
  16233. * @param onCompiled Called when the shader has been compiled.
  16234. * @param onError Called if there is an error when compiling a shader.
  16235. */
  16236. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16237. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16238. /**
  16239. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  16240. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  16241. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  16242. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  16243. * The gaps between physical kernels are compensated for in the weighting of the samples
  16244. * @param idealKernel Ideal blur kernel.
  16245. * @return Nearest best kernel.
  16246. */
  16247. protected _nearestBestKernel(idealKernel: number): number;
  16248. /**
  16249. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16250. * @param x The point on the Gaussian distribution to sample.
  16251. * @return the value of the Gaussian function at x.
  16252. */
  16253. protected _gaussianWeight(x: number): number;
  16254. /**
  16255. * Generates a string that can be used as a floating point number in GLSL.
  16256. * @param x Value to print.
  16257. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16258. * @return GLSL float string.
  16259. */
  16260. protected _glslFloat(x: number, decimalFigures?: number): string;
  16261. }
  16262. }
  16263. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16264. import { Scene } from "babylonjs/scene";
  16265. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16266. import { Plane } from "babylonjs/Maths/math.plane";
  16267. /**
  16268. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16269. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16270. * You can then easily use it as a reflectionTexture on a flat surface.
  16271. * In case the surface is not a plane, please consider relying on reflection probes.
  16272. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16273. */
  16274. export class MirrorTexture extends RenderTargetTexture {
  16275. private scene;
  16276. /**
  16277. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16278. * 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.
  16279. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16280. */
  16281. mirrorPlane: Plane;
  16282. /**
  16283. * Define the blur ratio used to blur the reflection if needed.
  16284. */
  16285. set blurRatio(value: number);
  16286. get blurRatio(): number;
  16287. /**
  16288. * Define the adaptive blur kernel used to blur the reflection if needed.
  16289. * This will autocompute the closest best match for the `blurKernel`
  16290. */
  16291. set adaptiveBlurKernel(value: number);
  16292. /**
  16293. * Define the blur kernel used to blur the reflection if needed.
  16294. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16295. */
  16296. set blurKernel(value: number);
  16297. /**
  16298. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16299. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16300. */
  16301. set blurKernelX(value: number);
  16302. get blurKernelX(): number;
  16303. /**
  16304. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16305. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16306. */
  16307. set blurKernelY(value: number);
  16308. get blurKernelY(): number;
  16309. private _autoComputeBlurKernel;
  16310. protected _onRatioRescale(): void;
  16311. private _updateGammaSpace;
  16312. private _imageProcessingConfigChangeObserver;
  16313. private _transformMatrix;
  16314. private _mirrorMatrix;
  16315. private _savedViewMatrix;
  16316. private _blurX;
  16317. private _blurY;
  16318. private _adaptiveBlurKernel;
  16319. private _blurKernelX;
  16320. private _blurKernelY;
  16321. private _blurRatio;
  16322. /**
  16323. * Instantiates a Mirror Texture.
  16324. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16325. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16326. * You can then easily use it as a reflectionTexture on a flat surface.
  16327. * In case the surface is not a plane, please consider relying on reflection probes.
  16328. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16329. * @param name
  16330. * @param size
  16331. * @param scene
  16332. * @param generateMipMaps
  16333. * @param type
  16334. * @param samplingMode
  16335. * @param generateDepthBuffer
  16336. */
  16337. constructor(name: string, size: number | {
  16338. width: number;
  16339. height: number;
  16340. } | {
  16341. ratio: number;
  16342. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16343. private _preparePostProcesses;
  16344. /**
  16345. * Clone the mirror texture.
  16346. * @returns the cloned texture
  16347. */
  16348. clone(): MirrorTexture;
  16349. /**
  16350. * Serialize the texture to a JSON representation you could use in Parse later on
  16351. * @returns the serialized JSON representation
  16352. */
  16353. serialize(): any;
  16354. /**
  16355. * Dispose the texture and release its associated resources.
  16356. */
  16357. dispose(): void;
  16358. }
  16359. }
  16360. declare module "babylonjs/Materials/Textures/texture" {
  16361. import { Observable } from "babylonjs/Misc/observable";
  16362. import { Nullable } from "babylonjs/types";
  16363. import { Matrix } from "babylonjs/Maths/math.vector";
  16364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16365. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16366. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  16367. import { Scene } from "babylonjs/scene";
  16368. /**
  16369. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16370. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16371. */
  16372. export class Texture extends BaseTexture {
  16373. /**
  16374. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16375. */
  16376. static SerializeBuffers: boolean;
  16377. /** @hidden */
  16378. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16379. /** @hidden */
  16380. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16381. /** @hidden */
  16382. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16383. /** nearest is mag = nearest and min = nearest and mip = linear */
  16384. static readonly NEAREST_SAMPLINGMODE: number;
  16385. /** nearest is mag = nearest and min = nearest and mip = linear */
  16386. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16387. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16388. static readonly BILINEAR_SAMPLINGMODE: number;
  16389. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16390. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16391. /** Trilinear is mag = linear and min = linear and mip = linear */
  16392. static readonly TRILINEAR_SAMPLINGMODE: number;
  16393. /** Trilinear is mag = linear and min = linear and mip = linear */
  16394. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16395. /** mag = nearest and min = nearest and mip = nearest */
  16396. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16397. /** mag = nearest and min = linear and mip = nearest */
  16398. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16399. /** mag = nearest and min = linear and mip = linear */
  16400. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16401. /** mag = nearest and min = linear and mip = none */
  16402. static readonly NEAREST_LINEAR: number;
  16403. /** mag = nearest and min = nearest and mip = none */
  16404. static readonly NEAREST_NEAREST: number;
  16405. /** mag = linear and min = nearest and mip = nearest */
  16406. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16407. /** mag = linear and min = nearest and mip = linear */
  16408. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16409. /** mag = linear and min = linear and mip = none */
  16410. static readonly LINEAR_LINEAR: number;
  16411. /** mag = linear and min = nearest and mip = none */
  16412. static readonly LINEAR_NEAREST: number;
  16413. /** Explicit coordinates mode */
  16414. static readonly EXPLICIT_MODE: number;
  16415. /** Spherical coordinates mode */
  16416. static readonly SPHERICAL_MODE: number;
  16417. /** Planar coordinates mode */
  16418. static readonly PLANAR_MODE: number;
  16419. /** Cubic coordinates mode */
  16420. static readonly CUBIC_MODE: number;
  16421. /** Projection coordinates mode */
  16422. static readonly PROJECTION_MODE: number;
  16423. /** Inverse Cubic coordinates mode */
  16424. static readonly SKYBOX_MODE: number;
  16425. /** Inverse Cubic coordinates mode */
  16426. static readonly INVCUBIC_MODE: number;
  16427. /** Equirectangular coordinates mode */
  16428. static readonly EQUIRECTANGULAR_MODE: number;
  16429. /** Equirectangular Fixed coordinates mode */
  16430. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16431. /** Equirectangular Fixed Mirrored coordinates mode */
  16432. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16433. /** Texture is not repeating outside of 0..1 UVs */
  16434. static readonly CLAMP_ADDRESSMODE: number;
  16435. /** Texture is repeating outside of 0..1 UVs */
  16436. static readonly WRAP_ADDRESSMODE: number;
  16437. /** Texture is repeating and mirrored */
  16438. static readonly MIRROR_ADDRESSMODE: number;
  16439. /**
  16440. * 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
  16441. */
  16442. static UseSerializedUrlIfAny: boolean;
  16443. /**
  16444. * Define the url of the texture.
  16445. */
  16446. url: Nullable<string>;
  16447. /**
  16448. * Define an offset on the texture to offset the u coordinates of the UVs
  16449. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16450. */
  16451. uOffset: number;
  16452. /**
  16453. * Define an offset on the texture to offset the v coordinates of the UVs
  16454. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16455. */
  16456. vOffset: number;
  16457. /**
  16458. * Define an offset on the texture to scale the u coordinates of the UVs
  16459. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16460. */
  16461. uScale: number;
  16462. /**
  16463. * Define an offset on the texture to scale the v coordinates of the UVs
  16464. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16465. */
  16466. vScale: number;
  16467. /**
  16468. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16469. * @see http://doc.babylonjs.com/how_to/more_materials
  16470. */
  16471. uAng: number;
  16472. /**
  16473. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16474. * @see http://doc.babylonjs.com/how_to/more_materials
  16475. */
  16476. vAng: number;
  16477. /**
  16478. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16479. * @see http://doc.babylonjs.com/how_to/more_materials
  16480. */
  16481. wAng: number;
  16482. /**
  16483. * Defines the center of rotation (U)
  16484. */
  16485. uRotationCenter: number;
  16486. /**
  16487. * Defines the center of rotation (V)
  16488. */
  16489. vRotationCenter: number;
  16490. /**
  16491. * Defines the center of rotation (W)
  16492. */
  16493. wRotationCenter: number;
  16494. /**
  16495. * Are mip maps generated for this texture or not.
  16496. */
  16497. get noMipmap(): boolean;
  16498. /**
  16499. * List of inspectable custom properties (used by the Inspector)
  16500. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16501. */
  16502. inspectableCustomProperties: Nullable<IInspectable[]>;
  16503. private _noMipmap;
  16504. /** @hidden */
  16505. _invertY: boolean;
  16506. private _rowGenerationMatrix;
  16507. private _cachedTextureMatrix;
  16508. private _projectionModeMatrix;
  16509. private _t0;
  16510. private _t1;
  16511. private _t2;
  16512. private _cachedUOffset;
  16513. private _cachedVOffset;
  16514. private _cachedUScale;
  16515. private _cachedVScale;
  16516. private _cachedUAng;
  16517. private _cachedVAng;
  16518. private _cachedWAng;
  16519. private _cachedProjectionMatrixId;
  16520. private _cachedCoordinatesMode;
  16521. /** @hidden */
  16522. protected _initialSamplingMode: number;
  16523. /** @hidden */
  16524. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  16525. private _deleteBuffer;
  16526. protected _format: Nullable<number>;
  16527. private _delayedOnLoad;
  16528. private _delayedOnError;
  16529. private _mimeType?;
  16530. /**
  16531. * Observable triggered once the texture has been loaded.
  16532. */
  16533. onLoadObservable: Observable<Texture>;
  16534. protected _isBlocking: boolean;
  16535. /**
  16536. * Is the texture preventing material to render while loading.
  16537. * If false, a default texture will be used instead of the loading one during the preparation step.
  16538. */
  16539. set isBlocking(value: boolean);
  16540. get isBlocking(): boolean;
  16541. /**
  16542. * Get the current sampling mode associated with the texture.
  16543. */
  16544. get samplingMode(): number;
  16545. /**
  16546. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16547. */
  16548. get invertY(): boolean;
  16549. /**
  16550. * Instantiates a new texture.
  16551. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16552. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16553. * @param url defines the url of the picture to load as a texture
  16554. * @param scene defines the scene or engine the texture will belong to
  16555. * @param noMipmap defines if the texture will require mip maps or not
  16556. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16557. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16558. * @param onLoad defines a callback triggered when the texture has been loaded
  16559. * @param onError defines a callback triggered when an error occurred during the loading session
  16560. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16561. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16562. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16563. * @param mimeType defines an optional mime type information
  16564. */
  16565. 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);
  16566. /**
  16567. * Update the url (and optional buffer) of this texture if url was null during construction.
  16568. * @param url the url of the texture
  16569. * @param buffer the buffer of the texture (defaults to null)
  16570. * @param onLoad callback called when the texture is loaded (defaults to null)
  16571. */
  16572. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16573. /**
  16574. * Finish the loading sequence of a texture flagged as delayed load.
  16575. * @hidden
  16576. */
  16577. delayLoad(): void;
  16578. private _prepareRowForTextureGeneration;
  16579. /**
  16580. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16581. * @returns the transform matrix of the texture.
  16582. */
  16583. getTextureMatrix(uBase?: number): Matrix;
  16584. /**
  16585. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16586. * @returns The reflection texture transform
  16587. */
  16588. getReflectionTextureMatrix(): Matrix;
  16589. /**
  16590. * Clones the texture.
  16591. * @returns the cloned texture
  16592. */
  16593. clone(): Texture;
  16594. /**
  16595. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16596. * @returns The JSON representation of the texture
  16597. */
  16598. serialize(): any;
  16599. /**
  16600. * Get the current class name of the texture useful for serialization or dynamic coding.
  16601. * @returns "Texture"
  16602. */
  16603. getClassName(): string;
  16604. /**
  16605. * Dispose the texture and release its associated resources.
  16606. */
  16607. dispose(): void;
  16608. /**
  16609. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16610. * @param parsedTexture Define the JSON representation of the texture
  16611. * @param scene Define the scene the parsed texture should be instantiated in
  16612. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16613. * @returns The parsed texture if successful
  16614. */
  16615. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16616. /**
  16617. * Creates a texture from its base 64 representation.
  16618. * @param data Define the base64 payload without the data: prefix
  16619. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16620. * @param scene Define the scene the texture should belong to
  16621. * @param noMipmap Forces the texture to not create mip map information if true
  16622. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16623. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16624. * @param onLoad define a callback triggered when the texture has been loaded
  16625. * @param onError define a callback triggered when an error occurred during the loading session
  16626. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16627. * @returns the created texture
  16628. */
  16629. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16630. /**
  16631. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16632. * @param data Define the base64 payload without the data: prefix
  16633. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16634. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16635. * @param scene Define the scene the texture should belong to
  16636. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16637. * @param noMipmap Forces the texture to not create mip map information if true
  16638. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16639. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16640. * @param onLoad define a callback triggered when the texture has been loaded
  16641. * @param onError define a callback triggered when an error occurred during the loading session
  16642. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16643. * @returns the created texture
  16644. */
  16645. 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;
  16646. }
  16647. }
  16648. declare module "babylonjs/PostProcesses/postProcessManager" {
  16649. import { Nullable } from "babylonjs/types";
  16650. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16651. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16652. import { Scene } from "babylonjs/scene";
  16653. /**
  16654. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16655. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16656. */
  16657. export class PostProcessManager {
  16658. private _scene;
  16659. private _indexBuffer;
  16660. private _vertexBuffers;
  16661. /**
  16662. * Creates a new instance PostProcess
  16663. * @param scene The scene that the post process is associated with.
  16664. */
  16665. constructor(scene: Scene);
  16666. private _prepareBuffers;
  16667. private _buildIndexBuffer;
  16668. /**
  16669. * Rebuilds the vertex buffers of the manager.
  16670. * @hidden
  16671. */
  16672. _rebuild(): void;
  16673. /**
  16674. * Prepares a frame to be run through a post process.
  16675. * @param sourceTexture The input texture to the post procesess. (default: null)
  16676. * @param postProcesses An array of post processes to be run. (default: null)
  16677. * @returns True if the post processes were able to be run.
  16678. * @hidden
  16679. */
  16680. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16681. /**
  16682. * Manually render a set of post processes to a texture.
  16683. * @param postProcesses An array of post processes to be run.
  16684. * @param targetTexture The target texture to render to.
  16685. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16686. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16687. * @param lodLevel defines which lod of the texture to render to
  16688. */
  16689. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16690. /**
  16691. * Finalize the result of the output of the postprocesses.
  16692. * @param doNotPresent If true the result will not be displayed to the screen.
  16693. * @param targetTexture The target texture to render to.
  16694. * @param faceIndex The index of the face to bind the target texture to.
  16695. * @param postProcesses The array of post processes to render.
  16696. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16697. * @hidden
  16698. */
  16699. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16700. /**
  16701. * Disposes of the post process manager.
  16702. */
  16703. dispose(): void;
  16704. }
  16705. }
  16706. declare module "babylonjs/Misc/gradients" {
  16707. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16708. /** Interface used by value gradients (color, factor, ...) */
  16709. export interface IValueGradient {
  16710. /**
  16711. * Gets or sets the gradient value (between 0 and 1)
  16712. */
  16713. gradient: number;
  16714. }
  16715. /** Class used to store color4 gradient */
  16716. export class ColorGradient implements IValueGradient {
  16717. /**
  16718. * Gets or sets the gradient value (between 0 and 1)
  16719. */
  16720. gradient: number;
  16721. /**
  16722. * Gets or sets first associated color
  16723. */
  16724. color1: Color4;
  16725. /**
  16726. * Gets or sets second associated color
  16727. */
  16728. color2?: Color4;
  16729. /**
  16730. * Will get a color picked randomly between color1 and color2.
  16731. * If color2 is undefined then color1 will be used
  16732. * @param result defines the target Color4 to store the result in
  16733. */
  16734. getColorToRef(result: Color4): void;
  16735. }
  16736. /** Class used to store color 3 gradient */
  16737. export class Color3Gradient implements IValueGradient {
  16738. /**
  16739. * Gets or sets the gradient value (between 0 and 1)
  16740. */
  16741. gradient: number;
  16742. /**
  16743. * Gets or sets the associated color
  16744. */
  16745. color: Color3;
  16746. }
  16747. /** Class used to store factor gradient */
  16748. export class FactorGradient implements IValueGradient {
  16749. /**
  16750. * Gets or sets the gradient value (between 0 and 1)
  16751. */
  16752. gradient: number;
  16753. /**
  16754. * Gets or sets first associated factor
  16755. */
  16756. factor1: number;
  16757. /**
  16758. * Gets or sets second associated factor
  16759. */
  16760. factor2?: number;
  16761. /**
  16762. * Will get a number picked randomly between factor1 and factor2.
  16763. * If factor2 is undefined then factor1 will be used
  16764. * @returns the picked number
  16765. */
  16766. getFactor(): number;
  16767. }
  16768. /**
  16769. * Helper used to simplify some generic gradient tasks
  16770. */
  16771. export class GradientHelper {
  16772. /**
  16773. * Gets the current gradient from an array of IValueGradient
  16774. * @param ratio defines the current ratio to get
  16775. * @param gradients defines the array of IValueGradient
  16776. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16777. */
  16778. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16779. }
  16780. }
  16781. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16782. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16783. import { Nullable } from "babylonjs/types";
  16784. module "babylonjs/Engines/thinEngine" {
  16785. interface ThinEngine {
  16786. /**
  16787. * Creates a dynamic texture
  16788. * @param width defines the width of the texture
  16789. * @param height defines the height of the texture
  16790. * @param generateMipMaps defines if the engine should generate the mip levels
  16791. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16792. * @returns the dynamic texture inside an InternalTexture
  16793. */
  16794. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16795. /**
  16796. * Update the content of a dynamic texture
  16797. * @param texture defines the texture to update
  16798. * @param canvas defines the canvas containing the source
  16799. * @param invertY defines if data must be stored with Y axis inverted
  16800. * @param premulAlpha defines if alpha is stored as premultiplied
  16801. * @param format defines the format of the data
  16802. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16803. */
  16804. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16805. }
  16806. }
  16807. }
  16808. declare module "babylonjs/Misc/canvasGenerator" {
  16809. /**
  16810. * Helper class used to generate a canvas to manipulate images
  16811. */
  16812. export class CanvasGenerator {
  16813. /**
  16814. * Create a new canvas (or offscreen canvas depending on the context)
  16815. * @param width defines the expected width
  16816. * @param height defines the expected height
  16817. * @return a new canvas or offscreen canvas
  16818. */
  16819. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  16820. }
  16821. }
  16822. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16823. import { Scene } from "babylonjs/scene";
  16824. import { Texture } from "babylonjs/Materials/Textures/texture";
  16825. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16826. /**
  16827. * A class extending Texture allowing drawing on a texture
  16828. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16829. */
  16830. export class DynamicTexture extends Texture {
  16831. private _generateMipMaps;
  16832. private _canvas;
  16833. private _context;
  16834. private _engine;
  16835. /**
  16836. * Creates a DynamicTexture
  16837. * @param name defines the name of the texture
  16838. * @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
  16839. * @param scene defines the scene where you want the texture
  16840. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16841. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16842. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16843. */
  16844. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16845. /**
  16846. * Get the current class name of the texture useful for serialization or dynamic coding.
  16847. * @returns "DynamicTexture"
  16848. */
  16849. getClassName(): string;
  16850. /**
  16851. * Gets the current state of canRescale
  16852. */
  16853. get canRescale(): boolean;
  16854. private _recreate;
  16855. /**
  16856. * Scales the texture
  16857. * @param ratio the scale factor to apply to both width and height
  16858. */
  16859. scale(ratio: number): void;
  16860. /**
  16861. * Resizes the texture
  16862. * @param width the new width
  16863. * @param height the new height
  16864. */
  16865. scaleTo(width: number, height: number): void;
  16866. /**
  16867. * Gets the context of the canvas used by the texture
  16868. * @returns the canvas context of the dynamic texture
  16869. */
  16870. getContext(): CanvasRenderingContext2D;
  16871. /**
  16872. * Clears the texture
  16873. */
  16874. clear(): void;
  16875. /**
  16876. * Updates the texture
  16877. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16878. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16879. */
  16880. update(invertY?: boolean, premulAlpha?: boolean): void;
  16881. /**
  16882. * Draws text onto the texture
  16883. * @param text defines the text to be drawn
  16884. * @param x defines the placement of the text from the left
  16885. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16886. * @param font defines the font to be used with font-style, font-size, font-name
  16887. * @param color defines the color used for the text
  16888. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16889. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16890. * @param update defines whether texture is immediately update (default is true)
  16891. */
  16892. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16893. /**
  16894. * Clones the texture
  16895. * @returns the clone of the texture.
  16896. */
  16897. clone(): DynamicTexture;
  16898. /**
  16899. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16900. * @returns a serialized dynamic texture object
  16901. */
  16902. serialize(): any;
  16903. /** @hidden */
  16904. _rebuild(): void;
  16905. }
  16906. }
  16907. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16908. import { Scene } from "babylonjs/scene";
  16909. import { ISceneComponent } from "babylonjs/sceneComponent";
  16910. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16911. module "babylonjs/abstractScene" {
  16912. interface AbstractScene {
  16913. /**
  16914. * The list of procedural textures added to the scene
  16915. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16916. */
  16917. proceduralTextures: Array<ProceduralTexture>;
  16918. }
  16919. }
  16920. /**
  16921. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16922. * in a given scene.
  16923. */
  16924. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16925. /**
  16926. * The component name helpfull to identify the component in the list of scene components.
  16927. */
  16928. readonly name: string;
  16929. /**
  16930. * The scene the component belongs to.
  16931. */
  16932. scene: Scene;
  16933. /**
  16934. * Creates a new instance of the component for the given scene
  16935. * @param scene Defines the scene to register the component in
  16936. */
  16937. constructor(scene: Scene);
  16938. /**
  16939. * Registers the component in a given scene
  16940. */
  16941. register(): void;
  16942. /**
  16943. * Rebuilds the elements related to this component in case of
  16944. * context lost for instance.
  16945. */
  16946. rebuild(): void;
  16947. /**
  16948. * Disposes the component and the associated ressources.
  16949. */
  16950. dispose(): void;
  16951. private _beforeClear;
  16952. }
  16953. }
  16954. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16955. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16956. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16957. module "babylonjs/Engines/thinEngine" {
  16958. interface ThinEngine {
  16959. /**
  16960. * Creates a new render target cube texture
  16961. * @param size defines the size of the texture
  16962. * @param options defines the options used to create the texture
  16963. * @returns a new render target cube texture stored in an InternalTexture
  16964. */
  16965. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16966. }
  16967. }
  16968. }
  16969. declare module "babylonjs/Shaders/procedural.vertex" {
  16970. /** @hidden */
  16971. export var proceduralVertexShader: {
  16972. name: string;
  16973. shader: string;
  16974. };
  16975. }
  16976. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16977. import { Observable } from "babylonjs/Misc/observable";
  16978. import { Nullable } from "babylonjs/types";
  16979. import { Scene } from "babylonjs/scene";
  16980. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16981. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16982. import { Effect } from "babylonjs/Materials/effect";
  16983. import { Texture } from "babylonjs/Materials/Textures/texture";
  16984. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16985. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16986. import "babylonjs/Shaders/procedural.vertex";
  16987. /**
  16988. * 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.
  16989. * This is the base class of any Procedural texture and contains most of the shareable code.
  16990. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16991. */
  16992. export class ProceduralTexture extends Texture {
  16993. isCube: boolean;
  16994. /**
  16995. * Define if the texture is enabled or not (disabled texture will not render)
  16996. */
  16997. isEnabled: boolean;
  16998. /**
  16999. * Define if the texture must be cleared before rendering (default is true)
  17000. */
  17001. autoClear: boolean;
  17002. /**
  17003. * Callback called when the texture is generated
  17004. */
  17005. onGenerated: () => void;
  17006. /**
  17007. * Event raised when the texture is generated
  17008. */
  17009. onGeneratedObservable: Observable<ProceduralTexture>;
  17010. /** @hidden */
  17011. _generateMipMaps: boolean;
  17012. /** @hidden **/
  17013. _effect: Effect;
  17014. /** @hidden */
  17015. _textures: {
  17016. [key: string]: Texture;
  17017. };
  17018. private _size;
  17019. private _currentRefreshId;
  17020. private _frameId;
  17021. private _refreshRate;
  17022. private _vertexBuffers;
  17023. private _indexBuffer;
  17024. private _uniforms;
  17025. private _samplers;
  17026. private _fragment;
  17027. private _floats;
  17028. private _ints;
  17029. private _floatsArrays;
  17030. private _colors3;
  17031. private _colors4;
  17032. private _vectors2;
  17033. private _vectors3;
  17034. private _matrices;
  17035. private _fallbackTexture;
  17036. private _fallbackTextureUsed;
  17037. private _engine;
  17038. private _cachedDefines;
  17039. private _contentUpdateId;
  17040. private _contentData;
  17041. /**
  17042. * Instantiates a new procedural texture.
  17043. * 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.
  17044. * This is the base class of any Procedural texture and contains most of the shareable code.
  17045. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  17046. * @param name Define the name of the texture
  17047. * @param size Define the size of the texture to create
  17048. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  17049. * @param scene Define the scene the texture belongs to
  17050. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  17051. * @param generateMipMaps Define if the texture should creates mip maps or not
  17052. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  17053. */
  17054. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  17055. /**
  17056. * The effect that is created when initializing the post process.
  17057. * @returns The created effect corresponding the the postprocess.
  17058. */
  17059. getEffect(): Effect;
  17060. /**
  17061. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  17062. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  17063. */
  17064. getContent(): Nullable<ArrayBufferView>;
  17065. private _createIndexBuffer;
  17066. /** @hidden */
  17067. _rebuild(): void;
  17068. /**
  17069. * Resets the texture in order to recreate its associated resources.
  17070. * This can be called in case of context loss
  17071. */
  17072. reset(): void;
  17073. protected _getDefines(): string;
  17074. /**
  17075. * Is the texture ready to be used ? (rendered at least once)
  17076. * @returns true if ready, otherwise, false.
  17077. */
  17078. isReady(): boolean;
  17079. /**
  17080. * Resets the refresh counter of the texture and start bak from scratch.
  17081. * Could be useful to regenerate the texture if it is setup to render only once.
  17082. */
  17083. resetRefreshCounter(): void;
  17084. /**
  17085. * Set the fragment shader to use in order to render the texture.
  17086. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  17087. */
  17088. setFragment(fragment: any): void;
  17089. /**
  17090. * Define the refresh rate of the texture or the rendering frequency.
  17091. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17092. */
  17093. get refreshRate(): number;
  17094. set refreshRate(value: number);
  17095. /** @hidden */
  17096. _shouldRender(): boolean;
  17097. /**
  17098. * Get the size the texture is rendering at.
  17099. * @returns the size (texture is always squared)
  17100. */
  17101. getRenderSize(): number;
  17102. /**
  17103. * Resize the texture to new value.
  17104. * @param size Define the new size the texture should have
  17105. * @param generateMipMaps Define whether the new texture should create mip maps
  17106. */
  17107. resize(size: number, generateMipMaps: boolean): void;
  17108. private _checkUniform;
  17109. /**
  17110. * Set a texture in the shader program used to render.
  17111. * @param name Define the name of the uniform samplers as defined in the shader
  17112. * @param texture Define the texture to bind to this sampler
  17113. * @return the texture itself allowing "fluent" like uniform updates
  17114. */
  17115. setTexture(name: string, texture: Texture): ProceduralTexture;
  17116. /**
  17117. * Set a float in the shader.
  17118. * @param name Define the name of the uniform as defined in the shader
  17119. * @param value Define the value to give to the uniform
  17120. * @return the texture itself allowing "fluent" like uniform updates
  17121. */
  17122. setFloat(name: string, value: number): ProceduralTexture;
  17123. /**
  17124. * Set a int in the shader.
  17125. * @param name Define the name of the uniform as defined in the shader
  17126. * @param value Define the value to give to the uniform
  17127. * @return the texture itself allowing "fluent" like uniform updates
  17128. */
  17129. setInt(name: string, value: number): ProceduralTexture;
  17130. /**
  17131. * Set an array of floats in the shader.
  17132. * @param name Define the name of the uniform as defined in the shader
  17133. * @param value Define the value to give to the uniform
  17134. * @return the texture itself allowing "fluent" like uniform updates
  17135. */
  17136. setFloats(name: string, value: number[]): ProceduralTexture;
  17137. /**
  17138. * Set a vec3 in the shader from a Color3.
  17139. * @param name Define the name of the uniform as defined in the shader
  17140. * @param value Define the value to give to the uniform
  17141. * @return the texture itself allowing "fluent" like uniform updates
  17142. */
  17143. setColor3(name: string, value: Color3): ProceduralTexture;
  17144. /**
  17145. * Set a vec4 in the shader from a Color4.
  17146. * @param name Define the name of the uniform as defined in the shader
  17147. * @param value Define the value to give to the uniform
  17148. * @return the texture itself allowing "fluent" like uniform updates
  17149. */
  17150. setColor4(name: string, value: Color4): ProceduralTexture;
  17151. /**
  17152. * Set a vec2 in the shader from a Vector2.
  17153. * @param name Define the name of the uniform as defined in the shader
  17154. * @param value Define the value to give to the uniform
  17155. * @return the texture itself allowing "fluent" like uniform updates
  17156. */
  17157. setVector2(name: string, value: Vector2): ProceduralTexture;
  17158. /**
  17159. * Set a vec3 in the shader from a Vector3.
  17160. * @param name Define the name of the uniform as defined in the shader
  17161. * @param value Define the value to give to the uniform
  17162. * @return the texture itself allowing "fluent" like uniform updates
  17163. */
  17164. setVector3(name: string, value: Vector3): ProceduralTexture;
  17165. /**
  17166. * Set a mat4 in the shader from a MAtrix.
  17167. * @param name Define the name of the uniform as defined in the shader
  17168. * @param value Define the value to give to the uniform
  17169. * @return the texture itself allowing "fluent" like uniform updates
  17170. */
  17171. setMatrix(name: string, value: Matrix): ProceduralTexture;
  17172. /**
  17173. * Render the texture to its associated render target.
  17174. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  17175. */
  17176. render(useCameraPostProcess?: boolean): void;
  17177. /**
  17178. * Clone the texture.
  17179. * @returns the cloned texture
  17180. */
  17181. clone(): ProceduralTexture;
  17182. /**
  17183. * Dispose the texture and release its asoociated resources.
  17184. */
  17185. dispose(): void;
  17186. }
  17187. }
  17188. declare module "babylonjs/Particles/baseParticleSystem" {
  17189. import { Nullable } from "babylonjs/types";
  17190. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  17191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17192. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  17193. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  17194. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  17195. import { Scene } from "babylonjs/scene";
  17196. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  17197. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  17198. import { Texture } from "babylonjs/Materials/Textures/texture";
  17199. import { Color4 } from "babylonjs/Maths/math.color";
  17200. import { Animation } from "babylonjs/Animations/animation";
  17201. /**
  17202. * This represents the base class for particle system in Babylon.
  17203. * 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.
  17204. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17205. * @example https://doc.babylonjs.com/babylon101/particles
  17206. */
  17207. export class BaseParticleSystem {
  17208. /**
  17209. * Source color is added to the destination color without alpha affecting the result
  17210. */
  17211. static BLENDMODE_ONEONE: number;
  17212. /**
  17213. * Blend current color and particle color using particle’s alpha
  17214. */
  17215. static BLENDMODE_STANDARD: number;
  17216. /**
  17217. * Add current color and particle color multiplied by particle’s alpha
  17218. */
  17219. static BLENDMODE_ADD: number;
  17220. /**
  17221. * Multiply current color with particle color
  17222. */
  17223. static BLENDMODE_MULTIPLY: number;
  17224. /**
  17225. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  17226. */
  17227. static BLENDMODE_MULTIPLYADD: number;
  17228. /**
  17229. * List of animations used by the particle system.
  17230. */
  17231. animations: Animation[];
  17232. /**
  17233. * The id of the Particle system.
  17234. */
  17235. id: string;
  17236. /**
  17237. * The friendly name of the Particle system.
  17238. */
  17239. name: string;
  17240. /**
  17241. * The rendering group used by the Particle system to chose when to render.
  17242. */
  17243. renderingGroupId: number;
  17244. /**
  17245. * The emitter represents the Mesh or position we are attaching the particle system to.
  17246. */
  17247. emitter: Nullable<AbstractMesh | Vector3>;
  17248. /**
  17249. * The maximum number of particles to emit per frame
  17250. */
  17251. emitRate: number;
  17252. /**
  17253. * If you want to launch only a few particles at once, that can be done, as well.
  17254. */
  17255. manualEmitCount: number;
  17256. /**
  17257. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17258. */
  17259. updateSpeed: number;
  17260. /**
  17261. * The amount of time the particle system is running (depends of the overall update speed).
  17262. */
  17263. targetStopDuration: number;
  17264. /**
  17265. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17266. */
  17267. disposeOnStop: boolean;
  17268. /**
  17269. * Minimum power of emitting particles.
  17270. */
  17271. minEmitPower: number;
  17272. /**
  17273. * Maximum power of emitting particles.
  17274. */
  17275. maxEmitPower: number;
  17276. /**
  17277. * Minimum life time of emitting particles.
  17278. */
  17279. minLifeTime: number;
  17280. /**
  17281. * Maximum life time of emitting particles.
  17282. */
  17283. maxLifeTime: number;
  17284. /**
  17285. * Minimum Size of emitting particles.
  17286. */
  17287. minSize: number;
  17288. /**
  17289. * Maximum Size of emitting particles.
  17290. */
  17291. maxSize: number;
  17292. /**
  17293. * Minimum scale of emitting particles on X axis.
  17294. */
  17295. minScaleX: number;
  17296. /**
  17297. * Maximum scale of emitting particles on X axis.
  17298. */
  17299. maxScaleX: number;
  17300. /**
  17301. * Minimum scale of emitting particles on Y axis.
  17302. */
  17303. minScaleY: number;
  17304. /**
  17305. * Maximum scale of emitting particles on Y axis.
  17306. */
  17307. maxScaleY: number;
  17308. /**
  17309. * Gets or sets the minimal initial rotation in radians.
  17310. */
  17311. minInitialRotation: number;
  17312. /**
  17313. * Gets or sets the maximal initial rotation in radians.
  17314. */
  17315. maxInitialRotation: number;
  17316. /**
  17317. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17318. */
  17319. minAngularSpeed: number;
  17320. /**
  17321. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17322. */
  17323. maxAngularSpeed: number;
  17324. /**
  17325. * The texture used to render each particle. (this can be a spritesheet)
  17326. */
  17327. particleTexture: Nullable<Texture>;
  17328. /**
  17329. * The layer mask we are rendering the particles through.
  17330. */
  17331. layerMask: number;
  17332. /**
  17333. * This can help using your own shader to render the particle system.
  17334. * The according effect will be created
  17335. */
  17336. customShader: any;
  17337. /**
  17338. * By default particle system starts as soon as they are created. This prevents the
  17339. * automatic start to happen and let you decide when to start emitting particles.
  17340. */
  17341. preventAutoStart: boolean;
  17342. private _noiseTexture;
  17343. /**
  17344. * Gets or sets a texture used to add random noise to particle positions
  17345. */
  17346. get noiseTexture(): Nullable<ProceduralTexture>;
  17347. set noiseTexture(value: Nullable<ProceduralTexture>);
  17348. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17349. noiseStrength: Vector3;
  17350. /**
  17351. * Callback triggered when the particle animation is ending.
  17352. */
  17353. onAnimationEnd: Nullable<() => void>;
  17354. /**
  17355. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17356. */
  17357. blendMode: number;
  17358. /**
  17359. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17360. * to override the particles.
  17361. */
  17362. forceDepthWrite: boolean;
  17363. /** 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 */
  17364. preWarmCycles: number;
  17365. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17366. preWarmStepOffset: number;
  17367. /**
  17368. * 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)
  17369. */
  17370. spriteCellChangeSpeed: number;
  17371. /**
  17372. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17373. */
  17374. startSpriteCellID: number;
  17375. /**
  17376. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17377. */
  17378. endSpriteCellID: number;
  17379. /**
  17380. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17381. */
  17382. spriteCellWidth: number;
  17383. /**
  17384. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17385. */
  17386. spriteCellHeight: number;
  17387. /**
  17388. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17389. */
  17390. spriteRandomStartCell: boolean;
  17391. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17392. translationPivot: Vector2;
  17393. /** @hidden */
  17394. protected _isAnimationSheetEnabled: boolean;
  17395. /**
  17396. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17397. */
  17398. beginAnimationOnStart: boolean;
  17399. /**
  17400. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17401. */
  17402. beginAnimationFrom: number;
  17403. /**
  17404. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17405. */
  17406. beginAnimationTo: number;
  17407. /**
  17408. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17409. */
  17410. beginAnimationLoop: boolean;
  17411. /**
  17412. * Gets or sets a world offset applied to all particles
  17413. */
  17414. worldOffset: Vector3;
  17415. /**
  17416. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17417. */
  17418. get isAnimationSheetEnabled(): boolean;
  17419. set isAnimationSheetEnabled(value: boolean);
  17420. /**
  17421. * Get hosting scene
  17422. * @returns the scene
  17423. */
  17424. getScene(): Scene;
  17425. /**
  17426. * You can use gravity if you want to give an orientation to your particles.
  17427. */
  17428. gravity: Vector3;
  17429. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17430. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17431. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17432. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17433. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17434. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17435. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17436. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17437. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17438. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17439. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17440. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17441. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17442. /**
  17443. * Defines the delay in milliseconds before starting the system (0 by default)
  17444. */
  17445. startDelay: number;
  17446. /**
  17447. * Gets the current list of drag gradients.
  17448. * You must use addDragGradient and removeDragGradient to udpate this list
  17449. * @returns the list of drag gradients
  17450. */
  17451. getDragGradients(): Nullable<Array<FactorGradient>>;
  17452. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17453. limitVelocityDamping: number;
  17454. /**
  17455. * Gets the current list of limit velocity gradients.
  17456. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17457. * @returns the list of limit velocity gradients
  17458. */
  17459. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17460. /**
  17461. * Gets the current list of color gradients.
  17462. * You must use addColorGradient and removeColorGradient to udpate this list
  17463. * @returns the list of color gradients
  17464. */
  17465. getColorGradients(): Nullable<Array<ColorGradient>>;
  17466. /**
  17467. * Gets the current list of size gradients.
  17468. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17469. * @returns the list of size gradients
  17470. */
  17471. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17472. /**
  17473. * Gets the current list of color remap gradients.
  17474. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17475. * @returns the list of color remap gradients
  17476. */
  17477. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17478. /**
  17479. * Gets the current list of alpha remap gradients.
  17480. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17481. * @returns the list of alpha remap gradients
  17482. */
  17483. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17484. /**
  17485. * Gets the current list of life time gradients.
  17486. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17487. * @returns the list of life time gradients
  17488. */
  17489. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17490. /**
  17491. * Gets the current list of angular speed gradients.
  17492. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17493. * @returns the list of angular speed gradients
  17494. */
  17495. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17496. /**
  17497. * Gets the current list of velocity gradients.
  17498. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17499. * @returns the list of velocity gradients
  17500. */
  17501. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17502. /**
  17503. * Gets the current list of start size gradients.
  17504. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17505. * @returns the list of start size gradients
  17506. */
  17507. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17508. /**
  17509. * Gets the current list of emit rate gradients.
  17510. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17511. * @returns the list of emit rate gradients
  17512. */
  17513. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17514. /**
  17515. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17516. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17517. */
  17518. get direction1(): Vector3;
  17519. set direction1(value: Vector3);
  17520. /**
  17521. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17522. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17523. */
  17524. get direction2(): Vector3;
  17525. set direction2(value: Vector3);
  17526. /**
  17527. * 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.
  17528. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17529. */
  17530. get minEmitBox(): Vector3;
  17531. set minEmitBox(value: Vector3);
  17532. /**
  17533. * 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.
  17534. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17535. */
  17536. get maxEmitBox(): Vector3;
  17537. set maxEmitBox(value: Vector3);
  17538. /**
  17539. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17540. */
  17541. color1: Color4;
  17542. /**
  17543. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17544. */
  17545. color2: Color4;
  17546. /**
  17547. * Color the particle will have at the end of its lifetime
  17548. */
  17549. colorDead: Color4;
  17550. /**
  17551. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17552. */
  17553. textureMask: Color4;
  17554. /**
  17555. * The particle emitter type defines the emitter used by the particle system.
  17556. * It can be for example box, sphere, or cone...
  17557. */
  17558. particleEmitterType: IParticleEmitterType;
  17559. /** @hidden */
  17560. _isSubEmitter: boolean;
  17561. /**
  17562. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17563. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17564. */
  17565. billboardMode: number;
  17566. protected _isBillboardBased: boolean;
  17567. /**
  17568. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17569. */
  17570. get isBillboardBased(): boolean;
  17571. set isBillboardBased(value: boolean);
  17572. /**
  17573. * The scene the particle system belongs to.
  17574. */
  17575. protected _scene: Scene;
  17576. /**
  17577. * Local cache of defines for image processing.
  17578. */
  17579. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17580. /**
  17581. * Default configuration related to image processing available in the standard Material.
  17582. */
  17583. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17584. /**
  17585. * Gets the image processing configuration used either in this material.
  17586. */
  17587. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17588. /**
  17589. * Sets the Default image processing configuration used either in the this material.
  17590. *
  17591. * If sets to null, the scene one is in use.
  17592. */
  17593. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17594. /**
  17595. * Attaches a new image processing configuration to the Standard Material.
  17596. * @param configuration
  17597. */
  17598. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17599. /** @hidden */
  17600. protected _reset(): void;
  17601. /** @hidden */
  17602. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17603. /**
  17604. * Instantiates a particle system.
  17605. * 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.
  17606. * @param name The name of the particle system
  17607. */
  17608. constructor(name: string);
  17609. /**
  17610. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17611. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17612. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17613. * @returns the emitter
  17614. */
  17615. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17616. /**
  17617. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17618. * @param radius The radius of the hemisphere to emit from
  17619. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17620. * @returns the emitter
  17621. */
  17622. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17623. /**
  17624. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17625. * @param radius The radius of the sphere to emit from
  17626. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17627. * @returns the emitter
  17628. */
  17629. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17630. /**
  17631. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17632. * @param radius The radius of the sphere to emit from
  17633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17635. * @returns the emitter
  17636. */
  17637. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17638. /**
  17639. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17640. * @param radius The radius of the emission cylinder
  17641. * @param height The height of the emission cylinder
  17642. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17643. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17644. * @returns the emitter
  17645. */
  17646. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17647. /**
  17648. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17649. * @param radius The radius of the cylinder to emit from
  17650. * @param height The height of the emission cylinder
  17651. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17654. * @returns the emitter
  17655. */
  17656. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17657. /**
  17658. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17659. * @param radius The radius of the cone to emit from
  17660. * @param angle The base angle of the cone
  17661. * @returns the emitter
  17662. */
  17663. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17664. /**
  17665. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17666. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17667. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17668. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17669. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17670. * @returns the emitter
  17671. */
  17672. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17673. }
  17674. }
  17675. declare module "babylonjs/Particles/subEmitter" {
  17676. import { Scene } from "babylonjs/scene";
  17677. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17678. /**
  17679. * Type of sub emitter
  17680. */
  17681. export enum SubEmitterType {
  17682. /**
  17683. * Attached to the particle over it's lifetime
  17684. */
  17685. ATTACHED = 0,
  17686. /**
  17687. * Created when the particle dies
  17688. */
  17689. END = 1
  17690. }
  17691. /**
  17692. * Sub emitter class used to emit particles from an existing particle
  17693. */
  17694. export class SubEmitter {
  17695. /**
  17696. * the particle system to be used by the sub emitter
  17697. */
  17698. particleSystem: ParticleSystem;
  17699. /**
  17700. * Type of the submitter (Default: END)
  17701. */
  17702. type: SubEmitterType;
  17703. /**
  17704. * 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)
  17705. * Note: This only is supported when using an emitter of type Mesh
  17706. */
  17707. inheritDirection: boolean;
  17708. /**
  17709. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17710. */
  17711. inheritedVelocityAmount: number;
  17712. /**
  17713. * Creates a sub emitter
  17714. * @param particleSystem the particle system to be used by the sub emitter
  17715. */
  17716. constructor(
  17717. /**
  17718. * the particle system to be used by the sub emitter
  17719. */
  17720. particleSystem: ParticleSystem);
  17721. /**
  17722. * Clones the sub emitter
  17723. * @returns the cloned sub emitter
  17724. */
  17725. clone(): SubEmitter;
  17726. /**
  17727. * Serialize current object to a JSON object
  17728. * @returns the serialized object
  17729. */
  17730. serialize(): any;
  17731. /** @hidden */
  17732. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17733. /**
  17734. * Creates a new SubEmitter from a serialized JSON version
  17735. * @param serializationObject defines the JSON object to read from
  17736. * @param scene defines the hosting scene
  17737. * @param rootUrl defines the rootUrl for data loading
  17738. * @returns a new SubEmitter
  17739. */
  17740. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17741. /** Release associated resources */
  17742. dispose(): void;
  17743. }
  17744. }
  17745. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17746. /** @hidden */
  17747. export var clipPlaneFragmentDeclaration: {
  17748. name: string;
  17749. shader: string;
  17750. };
  17751. }
  17752. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17753. /** @hidden */
  17754. export var imageProcessingDeclaration: {
  17755. name: string;
  17756. shader: string;
  17757. };
  17758. }
  17759. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17760. /** @hidden */
  17761. export var imageProcessingFunctions: {
  17762. name: string;
  17763. shader: string;
  17764. };
  17765. }
  17766. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17767. /** @hidden */
  17768. export var clipPlaneFragment: {
  17769. name: string;
  17770. shader: string;
  17771. };
  17772. }
  17773. declare module "babylonjs/Shaders/particles.fragment" {
  17774. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17775. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17776. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17777. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17778. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17779. /** @hidden */
  17780. export var particlesPixelShader: {
  17781. name: string;
  17782. shader: string;
  17783. };
  17784. }
  17785. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17786. /** @hidden */
  17787. export var clipPlaneVertexDeclaration: {
  17788. name: string;
  17789. shader: string;
  17790. };
  17791. }
  17792. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17793. /** @hidden */
  17794. export var clipPlaneVertex: {
  17795. name: string;
  17796. shader: string;
  17797. };
  17798. }
  17799. declare module "babylonjs/Shaders/particles.vertex" {
  17800. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17801. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17802. /** @hidden */
  17803. export var particlesVertexShader: {
  17804. name: string;
  17805. shader: string;
  17806. };
  17807. }
  17808. declare module "babylonjs/Particles/particleSystem" {
  17809. import { Nullable } from "babylonjs/types";
  17810. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17811. import { Observable } from "babylonjs/Misc/observable";
  17812. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17813. import { Effect } from "babylonjs/Materials/effect";
  17814. import { Scene, IDisposable } from "babylonjs/scene";
  17815. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17816. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17817. import { Particle } from "babylonjs/Particles/particle";
  17818. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17819. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17820. import "babylonjs/Shaders/particles.fragment";
  17821. import "babylonjs/Shaders/particles.vertex";
  17822. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17823. /**
  17824. * This represents a particle system in Babylon.
  17825. * 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.
  17826. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17827. * @example https://doc.babylonjs.com/babylon101/particles
  17828. */
  17829. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17830. /**
  17831. * Billboard mode will only apply to Y axis
  17832. */
  17833. static readonly BILLBOARDMODE_Y: number;
  17834. /**
  17835. * Billboard mode will apply to all axes
  17836. */
  17837. static readonly BILLBOARDMODE_ALL: number;
  17838. /**
  17839. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17840. */
  17841. static readonly BILLBOARDMODE_STRETCHED: number;
  17842. /**
  17843. * This function can be defined to provide custom update for active particles.
  17844. * This function will be called instead of regular update (age, position, color, etc.).
  17845. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17846. */
  17847. updateFunction: (particles: Particle[]) => void;
  17848. private _emitterWorldMatrix;
  17849. /**
  17850. * This function can be defined to specify initial direction for every new particle.
  17851. * It by default use the emitterType defined function
  17852. */
  17853. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17854. /**
  17855. * This function can be defined to specify initial position for every new particle.
  17856. * It by default use the emitterType defined function
  17857. */
  17858. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17859. /**
  17860. * @hidden
  17861. */
  17862. _inheritedVelocityOffset: Vector3;
  17863. /**
  17864. * An event triggered when the system is disposed
  17865. */
  17866. onDisposeObservable: Observable<ParticleSystem>;
  17867. private _onDisposeObserver;
  17868. /**
  17869. * Sets a callback that will be triggered when the system is disposed
  17870. */
  17871. set onDispose(callback: () => void);
  17872. private _particles;
  17873. private _epsilon;
  17874. private _capacity;
  17875. private _stockParticles;
  17876. private _newPartsExcess;
  17877. private _vertexData;
  17878. private _vertexBuffer;
  17879. private _vertexBuffers;
  17880. private _spriteBuffer;
  17881. private _indexBuffer;
  17882. private _effect;
  17883. private _customEffect;
  17884. private _cachedDefines;
  17885. private _scaledColorStep;
  17886. private _colorDiff;
  17887. private _scaledDirection;
  17888. private _scaledGravity;
  17889. private _currentRenderId;
  17890. private _alive;
  17891. private _useInstancing;
  17892. private _started;
  17893. private _stopped;
  17894. private _actualFrame;
  17895. private _scaledUpdateSpeed;
  17896. private _vertexBufferSize;
  17897. /** @hidden */
  17898. _currentEmitRateGradient: Nullable<FactorGradient>;
  17899. /** @hidden */
  17900. _currentEmitRate1: number;
  17901. /** @hidden */
  17902. _currentEmitRate2: number;
  17903. /** @hidden */
  17904. _currentStartSizeGradient: Nullable<FactorGradient>;
  17905. /** @hidden */
  17906. _currentStartSize1: number;
  17907. /** @hidden */
  17908. _currentStartSize2: number;
  17909. private readonly _rawTextureWidth;
  17910. private _rampGradientsTexture;
  17911. private _useRampGradients;
  17912. /** Gets or sets a boolean indicating that ramp gradients must be used
  17913. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17914. */
  17915. get useRampGradients(): boolean;
  17916. set useRampGradients(value: boolean);
  17917. /**
  17918. * 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.
  17919. * 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: [])
  17920. */
  17921. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17922. private _subEmitters;
  17923. /**
  17924. * @hidden
  17925. * If the particle systems emitter should be disposed when the particle system is disposed
  17926. */
  17927. _disposeEmitterOnDispose: boolean;
  17928. /**
  17929. * The current active Sub-systems, this property is used by the root particle system only.
  17930. */
  17931. activeSubSystems: Array<ParticleSystem>;
  17932. private _rootParticleSystem;
  17933. /**
  17934. * Gets the current list of active particles
  17935. */
  17936. get particles(): Particle[];
  17937. /**
  17938. * Returns the string "ParticleSystem"
  17939. * @returns a string containing the class name
  17940. */
  17941. getClassName(): string;
  17942. /**
  17943. * Instantiates a particle system.
  17944. * 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.
  17945. * @param name The name of the particle system
  17946. * @param capacity The max number of particles alive at the same time
  17947. * @param scene The scene the particle system belongs to
  17948. * @param customEffect a custom effect used to change the way particles are rendered by default
  17949. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17950. * @param epsilon Offset used to render the particles
  17951. */
  17952. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17953. private _addFactorGradient;
  17954. private _removeFactorGradient;
  17955. /**
  17956. * Adds a new life time gradient
  17957. * @param gradient defines the gradient to use (between 0 and 1)
  17958. * @param factor defines the life time factor to affect to the specified gradient
  17959. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17960. * @returns the current particle system
  17961. */
  17962. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17963. /**
  17964. * Remove a specific life time gradient
  17965. * @param gradient defines the gradient to remove
  17966. * @returns the current particle system
  17967. */
  17968. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17969. /**
  17970. * Adds a new size gradient
  17971. * @param gradient defines the gradient to use (between 0 and 1)
  17972. * @param factor defines the size factor to affect to the specified gradient
  17973. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17974. * @returns the current particle system
  17975. */
  17976. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17977. /**
  17978. * Remove a specific size gradient
  17979. * @param gradient defines the gradient to remove
  17980. * @returns the current particle system
  17981. */
  17982. removeSizeGradient(gradient: number): IParticleSystem;
  17983. /**
  17984. * Adds a new color remap gradient
  17985. * @param gradient defines the gradient to use (between 0 and 1)
  17986. * @param min defines the color remap minimal range
  17987. * @param max defines the color remap maximal range
  17988. * @returns the current particle system
  17989. */
  17990. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17991. /**
  17992. * Remove a specific color remap gradient
  17993. * @param gradient defines the gradient to remove
  17994. * @returns the current particle system
  17995. */
  17996. removeColorRemapGradient(gradient: number): IParticleSystem;
  17997. /**
  17998. * Adds a new alpha remap gradient
  17999. * @param gradient defines the gradient to use (between 0 and 1)
  18000. * @param min defines the alpha remap minimal range
  18001. * @param max defines the alpha remap maximal range
  18002. * @returns the current particle system
  18003. */
  18004. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18005. /**
  18006. * Remove a specific alpha remap gradient
  18007. * @param gradient defines the gradient to remove
  18008. * @returns the current particle system
  18009. */
  18010. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  18011. /**
  18012. * Adds a new angular speed gradient
  18013. * @param gradient defines the gradient to use (between 0 and 1)
  18014. * @param factor defines the angular speed to affect to the specified gradient
  18015. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18016. * @returns the current particle system
  18017. */
  18018. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18019. /**
  18020. * Remove a specific angular speed gradient
  18021. * @param gradient defines the gradient to remove
  18022. * @returns the current particle system
  18023. */
  18024. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18025. /**
  18026. * Adds a new velocity gradient
  18027. * @param gradient defines the gradient to use (between 0 and 1)
  18028. * @param factor defines the velocity to affect to the specified gradient
  18029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18030. * @returns the current particle system
  18031. */
  18032. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18033. /**
  18034. * Remove a specific velocity gradient
  18035. * @param gradient defines the gradient to remove
  18036. * @returns the current particle system
  18037. */
  18038. removeVelocityGradient(gradient: number): IParticleSystem;
  18039. /**
  18040. * Adds a new limit velocity gradient
  18041. * @param gradient defines the gradient to use (between 0 and 1)
  18042. * @param factor defines the limit velocity value to affect to the specified gradient
  18043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18044. * @returns the current particle system
  18045. */
  18046. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18047. /**
  18048. * Remove a specific limit velocity gradient
  18049. * @param gradient defines the gradient to remove
  18050. * @returns the current particle system
  18051. */
  18052. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18053. /**
  18054. * Adds a new drag gradient
  18055. * @param gradient defines the gradient to use (between 0 and 1)
  18056. * @param factor defines the drag value to affect to the specified gradient
  18057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18058. * @returns the current particle system
  18059. */
  18060. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18061. /**
  18062. * Remove a specific drag gradient
  18063. * @param gradient defines the gradient to remove
  18064. * @returns the current particle system
  18065. */
  18066. removeDragGradient(gradient: number): IParticleSystem;
  18067. /**
  18068. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18069. * @param gradient defines the gradient to use (between 0 and 1)
  18070. * @param factor defines the emit rate value to affect to the specified gradient
  18071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18072. * @returns the current particle system
  18073. */
  18074. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18075. /**
  18076. * Remove a specific emit rate gradient
  18077. * @param gradient defines the gradient to remove
  18078. * @returns the current particle system
  18079. */
  18080. removeEmitRateGradient(gradient: number): IParticleSystem;
  18081. /**
  18082. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18083. * @param gradient defines the gradient to use (between 0 and 1)
  18084. * @param factor defines the start size value to affect to the specified gradient
  18085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18086. * @returns the current particle system
  18087. */
  18088. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18089. /**
  18090. * Remove a specific start size gradient
  18091. * @param gradient defines the gradient to remove
  18092. * @returns the current particle system
  18093. */
  18094. removeStartSizeGradient(gradient: number): IParticleSystem;
  18095. private _createRampGradientTexture;
  18096. /**
  18097. * Gets the current list of ramp gradients.
  18098. * You must use addRampGradient and removeRampGradient to udpate this list
  18099. * @returns the list of ramp gradients
  18100. */
  18101. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18102. /**
  18103. * Adds a new ramp gradient used to remap particle colors
  18104. * @param gradient defines the gradient to use (between 0 and 1)
  18105. * @param color defines the color to affect to the specified gradient
  18106. * @returns the current particle system
  18107. */
  18108. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  18109. /**
  18110. * Remove a specific ramp gradient
  18111. * @param gradient defines the gradient to remove
  18112. * @returns the current particle system
  18113. */
  18114. removeRampGradient(gradient: number): ParticleSystem;
  18115. /**
  18116. * Adds a new color gradient
  18117. * @param gradient defines the gradient to use (between 0 and 1)
  18118. * @param color1 defines the color to affect to the specified gradient
  18119. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18120. * @returns this particle system
  18121. */
  18122. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18123. /**
  18124. * Remove a specific color gradient
  18125. * @param gradient defines the gradient to remove
  18126. * @returns this particle system
  18127. */
  18128. removeColorGradient(gradient: number): IParticleSystem;
  18129. private _fetchR;
  18130. protected _reset(): void;
  18131. private _resetEffect;
  18132. private _createVertexBuffers;
  18133. private _createIndexBuffer;
  18134. /**
  18135. * Gets the maximum number of particles active at the same time.
  18136. * @returns The max number of active particles.
  18137. */
  18138. getCapacity(): number;
  18139. /**
  18140. * Gets whether there are still active particles in the system.
  18141. * @returns True if it is alive, otherwise false.
  18142. */
  18143. isAlive(): boolean;
  18144. /**
  18145. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18146. * @returns True if it has been started, otherwise false.
  18147. */
  18148. isStarted(): boolean;
  18149. private _prepareSubEmitterInternalArray;
  18150. /**
  18151. * Starts the particle system and begins to emit
  18152. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  18153. */
  18154. start(delay?: number): void;
  18155. /**
  18156. * Stops the particle system.
  18157. * @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.
  18158. */
  18159. stop(stopSubEmitters?: boolean): void;
  18160. /**
  18161. * Remove all active particles
  18162. */
  18163. reset(): void;
  18164. /**
  18165. * @hidden (for internal use only)
  18166. */
  18167. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  18168. /**
  18169. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  18170. * Its lifetime will start back at 0.
  18171. */
  18172. recycleParticle: (particle: Particle) => void;
  18173. private _stopSubEmitters;
  18174. private _createParticle;
  18175. private _removeFromRoot;
  18176. private _emitFromParticle;
  18177. private _update;
  18178. /** @hidden */
  18179. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  18180. /** @hidden */
  18181. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  18182. /** @hidden */
  18183. private _getEffect;
  18184. /**
  18185. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  18186. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  18187. */
  18188. animate(preWarmOnly?: boolean): void;
  18189. private _appendParticleVertices;
  18190. /**
  18191. * Rebuilds the particle system.
  18192. */
  18193. rebuild(): void;
  18194. /**
  18195. * Is this system ready to be used/rendered
  18196. * @return true if the system is ready
  18197. */
  18198. isReady(): boolean;
  18199. private _render;
  18200. /**
  18201. * Renders the particle system in its current state.
  18202. * @returns the current number of particles
  18203. */
  18204. render(): number;
  18205. /**
  18206. * Disposes the particle system and free the associated resources
  18207. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18208. */
  18209. dispose(disposeTexture?: boolean): void;
  18210. /**
  18211. * Clones the particle system.
  18212. * @param name The name of the cloned object
  18213. * @param newEmitter The new emitter to use
  18214. * @returns the cloned particle system
  18215. */
  18216. clone(name: string, newEmitter: any): ParticleSystem;
  18217. /**
  18218. * Serializes the particle system to a JSON object.
  18219. * @returns the JSON object
  18220. */
  18221. serialize(): any;
  18222. /** @hidden */
  18223. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  18224. /** @hidden */
  18225. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  18226. /**
  18227. * Parses a JSON object to create a particle system.
  18228. * @param parsedParticleSystem The JSON object to parse
  18229. * @param scene The scene to create the particle system in
  18230. * @param rootUrl The root url to use to load external dependencies like texture
  18231. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  18232. * @returns the Parsed particle system
  18233. */
  18234. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  18235. }
  18236. }
  18237. declare module "babylonjs/Particles/particle" {
  18238. import { Nullable } from "babylonjs/types";
  18239. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  18240. import { Color4 } from "babylonjs/Maths/math.color";
  18241. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  18242. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  18243. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  18244. /**
  18245. * A particle represents one of the element emitted by a particle system.
  18246. * This is mainly define by its coordinates, direction, velocity and age.
  18247. */
  18248. export class Particle {
  18249. /**
  18250. * The particle system the particle belongs to.
  18251. */
  18252. particleSystem: ParticleSystem;
  18253. private static _Count;
  18254. /**
  18255. * Unique ID of the particle
  18256. */
  18257. id: number;
  18258. /**
  18259. * The world position of the particle in the scene.
  18260. */
  18261. position: Vector3;
  18262. /**
  18263. * The world direction of the particle in the scene.
  18264. */
  18265. direction: Vector3;
  18266. /**
  18267. * The color of the particle.
  18268. */
  18269. color: Color4;
  18270. /**
  18271. * The color change of the particle per step.
  18272. */
  18273. colorStep: Color4;
  18274. /**
  18275. * Defines how long will the life of the particle be.
  18276. */
  18277. lifeTime: number;
  18278. /**
  18279. * The current age of the particle.
  18280. */
  18281. age: number;
  18282. /**
  18283. * The current size of the particle.
  18284. */
  18285. size: number;
  18286. /**
  18287. * The current scale of the particle.
  18288. */
  18289. scale: Vector2;
  18290. /**
  18291. * The current angle of the particle.
  18292. */
  18293. angle: number;
  18294. /**
  18295. * Defines how fast is the angle changing.
  18296. */
  18297. angularSpeed: number;
  18298. /**
  18299. * Defines the cell index used by the particle to be rendered from a sprite.
  18300. */
  18301. cellIndex: number;
  18302. /**
  18303. * The information required to support color remapping
  18304. */
  18305. remapData: Vector4;
  18306. /** @hidden */
  18307. _randomCellOffset?: number;
  18308. /** @hidden */
  18309. _initialDirection: Nullable<Vector3>;
  18310. /** @hidden */
  18311. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18312. /** @hidden */
  18313. _initialStartSpriteCellID: number;
  18314. /** @hidden */
  18315. _initialEndSpriteCellID: number;
  18316. /** @hidden */
  18317. _currentColorGradient: Nullable<ColorGradient>;
  18318. /** @hidden */
  18319. _currentColor1: Color4;
  18320. /** @hidden */
  18321. _currentColor2: Color4;
  18322. /** @hidden */
  18323. _currentSizeGradient: Nullable<FactorGradient>;
  18324. /** @hidden */
  18325. _currentSize1: number;
  18326. /** @hidden */
  18327. _currentSize2: number;
  18328. /** @hidden */
  18329. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18330. /** @hidden */
  18331. _currentAngularSpeed1: number;
  18332. /** @hidden */
  18333. _currentAngularSpeed2: number;
  18334. /** @hidden */
  18335. _currentVelocityGradient: Nullable<FactorGradient>;
  18336. /** @hidden */
  18337. _currentVelocity1: number;
  18338. /** @hidden */
  18339. _currentVelocity2: number;
  18340. /** @hidden */
  18341. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18342. /** @hidden */
  18343. _currentLimitVelocity1: number;
  18344. /** @hidden */
  18345. _currentLimitVelocity2: number;
  18346. /** @hidden */
  18347. _currentDragGradient: Nullable<FactorGradient>;
  18348. /** @hidden */
  18349. _currentDrag1: number;
  18350. /** @hidden */
  18351. _currentDrag2: number;
  18352. /** @hidden */
  18353. _randomNoiseCoordinates1: Vector3;
  18354. /** @hidden */
  18355. _randomNoiseCoordinates2: Vector3;
  18356. /**
  18357. * Creates a new instance Particle
  18358. * @param particleSystem the particle system the particle belongs to
  18359. */
  18360. constructor(
  18361. /**
  18362. * The particle system the particle belongs to.
  18363. */
  18364. particleSystem: ParticleSystem);
  18365. private updateCellInfoFromSystem;
  18366. /**
  18367. * Defines how the sprite cell index is updated for the particle
  18368. */
  18369. updateCellIndex(): void;
  18370. /** @hidden */
  18371. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18372. /** @hidden */
  18373. _inheritParticleInfoToSubEmitters(): void;
  18374. /** @hidden */
  18375. _reset(): void;
  18376. /**
  18377. * Copy the properties of particle to another one.
  18378. * @param other the particle to copy the information to.
  18379. */
  18380. copyTo(other: Particle): void;
  18381. }
  18382. }
  18383. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18384. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18385. import { Effect } from "babylonjs/Materials/effect";
  18386. import { Particle } from "babylonjs/Particles/particle";
  18387. /**
  18388. * Particle emitter represents a volume emitting particles.
  18389. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18390. */
  18391. export interface IParticleEmitterType {
  18392. /**
  18393. * Called by the particle System when the direction is computed for the created particle.
  18394. * @param worldMatrix is the world matrix of the particle system
  18395. * @param directionToUpdate is the direction vector to update with the result
  18396. * @param particle is the particle we are computed the direction for
  18397. */
  18398. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18399. /**
  18400. * Called by the particle System when the position is computed for the created particle.
  18401. * @param worldMatrix is the world matrix of the particle system
  18402. * @param positionToUpdate is the position vector to update with the result
  18403. * @param particle is the particle we are computed the position for
  18404. */
  18405. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18406. /**
  18407. * Clones the current emitter and returns a copy of it
  18408. * @returns the new emitter
  18409. */
  18410. clone(): IParticleEmitterType;
  18411. /**
  18412. * Called by the GPUParticleSystem to setup the update shader
  18413. * @param effect defines the update shader
  18414. */
  18415. applyToShader(effect: Effect): void;
  18416. /**
  18417. * Returns a string to use to update the GPU particles update shader
  18418. * @returns the effect defines string
  18419. */
  18420. getEffectDefines(): string;
  18421. /**
  18422. * Returns a string representing the class name
  18423. * @returns a string containing the class name
  18424. */
  18425. getClassName(): string;
  18426. /**
  18427. * Serializes the particle system to a JSON object.
  18428. * @returns the JSON object
  18429. */
  18430. serialize(): any;
  18431. /**
  18432. * Parse properties from a JSON object
  18433. * @param serializationObject defines the JSON object
  18434. */
  18435. parse(serializationObject: any): void;
  18436. }
  18437. }
  18438. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18439. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18440. import { Effect } from "babylonjs/Materials/effect";
  18441. import { Particle } from "babylonjs/Particles/particle";
  18442. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18443. /**
  18444. * Particle emitter emitting particles from the inside of a box.
  18445. * It emits the particles randomly between 2 given directions.
  18446. */
  18447. export class BoxParticleEmitter implements IParticleEmitterType {
  18448. /**
  18449. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18450. */
  18451. direction1: Vector3;
  18452. /**
  18453. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18454. */
  18455. direction2: Vector3;
  18456. /**
  18457. * 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.
  18458. */
  18459. minEmitBox: Vector3;
  18460. /**
  18461. * 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.
  18462. */
  18463. maxEmitBox: Vector3;
  18464. /**
  18465. * Creates a new instance BoxParticleEmitter
  18466. */
  18467. constructor();
  18468. /**
  18469. * Called by the particle System when the direction is computed for the created particle.
  18470. * @param worldMatrix is the world matrix of the particle system
  18471. * @param directionToUpdate is the direction vector to update with the result
  18472. * @param particle is the particle we are computed the direction for
  18473. */
  18474. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18475. /**
  18476. * Called by the particle System when the position is computed for the created particle.
  18477. * @param worldMatrix is the world matrix of the particle system
  18478. * @param positionToUpdate is the position vector to update with the result
  18479. * @param particle is the particle we are computed the position for
  18480. */
  18481. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18482. /**
  18483. * Clones the current emitter and returns a copy of it
  18484. * @returns the new emitter
  18485. */
  18486. clone(): BoxParticleEmitter;
  18487. /**
  18488. * Called by the GPUParticleSystem to setup the update shader
  18489. * @param effect defines the update shader
  18490. */
  18491. applyToShader(effect: Effect): void;
  18492. /**
  18493. * Returns a string to use to update the GPU particles update shader
  18494. * @returns a string containng the defines string
  18495. */
  18496. getEffectDefines(): string;
  18497. /**
  18498. * Returns the string "BoxParticleEmitter"
  18499. * @returns a string containing the class name
  18500. */
  18501. getClassName(): string;
  18502. /**
  18503. * Serializes the particle system to a JSON object.
  18504. * @returns the JSON object
  18505. */
  18506. serialize(): any;
  18507. /**
  18508. * Parse properties from a JSON object
  18509. * @param serializationObject defines the JSON object
  18510. */
  18511. parse(serializationObject: any): void;
  18512. }
  18513. }
  18514. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18515. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18516. import { Effect } from "babylonjs/Materials/effect";
  18517. import { Particle } from "babylonjs/Particles/particle";
  18518. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18519. /**
  18520. * Particle emitter emitting particles from the inside of a cone.
  18521. * It emits the particles alongside the cone volume from the base to the particle.
  18522. * The emission direction might be randomized.
  18523. */
  18524. export class ConeParticleEmitter implements IParticleEmitterType {
  18525. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18526. directionRandomizer: number;
  18527. private _radius;
  18528. private _angle;
  18529. private _height;
  18530. /**
  18531. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18532. */
  18533. radiusRange: number;
  18534. /**
  18535. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18536. */
  18537. heightRange: number;
  18538. /**
  18539. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18540. */
  18541. emitFromSpawnPointOnly: boolean;
  18542. /**
  18543. * Gets or sets the radius of the emission cone
  18544. */
  18545. get radius(): number;
  18546. set radius(value: number);
  18547. /**
  18548. * Gets or sets the angle of the emission cone
  18549. */
  18550. get angle(): number;
  18551. set angle(value: number);
  18552. private _buildHeight;
  18553. /**
  18554. * Creates a new instance ConeParticleEmitter
  18555. * @param radius the radius of the emission cone (1 by default)
  18556. * @param angle the cone base angle (PI by default)
  18557. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18558. */
  18559. constructor(radius?: number, angle?: number,
  18560. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18561. directionRandomizer?: number);
  18562. /**
  18563. * Called by the particle System when the direction is computed for the created particle.
  18564. * @param worldMatrix is the world matrix of the particle system
  18565. * @param directionToUpdate is the direction vector to update with the result
  18566. * @param particle is the particle we are computed the direction for
  18567. */
  18568. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18569. /**
  18570. * Called by the particle System when the position is computed for the created particle.
  18571. * @param worldMatrix is the world matrix of the particle system
  18572. * @param positionToUpdate is the position vector to update with the result
  18573. * @param particle is the particle we are computed the position for
  18574. */
  18575. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18576. /**
  18577. * Clones the current emitter and returns a copy of it
  18578. * @returns the new emitter
  18579. */
  18580. clone(): ConeParticleEmitter;
  18581. /**
  18582. * Called by the GPUParticleSystem to setup the update shader
  18583. * @param effect defines the update shader
  18584. */
  18585. applyToShader(effect: Effect): void;
  18586. /**
  18587. * Returns a string to use to update the GPU particles update shader
  18588. * @returns a string containng the defines string
  18589. */
  18590. getEffectDefines(): string;
  18591. /**
  18592. * Returns the string "ConeParticleEmitter"
  18593. * @returns a string containing the class name
  18594. */
  18595. getClassName(): string;
  18596. /**
  18597. * Serializes the particle system to a JSON object.
  18598. * @returns the JSON object
  18599. */
  18600. serialize(): any;
  18601. /**
  18602. * Parse properties from a JSON object
  18603. * @param serializationObject defines the JSON object
  18604. */
  18605. parse(serializationObject: any): void;
  18606. }
  18607. }
  18608. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18609. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18610. import { Effect } from "babylonjs/Materials/effect";
  18611. import { Particle } from "babylonjs/Particles/particle";
  18612. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18613. /**
  18614. * Particle emitter emitting particles from the inside of a cylinder.
  18615. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18616. */
  18617. export class CylinderParticleEmitter implements IParticleEmitterType {
  18618. /**
  18619. * The radius of the emission cylinder.
  18620. */
  18621. radius: number;
  18622. /**
  18623. * The height of the emission cylinder.
  18624. */
  18625. height: number;
  18626. /**
  18627. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18628. */
  18629. radiusRange: number;
  18630. /**
  18631. * How much to randomize the particle direction [0-1].
  18632. */
  18633. directionRandomizer: number;
  18634. /**
  18635. * Creates a new instance CylinderParticleEmitter
  18636. * @param radius the radius of the emission cylinder (1 by default)
  18637. * @param height the height of the emission cylinder (1 by default)
  18638. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18639. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18640. */
  18641. constructor(
  18642. /**
  18643. * The radius of the emission cylinder.
  18644. */
  18645. radius?: number,
  18646. /**
  18647. * The height of the emission cylinder.
  18648. */
  18649. height?: number,
  18650. /**
  18651. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18652. */
  18653. radiusRange?: number,
  18654. /**
  18655. * How much to randomize the particle direction [0-1].
  18656. */
  18657. directionRandomizer?: number);
  18658. /**
  18659. * Called by the particle System when the direction is computed for the created particle.
  18660. * @param worldMatrix is the world matrix of the particle system
  18661. * @param directionToUpdate is the direction vector to update with the result
  18662. * @param particle is the particle we are computed the direction for
  18663. */
  18664. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18665. /**
  18666. * Called by the particle System when the position is computed for the created particle.
  18667. * @param worldMatrix is the world matrix of the particle system
  18668. * @param positionToUpdate is the position vector to update with the result
  18669. * @param particle is the particle we are computed the position for
  18670. */
  18671. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18672. /**
  18673. * Clones the current emitter and returns a copy of it
  18674. * @returns the new emitter
  18675. */
  18676. clone(): CylinderParticleEmitter;
  18677. /**
  18678. * Called by the GPUParticleSystem to setup the update shader
  18679. * @param effect defines the update shader
  18680. */
  18681. applyToShader(effect: Effect): void;
  18682. /**
  18683. * Returns a string to use to update the GPU particles update shader
  18684. * @returns a string containng the defines string
  18685. */
  18686. getEffectDefines(): string;
  18687. /**
  18688. * Returns the string "CylinderParticleEmitter"
  18689. * @returns a string containing the class name
  18690. */
  18691. getClassName(): string;
  18692. /**
  18693. * Serializes the particle system to a JSON object.
  18694. * @returns the JSON object
  18695. */
  18696. serialize(): any;
  18697. /**
  18698. * Parse properties from a JSON object
  18699. * @param serializationObject defines the JSON object
  18700. */
  18701. parse(serializationObject: any): void;
  18702. }
  18703. /**
  18704. * Particle emitter emitting particles from the inside of a cylinder.
  18705. * It emits the particles randomly between two vectors.
  18706. */
  18707. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18708. /**
  18709. * The min limit of the emission direction.
  18710. */
  18711. direction1: Vector3;
  18712. /**
  18713. * The max limit of the emission direction.
  18714. */
  18715. direction2: Vector3;
  18716. /**
  18717. * Creates a new instance CylinderDirectedParticleEmitter
  18718. * @param radius the radius of the emission cylinder (1 by default)
  18719. * @param height the height of the emission cylinder (1 by default)
  18720. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18721. * @param direction1 the min limit of the emission direction (up vector by default)
  18722. * @param direction2 the max limit of the emission direction (up vector by default)
  18723. */
  18724. constructor(radius?: number, height?: number, radiusRange?: number,
  18725. /**
  18726. * The min limit of the emission direction.
  18727. */
  18728. direction1?: Vector3,
  18729. /**
  18730. * The max limit of the emission direction.
  18731. */
  18732. direction2?: Vector3);
  18733. /**
  18734. * Called by the particle System when the direction is computed for the created particle.
  18735. * @param worldMatrix is the world matrix of the particle system
  18736. * @param directionToUpdate is the direction vector to update with the result
  18737. * @param particle is the particle we are computed the direction for
  18738. */
  18739. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18740. /**
  18741. * Clones the current emitter and returns a copy of it
  18742. * @returns the new emitter
  18743. */
  18744. clone(): CylinderDirectedParticleEmitter;
  18745. /**
  18746. * Called by the GPUParticleSystem to setup the update shader
  18747. * @param effect defines the update shader
  18748. */
  18749. applyToShader(effect: Effect): void;
  18750. /**
  18751. * Returns a string to use to update the GPU particles update shader
  18752. * @returns a string containng the defines string
  18753. */
  18754. getEffectDefines(): string;
  18755. /**
  18756. * Returns the string "CylinderDirectedParticleEmitter"
  18757. * @returns a string containing the class name
  18758. */
  18759. getClassName(): string;
  18760. /**
  18761. * Serializes the particle system to a JSON object.
  18762. * @returns the JSON object
  18763. */
  18764. serialize(): any;
  18765. /**
  18766. * Parse properties from a JSON object
  18767. * @param serializationObject defines the JSON object
  18768. */
  18769. parse(serializationObject: any): void;
  18770. }
  18771. }
  18772. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18773. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18774. import { Effect } from "babylonjs/Materials/effect";
  18775. import { Particle } from "babylonjs/Particles/particle";
  18776. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18777. /**
  18778. * Particle emitter emitting particles from the inside of a hemisphere.
  18779. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18780. */
  18781. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18782. /**
  18783. * The radius of the emission hemisphere.
  18784. */
  18785. radius: number;
  18786. /**
  18787. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18788. */
  18789. radiusRange: number;
  18790. /**
  18791. * How much to randomize the particle direction [0-1].
  18792. */
  18793. directionRandomizer: number;
  18794. /**
  18795. * Creates a new instance HemisphericParticleEmitter
  18796. * @param radius the radius of the emission hemisphere (1 by default)
  18797. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18798. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18799. */
  18800. constructor(
  18801. /**
  18802. * The radius of the emission hemisphere.
  18803. */
  18804. radius?: number,
  18805. /**
  18806. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18807. */
  18808. radiusRange?: number,
  18809. /**
  18810. * How much to randomize the particle direction [0-1].
  18811. */
  18812. directionRandomizer?: number);
  18813. /**
  18814. * Called by the particle System when the direction is computed for the created particle.
  18815. * @param worldMatrix is the world matrix of the particle system
  18816. * @param directionToUpdate is the direction vector to update with the result
  18817. * @param particle is the particle we are computed the direction for
  18818. */
  18819. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18820. /**
  18821. * Called by the particle System when the position is computed for the created particle.
  18822. * @param worldMatrix is the world matrix of the particle system
  18823. * @param positionToUpdate is the position vector to update with the result
  18824. * @param particle is the particle we are computed the position for
  18825. */
  18826. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18827. /**
  18828. * Clones the current emitter and returns a copy of it
  18829. * @returns the new emitter
  18830. */
  18831. clone(): HemisphericParticleEmitter;
  18832. /**
  18833. * Called by the GPUParticleSystem to setup the update shader
  18834. * @param effect defines the update shader
  18835. */
  18836. applyToShader(effect: Effect): void;
  18837. /**
  18838. * Returns a string to use to update the GPU particles update shader
  18839. * @returns a string containng the defines string
  18840. */
  18841. getEffectDefines(): string;
  18842. /**
  18843. * Returns the string "HemisphericParticleEmitter"
  18844. * @returns a string containing the class name
  18845. */
  18846. getClassName(): string;
  18847. /**
  18848. * Serializes the particle system to a JSON object.
  18849. * @returns the JSON object
  18850. */
  18851. serialize(): any;
  18852. /**
  18853. * Parse properties from a JSON object
  18854. * @param serializationObject defines the JSON object
  18855. */
  18856. parse(serializationObject: any): void;
  18857. }
  18858. }
  18859. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18860. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18861. import { Effect } from "babylonjs/Materials/effect";
  18862. import { Particle } from "babylonjs/Particles/particle";
  18863. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18864. /**
  18865. * Particle emitter emitting particles from a point.
  18866. * It emits the particles randomly between 2 given directions.
  18867. */
  18868. export class PointParticleEmitter implements IParticleEmitterType {
  18869. /**
  18870. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18871. */
  18872. direction1: Vector3;
  18873. /**
  18874. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18875. */
  18876. direction2: Vector3;
  18877. /**
  18878. * Creates a new instance PointParticleEmitter
  18879. */
  18880. constructor();
  18881. /**
  18882. * Called by the particle System when the direction is computed for the created particle.
  18883. * @param worldMatrix is the world matrix of the particle system
  18884. * @param directionToUpdate is the direction vector to update with the result
  18885. * @param particle is the particle we are computed the direction for
  18886. */
  18887. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18888. /**
  18889. * Called by the particle System when the position is computed for the created particle.
  18890. * @param worldMatrix is the world matrix of the particle system
  18891. * @param positionToUpdate is the position vector to update with the result
  18892. * @param particle is the particle we are computed the position for
  18893. */
  18894. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18895. /**
  18896. * Clones the current emitter and returns a copy of it
  18897. * @returns the new emitter
  18898. */
  18899. clone(): PointParticleEmitter;
  18900. /**
  18901. * Called by the GPUParticleSystem to setup the update shader
  18902. * @param effect defines the update shader
  18903. */
  18904. applyToShader(effect: Effect): void;
  18905. /**
  18906. * Returns a string to use to update the GPU particles update shader
  18907. * @returns a string containng the defines string
  18908. */
  18909. getEffectDefines(): string;
  18910. /**
  18911. * Returns the string "PointParticleEmitter"
  18912. * @returns a string containing the class name
  18913. */
  18914. getClassName(): string;
  18915. /**
  18916. * Serializes the particle system to a JSON object.
  18917. * @returns the JSON object
  18918. */
  18919. serialize(): any;
  18920. /**
  18921. * Parse properties from a JSON object
  18922. * @param serializationObject defines the JSON object
  18923. */
  18924. parse(serializationObject: any): void;
  18925. }
  18926. }
  18927. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18928. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18929. import { Effect } from "babylonjs/Materials/effect";
  18930. import { Particle } from "babylonjs/Particles/particle";
  18931. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18932. /**
  18933. * Particle emitter emitting particles from the inside of a sphere.
  18934. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18935. */
  18936. export class SphereParticleEmitter implements IParticleEmitterType {
  18937. /**
  18938. * The radius of the emission sphere.
  18939. */
  18940. radius: number;
  18941. /**
  18942. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18943. */
  18944. radiusRange: number;
  18945. /**
  18946. * How much to randomize the particle direction [0-1].
  18947. */
  18948. directionRandomizer: number;
  18949. /**
  18950. * Creates a new instance SphereParticleEmitter
  18951. * @param radius the radius of the emission sphere (1 by default)
  18952. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18953. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18954. */
  18955. constructor(
  18956. /**
  18957. * The radius of the emission sphere.
  18958. */
  18959. radius?: number,
  18960. /**
  18961. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18962. */
  18963. radiusRange?: number,
  18964. /**
  18965. * How much to randomize the particle direction [0-1].
  18966. */
  18967. directionRandomizer?: number);
  18968. /**
  18969. * Called by the particle System when the direction is computed for the created particle.
  18970. * @param worldMatrix is the world matrix of the particle system
  18971. * @param directionToUpdate is the direction vector to update with the result
  18972. * @param particle is the particle we are computed the direction for
  18973. */
  18974. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18975. /**
  18976. * Called by the particle System when the position is computed for the created particle.
  18977. * @param worldMatrix is the world matrix of the particle system
  18978. * @param positionToUpdate is the position vector to update with the result
  18979. * @param particle is the particle we are computed the position for
  18980. */
  18981. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18982. /**
  18983. * Clones the current emitter and returns a copy of it
  18984. * @returns the new emitter
  18985. */
  18986. clone(): SphereParticleEmitter;
  18987. /**
  18988. * Called by the GPUParticleSystem to setup the update shader
  18989. * @param effect defines the update shader
  18990. */
  18991. applyToShader(effect: Effect): void;
  18992. /**
  18993. * Returns a string to use to update the GPU particles update shader
  18994. * @returns a string containng the defines string
  18995. */
  18996. getEffectDefines(): string;
  18997. /**
  18998. * Returns the string "SphereParticleEmitter"
  18999. * @returns a string containing the class name
  19000. */
  19001. getClassName(): string;
  19002. /**
  19003. * Serializes the particle system to a JSON object.
  19004. * @returns the JSON object
  19005. */
  19006. serialize(): any;
  19007. /**
  19008. * Parse properties from a JSON object
  19009. * @param serializationObject defines the JSON object
  19010. */
  19011. parse(serializationObject: any): void;
  19012. }
  19013. /**
  19014. * Particle emitter emitting particles from the inside of a sphere.
  19015. * It emits the particles randomly between two vectors.
  19016. */
  19017. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  19018. /**
  19019. * The min limit of the emission direction.
  19020. */
  19021. direction1: Vector3;
  19022. /**
  19023. * The max limit of the emission direction.
  19024. */
  19025. direction2: Vector3;
  19026. /**
  19027. * Creates a new instance SphereDirectedParticleEmitter
  19028. * @param radius the radius of the emission sphere (1 by default)
  19029. * @param direction1 the min limit of the emission direction (up vector by default)
  19030. * @param direction2 the max limit of the emission direction (up vector by default)
  19031. */
  19032. constructor(radius?: number,
  19033. /**
  19034. * The min limit of the emission direction.
  19035. */
  19036. direction1?: Vector3,
  19037. /**
  19038. * The max limit of the emission direction.
  19039. */
  19040. direction2?: Vector3);
  19041. /**
  19042. * Called by the particle System when the direction is computed for the created particle.
  19043. * @param worldMatrix is the world matrix of the particle system
  19044. * @param directionToUpdate is the direction vector to update with the result
  19045. * @param particle is the particle we are computed the direction for
  19046. */
  19047. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  19048. /**
  19049. * Clones the current emitter and returns a copy of it
  19050. * @returns the new emitter
  19051. */
  19052. clone(): SphereDirectedParticleEmitter;
  19053. /**
  19054. * Called by the GPUParticleSystem to setup the update shader
  19055. * @param effect defines the update shader
  19056. */
  19057. applyToShader(effect: Effect): void;
  19058. /**
  19059. * Returns a string to use to update the GPU particles update shader
  19060. * @returns a string containng the defines string
  19061. */
  19062. getEffectDefines(): string;
  19063. /**
  19064. * Returns the string "SphereDirectedParticleEmitter"
  19065. * @returns a string containing the class name
  19066. */
  19067. getClassName(): string;
  19068. /**
  19069. * Serializes the particle system to a JSON object.
  19070. * @returns the JSON object
  19071. */
  19072. serialize(): any;
  19073. /**
  19074. * Parse properties from a JSON object
  19075. * @param serializationObject defines the JSON object
  19076. */
  19077. parse(serializationObject: any): void;
  19078. }
  19079. }
  19080. declare module "babylonjs/Particles/EmitterTypes/index" {
  19081. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  19082. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  19083. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  19084. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  19085. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  19086. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  19087. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  19088. }
  19089. declare module "babylonjs/Particles/IParticleSystem" {
  19090. import { Nullable } from "babylonjs/types";
  19091. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  19092. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19094. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19095. import { Texture } from "babylonjs/Materials/Textures/texture";
  19096. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19097. import { Scene } from "babylonjs/scene";
  19098. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  19099. import { Animation } from "babylonjs/Animations/animation";
  19100. /**
  19101. * Interface representing a particle system in Babylon.js.
  19102. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  19103. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  19104. */
  19105. export interface IParticleSystem {
  19106. /**
  19107. * List of animations used by the particle system.
  19108. */
  19109. animations: Animation[];
  19110. /**
  19111. * The id of the Particle system.
  19112. */
  19113. id: string;
  19114. /**
  19115. * The name of the Particle system.
  19116. */
  19117. name: string;
  19118. /**
  19119. * The emitter represents the Mesh or position we are attaching the particle system to.
  19120. */
  19121. emitter: Nullable<AbstractMesh | Vector3>;
  19122. /**
  19123. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19124. */
  19125. isBillboardBased: boolean;
  19126. /**
  19127. * The rendering group used by the Particle system to chose when to render.
  19128. */
  19129. renderingGroupId: number;
  19130. /**
  19131. * The layer mask we are rendering the particles through.
  19132. */
  19133. layerMask: number;
  19134. /**
  19135. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19136. */
  19137. updateSpeed: number;
  19138. /**
  19139. * The amount of time the particle system is running (depends of the overall update speed).
  19140. */
  19141. targetStopDuration: number;
  19142. /**
  19143. * The texture used to render each particle. (this can be a spritesheet)
  19144. */
  19145. particleTexture: Nullable<Texture>;
  19146. /**
  19147. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  19148. */
  19149. blendMode: number;
  19150. /**
  19151. * Minimum life time of emitting particles.
  19152. */
  19153. minLifeTime: number;
  19154. /**
  19155. * Maximum life time of emitting particles.
  19156. */
  19157. maxLifeTime: number;
  19158. /**
  19159. * Minimum Size of emitting particles.
  19160. */
  19161. minSize: number;
  19162. /**
  19163. * Maximum Size of emitting particles.
  19164. */
  19165. maxSize: number;
  19166. /**
  19167. * Minimum scale of emitting particles on X axis.
  19168. */
  19169. minScaleX: number;
  19170. /**
  19171. * Maximum scale of emitting particles on X axis.
  19172. */
  19173. maxScaleX: number;
  19174. /**
  19175. * Minimum scale of emitting particles on Y axis.
  19176. */
  19177. minScaleY: number;
  19178. /**
  19179. * Maximum scale of emitting particles on Y axis.
  19180. */
  19181. maxScaleY: number;
  19182. /**
  19183. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19184. */
  19185. color1: Color4;
  19186. /**
  19187. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  19188. */
  19189. color2: Color4;
  19190. /**
  19191. * Color the particle will have at the end of its lifetime.
  19192. */
  19193. colorDead: Color4;
  19194. /**
  19195. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  19196. */
  19197. emitRate: number;
  19198. /**
  19199. * You can use gravity if you want to give an orientation to your particles.
  19200. */
  19201. gravity: Vector3;
  19202. /**
  19203. * Minimum power of emitting particles.
  19204. */
  19205. minEmitPower: number;
  19206. /**
  19207. * Maximum power of emitting particles.
  19208. */
  19209. maxEmitPower: number;
  19210. /**
  19211. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19212. */
  19213. minAngularSpeed: number;
  19214. /**
  19215. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19216. */
  19217. maxAngularSpeed: number;
  19218. /**
  19219. * Gets or sets the minimal initial rotation in radians.
  19220. */
  19221. minInitialRotation: number;
  19222. /**
  19223. * Gets or sets the maximal initial rotation in radians.
  19224. */
  19225. maxInitialRotation: number;
  19226. /**
  19227. * The particle emitter type defines the emitter used by the particle system.
  19228. * It can be for example box, sphere, or cone...
  19229. */
  19230. particleEmitterType: Nullable<IParticleEmitterType>;
  19231. /**
  19232. * Defines the delay in milliseconds before starting the system (0 by default)
  19233. */
  19234. startDelay: number;
  19235. /**
  19236. * 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
  19237. */
  19238. preWarmCycles: number;
  19239. /**
  19240. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  19241. */
  19242. preWarmStepOffset: number;
  19243. /**
  19244. * 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)
  19245. */
  19246. spriteCellChangeSpeed: number;
  19247. /**
  19248. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19249. */
  19250. startSpriteCellID: number;
  19251. /**
  19252. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19253. */
  19254. endSpriteCellID: number;
  19255. /**
  19256. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19257. */
  19258. spriteCellWidth: number;
  19259. /**
  19260. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19261. */
  19262. spriteCellHeight: number;
  19263. /**
  19264. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19265. */
  19266. spriteRandomStartCell: boolean;
  19267. /**
  19268. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  19269. */
  19270. isAnimationSheetEnabled: boolean;
  19271. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19272. translationPivot: Vector2;
  19273. /**
  19274. * Gets or sets a texture used to add random noise to particle positions
  19275. */
  19276. noiseTexture: Nullable<BaseTexture>;
  19277. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19278. noiseStrength: Vector3;
  19279. /**
  19280. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19281. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19282. */
  19283. billboardMode: number;
  19284. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19285. limitVelocityDamping: number;
  19286. /**
  19287. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19288. */
  19289. beginAnimationOnStart: boolean;
  19290. /**
  19291. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19292. */
  19293. beginAnimationFrom: number;
  19294. /**
  19295. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19296. */
  19297. beginAnimationTo: number;
  19298. /**
  19299. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19300. */
  19301. beginAnimationLoop: boolean;
  19302. /**
  19303. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19304. */
  19305. disposeOnStop: boolean;
  19306. /**
  19307. * Gets the maximum number of particles active at the same time.
  19308. * @returns The max number of active particles.
  19309. */
  19310. getCapacity(): number;
  19311. /**
  19312. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19313. * @returns True if it has been started, otherwise false.
  19314. */
  19315. isStarted(): boolean;
  19316. /**
  19317. * Animates the particle system for this frame.
  19318. */
  19319. animate(): void;
  19320. /**
  19321. * Renders the particle system in its current state.
  19322. * @returns the current number of particles
  19323. */
  19324. render(): number;
  19325. /**
  19326. * Dispose the particle system and frees its associated resources.
  19327. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19328. */
  19329. dispose(disposeTexture?: boolean): void;
  19330. /**
  19331. * Clones the particle system.
  19332. * @param name The name of the cloned object
  19333. * @param newEmitter The new emitter to use
  19334. * @returns the cloned particle system
  19335. */
  19336. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19337. /**
  19338. * Serializes the particle system to a JSON object.
  19339. * @returns the JSON object
  19340. */
  19341. serialize(): any;
  19342. /**
  19343. * Rebuild the particle system
  19344. */
  19345. rebuild(): void;
  19346. /**
  19347. * Starts the particle system and begins to emit
  19348. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19349. */
  19350. start(delay?: number): void;
  19351. /**
  19352. * Stops the particle system.
  19353. */
  19354. stop(): void;
  19355. /**
  19356. * Remove all active particles
  19357. */
  19358. reset(): void;
  19359. /**
  19360. * Is this system ready to be used/rendered
  19361. * @return true if the system is ready
  19362. */
  19363. isReady(): boolean;
  19364. /**
  19365. * Adds a new color gradient
  19366. * @param gradient defines the gradient to use (between 0 and 1)
  19367. * @param color1 defines the color to affect to the specified gradient
  19368. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19369. * @returns the current particle system
  19370. */
  19371. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19372. /**
  19373. * Remove a specific color gradient
  19374. * @param gradient defines the gradient to remove
  19375. * @returns the current particle system
  19376. */
  19377. removeColorGradient(gradient: number): IParticleSystem;
  19378. /**
  19379. * Adds a new size gradient
  19380. * @param gradient defines the gradient to use (between 0 and 1)
  19381. * @param factor defines the size factor to affect to the specified gradient
  19382. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19383. * @returns the current particle system
  19384. */
  19385. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19386. /**
  19387. * Remove a specific size gradient
  19388. * @param gradient defines the gradient to remove
  19389. * @returns the current particle system
  19390. */
  19391. removeSizeGradient(gradient: number): IParticleSystem;
  19392. /**
  19393. * Gets the current list of color gradients.
  19394. * You must use addColorGradient and removeColorGradient to udpate this list
  19395. * @returns the list of color gradients
  19396. */
  19397. getColorGradients(): Nullable<Array<ColorGradient>>;
  19398. /**
  19399. * Gets the current list of size gradients.
  19400. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19401. * @returns the list of size gradients
  19402. */
  19403. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19404. /**
  19405. * Gets the current list of angular speed gradients.
  19406. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19407. * @returns the list of angular speed gradients
  19408. */
  19409. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19410. /**
  19411. * Adds a new angular speed gradient
  19412. * @param gradient defines the gradient to use (between 0 and 1)
  19413. * @param factor defines the angular speed to affect to the specified gradient
  19414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19415. * @returns the current particle system
  19416. */
  19417. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19418. /**
  19419. * Remove a specific angular speed gradient
  19420. * @param gradient defines the gradient to remove
  19421. * @returns the current particle system
  19422. */
  19423. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19424. /**
  19425. * Gets the current list of velocity gradients.
  19426. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19427. * @returns the list of velocity gradients
  19428. */
  19429. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19430. /**
  19431. * Adds a new velocity gradient
  19432. * @param gradient defines the gradient to use (between 0 and 1)
  19433. * @param factor defines the velocity to affect to the specified gradient
  19434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19435. * @returns the current particle system
  19436. */
  19437. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19438. /**
  19439. * Remove a specific velocity gradient
  19440. * @param gradient defines the gradient to remove
  19441. * @returns the current particle system
  19442. */
  19443. removeVelocityGradient(gradient: number): IParticleSystem;
  19444. /**
  19445. * Gets the current list of limit velocity gradients.
  19446. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19447. * @returns the list of limit velocity gradients
  19448. */
  19449. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19450. /**
  19451. * Adds a new limit velocity gradient
  19452. * @param gradient defines the gradient to use (between 0 and 1)
  19453. * @param factor defines the limit velocity to affect to the specified gradient
  19454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19455. * @returns the current particle system
  19456. */
  19457. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19458. /**
  19459. * Remove a specific limit velocity gradient
  19460. * @param gradient defines the gradient to remove
  19461. * @returns the current particle system
  19462. */
  19463. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19464. /**
  19465. * Adds a new drag gradient
  19466. * @param gradient defines the gradient to use (between 0 and 1)
  19467. * @param factor defines the drag to affect to the specified gradient
  19468. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19469. * @returns the current particle system
  19470. */
  19471. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19472. /**
  19473. * Remove a specific drag gradient
  19474. * @param gradient defines the gradient to remove
  19475. * @returns the current particle system
  19476. */
  19477. removeDragGradient(gradient: number): IParticleSystem;
  19478. /**
  19479. * Gets the current list of drag gradients.
  19480. * You must use addDragGradient and removeDragGradient to udpate this list
  19481. * @returns the list of drag gradients
  19482. */
  19483. getDragGradients(): Nullable<Array<FactorGradient>>;
  19484. /**
  19485. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19486. * @param gradient defines the gradient to use (between 0 and 1)
  19487. * @param factor defines the emit rate to affect to the specified gradient
  19488. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19489. * @returns the current particle system
  19490. */
  19491. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19492. /**
  19493. * Remove a specific emit rate gradient
  19494. * @param gradient defines the gradient to remove
  19495. * @returns the current particle system
  19496. */
  19497. removeEmitRateGradient(gradient: number): IParticleSystem;
  19498. /**
  19499. * Gets the current list of emit rate gradients.
  19500. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19501. * @returns the list of emit rate gradients
  19502. */
  19503. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19504. /**
  19505. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19506. * @param gradient defines the gradient to use (between 0 and 1)
  19507. * @param factor defines the start size to affect to the specified gradient
  19508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19509. * @returns the current particle system
  19510. */
  19511. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19512. /**
  19513. * Remove a specific start size gradient
  19514. * @param gradient defines the gradient to remove
  19515. * @returns the current particle system
  19516. */
  19517. removeStartSizeGradient(gradient: number): IParticleSystem;
  19518. /**
  19519. * Gets the current list of start size gradients.
  19520. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19521. * @returns the list of start size gradients
  19522. */
  19523. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19524. /**
  19525. * Adds a new life time gradient
  19526. * @param gradient defines the gradient to use (between 0 and 1)
  19527. * @param factor defines the life time factor to affect to the specified gradient
  19528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19529. * @returns the current particle system
  19530. */
  19531. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19532. /**
  19533. * Remove a specific life time gradient
  19534. * @param gradient defines the gradient to remove
  19535. * @returns the current particle system
  19536. */
  19537. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19538. /**
  19539. * Gets the current list of life time gradients.
  19540. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19541. * @returns the list of life time gradients
  19542. */
  19543. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19544. /**
  19545. * Gets the current list of color gradients.
  19546. * You must use addColorGradient and removeColorGradient to udpate this list
  19547. * @returns the list of color gradients
  19548. */
  19549. getColorGradients(): Nullable<Array<ColorGradient>>;
  19550. /**
  19551. * Adds a new ramp gradient used to remap particle colors
  19552. * @param gradient defines the gradient to use (between 0 and 1)
  19553. * @param color defines the color to affect to the specified gradient
  19554. * @returns the current particle system
  19555. */
  19556. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19557. /**
  19558. * Gets the current list of ramp gradients.
  19559. * You must use addRampGradient and removeRampGradient to udpate this list
  19560. * @returns the list of ramp gradients
  19561. */
  19562. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19563. /** Gets or sets a boolean indicating that ramp gradients must be used
  19564. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19565. */
  19566. useRampGradients: boolean;
  19567. /**
  19568. * Adds a new color remap gradient
  19569. * @param gradient defines the gradient to use (between 0 and 1)
  19570. * @param min defines the color remap minimal range
  19571. * @param max defines the color remap maximal range
  19572. * @returns the current particle system
  19573. */
  19574. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19575. /**
  19576. * Gets the current list of color remap gradients.
  19577. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19578. * @returns the list of color remap gradients
  19579. */
  19580. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19581. /**
  19582. * Adds a new alpha remap gradient
  19583. * @param gradient defines the gradient to use (between 0 and 1)
  19584. * @param min defines the alpha remap minimal range
  19585. * @param max defines the alpha remap maximal range
  19586. * @returns the current particle system
  19587. */
  19588. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19589. /**
  19590. * Gets the current list of alpha remap gradients.
  19591. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19592. * @returns the list of alpha remap gradients
  19593. */
  19594. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19595. /**
  19596. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19597. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19598. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19599. * @returns the emitter
  19600. */
  19601. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19602. /**
  19603. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19604. * @param radius The radius of the hemisphere to emit from
  19605. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19606. * @returns the emitter
  19607. */
  19608. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19609. /**
  19610. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19611. * @param radius The radius of the sphere to emit from
  19612. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19613. * @returns the emitter
  19614. */
  19615. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19616. /**
  19617. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19618. * @param radius The radius of the sphere to emit from
  19619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19621. * @returns the emitter
  19622. */
  19623. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19624. /**
  19625. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19626. * @param radius The radius of the emission cylinder
  19627. * @param height The height of the emission cylinder
  19628. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19629. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19630. * @returns the emitter
  19631. */
  19632. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19633. /**
  19634. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19635. * @param radius The radius of the cylinder to emit from
  19636. * @param height The height of the emission cylinder
  19637. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19640. * @returns the emitter
  19641. */
  19642. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19643. /**
  19644. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19645. * @param radius The radius of the cone to emit from
  19646. * @param angle The base angle of the cone
  19647. * @returns the emitter
  19648. */
  19649. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19650. /**
  19651. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19654. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19655. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19656. * @returns the emitter
  19657. */
  19658. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19659. /**
  19660. * Get hosting scene
  19661. * @returns the scene
  19662. */
  19663. getScene(): Scene;
  19664. }
  19665. }
  19666. declare module "babylonjs/Meshes/instancedMesh" {
  19667. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19668. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19669. import { Camera } from "babylonjs/Cameras/camera";
  19670. import { Node } from "babylonjs/node";
  19671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19672. import { Mesh } from "babylonjs/Meshes/mesh";
  19673. import { Material } from "babylonjs/Materials/material";
  19674. import { Skeleton } from "babylonjs/Bones/skeleton";
  19675. import { Light } from "babylonjs/Lights/light";
  19676. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19677. /**
  19678. * Creates an instance based on a source mesh.
  19679. */
  19680. export class InstancedMesh extends AbstractMesh {
  19681. private _sourceMesh;
  19682. private _currentLOD;
  19683. /** @hidden */
  19684. _indexInSourceMeshInstanceArray: number;
  19685. constructor(name: string, source: Mesh);
  19686. /**
  19687. * Returns the string "InstancedMesh".
  19688. */
  19689. getClassName(): string;
  19690. /** Gets the list of lights affecting that mesh */
  19691. get lightSources(): Light[];
  19692. _resyncLightSources(): void;
  19693. _resyncLightSource(light: Light): void;
  19694. _removeLightSource(light: Light, dispose: boolean): void;
  19695. /**
  19696. * If the source mesh receives shadows
  19697. */
  19698. get receiveShadows(): boolean;
  19699. /**
  19700. * The material of the source mesh
  19701. */
  19702. get material(): Nullable<Material>;
  19703. /**
  19704. * Visibility of the source mesh
  19705. */
  19706. get visibility(): number;
  19707. /**
  19708. * Skeleton of the source mesh
  19709. */
  19710. get skeleton(): Nullable<Skeleton>;
  19711. /**
  19712. * Rendering ground id of the source mesh
  19713. */
  19714. get renderingGroupId(): number;
  19715. set renderingGroupId(value: number);
  19716. /**
  19717. * Returns the total number of vertices (integer).
  19718. */
  19719. getTotalVertices(): number;
  19720. /**
  19721. * Returns a positive integer : the total number of indices in this mesh geometry.
  19722. * @returns the numner of indices or zero if the mesh has no geometry.
  19723. */
  19724. getTotalIndices(): number;
  19725. /**
  19726. * The source mesh of the instance
  19727. */
  19728. get sourceMesh(): Mesh;
  19729. /**
  19730. * Is this node ready to be used/rendered
  19731. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19732. * @return {boolean} is it ready
  19733. */
  19734. isReady(completeCheck?: boolean): boolean;
  19735. /**
  19736. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19737. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19738. * @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.
  19739. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19740. */
  19741. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19742. /**
  19743. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19744. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19745. * The `data` are either a numeric array either a Float32Array.
  19746. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19747. * 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).
  19748. * Note that a new underlying VertexBuffer object is created each call.
  19749. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19750. *
  19751. * Possible `kind` values :
  19752. * - VertexBuffer.PositionKind
  19753. * - VertexBuffer.UVKind
  19754. * - VertexBuffer.UV2Kind
  19755. * - VertexBuffer.UV3Kind
  19756. * - VertexBuffer.UV4Kind
  19757. * - VertexBuffer.UV5Kind
  19758. * - VertexBuffer.UV6Kind
  19759. * - VertexBuffer.ColorKind
  19760. * - VertexBuffer.MatricesIndicesKind
  19761. * - VertexBuffer.MatricesIndicesExtraKind
  19762. * - VertexBuffer.MatricesWeightsKind
  19763. * - VertexBuffer.MatricesWeightsExtraKind
  19764. *
  19765. * Returns the Mesh.
  19766. */
  19767. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19768. /**
  19769. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19770. * If the mesh has no geometry, it is simply returned as it is.
  19771. * The `data` are either a numeric array either a Float32Array.
  19772. * No new underlying VertexBuffer object is created.
  19773. * 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.
  19774. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19775. *
  19776. * Possible `kind` values :
  19777. * - VertexBuffer.PositionKind
  19778. * - VertexBuffer.UVKind
  19779. * - VertexBuffer.UV2Kind
  19780. * - VertexBuffer.UV3Kind
  19781. * - VertexBuffer.UV4Kind
  19782. * - VertexBuffer.UV5Kind
  19783. * - VertexBuffer.UV6Kind
  19784. * - VertexBuffer.ColorKind
  19785. * - VertexBuffer.MatricesIndicesKind
  19786. * - VertexBuffer.MatricesIndicesExtraKind
  19787. * - VertexBuffer.MatricesWeightsKind
  19788. * - VertexBuffer.MatricesWeightsExtraKind
  19789. *
  19790. * Returns the Mesh.
  19791. */
  19792. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19793. /**
  19794. * Sets the mesh indices.
  19795. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19796. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19797. * This method creates a new index buffer each call.
  19798. * Returns the Mesh.
  19799. */
  19800. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19801. /**
  19802. * Boolean : True if the mesh owns the requested kind of data.
  19803. */
  19804. isVerticesDataPresent(kind: string): boolean;
  19805. /**
  19806. * Returns an array of indices (IndicesArray).
  19807. */
  19808. getIndices(): Nullable<IndicesArray>;
  19809. get _positions(): Nullable<Vector3[]>;
  19810. /**
  19811. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19812. * This means the mesh underlying bounding box and sphere are recomputed.
  19813. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19814. * @returns the current mesh
  19815. */
  19816. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19817. /** @hidden */
  19818. _preActivate(): InstancedMesh;
  19819. /** @hidden */
  19820. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19821. /** @hidden */
  19822. _postActivate(): void;
  19823. getWorldMatrix(): Matrix;
  19824. get isAnInstance(): boolean;
  19825. /**
  19826. * Returns the current associated LOD AbstractMesh.
  19827. */
  19828. getLOD(camera: Camera): AbstractMesh;
  19829. /** @hidden */
  19830. _syncSubMeshes(): InstancedMesh;
  19831. /** @hidden */
  19832. _generatePointsArray(): boolean;
  19833. /**
  19834. * Creates a new InstancedMesh from the current mesh.
  19835. * - name (string) : the cloned mesh name
  19836. * - newParent (optional Node) : the optional Node to parent the clone to.
  19837. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19838. *
  19839. * Returns the clone.
  19840. */
  19841. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19842. /**
  19843. * Disposes the InstancedMesh.
  19844. * Returns nothing.
  19845. */
  19846. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19847. }
  19848. module "babylonjs/Meshes/mesh" {
  19849. interface Mesh {
  19850. /**
  19851. * Register a custom buffer that will be instanced
  19852. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19853. * @param kind defines the buffer kind
  19854. * @param stride defines the stride in floats
  19855. */
  19856. registerInstancedBuffer(kind: string, stride: number): void;
  19857. /** @hidden */
  19858. _userInstancedBuffersStorage: {
  19859. data: {
  19860. [key: string]: Float32Array;
  19861. };
  19862. sizes: {
  19863. [key: string]: number;
  19864. };
  19865. vertexBuffers: {
  19866. [key: string]: Nullable<VertexBuffer>;
  19867. };
  19868. strides: {
  19869. [key: string]: number;
  19870. };
  19871. };
  19872. }
  19873. }
  19874. module "babylonjs/Meshes/abstractMesh" {
  19875. interface AbstractMesh {
  19876. /**
  19877. * Object used to store instanced buffers defined by user
  19878. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  19879. */
  19880. instancedBuffers: {
  19881. [key: string]: any;
  19882. };
  19883. }
  19884. }
  19885. }
  19886. declare module "babylonjs/Materials/shaderMaterial" {
  19887. import { Scene } from "babylonjs/scene";
  19888. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19890. import { Mesh } from "babylonjs/Meshes/mesh";
  19891. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19892. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19893. import { Texture } from "babylonjs/Materials/Textures/texture";
  19894. import { Material } from "babylonjs/Materials/material";
  19895. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19896. /**
  19897. * Defines the options associated with the creation of a shader material.
  19898. */
  19899. export interface IShaderMaterialOptions {
  19900. /**
  19901. * Does the material work in alpha blend mode
  19902. */
  19903. needAlphaBlending: boolean;
  19904. /**
  19905. * Does the material work in alpha test mode
  19906. */
  19907. needAlphaTesting: boolean;
  19908. /**
  19909. * The list of attribute names used in the shader
  19910. */
  19911. attributes: string[];
  19912. /**
  19913. * The list of unifrom names used in the shader
  19914. */
  19915. uniforms: string[];
  19916. /**
  19917. * The list of UBO names used in the shader
  19918. */
  19919. uniformBuffers: string[];
  19920. /**
  19921. * The list of sampler names used in the shader
  19922. */
  19923. samplers: string[];
  19924. /**
  19925. * The list of defines used in the shader
  19926. */
  19927. defines: string[];
  19928. }
  19929. /**
  19930. * 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.
  19931. *
  19932. * This returned material effects how the mesh will look based on the code in the shaders.
  19933. *
  19934. * @see http://doc.babylonjs.com/how_to/shader_material
  19935. */
  19936. export class ShaderMaterial extends Material {
  19937. private _shaderPath;
  19938. private _options;
  19939. private _textures;
  19940. private _textureArrays;
  19941. private _floats;
  19942. private _ints;
  19943. private _floatsArrays;
  19944. private _colors3;
  19945. private _colors3Arrays;
  19946. private _colors4;
  19947. private _colors4Arrays;
  19948. private _vectors2;
  19949. private _vectors3;
  19950. private _vectors4;
  19951. private _matrices;
  19952. private _matrixArrays;
  19953. private _matrices3x3;
  19954. private _matrices2x2;
  19955. private _vectors2Arrays;
  19956. private _vectors3Arrays;
  19957. private _vectors4Arrays;
  19958. private _cachedWorldViewMatrix;
  19959. private _cachedWorldViewProjectionMatrix;
  19960. private _renderId;
  19961. private _multiview;
  19962. /**
  19963. * Instantiate a new shader material.
  19964. * 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.
  19965. * This returned material effects how the mesh will look based on the code in the shaders.
  19966. * @see http://doc.babylonjs.com/how_to/shader_material
  19967. * @param name Define the name of the material in the scene
  19968. * @param scene Define the scene the material belongs to
  19969. * @param shaderPath Defines the route to the shader code in one of three ways:
  19970. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19971. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19972. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19973. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19974. * @param options Define the options used to create the shader
  19975. */
  19976. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19977. /**
  19978. * Gets the shader path used to define the shader code
  19979. * It can be modified to trigger a new compilation
  19980. */
  19981. get shaderPath(): any;
  19982. /**
  19983. * Sets the shader path used to define the shader code
  19984. * It can be modified to trigger a new compilation
  19985. */
  19986. set shaderPath(shaderPath: any);
  19987. /**
  19988. * Gets the options used to compile the shader.
  19989. * They can be modified to trigger a new compilation
  19990. */
  19991. get options(): IShaderMaterialOptions;
  19992. /**
  19993. * Gets the current class name of the material e.g. "ShaderMaterial"
  19994. * Mainly use in serialization.
  19995. * @returns the class name
  19996. */
  19997. getClassName(): string;
  19998. /**
  19999. * Specifies if the material will require alpha blending
  20000. * @returns a boolean specifying if alpha blending is needed
  20001. */
  20002. needAlphaBlending(): boolean;
  20003. /**
  20004. * Specifies if this material should be rendered in alpha test mode
  20005. * @returns a boolean specifying if an alpha test is needed.
  20006. */
  20007. needAlphaTesting(): boolean;
  20008. private _checkUniform;
  20009. /**
  20010. * Set a texture in the shader.
  20011. * @param name Define the name of the uniform samplers as defined in the shader
  20012. * @param texture Define the texture to bind to this sampler
  20013. * @return the material itself allowing "fluent" like uniform updates
  20014. */
  20015. setTexture(name: string, texture: Texture): ShaderMaterial;
  20016. /**
  20017. * Set a texture array in the shader.
  20018. * @param name Define the name of the uniform sampler array as defined in the shader
  20019. * @param textures Define the list of textures to bind to this sampler
  20020. * @return the material itself allowing "fluent" like uniform updates
  20021. */
  20022. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  20023. /**
  20024. * Set a float in the shader.
  20025. * @param name Define the name of the uniform as defined in the shader
  20026. * @param value Define the value to give to the uniform
  20027. * @return the material itself allowing "fluent" like uniform updates
  20028. */
  20029. setFloat(name: string, value: number): ShaderMaterial;
  20030. /**
  20031. * Set a int in the shader.
  20032. * @param name Define the name of the uniform as defined in the shader
  20033. * @param value Define the value to give to the uniform
  20034. * @return the material itself allowing "fluent" like uniform updates
  20035. */
  20036. setInt(name: string, value: number): ShaderMaterial;
  20037. /**
  20038. * Set an array of floats in the shader.
  20039. * @param name Define the name of the uniform as defined in the shader
  20040. * @param value Define the value to give to the uniform
  20041. * @return the material itself allowing "fluent" like uniform updates
  20042. */
  20043. setFloats(name: string, value: number[]): ShaderMaterial;
  20044. /**
  20045. * Set a vec3 in the shader from a Color3.
  20046. * @param name Define the name of the uniform as defined in the shader
  20047. * @param value Define the value to give to the uniform
  20048. * @return the material itself allowing "fluent" like uniform updates
  20049. */
  20050. setColor3(name: string, value: Color3): ShaderMaterial;
  20051. /**
  20052. * Set a vec3 array in the shader from a Color3 array.
  20053. * @param name Define the name of the uniform as defined in the shader
  20054. * @param value Define the value to give to the uniform
  20055. * @return the material itself allowing "fluent" like uniform updates
  20056. */
  20057. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  20058. /**
  20059. * Set a vec4 in the shader from a Color4.
  20060. * @param name Define the name of the uniform as defined in the shader
  20061. * @param value Define the value to give to the uniform
  20062. * @return the material itself allowing "fluent" like uniform updates
  20063. */
  20064. setColor4(name: string, value: Color4): ShaderMaterial;
  20065. /**
  20066. * Set a vec4 array in the shader from a Color4 array.
  20067. * @param name Define the name of the uniform as defined in the shader
  20068. * @param value Define the value to give to the uniform
  20069. * @return the material itself allowing "fluent" like uniform updates
  20070. */
  20071. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  20072. /**
  20073. * Set a vec2 in the shader from a Vector2.
  20074. * @param name Define the name of the uniform as defined in the shader
  20075. * @param value Define the value to give to the uniform
  20076. * @return the material itself allowing "fluent" like uniform updates
  20077. */
  20078. setVector2(name: string, value: Vector2): ShaderMaterial;
  20079. /**
  20080. * Set a vec3 in the shader from a Vector3.
  20081. * @param name Define the name of the uniform as defined in the shader
  20082. * @param value Define the value to give to the uniform
  20083. * @return the material itself allowing "fluent" like uniform updates
  20084. */
  20085. setVector3(name: string, value: Vector3): ShaderMaterial;
  20086. /**
  20087. * Set a vec4 in the shader from a Vector4.
  20088. * @param name Define the name of the uniform as defined in the shader
  20089. * @param value Define the value to give to the uniform
  20090. * @return the material itself allowing "fluent" like uniform updates
  20091. */
  20092. setVector4(name: string, value: Vector4): ShaderMaterial;
  20093. /**
  20094. * Set a mat4 in the shader from a Matrix.
  20095. * @param name Define the name of the uniform as defined in the shader
  20096. * @param value Define the value to give to the uniform
  20097. * @return the material itself allowing "fluent" like uniform updates
  20098. */
  20099. setMatrix(name: string, value: Matrix): ShaderMaterial;
  20100. /**
  20101. * Set a float32Array in the shader from a matrix array.
  20102. * @param name Define the name of the uniform as defined in the shader
  20103. * @param value Define the value to give to the uniform
  20104. * @return the material itself allowing "fluent" like uniform updates
  20105. */
  20106. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  20107. /**
  20108. * Set a mat3 in the shader from a Float32Array.
  20109. * @param name Define the name of the uniform as defined in the shader
  20110. * @param value Define the value to give to the uniform
  20111. * @return the material itself allowing "fluent" like uniform updates
  20112. */
  20113. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  20114. /**
  20115. * Set a mat2 in the shader from a Float32Array.
  20116. * @param name Define the name of the uniform as defined in the shader
  20117. * @param value Define the value to give to the uniform
  20118. * @return the material itself allowing "fluent" like uniform updates
  20119. */
  20120. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  20121. /**
  20122. * Set a vec2 array in the shader from a number array.
  20123. * @param name Define the name of the uniform as defined in the shader
  20124. * @param value Define the value to give to the uniform
  20125. * @return the material itself allowing "fluent" like uniform updates
  20126. */
  20127. setArray2(name: string, value: number[]): ShaderMaterial;
  20128. /**
  20129. * Set a vec3 array in the shader from a number array.
  20130. * @param name Define the name of the uniform as defined in the shader
  20131. * @param value Define the value to give to the uniform
  20132. * @return the material itself allowing "fluent" like uniform updates
  20133. */
  20134. setArray3(name: string, value: number[]): ShaderMaterial;
  20135. /**
  20136. * Set a vec4 array in the shader from a number array.
  20137. * @param name Define the name of the uniform as defined in the shader
  20138. * @param value Define the value to give to the uniform
  20139. * @return the material itself allowing "fluent" like uniform updates
  20140. */
  20141. setArray4(name: string, value: number[]): ShaderMaterial;
  20142. private _checkCache;
  20143. /**
  20144. * Specifies that the submesh is ready to be used
  20145. * @param mesh defines the mesh to check
  20146. * @param subMesh defines which submesh to check
  20147. * @param useInstances specifies that instances should be used
  20148. * @returns a boolean indicating that the submesh is ready or not
  20149. */
  20150. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20151. /**
  20152. * Checks if the material is ready to render the requested mesh
  20153. * @param mesh Define the mesh to render
  20154. * @param useInstances Define whether or not the material is used with instances
  20155. * @returns true if ready, otherwise false
  20156. */
  20157. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20158. /**
  20159. * Binds the world matrix to the material
  20160. * @param world defines the world transformation matrix
  20161. */
  20162. bindOnlyWorldMatrix(world: Matrix): void;
  20163. /**
  20164. * Binds the material to the mesh
  20165. * @param world defines the world transformation matrix
  20166. * @param mesh defines the mesh to bind the material to
  20167. */
  20168. bind(world: Matrix, mesh?: Mesh): void;
  20169. /**
  20170. * Gets the active textures from the material
  20171. * @returns an array of textures
  20172. */
  20173. getActiveTextures(): BaseTexture[];
  20174. /**
  20175. * Specifies if the material uses a texture
  20176. * @param texture defines the texture to check against the material
  20177. * @returns a boolean specifying if the material uses the texture
  20178. */
  20179. hasTexture(texture: BaseTexture): boolean;
  20180. /**
  20181. * Makes a duplicate of the material, and gives it a new name
  20182. * @param name defines the new name for the duplicated material
  20183. * @returns the cloned material
  20184. */
  20185. clone(name: string): ShaderMaterial;
  20186. /**
  20187. * Disposes the material
  20188. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20189. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20190. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20191. */
  20192. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20193. /**
  20194. * Serializes this material in a JSON representation
  20195. * @returns the serialized material object
  20196. */
  20197. serialize(): any;
  20198. /**
  20199. * Creates a shader material from parsed shader material data
  20200. * @param source defines the JSON represnetation of the material
  20201. * @param scene defines the hosting scene
  20202. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  20203. * @returns a new material
  20204. */
  20205. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  20206. }
  20207. }
  20208. declare module "babylonjs/Shaders/color.fragment" {
  20209. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20210. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20211. /** @hidden */
  20212. export var colorPixelShader: {
  20213. name: string;
  20214. shader: string;
  20215. };
  20216. }
  20217. declare module "babylonjs/Shaders/color.vertex" {
  20218. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  20219. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20220. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  20221. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  20222. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  20223. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20224. /** @hidden */
  20225. export var colorVertexShader: {
  20226. name: string;
  20227. shader: string;
  20228. };
  20229. }
  20230. declare module "babylonjs/Meshes/linesMesh" {
  20231. import { Nullable } from "babylonjs/types";
  20232. import { Scene } from "babylonjs/scene";
  20233. import { Color3 } from "babylonjs/Maths/math.color";
  20234. import { Node } from "babylonjs/node";
  20235. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20236. import { Mesh } from "babylonjs/Meshes/mesh";
  20237. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  20238. import { Effect } from "babylonjs/Materials/effect";
  20239. import { Material } from "babylonjs/Materials/material";
  20240. import "babylonjs/Shaders/color.fragment";
  20241. import "babylonjs/Shaders/color.vertex";
  20242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20243. /**
  20244. * Line mesh
  20245. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  20246. */
  20247. export class LinesMesh extends Mesh {
  20248. /**
  20249. * If vertex color should be applied to the mesh
  20250. */
  20251. readonly useVertexColor?: boolean | undefined;
  20252. /**
  20253. * If vertex alpha should be applied to the mesh
  20254. */
  20255. readonly useVertexAlpha?: boolean | undefined;
  20256. /**
  20257. * Color of the line (Default: White)
  20258. */
  20259. color: Color3;
  20260. /**
  20261. * Alpha of the line (Default: 1)
  20262. */
  20263. alpha: number;
  20264. /**
  20265. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20266. * This margin is expressed in world space coordinates, so its value may vary.
  20267. * Default value is 0.1
  20268. */
  20269. intersectionThreshold: number;
  20270. private _colorShader;
  20271. private color4;
  20272. /**
  20273. * Creates a new LinesMesh
  20274. * @param name defines the name
  20275. * @param scene defines the hosting scene
  20276. * @param parent defines the parent mesh if any
  20277. * @param source defines the optional source LinesMesh used to clone data from
  20278. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20279. * When false, achieved by calling a clone(), also passing False.
  20280. * This will make creation of children, recursive.
  20281. * @param useVertexColor defines if this LinesMesh supports vertex color
  20282. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  20283. */
  20284. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  20285. /**
  20286. * If vertex color should be applied to the mesh
  20287. */
  20288. useVertexColor?: boolean | undefined,
  20289. /**
  20290. * If vertex alpha should be applied to the mesh
  20291. */
  20292. useVertexAlpha?: boolean | undefined);
  20293. private _addClipPlaneDefine;
  20294. private _removeClipPlaneDefine;
  20295. isReady(): boolean;
  20296. /**
  20297. * Returns the string "LineMesh"
  20298. */
  20299. getClassName(): string;
  20300. /**
  20301. * @hidden
  20302. */
  20303. get material(): Material;
  20304. /**
  20305. * @hidden
  20306. */
  20307. set material(value: Material);
  20308. /**
  20309. * @hidden
  20310. */
  20311. get checkCollisions(): boolean;
  20312. /** @hidden */
  20313. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20314. /** @hidden */
  20315. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20316. /**
  20317. * Disposes of the line mesh
  20318. * @param doNotRecurse If children should be disposed
  20319. */
  20320. dispose(doNotRecurse?: boolean): void;
  20321. /**
  20322. * Returns a new LineMesh object cloned from the current one.
  20323. */
  20324. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  20325. /**
  20326. * Creates a new InstancedLinesMesh object from the mesh model.
  20327. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20328. * @param name defines the name of the new instance
  20329. * @returns a new InstancedLinesMesh
  20330. */
  20331. createInstance(name: string): InstancedLinesMesh;
  20332. }
  20333. /**
  20334. * Creates an instance based on a source LinesMesh
  20335. */
  20336. export class InstancedLinesMesh extends InstancedMesh {
  20337. /**
  20338. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20339. * This margin is expressed in world space coordinates, so its value may vary.
  20340. * Initilized with the intersectionThreshold value of the source LinesMesh
  20341. */
  20342. intersectionThreshold: number;
  20343. constructor(name: string, source: LinesMesh);
  20344. /**
  20345. * Returns the string "InstancedLinesMesh".
  20346. */
  20347. getClassName(): string;
  20348. }
  20349. }
  20350. declare module "babylonjs/Shaders/line.fragment" {
  20351. /** @hidden */
  20352. export var linePixelShader: {
  20353. name: string;
  20354. shader: string;
  20355. };
  20356. }
  20357. declare module "babylonjs/Shaders/line.vertex" {
  20358. /** @hidden */
  20359. export var lineVertexShader: {
  20360. name: string;
  20361. shader: string;
  20362. };
  20363. }
  20364. declare module "babylonjs/Rendering/edgesRenderer" {
  20365. import { Nullable } from "babylonjs/types";
  20366. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20368. import { Vector3 } from "babylonjs/Maths/math.vector";
  20369. import { IDisposable } from "babylonjs/scene";
  20370. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20371. import "babylonjs/Shaders/line.fragment";
  20372. import "babylonjs/Shaders/line.vertex";
  20373. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20374. module "babylonjs/Meshes/abstractMesh" {
  20375. interface AbstractMesh {
  20376. /**
  20377. * Gets the edgesRenderer associated with the mesh
  20378. */
  20379. edgesRenderer: Nullable<EdgesRenderer>;
  20380. }
  20381. }
  20382. module "babylonjs/Meshes/linesMesh" {
  20383. interface LinesMesh {
  20384. /**
  20385. * Enables the edge rendering mode on the mesh.
  20386. * This mode makes the mesh edges visible
  20387. * @param epsilon defines the maximal distance between two angles to detect a face
  20388. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20389. * @returns the currentAbstractMesh
  20390. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20391. */
  20392. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20393. }
  20394. }
  20395. module "babylonjs/Meshes/linesMesh" {
  20396. interface InstancedLinesMesh {
  20397. /**
  20398. * Enables the edge rendering mode on the mesh.
  20399. * This mode makes the mesh edges visible
  20400. * @param epsilon defines the maximal distance between two angles to detect a face
  20401. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20402. * @returns the current InstancedLinesMesh
  20403. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20404. */
  20405. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20406. }
  20407. }
  20408. /**
  20409. * Defines the minimum contract an Edges renderer should follow.
  20410. */
  20411. export interface IEdgesRenderer extends IDisposable {
  20412. /**
  20413. * Gets or sets a boolean indicating if the edgesRenderer is active
  20414. */
  20415. isEnabled: boolean;
  20416. /**
  20417. * Renders the edges of the attached mesh,
  20418. */
  20419. render(): void;
  20420. /**
  20421. * Checks wether or not the edges renderer is ready to render.
  20422. * @return true if ready, otherwise false.
  20423. */
  20424. isReady(): boolean;
  20425. }
  20426. /**
  20427. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20428. */
  20429. export class EdgesRenderer implements IEdgesRenderer {
  20430. /**
  20431. * Define the size of the edges with an orthographic camera
  20432. */
  20433. edgesWidthScalerForOrthographic: number;
  20434. /**
  20435. * Define the size of the edges with a perspective camera
  20436. */
  20437. edgesWidthScalerForPerspective: number;
  20438. protected _source: AbstractMesh;
  20439. protected _linesPositions: number[];
  20440. protected _linesNormals: number[];
  20441. protected _linesIndices: number[];
  20442. protected _epsilon: number;
  20443. protected _indicesCount: number;
  20444. protected _lineShader: ShaderMaterial;
  20445. protected _ib: DataBuffer;
  20446. protected _buffers: {
  20447. [key: string]: Nullable<VertexBuffer>;
  20448. };
  20449. protected _checkVerticesInsteadOfIndices: boolean;
  20450. private _meshRebuildObserver;
  20451. private _meshDisposeObserver;
  20452. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20453. isEnabled: boolean;
  20454. /**
  20455. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20456. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20457. * @param source Mesh used to create edges
  20458. * @param epsilon sum of angles in adjacency to check for edge
  20459. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20460. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20461. */
  20462. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20463. protected _prepareRessources(): void;
  20464. /** @hidden */
  20465. _rebuild(): void;
  20466. /**
  20467. * Releases the required resources for the edges renderer
  20468. */
  20469. dispose(): void;
  20470. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20471. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20472. /**
  20473. * Checks if the pair of p0 and p1 is en edge
  20474. * @param faceIndex
  20475. * @param edge
  20476. * @param faceNormals
  20477. * @param p0
  20478. * @param p1
  20479. * @private
  20480. */
  20481. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20482. /**
  20483. * push line into the position, normal and index buffer
  20484. * @protected
  20485. */
  20486. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20487. /**
  20488. * Generates lines edges from adjacencjes
  20489. * @private
  20490. */
  20491. _generateEdgesLines(): void;
  20492. /**
  20493. * Checks wether or not the edges renderer is ready to render.
  20494. * @return true if ready, otherwise false.
  20495. */
  20496. isReady(): boolean;
  20497. /**
  20498. * Renders the edges of the attached mesh,
  20499. */
  20500. render(): void;
  20501. }
  20502. /**
  20503. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20504. */
  20505. export class LineEdgesRenderer extends EdgesRenderer {
  20506. /**
  20507. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20508. * @param source LineMesh used to generate edges
  20509. * @param epsilon not important (specified angle for edge detection)
  20510. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20511. */
  20512. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20513. /**
  20514. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20515. */
  20516. _generateEdgesLines(): void;
  20517. }
  20518. }
  20519. declare module "babylonjs/Rendering/renderingGroup" {
  20520. import { SmartArray } from "babylonjs/Misc/smartArray";
  20521. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20523. import { Nullable } from "babylonjs/types";
  20524. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20525. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20526. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20527. import { Material } from "babylonjs/Materials/material";
  20528. import { Scene } from "babylonjs/scene";
  20529. /**
  20530. * This represents the object necessary to create a rendering group.
  20531. * This is exclusively used and created by the rendering manager.
  20532. * To modify the behavior, you use the available helpers in your scene or meshes.
  20533. * @hidden
  20534. */
  20535. export class RenderingGroup {
  20536. index: number;
  20537. private static _zeroVector;
  20538. private _scene;
  20539. private _opaqueSubMeshes;
  20540. private _transparentSubMeshes;
  20541. private _alphaTestSubMeshes;
  20542. private _depthOnlySubMeshes;
  20543. private _particleSystems;
  20544. private _spriteManagers;
  20545. private _opaqueSortCompareFn;
  20546. private _alphaTestSortCompareFn;
  20547. private _transparentSortCompareFn;
  20548. private _renderOpaque;
  20549. private _renderAlphaTest;
  20550. private _renderTransparent;
  20551. /** @hidden */
  20552. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20553. onBeforeTransparentRendering: () => void;
  20554. /**
  20555. * Set the opaque sort comparison function.
  20556. * If null the sub meshes will be render in the order they were created
  20557. */
  20558. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20559. /**
  20560. * Set the alpha test sort comparison function.
  20561. * If null the sub meshes will be render in the order they were created
  20562. */
  20563. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20564. /**
  20565. * Set the transparent sort comparison function.
  20566. * If null the sub meshes will be render in the order they were created
  20567. */
  20568. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20569. /**
  20570. * Creates a new rendering group.
  20571. * @param index The rendering group index
  20572. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20573. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20574. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20575. */
  20576. 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>);
  20577. /**
  20578. * Render all the sub meshes contained in the group.
  20579. * @param customRenderFunction Used to override the default render behaviour of the group.
  20580. * @returns true if rendered some submeshes.
  20581. */
  20582. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20583. /**
  20584. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20585. * @param subMeshes The submeshes to render
  20586. */
  20587. private renderOpaqueSorted;
  20588. /**
  20589. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20590. * @param subMeshes The submeshes to render
  20591. */
  20592. private renderAlphaTestSorted;
  20593. /**
  20594. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20595. * @param subMeshes The submeshes to render
  20596. */
  20597. private renderTransparentSorted;
  20598. /**
  20599. * Renders the submeshes in a specified order.
  20600. * @param subMeshes The submeshes to sort before render
  20601. * @param sortCompareFn The comparison function use to sort
  20602. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20603. * @param transparent Specifies to activate blending if true
  20604. */
  20605. private static renderSorted;
  20606. /**
  20607. * Renders the submeshes in the order they were dispatched (no sort applied).
  20608. * @param subMeshes The submeshes to render
  20609. */
  20610. private static renderUnsorted;
  20611. /**
  20612. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20613. * are rendered back to front if in the same alpha index.
  20614. *
  20615. * @param a The first submesh
  20616. * @param b The second submesh
  20617. * @returns The result of the comparison
  20618. */
  20619. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20620. /**
  20621. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20622. * are rendered back to front.
  20623. *
  20624. * @param a The first submesh
  20625. * @param b The second submesh
  20626. * @returns The result of the comparison
  20627. */
  20628. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20629. /**
  20630. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20631. * are rendered front to back (prevent overdraw).
  20632. *
  20633. * @param a The first submesh
  20634. * @param b The second submesh
  20635. * @returns The result of the comparison
  20636. */
  20637. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20638. /**
  20639. * Resets the different lists of submeshes to prepare a new frame.
  20640. */
  20641. prepare(): void;
  20642. dispose(): void;
  20643. /**
  20644. * Inserts the submesh in its correct queue depending on its material.
  20645. * @param subMesh The submesh to dispatch
  20646. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20647. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20648. */
  20649. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20650. dispatchSprites(spriteManager: ISpriteManager): void;
  20651. dispatchParticles(particleSystem: IParticleSystem): void;
  20652. private _renderParticles;
  20653. private _renderSprites;
  20654. }
  20655. }
  20656. declare module "babylonjs/Rendering/renderingManager" {
  20657. import { Nullable } from "babylonjs/types";
  20658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20659. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20660. import { SmartArray } from "babylonjs/Misc/smartArray";
  20661. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20662. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20663. import { Material } from "babylonjs/Materials/material";
  20664. import { Scene } from "babylonjs/scene";
  20665. import { Camera } from "babylonjs/Cameras/camera";
  20666. /**
  20667. * Interface describing the different options available in the rendering manager
  20668. * regarding Auto Clear between groups.
  20669. */
  20670. export interface IRenderingManagerAutoClearSetup {
  20671. /**
  20672. * Defines whether or not autoclear is enable.
  20673. */
  20674. autoClear: boolean;
  20675. /**
  20676. * Defines whether or not to autoclear the depth buffer.
  20677. */
  20678. depth: boolean;
  20679. /**
  20680. * Defines whether or not to autoclear the stencil buffer.
  20681. */
  20682. stencil: boolean;
  20683. }
  20684. /**
  20685. * This class is used by the onRenderingGroupObservable
  20686. */
  20687. export class RenderingGroupInfo {
  20688. /**
  20689. * The Scene that being rendered
  20690. */
  20691. scene: Scene;
  20692. /**
  20693. * The camera currently used for the rendering pass
  20694. */
  20695. camera: Nullable<Camera>;
  20696. /**
  20697. * The ID of the renderingGroup being processed
  20698. */
  20699. renderingGroupId: number;
  20700. }
  20701. /**
  20702. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20703. * It is enable to manage the different groups as well as the different necessary sort functions.
  20704. * This should not be used directly aside of the few static configurations
  20705. */
  20706. export class RenderingManager {
  20707. /**
  20708. * The max id used for rendering groups (not included)
  20709. */
  20710. static MAX_RENDERINGGROUPS: number;
  20711. /**
  20712. * The min id used for rendering groups (included)
  20713. */
  20714. static MIN_RENDERINGGROUPS: number;
  20715. /**
  20716. * Used to globally prevent autoclearing scenes.
  20717. */
  20718. static AUTOCLEAR: boolean;
  20719. /**
  20720. * @hidden
  20721. */
  20722. _useSceneAutoClearSetup: boolean;
  20723. private _scene;
  20724. private _renderingGroups;
  20725. private _depthStencilBufferAlreadyCleaned;
  20726. private _autoClearDepthStencil;
  20727. private _customOpaqueSortCompareFn;
  20728. private _customAlphaTestSortCompareFn;
  20729. private _customTransparentSortCompareFn;
  20730. private _renderingGroupInfo;
  20731. /**
  20732. * Instantiates a new rendering group for a particular scene
  20733. * @param scene Defines the scene the groups belongs to
  20734. */
  20735. constructor(scene: Scene);
  20736. private _clearDepthStencilBuffer;
  20737. /**
  20738. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20739. * @hidden
  20740. */
  20741. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20742. /**
  20743. * Resets the different information of the group to prepare a new frame
  20744. * @hidden
  20745. */
  20746. reset(): void;
  20747. /**
  20748. * Dispose and release the group and its associated resources.
  20749. * @hidden
  20750. */
  20751. dispose(): void;
  20752. /**
  20753. * Clear the info related to rendering groups preventing retention points during dispose.
  20754. */
  20755. freeRenderingGroups(): void;
  20756. private _prepareRenderingGroup;
  20757. /**
  20758. * Add a sprite manager to the rendering manager in order to render it this frame.
  20759. * @param spriteManager Define the sprite manager to render
  20760. */
  20761. dispatchSprites(spriteManager: ISpriteManager): void;
  20762. /**
  20763. * Add a particle system to the rendering manager in order to render it this frame.
  20764. * @param particleSystem Define the particle system to render
  20765. */
  20766. dispatchParticles(particleSystem: IParticleSystem): void;
  20767. /**
  20768. * Add a submesh to the manager in order to render it this frame
  20769. * @param subMesh The submesh to dispatch
  20770. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20771. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20772. */
  20773. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20774. /**
  20775. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20776. * This allowed control for front to back rendering or reversly depending of the special needs.
  20777. *
  20778. * @param renderingGroupId The rendering group id corresponding to its index
  20779. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20780. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20781. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20782. */
  20783. 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;
  20784. /**
  20785. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20786. *
  20787. * @param renderingGroupId The rendering group id corresponding to its index
  20788. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20789. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20790. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20791. */
  20792. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20793. /**
  20794. * Gets the current auto clear configuration for one rendering group of the rendering
  20795. * manager.
  20796. * @param index the rendering group index to get the information for
  20797. * @returns The auto clear setup for the requested rendering group
  20798. */
  20799. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20800. }
  20801. }
  20802. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20803. import { Observable } from "babylonjs/Misc/observable";
  20804. import { SmartArray } from "babylonjs/Misc/smartArray";
  20805. import { Nullable } from "babylonjs/types";
  20806. import { Camera } from "babylonjs/Cameras/camera";
  20807. import { Scene } from "babylonjs/scene";
  20808. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20809. import { Color4 } from "babylonjs/Maths/math.color";
  20810. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20812. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20813. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20814. import { Texture } from "babylonjs/Materials/Textures/texture";
  20815. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20816. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20817. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20818. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20819. import { Engine } from "babylonjs/Engines/engine";
  20820. /**
  20821. * This Helps creating a texture that will be created from a camera in your scene.
  20822. * It is basically a dynamic texture that could be used to create special effects for instance.
  20823. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20824. */
  20825. export class RenderTargetTexture extends Texture {
  20826. isCube: boolean;
  20827. /**
  20828. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20829. */
  20830. static readonly REFRESHRATE_RENDER_ONCE: number;
  20831. /**
  20832. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20833. */
  20834. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20835. /**
  20836. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20837. * the central point of your effect and can save a lot of performances.
  20838. */
  20839. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20840. /**
  20841. * Use this predicate to dynamically define the list of mesh you want to render.
  20842. * If set, the renderList property will be overwritten.
  20843. */
  20844. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20845. private _renderList;
  20846. /**
  20847. * Use this list to define the list of mesh you want to render.
  20848. */
  20849. get renderList(): Nullable<Array<AbstractMesh>>;
  20850. set renderList(value: Nullable<Array<AbstractMesh>>);
  20851. private _hookArray;
  20852. /**
  20853. * Define if particles should be rendered in your texture.
  20854. */
  20855. renderParticles: boolean;
  20856. /**
  20857. * Define if sprites should be rendered in your texture.
  20858. */
  20859. renderSprites: boolean;
  20860. /**
  20861. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20862. */
  20863. coordinatesMode: number;
  20864. /**
  20865. * Define the camera used to render the texture.
  20866. */
  20867. activeCamera: Nullable<Camera>;
  20868. /**
  20869. * Override the render function of the texture with your own one.
  20870. */
  20871. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20872. /**
  20873. * Define if camera post processes should be use while rendering the texture.
  20874. */
  20875. useCameraPostProcesses: boolean;
  20876. /**
  20877. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20878. */
  20879. ignoreCameraViewport: boolean;
  20880. private _postProcessManager;
  20881. private _postProcesses;
  20882. private _resizeObserver;
  20883. /**
  20884. * An event triggered when the texture is unbind.
  20885. */
  20886. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20887. /**
  20888. * An event triggered when the texture is unbind.
  20889. */
  20890. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20891. private _onAfterUnbindObserver;
  20892. /**
  20893. * Set a after unbind callback in the texture.
  20894. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20895. */
  20896. set onAfterUnbind(callback: () => void);
  20897. /**
  20898. * An event triggered before rendering the texture
  20899. */
  20900. onBeforeRenderObservable: Observable<number>;
  20901. private _onBeforeRenderObserver;
  20902. /**
  20903. * Set a before render callback in the texture.
  20904. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20905. */
  20906. set onBeforeRender(callback: (faceIndex: number) => void);
  20907. /**
  20908. * An event triggered after rendering the texture
  20909. */
  20910. onAfterRenderObservable: Observable<number>;
  20911. private _onAfterRenderObserver;
  20912. /**
  20913. * Set a after render callback in the texture.
  20914. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20915. */
  20916. set onAfterRender(callback: (faceIndex: number) => void);
  20917. /**
  20918. * An event triggered after the texture clear
  20919. */
  20920. onClearObservable: Observable<Engine>;
  20921. private _onClearObserver;
  20922. /**
  20923. * Set a clear callback in the texture.
  20924. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20925. */
  20926. set onClear(callback: (Engine: Engine) => void);
  20927. /**
  20928. * An event triggered when the texture is resized.
  20929. */
  20930. onResizeObservable: Observable<RenderTargetTexture>;
  20931. /**
  20932. * Define the clear color of the Render Target if it should be different from the scene.
  20933. */
  20934. clearColor: Color4;
  20935. protected _size: number | {
  20936. width: number;
  20937. height: number;
  20938. };
  20939. protected _initialSizeParameter: number | {
  20940. width: number;
  20941. height: number;
  20942. } | {
  20943. ratio: number;
  20944. };
  20945. protected _sizeRatio: Nullable<number>;
  20946. /** @hidden */
  20947. _generateMipMaps: boolean;
  20948. protected _renderingManager: RenderingManager;
  20949. /** @hidden */
  20950. _waitingRenderList: string[];
  20951. protected _doNotChangeAspectRatio: boolean;
  20952. protected _currentRefreshId: number;
  20953. protected _refreshRate: number;
  20954. protected _textureMatrix: Matrix;
  20955. protected _samples: number;
  20956. protected _renderTargetOptions: RenderTargetCreationOptions;
  20957. /**
  20958. * Gets render target creation options that were used.
  20959. */
  20960. get renderTargetOptions(): RenderTargetCreationOptions;
  20961. protected _engine: Engine;
  20962. protected _onRatioRescale(): void;
  20963. /**
  20964. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20965. * It must define where the camera used to render the texture is set
  20966. */
  20967. boundingBoxPosition: Vector3;
  20968. private _boundingBoxSize;
  20969. /**
  20970. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20971. * When defined, the cubemap will switch to local mode
  20972. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20973. * @example https://www.babylonjs-playground.com/#RNASML
  20974. */
  20975. set boundingBoxSize(value: Vector3);
  20976. get boundingBoxSize(): Vector3;
  20977. /**
  20978. * In case the RTT has been created with a depth texture, get the associated
  20979. * depth texture.
  20980. * Otherwise, return null.
  20981. */
  20982. depthStencilTexture: Nullable<InternalTexture>;
  20983. /**
  20984. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20985. * or used a shadow, depth texture...
  20986. * @param name The friendly name of the texture
  20987. * @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)
  20988. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20989. * @param generateMipMaps True if mip maps need to be generated after render.
  20990. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20991. * @param type The type of the buffer in the RTT (int, half float, float...)
  20992. * @param isCube True if a cube texture needs to be created
  20993. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20994. * @param generateDepthBuffer True to generate a depth buffer
  20995. * @param generateStencilBuffer True to generate a stencil buffer
  20996. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20997. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20998. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20999. */
  21000. constructor(name: string, size: number | {
  21001. width: number;
  21002. height: number;
  21003. } | {
  21004. ratio: number;
  21005. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21006. /**
  21007. * Creates a depth stencil texture.
  21008. * This is only available in WebGL 2 or with the depth texture extension available.
  21009. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21010. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21011. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21012. */
  21013. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21014. private _processSizeParameter;
  21015. /**
  21016. * Define the number of samples to use in case of MSAA.
  21017. * It defaults to one meaning no MSAA has been enabled.
  21018. */
  21019. get samples(): number;
  21020. set samples(value: number);
  21021. /**
  21022. * Resets the refresh counter of the texture and start bak from scratch.
  21023. * Could be useful to regenerate the texture if it is setup to render only once.
  21024. */
  21025. resetRefreshCounter(): void;
  21026. /**
  21027. * Define the refresh rate of the texture or the rendering frequency.
  21028. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21029. */
  21030. get refreshRate(): number;
  21031. set refreshRate(value: number);
  21032. /**
  21033. * Adds a post process to the render target rendering passes.
  21034. * @param postProcess define the post process to add
  21035. */
  21036. addPostProcess(postProcess: PostProcess): void;
  21037. /**
  21038. * Clear all the post processes attached to the render target
  21039. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21040. */
  21041. clearPostProcesses(dispose?: boolean): void;
  21042. /**
  21043. * Remove one of the post process from the list of attached post processes to the texture
  21044. * @param postProcess define the post process to remove from the list
  21045. */
  21046. removePostProcess(postProcess: PostProcess): void;
  21047. /** @hidden */
  21048. _shouldRender(): boolean;
  21049. /**
  21050. * Gets the actual render size of the texture.
  21051. * @returns the width of the render size
  21052. */
  21053. getRenderSize(): number;
  21054. /**
  21055. * Gets the actual render width of the texture.
  21056. * @returns the width of the render size
  21057. */
  21058. getRenderWidth(): number;
  21059. /**
  21060. * Gets the actual render height of the texture.
  21061. * @returns the height of the render size
  21062. */
  21063. getRenderHeight(): number;
  21064. /**
  21065. * Get if the texture can be rescaled or not.
  21066. */
  21067. get canRescale(): boolean;
  21068. /**
  21069. * Resize the texture using a ratio.
  21070. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21071. */
  21072. scale(ratio: number): void;
  21073. /**
  21074. * Get the texture reflection matrix used to rotate/transform the reflection.
  21075. * @returns the reflection matrix
  21076. */
  21077. getReflectionTextureMatrix(): Matrix;
  21078. /**
  21079. * Resize the texture to a new desired size.
  21080. * Be carrefull as it will recreate all the data in the new texture.
  21081. * @param size Define the new size. It can be:
  21082. * - a number for squared texture,
  21083. * - an object containing { width: number, height: number }
  21084. * - or an object containing a ratio { ratio: number }
  21085. */
  21086. resize(size: number | {
  21087. width: number;
  21088. height: number;
  21089. } | {
  21090. ratio: number;
  21091. }): void;
  21092. /**
  21093. * Renders all the objects from the render list into the texture.
  21094. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21095. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21096. */
  21097. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21098. private _bestReflectionRenderTargetDimension;
  21099. /**
  21100. * @hidden
  21101. * @param faceIndex face index to bind to if this is a cubetexture
  21102. */
  21103. _bindFrameBuffer(faceIndex?: number): void;
  21104. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21105. private renderToTarget;
  21106. /**
  21107. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21108. * This allowed control for front to back rendering or reversly depending of the special needs.
  21109. *
  21110. * @param renderingGroupId The rendering group id corresponding to its index
  21111. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21112. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21113. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21114. */
  21115. 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;
  21116. /**
  21117. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21118. *
  21119. * @param renderingGroupId The rendering group id corresponding to its index
  21120. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21121. */
  21122. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21123. /**
  21124. * Clones the texture.
  21125. * @returns the cloned texture
  21126. */
  21127. clone(): RenderTargetTexture;
  21128. /**
  21129. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21130. * @returns The JSON representation of the texture
  21131. */
  21132. serialize(): any;
  21133. /**
  21134. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21135. */
  21136. disposeFramebufferObjects(): void;
  21137. /**
  21138. * Dispose the texture and release its associated resources.
  21139. */
  21140. dispose(): void;
  21141. /** @hidden */
  21142. _rebuild(): void;
  21143. /**
  21144. * Clear the info related to rendering groups preventing retention point in material dispose.
  21145. */
  21146. freeRenderingGroups(): void;
  21147. /**
  21148. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21149. * @returns the view count
  21150. */
  21151. getViewCount(): number;
  21152. }
  21153. }
  21154. declare module "babylonjs/Materials/material" {
  21155. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21156. import { SmartArray } from "babylonjs/Misc/smartArray";
  21157. import { Observable } from "babylonjs/Misc/observable";
  21158. import { Nullable } from "babylonjs/types";
  21159. import { Scene } from "babylonjs/scene";
  21160. import { Matrix } from "babylonjs/Maths/math.vector";
  21161. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21163. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21164. import { Effect } from "babylonjs/Materials/effect";
  21165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21166. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21167. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21168. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21169. import { Mesh } from "babylonjs/Meshes/mesh";
  21170. import { Animation } from "babylonjs/Animations/animation";
  21171. /**
  21172. * Options for compiling materials.
  21173. */
  21174. export interface IMaterialCompilationOptions {
  21175. /**
  21176. * Defines whether clip planes are enabled.
  21177. */
  21178. clipPlane: boolean;
  21179. /**
  21180. * Defines whether instances are enabled.
  21181. */
  21182. useInstances: boolean;
  21183. }
  21184. /**
  21185. * Base class for the main features of a material in Babylon.js
  21186. */
  21187. export class Material implements IAnimatable {
  21188. /**
  21189. * Returns the triangle fill mode
  21190. */
  21191. static readonly TriangleFillMode: number;
  21192. /**
  21193. * Returns the wireframe mode
  21194. */
  21195. static readonly WireFrameFillMode: number;
  21196. /**
  21197. * Returns the point fill mode
  21198. */
  21199. static readonly PointFillMode: number;
  21200. /**
  21201. * Returns the point list draw mode
  21202. */
  21203. static readonly PointListDrawMode: number;
  21204. /**
  21205. * Returns the line list draw mode
  21206. */
  21207. static readonly LineListDrawMode: number;
  21208. /**
  21209. * Returns the line loop draw mode
  21210. */
  21211. static readonly LineLoopDrawMode: number;
  21212. /**
  21213. * Returns the line strip draw mode
  21214. */
  21215. static readonly LineStripDrawMode: number;
  21216. /**
  21217. * Returns the triangle strip draw mode
  21218. */
  21219. static readonly TriangleStripDrawMode: number;
  21220. /**
  21221. * Returns the triangle fan draw mode
  21222. */
  21223. static readonly TriangleFanDrawMode: number;
  21224. /**
  21225. * Stores the clock-wise side orientation
  21226. */
  21227. static readonly ClockWiseSideOrientation: number;
  21228. /**
  21229. * Stores the counter clock-wise side orientation
  21230. */
  21231. static readonly CounterClockWiseSideOrientation: number;
  21232. /**
  21233. * The dirty texture flag value
  21234. */
  21235. static readonly TextureDirtyFlag: number;
  21236. /**
  21237. * The dirty light flag value
  21238. */
  21239. static readonly LightDirtyFlag: number;
  21240. /**
  21241. * The dirty fresnel flag value
  21242. */
  21243. static readonly FresnelDirtyFlag: number;
  21244. /**
  21245. * The dirty attribute flag value
  21246. */
  21247. static readonly AttributesDirtyFlag: number;
  21248. /**
  21249. * The dirty misc flag value
  21250. */
  21251. static readonly MiscDirtyFlag: number;
  21252. /**
  21253. * The all dirty flag value
  21254. */
  21255. static readonly AllDirtyFlag: number;
  21256. /**
  21257. * The ID of the material
  21258. */
  21259. id: string;
  21260. /**
  21261. * Gets or sets the unique id of the material
  21262. */
  21263. uniqueId: number;
  21264. /**
  21265. * The name of the material
  21266. */
  21267. name: string;
  21268. /**
  21269. * Gets or sets user defined metadata
  21270. */
  21271. metadata: any;
  21272. /**
  21273. * For internal use only. Please do not use.
  21274. */
  21275. reservedDataStore: any;
  21276. /**
  21277. * Specifies if the ready state should be checked on each call
  21278. */
  21279. checkReadyOnEveryCall: boolean;
  21280. /**
  21281. * Specifies if the ready state should be checked once
  21282. */
  21283. checkReadyOnlyOnce: boolean;
  21284. /**
  21285. * The state of the material
  21286. */
  21287. state: string;
  21288. /**
  21289. * The alpha value of the material
  21290. */
  21291. protected _alpha: number;
  21292. /**
  21293. * List of inspectable custom properties (used by the Inspector)
  21294. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21295. */
  21296. inspectableCustomProperties: IInspectable[];
  21297. /**
  21298. * Sets the alpha value of the material
  21299. */
  21300. set alpha(value: number);
  21301. /**
  21302. * Gets the alpha value of the material
  21303. */
  21304. get alpha(): number;
  21305. /**
  21306. * Specifies if back face culling is enabled
  21307. */
  21308. protected _backFaceCulling: boolean;
  21309. /**
  21310. * Sets the back-face culling state
  21311. */
  21312. set backFaceCulling(value: boolean);
  21313. /**
  21314. * Gets the back-face culling state
  21315. */
  21316. get backFaceCulling(): boolean;
  21317. /**
  21318. * Stores the value for side orientation
  21319. */
  21320. sideOrientation: number;
  21321. /**
  21322. * Callback triggered when the material is compiled
  21323. */
  21324. onCompiled: Nullable<(effect: Effect) => void>;
  21325. /**
  21326. * Callback triggered when an error occurs
  21327. */
  21328. onError: Nullable<(effect: Effect, errors: string) => void>;
  21329. /**
  21330. * Callback triggered to get the render target textures
  21331. */
  21332. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21333. /**
  21334. * Gets a boolean indicating that current material needs to register RTT
  21335. */
  21336. get hasRenderTargetTextures(): boolean;
  21337. /**
  21338. * Specifies if the material should be serialized
  21339. */
  21340. doNotSerialize: boolean;
  21341. /**
  21342. * @hidden
  21343. */
  21344. _storeEffectOnSubMeshes: boolean;
  21345. /**
  21346. * Stores the animations for the material
  21347. */
  21348. animations: Nullable<Array<Animation>>;
  21349. /**
  21350. * An event triggered when the material is disposed
  21351. */
  21352. onDisposeObservable: Observable<Material>;
  21353. /**
  21354. * An observer which watches for dispose events
  21355. */
  21356. private _onDisposeObserver;
  21357. private _onUnBindObservable;
  21358. /**
  21359. * Called during a dispose event
  21360. */
  21361. set onDispose(callback: () => void);
  21362. private _onBindObservable;
  21363. /**
  21364. * An event triggered when the material is bound
  21365. */
  21366. get onBindObservable(): Observable<AbstractMesh>;
  21367. /**
  21368. * An observer which watches for bind events
  21369. */
  21370. private _onBindObserver;
  21371. /**
  21372. * Called during a bind event
  21373. */
  21374. set onBind(callback: (Mesh: AbstractMesh) => void);
  21375. /**
  21376. * An event triggered when the material is unbound
  21377. */
  21378. get onUnBindObservable(): Observable<Material>;
  21379. /**
  21380. * Stores the value of the alpha mode
  21381. */
  21382. private _alphaMode;
  21383. /**
  21384. * Sets the value of the alpha mode.
  21385. *
  21386. * | Value | Type | Description |
  21387. * | --- | --- | --- |
  21388. * | 0 | ALPHA_DISABLE | |
  21389. * | 1 | ALPHA_ADD | |
  21390. * | 2 | ALPHA_COMBINE | |
  21391. * | 3 | ALPHA_SUBTRACT | |
  21392. * | 4 | ALPHA_MULTIPLY | |
  21393. * | 5 | ALPHA_MAXIMIZED | |
  21394. * | 6 | ALPHA_ONEONE | |
  21395. * | 7 | ALPHA_PREMULTIPLIED | |
  21396. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21397. * | 9 | ALPHA_INTERPOLATE | |
  21398. * | 10 | ALPHA_SCREENMODE | |
  21399. *
  21400. */
  21401. set alphaMode(value: number);
  21402. /**
  21403. * Gets the value of the alpha mode
  21404. */
  21405. get alphaMode(): number;
  21406. /**
  21407. * Stores the state of the need depth pre-pass value
  21408. */
  21409. private _needDepthPrePass;
  21410. /**
  21411. * Sets the need depth pre-pass value
  21412. */
  21413. set needDepthPrePass(value: boolean);
  21414. /**
  21415. * Gets the depth pre-pass value
  21416. */
  21417. get needDepthPrePass(): boolean;
  21418. /**
  21419. * Specifies if depth writing should be disabled
  21420. */
  21421. disableDepthWrite: boolean;
  21422. /**
  21423. * Specifies if depth writing should be forced
  21424. */
  21425. forceDepthWrite: boolean;
  21426. /**
  21427. * Specifies the depth function that should be used. 0 means the default engine function
  21428. */
  21429. depthFunction: number;
  21430. /**
  21431. * Specifies if there should be a separate pass for culling
  21432. */
  21433. separateCullingPass: boolean;
  21434. /**
  21435. * Stores the state specifing if fog should be enabled
  21436. */
  21437. private _fogEnabled;
  21438. /**
  21439. * Sets the state for enabling fog
  21440. */
  21441. set fogEnabled(value: boolean);
  21442. /**
  21443. * Gets the value of the fog enabled state
  21444. */
  21445. get fogEnabled(): boolean;
  21446. /**
  21447. * Stores the size of points
  21448. */
  21449. pointSize: number;
  21450. /**
  21451. * Stores the z offset value
  21452. */
  21453. zOffset: number;
  21454. /**
  21455. * Gets a value specifying if wireframe mode is enabled
  21456. */
  21457. get wireframe(): boolean;
  21458. /**
  21459. * Sets the state of wireframe mode
  21460. */
  21461. set wireframe(value: boolean);
  21462. /**
  21463. * Gets the value specifying if point clouds are enabled
  21464. */
  21465. get pointsCloud(): boolean;
  21466. /**
  21467. * Sets the state of point cloud mode
  21468. */
  21469. set pointsCloud(value: boolean);
  21470. /**
  21471. * Gets the material fill mode
  21472. */
  21473. get fillMode(): number;
  21474. /**
  21475. * Sets the material fill mode
  21476. */
  21477. set fillMode(value: number);
  21478. /**
  21479. * @hidden
  21480. * Stores the effects for the material
  21481. */
  21482. _effect: Nullable<Effect>;
  21483. /**
  21484. * Specifies if uniform buffers should be used
  21485. */
  21486. private _useUBO;
  21487. /**
  21488. * Stores a reference to the scene
  21489. */
  21490. private _scene;
  21491. /**
  21492. * Stores the fill mode state
  21493. */
  21494. private _fillMode;
  21495. /**
  21496. * Specifies if the depth write state should be cached
  21497. */
  21498. private _cachedDepthWriteState;
  21499. /**
  21500. * Specifies if the depth function state should be cached
  21501. */
  21502. private _cachedDepthFunctionState;
  21503. /**
  21504. * Stores the uniform buffer
  21505. */
  21506. protected _uniformBuffer: UniformBuffer;
  21507. /** @hidden */
  21508. _indexInSceneMaterialArray: number;
  21509. /** @hidden */
  21510. meshMap: Nullable<{
  21511. [id: string]: AbstractMesh | undefined;
  21512. }>;
  21513. /**
  21514. * Creates a material instance
  21515. * @param name defines the name of the material
  21516. * @param scene defines the scene to reference
  21517. * @param doNotAdd specifies if the material should be added to the scene
  21518. */
  21519. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21520. /**
  21521. * Returns a string representation of the current material
  21522. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21523. * @returns a string with material information
  21524. */
  21525. toString(fullDetails?: boolean): string;
  21526. /**
  21527. * Gets the class name of the material
  21528. * @returns a string with the class name of the material
  21529. */
  21530. getClassName(): string;
  21531. /**
  21532. * Specifies if updates for the material been locked
  21533. */
  21534. get isFrozen(): boolean;
  21535. /**
  21536. * Locks updates for the material
  21537. */
  21538. freeze(): void;
  21539. /**
  21540. * Unlocks updates for the material
  21541. */
  21542. unfreeze(): void;
  21543. /**
  21544. * Specifies if the material is ready to be used
  21545. * @param mesh defines the mesh to check
  21546. * @param useInstances specifies if instances should be used
  21547. * @returns a boolean indicating if the material is ready to be used
  21548. */
  21549. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21550. /**
  21551. * Specifies that the submesh is ready to be used
  21552. * @param mesh defines the mesh to check
  21553. * @param subMesh defines which submesh to check
  21554. * @param useInstances specifies that instances should be used
  21555. * @returns a boolean indicating that the submesh is ready or not
  21556. */
  21557. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21558. /**
  21559. * Returns the material effect
  21560. * @returns the effect associated with the material
  21561. */
  21562. getEffect(): Nullable<Effect>;
  21563. /**
  21564. * Returns the current scene
  21565. * @returns a Scene
  21566. */
  21567. getScene(): Scene;
  21568. /**
  21569. * Specifies if the material will require alpha blending
  21570. * @returns a boolean specifying if alpha blending is needed
  21571. */
  21572. needAlphaBlending(): boolean;
  21573. /**
  21574. * Specifies if the mesh will require alpha blending
  21575. * @param mesh defines the mesh to check
  21576. * @returns a boolean specifying if alpha blending is needed for the mesh
  21577. */
  21578. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21579. /**
  21580. * Specifies if this material should be rendered in alpha test mode
  21581. * @returns a boolean specifying if an alpha test is needed.
  21582. */
  21583. needAlphaTesting(): boolean;
  21584. /**
  21585. * Gets the texture used for the alpha test
  21586. * @returns the texture to use for alpha testing
  21587. */
  21588. getAlphaTestTexture(): Nullable<BaseTexture>;
  21589. /**
  21590. * Marks the material to indicate that it needs to be re-calculated
  21591. */
  21592. markDirty(): void;
  21593. /** @hidden */
  21594. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21595. /**
  21596. * Binds the material to the mesh
  21597. * @param world defines the world transformation matrix
  21598. * @param mesh defines the mesh to bind the material to
  21599. */
  21600. bind(world: Matrix, mesh?: Mesh): void;
  21601. /**
  21602. * Binds the submesh to the material
  21603. * @param world defines the world transformation matrix
  21604. * @param mesh defines the mesh containing the submesh
  21605. * @param subMesh defines the submesh to bind the material to
  21606. */
  21607. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21608. /**
  21609. * Binds the world matrix to the material
  21610. * @param world defines the world transformation matrix
  21611. */
  21612. bindOnlyWorldMatrix(world: Matrix): void;
  21613. /**
  21614. * Binds the scene's uniform buffer to the effect.
  21615. * @param effect defines the effect to bind to the scene uniform buffer
  21616. * @param sceneUbo defines the uniform buffer storing scene data
  21617. */
  21618. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21619. /**
  21620. * Binds the view matrix to the effect
  21621. * @param effect defines the effect to bind the view matrix to
  21622. */
  21623. bindView(effect: Effect): void;
  21624. /**
  21625. * Binds the view projection matrix to the effect
  21626. * @param effect defines the effect to bind the view projection matrix to
  21627. */
  21628. bindViewProjection(effect: Effect): void;
  21629. /**
  21630. * Specifies if material alpha testing should be turned on for the mesh
  21631. * @param mesh defines the mesh to check
  21632. */
  21633. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21634. /**
  21635. * Processes to execute after binding the material to a mesh
  21636. * @param mesh defines the rendered mesh
  21637. */
  21638. protected _afterBind(mesh?: Mesh): void;
  21639. /**
  21640. * Unbinds the material from the mesh
  21641. */
  21642. unbind(): void;
  21643. /**
  21644. * Gets the active textures from the material
  21645. * @returns an array of textures
  21646. */
  21647. getActiveTextures(): BaseTexture[];
  21648. /**
  21649. * Specifies if the material uses a texture
  21650. * @param texture defines the texture to check against the material
  21651. * @returns a boolean specifying if the material uses the texture
  21652. */
  21653. hasTexture(texture: BaseTexture): boolean;
  21654. /**
  21655. * Makes a duplicate of the material, and gives it a new name
  21656. * @param name defines the new name for the duplicated material
  21657. * @returns the cloned material
  21658. */
  21659. clone(name: string): Nullable<Material>;
  21660. /**
  21661. * Gets the meshes bound to the material
  21662. * @returns an array of meshes bound to the material
  21663. */
  21664. getBindedMeshes(): AbstractMesh[];
  21665. /**
  21666. * Force shader compilation
  21667. * @param mesh defines the mesh associated with this material
  21668. * @param onCompiled defines a function to execute once the material is compiled
  21669. * @param options defines the options to configure the compilation
  21670. * @param onError defines a function to execute if the material fails compiling
  21671. */
  21672. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21673. /**
  21674. * Force shader compilation
  21675. * @param mesh defines the mesh that will use this material
  21676. * @param options defines additional options for compiling the shaders
  21677. * @returns a promise that resolves when the compilation completes
  21678. */
  21679. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21680. private static readonly _AllDirtyCallBack;
  21681. private static readonly _ImageProcessingDirtyCallBack;
  21682. private static readonly _TextureDirtyCallBack;
  21683. private static readonly _FresnelDirtyCallBack;
  21684. private static readonly _MiscDirtyCallBack;
  21685. private static readonly _LightsDirtyCallBack;
  21686. private static readonly _AttributeDirtyCallBack;
  21687. private static _FresnelAndMiscDirtyCallBack;
  21688. private static _TextureAndMiscDirtyCallBack;
  21689. private static readonly _DirtyCallbackArray;
  21690. private static readonly _RunDirtyCallBacks;
  21691. /**
  21692. * Marks a define in the material to indicate that it needs to be re-computed
  21693. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21694. */
  21695. markAsDirty(flag: number): void;
  21696. /**
  21697. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21698. * @param func defines a function which checks material defines against the submeshes
  21699. */
  21700. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21701. /**
  21702. * Indicates that we need to re-calculated for all submeshes
  21703. */
  21704. protected _markAllSubMeshesAsAllDirty(): void;
  21705. /**
  21706. * Indicates that image processing needs to be re-calculated for all submeshes
  21707. */
  21708. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21709. /**
  21710. * Indicates that textures need to be re-calculated for all submeshes
  21711. */
  21712. protected _markAllSubMeshesAsTexturesDirty(): void;
  21713. /**
  21714. * Indicates that fresnel needs to be re-calculated for all submeshes
  21715. */
  21716. protected _markAllSubMeshesAsFresnelDirty(): void;
  21717. /**
  21718. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21719. */
  21720. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21721. /**
  21722. * Indicates that lights need to be re-calculated for all submeshes
  21723. */
  21724. protected _markAllSubMeshesAsLightsDirty(): void;
  21725. /**
  21726. * Indicates that attributes need to be re-calculated for all submeshes
  21727. */
  21728. protected _markAllSubMeshesAsAttributesDirty(): void;
  21729. /**
  21730. * Indicates that misc needs to be re-calculated for all submeshes
  21731. */
  21732. protected _markAllSubMeshesAsMiscDirty(): void;
  21733. /**
  21734. * Indicates that textures and misc need to be re-calculated for all submeshes
  21735. */
  21736. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21737. /**
  21738. * Disposes the material
  21739. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21740. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21741. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21742. */
  21743. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21744. /** @hidden */
  21745. private releaseVertexArrayObject;
  21746. /**
  21747. * Serializes this material
  21748. * @returns the serialized material object
  21749. */
  21750. serialize(): any;
  21751. /**
  21752. * Creates a material from parsed material data
  21753. * @param parsedMaterial defines parsed material data
  21754. * @param scene defines the hosting scene
  21755. * @param rootUrl defines the root URL to use to load textures
  21756. * @returns a new material
  21757. */
  21758. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21759. }
  21760. }
  21761. declare module "babylonjs/Materials/multiMaterial" {
  21762. import { Nullable } from "babylonjs/types";
  21763. import { Scene } from "babylonjs/scene";
  21764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21765. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21766. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21767. import { Material } from "babylonjs/Materials/material";
  21768. /**
  21769. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21770. * separate meshes. This can be use to improve performances.
  21771. * @see http://doc.babylonjs.com/how_to/multi_materials
  21772. */
  21773. export class MultiMaterial extends Material {
  21774. private _subMaterials;
  21775. /**
  21776. * Gets or Sets the list of Materials used within the multi material.
  21777. * They need to be ordered according to the submeshes order in the associated mesh
  21778. */
  21779. get subMaterials(): Nullable<Material>[];
  21780. set subMaterials(value: Nullable<Material>[]);
  21781. /**
  21782. * Function used to align with Node.getChildren()
  21783. * @returns the list of Materials used within the multi material
  21784. */
  21785. getChildren(): Nullable<Material>[];
  21786. /**
  21787. * Instantiates a new Multi Material
  21788. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21789. * separate meshes. This can be use to improve performances.
  21790. * @see http://doc.babylonjs.com/how_to/multi_materials
  21791. * @param name Define the name in the scene
  21792. * @param scene Define the scene the material belongs to
  21793. */
  21794. constructor(name: string, scene: Scene);
  21795. private _hookArray;
  21796. /**
  21797. * Get one of the submaterial by its index in the submaterials array
  21798. * @param index The index to look the sub material at
  21799. * @returns The Material if the index has been defined
  21800. */
  21801. getSubMaterial(index: number): Nullable<Material>;
  21802. /**
  21803. * Get the list of active textures for the whole sub materials list.
  21804. * @returns All the textures that will be used during the rendering
  21805. */
  21806. getActiveTextures(): BaseTexture[];
  21807. /**
  21808. * Gets the current class name of the material e.g. "MultiMaterial"
  21809. * Mainly use in serialization.
  21810. * @returns the class name
  21811. */
  21812. getClassName(): string;
  21813. /**
  21814. * Checks if the material is ready to render the requested sub mesh
  21815. * @param mesh Define the mesh the submesh belongs to
  21816. * @param subMesh Define the sub mesh to look readyness for
  21817. * @param useInstances Define whether or not the material is used with instances
  21818. * @returns true if ready, otherwise false
  21819. */
  21820. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21821. /**
  21822. * Clones the current material and its related sub materials
  21823. * @param name Define the name of the newly cloned material
  21824. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21825. * @returns the cloned material
  21826. */
  21827. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21828. /**
  21829. * Serializes the materials into a JSON representation.
  21830. * @returns the JSON representation
  21831. */
  21832. serialize(): any;
  21833. /**
  21834. * Dispose the material and release its associated resources
  21835. * @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)
  21836. * @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)
  21837. * @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)
  21838. */
  21839. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21840. /**
  21841. * Creates a MultiMaterial from parsed MultiMaterial data.
  21842. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21843. * @param scene defines the hosting scene
  21844. * @returns a new MultiMaterial
  21845. */
  21846. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21847. }
  21848. }
  21849. declare module "babylonjs/Meshes/subMesh" {
  21850. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21851. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21852. import { Engine } from "babylonjs/Engines/engine";
  21853. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21854. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21855. import { Effect } from "babylonjs/Materials/effect";
  21856. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21857. import { Plane } from "babylonjs/Maths/math.plane";
  21858. import { Collider } from "babylonjs/Collisions/collider";
  21859. import { Material } from "babylonjs/Materials/material";
  21860. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21862. import { Mesh } from "babylonjs/Meshes/mesh";
  21863. import { Ray } from "babylonjs/Culling/ray";
  21864. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21865. /**
  21866. * Base class for submeshes
  21867. */
  21868. export class BaseSubMesh {
  21869. /** @hidden */
  21870. _materialDefines: Nullable<MaterialDefines>;
  21871. /** @hidden */
  21872. _materialEffect: Nullable<Effect>;
  21873. /**
  21874. * Gets material defines used by the effect associated to the sub mesh
  21875. */
  21876. get materialDefines(): Nullable<MaterialDefines>;
  21877. /**
  21878. * Sets material defines used by the effect associated to the sub mesh
  21879. */
  21880. set materialDefines(defines: Nullable<MaterialDefines>);
  21881. /**
  21882. * Gets associated effect
  21883. */
  21884. get effect(): Nullable<Effect>;
  21885. /**
  21886. * Sets associated effect (effect used to render this submesh)
  21887. * @param effect defines the effect to associate with
  21888. * @param defines defines the set of defines used to compile this effect
  21889. */
  21890. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21891. }
  21892. /**
  21893. * Defines a subdivision inside a mesh
  21894. */
  21895. export class SubMesh extends BaseSubMesh implements ICullable {
  21896. /** the material index to use */
  21897. materialIndex: number;
  21898. /** vertex index start */
  21899. verticesStart: number;
  21900. /** vertices count */
  21901. verticesCount: number;
  21902. /** index start */
  21903. indexStart: number;
  21904. /** indices count */
  21905. indexCount: number;
  21906. /** @hidden */
  21907. _linesIndexCount: number;
  21908. private _mesh;
  21909. private _renderingMesh;
  21910. private _boundingInfo;
  21911. private _linesIndexBuffer;
  21912. /** @hidden */
  21913. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21914. /** @hidden */
  21915. _trianglePlanes: Plane[];
  21916. /** @hidden */
  21917. _lastColliderTransformMatrix: Nullable<Matrix>;
  21918. /** @hidden */
  21919. _renderId: number;
  21920. /** @hidden */
  21921. _alphaIndex: number;
  21922. /** @hidden */
  21923. _distanceToCamera: number;
  21924. /** @hidden */
  21925. _id: number;
  21926. private _currentMaterial;
  21927. /**
  21928. * Add a new submesh to a mesh
  21929. * @param materialIndex defines the material index to use
  21930. * @param verticesStart defines vertex index start
  21931. * @param verticesCount defines vertices count
  21932. * @param indexStart defines index start
  21933. * @param indexCount defines indices count
  21934. * @param mesh defines the parent mesh
  21935. * @param renderingMesh defines an optional rendering mesh
  21936. * @param createBoundingBox defines if bounding box should be created for this submesh
  21937. * @returns the new submesh
  21938. */
  21939. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21940. /**
  21941. * Creates a new submesh
  21942. * @param materialIndex defines the material index to use
  21943. * @param verticesStart defines vertex index start
  21944. * @param verticesCount defines vertices count
  21945. * @param indexStart defines index start
  21946. * @param indexCount defines indices count
  21947. * @param mesh defines the parent mesh
  21948. * @param renderingMesh defines an optional rendering mesh
  21949. * @param createBoundingBox defines if bounding box should be created for this submesh
  21950. */
  21951. constructor(
  21952. /** the material index to use */
  21953. materialIndex: number,
  21954. /** vertex index start */
  21955. verticesStart: number,
  21956. /** vertices count */
  21957. verticesCount: number,
  21958. /** index start */
  21959. indexStart: number,
  21960. /** indices count */
  21961. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21962. /**
  21963. * Returns true if this submesh covers the entire parent mesh
  21964. * @ignorenaming
  21965. */
  21966. get IsGlobal(): boolean;
  21967. /**
  21968. * Returns the submesh BoudingInfo object
  21969. * @returns current bounding info (or mesh's one if the submesh is global)
  21970. */
  21971. getBoundingInfo(): BoundingInfo;
  21972. /**
  21973. * Sets the submesh BoundingInfo
  21974. * @param boundingInfo defines the new bounding info to use
  21975. * @returns the SubMesh
  21976. */
  21977. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21978. /**
  21979. * Returns the mesh of the current submesh
  21980. * @return the parent mesh
  21981. */
  21982. getMesh(): AbstractMesh;
  21983. /**
  21984. * Returns the rendering mesh of the submesh
  21985. * @returns the rendering mesh (could be different from parent mesh)
  21986. */
  21987. getRenderingMesh(): Mesh;
  21988. /**
  21989. * Returns the submesh material
  21990. * @returns null or the current material
  21991. */
  21992. getMaterial(): Nullable<Material>;
  21993. /**
  21994. * Sets a new updated BoundingInfo object to the submesh
  21995. * @param data defines an optional position array to use to determine the bounding info
  21996. * @returns the SubMesh
  21997. */
  21998. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21999. /** @hidden */
  22000. _checkCollision(collider: Collider): boolean;
  22001. /**
  22002. * Updates the submesh BoundingInfo
  22003. * @param world defines the world matrix to use to update the bounding info
  22004. * @returns the submesh
  22005. */
  22006. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22007. /**
  22008. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22009. * @param frustumPlanes defines the frustum planes
  22010. * @returns true if the submesh is intersecting with the frustum
  22011. */
  22012. isInFrustum(frustumPlanes: Plane[]): boolean;
  22013. /**
  22014. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22015. * @param frustumPlanes defines the frustum planes
  22016. * @returns true if the submesh is inside the frustum
  22017. */
  22018. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22019. /**
  22020. * Renders the submesh
  22021. * @param enableAlphaMode defines if alpha needs to be used
  22022. * @returns the submesh
  22023. */
  22024. render(enableAlphaMode: boolean): SubMesh;
  22025. /**
  22026. * @hidden
  22027. */
  22028. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22029. /**
  22030. * Checks if the submesh intersects with a ray
  22031. * @param ray defines the ray to test
  22032. * @returns true is the passed ray intersects the submesh bounding box
  22033. */
  22034. canIntersects(ray: Ray): boolean;
  22035. /**
  22036. * Intersects current submesh with a ray
  22037. * @param ray defines the ray to test
  22038. * @param positions defines mesh's positions array
  22039. * @param indices defines mesh's indices array
  22040. * @param fastCheck defines if only bounding info should be used
  22041. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22042. * @returns intersection info or null if no intersection
  22043. */
  22044. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22045. /** @hidden */
  22046. private _intersectLines;
  22047. /** @hidden */
  22048. private _intersectUnIndexedLines;
  22049. /** @hidden */
  22050. private _intersectTriangles;
  22051. /** @hidden */
  22052. private _intersectUnIndexedTriangles;
  22053. /** @hidden */
  22054. _rebuild(): void;
  22055. /**
  22056. * Creates a new submesh from the passed mesh
  22057. * @param newMesh defines the new hosting mesh
  22058. * @param newRenderingMesh defines an optional rendering mesh
  22059. * @returns the new submesh
  22060. */
  22061. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22062. /**
  22063. * Release associated resources
  22064. */
  22065. dispose(): void;
  22066. /**
  22067. * Gets the class name
  22068. * @returns the string "SubMesh".
  22069. */
  22070. getClassName(): string;
  22071. /**
  22072. * Creates a new submesh from indices data
  22073. * @param materialIndex the index of the main mesh material
  22074. * @param startIndex the index where to start the copy in the mesh indices array
  22075. * @param indexCount the number of indices to copy then from the startIndex
  22076. * @param mesh the main mesh to create the submesh from
  22077. * @param renderingMesh the optional rendering mesh
  22078. * @returns a new submesh
  22079. */
  22080. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22081. }
  22082. }
  22083. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22084. /**
  22085. * Class used to represent data loading progression
  22086. */
  22087. export class SceneLoaderFlags {
  22088. private static _ForceFullSceneLoadingForIncremental;
  22089. private static _ShowLoadingScreen;
  22090. private static _CleanBoneMatrixWeights;
  22091. private static _loggingLevel;
  22092. /**
  22093. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22094. */
  22095. static get ForceFullSceneLoadingForIncremental(): boolean;
  22096. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22097. /**
  22098. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22099. */
  22100. static get ShowLoadingScreen(): boolean;
  22101. static set ShowLoadingScreen(value: boolean);
  22102. /**
  22103. * Defines the current logging level (while loading the scene)
  22104. * @ignorenaming
  22105. */
  22106. static get loggingLevel(): number;
  22107. static set loggingLevel(value: number);
  22108. /**
  22109. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22110. */
  22111. static get CleanBoneMatrixWeights(): boolean;
  22112. static set CleanBoneMatrixWeights(value: boolean);
  22113. }
  22114. }
  22115. declare module "babylonjs/Meshes/geometry" {
  22116. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22117. import { Scene } from "babylonjs/scene";
  22118. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22119. import { Engine } from "babylonjs/Engines/engine";
  22120. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22121. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22122. import { Effect } from "babylonjs/Materials/effect";
  22123. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22124. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22125. import { Mesh } from "babylonjs/Meshes/mesh";
  22126. /**
  22127. * Class used to store geometry data (vertex buffers + index buffer)
  22128. */
  22129. export class Geometry implements IGetSetVerticesData {
  22130. /**
  22131. * Gets or sets the ID of the geometry
  22132. */
  22133. id: string;
  22134. /**
  22135. * Gets or sets the unique ID of the geometry
  22136. */
  22137. uniqueId: number;
  22138. /**
  22139. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22140. */
  22141. delayLoadState: number;
  22142. /**
  22143. * Gets the file containing the data to load when running in delay load state
  22144. */
  22145. delayLoadingFile: Nullable<string>;
  22146. /**
  22147. * Callback called when the geometry is updated
  22148. */
  22149. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22150. private _scene;
  22151. private _engine;
  22152. private _meshes;
  22153. private _totalVertices;
  22154. /** @hidden */
  22155. _indices: IndicesArray;
  22156. /** @hidden */
  22157. _vertexBuffers: {
  22158. [key: string]: VertexBuffer;
  22159. };
  22160. private _isDisposed;
  22161. private _extend;
  22162. private _boundingBias;
  22163. /** @hidden */
  22164. _delayInfo: Array<string>;
  22165. private _indexBuffer;
  22166. private _indexBufferIsUpdatable;
  22167. /** @hidden */
  22168. _boundingInfo: Nullable<BoundingInfo>;
  22169. /** @hidden */
  22170. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22171. /** @hidden */
  22172. _softwareSkinningFrameId: number;
  22173. private _vertexArrayObjects;
  22174. private _updatable;
  22175. /** @hidden */
  22176. _positions: Nullable<Vector3[]>;
  22177. /**
  22178. * 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
  22179. */
  22180. get boundingBias(): Vector2;
  22181. /**
  22182. * 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
  22183. */
  22184. set boundingBias(value: Vector2);
  22185. /**
  22186. * Static function used to attach a new empty geometry to a mesh
  22187. * @param mesh defines the mesh to attach the geometry to
  22188. * @returns the new Geometry
  22189. */
  22190. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22191. /**
  22192. * Creates a new geometry
  22193. * @param id defines the unique ID
  22194. * @param scene defines the hosting scene
  22195. * @param vertexData defines the VertexData used to get geometry data
  22196. * @param updatable defines if geometry must be updatable (false by default)
  22197. * @param mesh defines the mesh that will be associated with the geometry
  22198. */
  22199. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22200. /**
  22201. * Gets the current extend of the geometry
  22202. */
  22203. get extend(): {
  22204. minimum: Vector3;
  22205. maximum: Vector3;
  22206. };
  22207. /**
  22208. * Gets the hosting scene
  22209. * @returns the hosting Scene
  22210. */
  22211. getScene(): Scene;
  22212. /**
  22213. * Gets the hosting engine
  22214. * @returns the hosting Engine
  22215. */
  22216. getEngine(): Engine;
  22217. /**
  22218. * Defines if the geometry is ready to use
  22219. * @returns true if the geometry is ready to be used
  22220. */
  22221. isReady(): boolean;
  22222. /**
  22223. * Gets a value indicating that the geometry should not be serialized
  22224. */
  22225. get doNotSerialize(): boolean;
  22226. /** @hidden */
  22227. _rebuild(): void;
  22228. /**
  22229. * Affects all geometry data in one call
  22230. * @param vertexData defines the geometry data
  22231. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22232. */
  22233. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22234. /**
  22235. * Set specific vertex data
  22236. * @param kind defines the data kind (Position, normal, etc...)
  22237. * @param data defines the vertex data to use
  22238. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22239. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22240. */
  22241. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22242. /**
  22243. * Removes a specific vertex data
  22244. * @param kind defines the data kind (Position, normal, etc...)
  22245. */
  22246. removeVerticesData(kind: string): void;
  22247. /**
  22248. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22249. * @param buffer defines the vertex buffer to use
  22250. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22251. */
  22252. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22253. /**
  22254. * Update a specific vertex buffer
  22255. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22256. * It will do nothing if the buffer is not updatable
  22257. * @param kind defines the data kind (Position, normal, etc...)
  22258. * @param data defines the data to use
  22259. * @param offset defines the offset in the target buffer where to store the data
  22260. * @param useBytes set to true if the offset is in bytes
  22261. */
  22262. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22263. /**
  22264. * Update a specific vertex buffer
  22265. * This function will create a new buffer if the current one is not updatable
  22266. * @param kind defines the data kind (Position, normal, etc...)
  22267. * @param data defines the data to use
  22268. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22269. */
  22270. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22271. private _updateBoundingInfo;
  22272. /** @hidden */
  22273. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22274. /**
  22275. * Gets total number of vertices
  22276. * @returns the total number of vertices
  22277. */
  22278. getTotalVertices(): number;
  22279. /**
  22280. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22281. * @param kind defines the data kind (Position, normal, etc...)
  22282. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22283. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22284. * @returns a float array containing vertex data
  22285. */
  22286. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22287. /**
  22288. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22289. * @param kind defines the data kind (Position, normal, etc...)
  22290. * @returns true if the vertex buffer with the specified kind is updatable
  22291. */
  22292. isVertexBufferUpdatable(kind: string): boolean;
  22293. /**
  22294. * Gets a specific vertex buffer
  22295. * @param kind defines the data kind (Position, normal, etc...)
  22296. * @returns a VertexBuffer
  22297. */
  22298. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22299. /**
  22300. * Returns all vertex buffers
  22301. * @return an object holding all vertex buffers indexed by kind
  22302. */
  22303. getVertexBuffers(): Nullable<{
  22304. [key: string]: VertexBuffer;
  22305. }>;
  22306. /**
  22307. * Gets a boolean indicating if specific vertex buffer is present
  22308. * @param kind defines the data kind (Position, normal, etc...)
  22309. * @returns true if data is present
  22310. */
  22311. isVerticesDataPresent(kind: string): boolean;
  22312. /**
  22313. * Gets a list of all attached data kinds (Position, normal, etc...)
  22314. * @returns a list of string containing all kinds
  22315. */
  22316. getVerticesDataKinds(): string[];
  22317. /**
  22318. * Update index buffer
  22319. * @param indices defines the indices to store in the index buffer
  22320. * @param offset defines the offset in the target buffer where to store the data
  22321. * @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)
  22322. */
  22323. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22324. /**
  22325. * Creates a new index buffer
  22326. * @param indices defines the indices to store in the index buffer
  22327. * @param totalVertices defines the total number of vertices (could be null)
  22328. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22329. */
  22330. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22331. /**
  22332. * Return the total number of indices
  22333. * @returns the total number of indices
  22334. */
  22335. getTotalIndices(): number;
  22336. /**
  22337. * Gets the index buffer array
  22338. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22339. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22340. * @returns the index buffer array
  22341. */
  22342. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22343. /**
  22344. * Gets the index buffer
  22345. * @return the index buffer
  22346. */
  22347. getIndexBuffer(): Nullable<DataBuffer>;
  22348. /** @hidden */
  22349. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22350. /**
  22351. * Release the associated resources for a specific mesh
  22352. * @param mesh defines the source mesh
  22353. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22354. */
  22355. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22356. /**
  22357. * Apply current geometry to a given mesh
  22358. * @param mesh defines the mesh to apply geometry to
  22359. */
  22360. applyToMesh(mesh: Mesh): void;
  22361. private _updateExtend;
  22362. private _applyToMesh;
  22363. private notifyUpdate;
  22364. /**
  22365. * Load the geometry if it was flagged as delay loaded
  22366. * @param scene defines the hosting scene
  22367. * @param onLoaded defines a callback called when the geometry is loaded
  22368. */
  22369. load(scene: Scene, onLoaded?: () => void): void;
  22370. private _queueLoad;
  22371. /**
  22372. * Invert the geometry to move from a right handed system to a left handed one.
  22373. */
  22374. toLeftHanded(): void;
  22375. /** @hidden */
  22376. _resetPointsArrayCache(): void;
  22377. /** @hidden */
  22378. _generatePointsArray(): boolean;
  22379. /**
  22380. * Gets a value indicating if the geometry is disposed
  22381. * @returns true if the geometry was disposed
  22382. */
  22383. isDisposed(): boolean;
  22384. private _disposeVertexArrayObjects;
  22385. /**
  22386. * Free all associated resources
  22387. */
  22388. dispose(): void;
  22389. /**
  22390. * Clone the current geometry into a new geometry
  22391. * @param id defines the unique ID of the new geometry
  22392. * @returns a new geometry object
  22393. */
  22394. copy(id: string): Geometry;
  22395. /**
  22396. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22397. * @return a JSON representation of the current geometry data (without the vertices data)
  22398. */
  22399. serialize(): any;
  22400. private toNumberArray;
  22401. /**
  22402. * Serialize all vertices data into a JSON oject
  22403. * @returns a JSON representation of the current geometry data
  22404. */
  22405. serializeVerticeData(): any;
  22406. /**
  22407. * Extracts a clone of a mesh geometry
  22408. * @param mesh defines the source mesh
  22409. * @param id defines the unique ID of the new geometry object
  22410. * @returns the new geometry object
  22411. */
  22412. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22413. /**
  22414. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22415. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22416. * Be aware Math.random() could cause collisions, but:
  22417. * "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"
  22418. * @returns a string containing a new GUID
  22419. */
  22420. static RandomId(): string;
  22421. /** @hidden */
  22422. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22423. private static _CleanMatricesWeights;
  22424. /**
  22425. * Create a new geometry from persisted data (Using .babylon file format)
  22426. * @param parsedVertexData defines the persisted data
  22427. * @param scene defines the hosting scene
  22428. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22429. * @returns the new geometry object
  22430. */
  22431. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22432. }
  22433. }
  22434. declare module "babylonjs/Meshes/mesh.vertexData" {
  22435. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22436. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22437. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22438. import { Geometry } from "babylonjs/Meshes/geometry";
  22439. import { Mesh } from "babylonjs/Meshes/mesh";
  22440. /**
  22441. * Define an interface for all classes that will get and set the data on vertices
  22442. */
  22443. export interface IGetSetVerticesData {
  22444. /**
  22445. * Gets a boolean indicating if specific vertex data is present
  22446. * @param kind defines the vertex data kind to use
  22447. * @returns true is data kind is present
  22448. */
  22449. isVerticesDataPresent(kind: string): boolean;
  22450. /**
  22451. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22452. * @param kind defines the data kind (Position, normal, etc...)
  22453. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22454. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22455. * @returns a float array containing vertex data
  22456. */
  22457. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22458. /**
  22459. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22460. * @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.
  22461. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22462. * @returns the indices array or an empty array if the mesh has no geometry
  22463. */
  22464. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22465. /**
  22466. * Set specific vertex data
  22467. * @param kind defines the data kind (Position, normal, etc...)
  22468. * @param data defines the vertex data to use
  22469. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22470. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22471. */
  22472. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22473. /**
  22474. * Update a specific associated vertex buffer
  22475. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22476. * - VertexBuffer.PositionKind
  22477. * - VertexBuffer.UVKind
  22478. * - VertexBuffer.UV2Kind
  22479. * - VertexBuffer.UV3Kind
  22480. * - VertexBuffer.UV4Kind
  22481. * - VertexBuffer.UV5Kind
  22482. * - VertexBuffer.UV6Kind
  22483. * - VertexBuffer.ColorKind
  22484. * - VertexBuffer.MatricesIndicesKind
  22485. * - VertexBuffer.MatricesIndicesExtraKind
  22486. * - VertexBuffer.MatricesWeightsKind
  22487. * - VertexBuffer.MatricesWeightsExtraKind
  22488. * @param data defines the data source
  22489. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22490. * @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)
  22491. */
  22492. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22493. /**
  22494. * Creates a new index buffer
  22495. * @param indices defines the indices to store in the index buffer
  22496. * @param totalVertices defines the total number of vertices (could be null)
  22497. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22498. */
  22499. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22500. }
  22501. /**
  22502. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22503. */
  22504. export class VertexData {
  22505. /**
  22506. * Mesh side orientation : usually the external or front surface
  22507. */
  22508. static readonly FRONTSIDE: number;
  22509. /**
  22510. * Mesh side orientation : usually the internal or back surface
  22511. */
  22512. static readonly BACKSIDE: number;
  22513. /**
  22514. * Mesh side orientation : both internal and external or front and back surfaces
  22515. */
  22516. static readonly DOUBLESIDE: number;
  22517. /**
  22518. * Mesh side orientation : by default, `FRONTSIDE`
  22519. */
  22520. static readonly DEFAULTSIDE: number;
  22521. /**
  22522. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22523. */
  22524. positions: Nullable<FloatArray>;
  22525. /**
  22526. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22527. */
  22528. normals: Nullable<FloatArray>;
  22529. /**
  22530. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22531. */
  22532. tangents: Nullable<FloatArray>;
  22533. /**
  22534. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22535. */
  22536. uvs: Nullable<FloatArray>;
  22537. /**
  22538. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22539. */
  22540. uvs2: Nullable<FloatArray>;
  22541. /**
  22542. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22543. */
  22544. uvs3: Nullable<FloatArray>;
  22545. /**
  22546. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22547. */
  22548. uvs4: Nullable<FloatArray>;
  22549. /**
  22550. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22551. */
  22552. uvs5: Nullable<FloatArray>;
  22553. /**
  22554. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22555. */
  22556. uvs6: Nullable<FloatArray>;
  22557. /**
  22558. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22559. */
  22560. colors: Nullable<FloatArray>;
  22561. /**
  22562. * 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).
  22563. */
  22564. matricesIndices: Nullable<FloatArray>;
  22565. /**
  22566. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22567. */
  22568. matricesWeights: Nullable<FloatArray>;
  22569. /**
  22570. * An array extending the number of possible indices
  22571. */
  22572. matricesIndicesExtra: Nullable<FloatArray>;
  22573. /**
  22574. * An array extending the number of possible weights when the number of indices is extended
  22575. */
  22576. matricesWeightsExtra: Nullable<FloatArray>;
  22577. /**
  22578. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22579. */
  22580. indices: Nullable<IndicesArray>;
  22581. /**
  22582. * Uses the passed data array to set the set the values for the specified kind of data
  22583. * @param data a linear array of floating numbers
  22584. * @param kind the type of data that is being set, eg positions, colors etc
  22585. */
  22586. set(data: FloatArray, kind: string): void;
  22587. /**
  22588. * Associates the vertexData to the passed Mesh.
  22589. * Sets it as updatable or not (default `false`)
  22590. * @param mesh the mesh the vertexData is applied to
  22591. * @param updatable when used and having the value true allows new data to update the vertexData
  22592. * @returns the VertexData
  22593. */
  22594. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22595. /**
  22596. * Associates the vertexData to the passed Geometry.
  22597. * Sets it as updatable or not (default `false`)
  22598. * @param geometry the geometry the vertexData is applied to
  22599. * @param updatable when used and having the value true allows new data to update the vertexData
  22600. * @returns VertexData
  22601. */
  22602. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22603. /**
  22604. * Updates the associated mesh
  22605. * @param mesh the mesh to be updated
  22606. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22607. * @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
  22608. * @returns VertexData
  22609. */
  22610. updateMesh(mesh: Mesh): VertexData;
  22611. /**
  22612. * Updates the associated geometry
  22613. * @param geometry the geometry to be updated
  22614. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22615. * @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
  22616. * @returns VertexData.
  22617. */
  22618. updateGeometry(geometry: Geometry): VertexData;
  22619. private _applyTo;
  22620. private _update;
  22621. /**
  22622. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22623. * @param matrix the transforming matrix
  22624. * @returns the VertexData
  22625. */
  22626. transform(matrix: Matrix): VertexData;
  22627. /**
  22628. * Merges the passed VertexData into the current one
  22629. * @param other the VertexData to be merged into the current one
  22630. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22631. * @returns the modified VertexData
  22632. */
  22633. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22634. private _mergeElement;
  22635. private _validate;
  22636. /**
  22637. * Serializes the VertexData
  22638. * @returns a serialized object
  22639. */
  22640. serialize(): any;
  22641. /**
  22642. * Extracts the vertexData from a mesh
  22643. * @param mesh the mesh from which to extract the VertexData
  22644. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22645. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22646. * @returns the object VertexData associated to the passed mesh
  22647. */
  22648. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22649. /**
  22650. * Extracts the vertexData from the geometry
  22651. * @param geometry the geometry from which to extract the VertexData
  22652. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22653. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22654. * @returns the object VertexData associated to the passed mesh
  22655. */
  22656. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22657. private static _ExtractFrom;
  22658. /**
  22659. * Creates the VertexData for a Ribbon
  22660. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22661. * * pathArray array of paths, each of which an array of successive Vector3
  22662. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22663. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22664. * * 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
  22665. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22666. * * 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)
  22667. * * 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)
  22668. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22669. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22670. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22671. * @returns the VertexData of the ribbon
  22672. */
  22673. static CreateRibbon(options: {
  22674. pathArray: Vector3[][];
  22675. closeArray?: boolean;
  22676. closePath?: boolean;
  22677. offset?: number;
  22678. sideOrientation?: number;
  22679. frontUVs?: Vector4;
  22680. backUVs?: Vector4;
  22681. invertUV?: boolean;
  22682. uvs?: Vector2[];
  22683. colors?: Color4[];
  22684. }): VertexData;
  22685. /**
  22686. * Creates the VertexData for a box
  22687. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22688. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22689. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22690. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22691. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22692. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22693. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22694. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22695. * * 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)
  22696. * * 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)
  22697. * @returns the VertexData of the box
  22698. */
  22699. static CreateBox(options: {
  22700. size?: number;
  22701. width?: number;
  22702. height?: number;
  22703. depth?: number;
  22704. faceUV?: Vector4[];
  22705. faceColors?: Color4[];
  22706. sideOrientation?: number;
  22707. frontUVs?: Vector4;
  22708. backUVs?: Vector4;
  22709. }): VertexData;
  22710. /**
  22711. * Creates the VertexData for a tiled box
  22712. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22713. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22714. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22715. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22716. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22717. * @returns the VertexData of the box
  22718. */
  22719. static CreateTiledBox(options: {
  22720. pattern?: number;
  22721. width?: number;
  22722. height?: number;
  22723. depth?: number;
  22724. tileSize?: number;
  22725. tileWidth?: number;
  22726. tileHeight?: number;
  22727. alignHorizontal?: number;
  22728. alignVertical?: number;
  22729. faceUV?: Vector4[];
  22730. faceColors?: Color4[];
  22731. sideOrientation?: number;
  22732. }): VertexData;
  22733. /**
  22734. * Creates the VertexData for a tiled plane
  22735. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22736. * * pattern a limited pattern arrangement depending on the number
  22737. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22738. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22739. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22741. * * 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)
  22742. * * 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)
  22743. * @returns the VertexData of the tiled plane
  22744. */
  22745. static CreateTiledPlane(options: {
  22746. pattern?: number;
  22747. tileSize?: number;
  22748. tileWidth?: number;
  22749. tileHeight?: number;
  22750. size?: number;
  22751. width?: number;
  22752. height?: number;
  22753. alignHorizontal?: number;
  22754. alignVertical?: number;
  22755. sideOrientation?: number;
  22756. frontUVs?: Vector4;
  22757. backUVs?: Vector4;
  22758. }): VertexData;
  22759. /**
  22760. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22761. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22762. * * segments sets the number of horizontal strips optional, default 32
  22763. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22764. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22765. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22766. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22767. * * 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
  22768. * * 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
  22769. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22770. * * 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)
  22771. * * 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)
  22772. * @returns the VertexData of the ellipsoid
  22773. */
  22774. static CreateSphere(options: {
  22775. segments?: number;
  22776. diameter?: number;
  22777. diameterX?: number;
  22778. diameterY?: number;
  22779. diameterZ?: number;
  22780. arc?: number;
  22781. slice?: number;
  22782. sideOrientation?: number;
  22783. frontUVs?: Vector4;
  22784. backUVs?: Vector4;
  22785. }): VertexData;
  22786. /**
  22787. * Creates the VertexData for a cylinder, cone or prism
  22788. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22789. * * height sets the height (y direction) of the cylinder, optional, default 2
  22790. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22791. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22792. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22793. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22794. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22795. * * 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
  22796. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22797. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22798. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22799. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22800. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22801. * * 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)
  22802. * * 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)
  22803. * @returns the VertexData of the cylinder, cone or prism
  22804. */
  22805. static CreateCylinder(options: {
  22806. height?: number;
  22807. diameterTop?: number;
  22808. diameterBottom?: number;
  22809. diameter?: number;
  22810. tessellation?: number;
  22811. subdivisions?: number;
  22812. arc?: number;
  22813. faceColors?: Color4[];
  22814. faceUV?: Vector4[];
  22815. hasRings?: boolean;
  22816. enclose?: boolean;
  22817. sideOrientation?: number;
  22818. frontUVs?: Vector4;
  22819. backUVs?: Vector4;
  22820. }): VertexData;
  22821. /**
  22822. * Creates the VertexData for a torus
  22823. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22824. * * diameter the diameter of the torus, optional default 1
  22825. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22826. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22827. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22828. * * 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)
  22829. * * 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)
  22830. * @returns the VertexData of the torus
  22831. */
  22832. static CreateTorus(options: {
  22833. diameter?: number;
  22834. thickness?: number;
  22835. tessellation?: number;
  22836. sideOrientation?: number;
  22837. frontUVs?: Vector4;
  22838. backUVs?: Vector4;
  22839. }): VertexData;
  22840. /**
  22841. * Creates the VertexData of the LineSystem
  22842. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22843. * - lines an array of lines, each line being an array of successive Vector3
  22844. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22845. * @returns the VertexData of the LineSystem
  22846. */
  22847. static CreateLineSystem(options: {
  22848. lines: Vector3[][];
  22849. colors?: Nullable<Color4[][]>;
  22850. }): VertexData;
  22851. /**
  22852. * Create the VertexData for a DashedLines
  22853. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22854. * - points an array successive Vector3
  22855. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22856. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22857. * - dashNb the intended total number of dashes, optional, default 200
  22858. * @returns the VertexData for the DashedLines
  22859. */
  22860. static CreateDashedLines(options: {
  22861. points: Vector3[];
  22862. dashSize?: number;
  22863. gapSize?: number;
  22864. dashNb?: number;
  22865. }): VertexData;
  22866. /**
  22867. * Creates the VertexData for a Ground
  22868. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22869. * - width the width (x direction) of the ground, optional, default 1
  22870. * - height the height (z direction) of the ground, optional, default 1
  22871. * - subdivisions the number of subdivisions per side, optional, default 1
  22872. * @returns the VertexData of the Ground
  22873. */
  22874. static CreateGround(options: {
  22875. width?: number;
  22876. height?: number;
  22877. subdivisions?: number;
  22878. subdivisionsX?: number;
  22879. subdivisionsY?: number;
  22880. }): VertexData;
  22881. /**
  22882. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22883. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22884. * * xmin the ground minimum X coordinate, optional, default -1
  22885. * * zmin the ground minimum Z coordinate, optional, default -1
  22886. * * xmax the ground maximum X coordinate, optional, default 1
  22887. * * zmax the ground maximum Z coordinate, optional, default 1
  22888. * * 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}
  22889. * * 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}
  22890. * @returns the VertexData of the TiledGround
  22891. */
  22892. static CreateTiledGround(options: {
  22893. xmin: number;
  22894. zmin: number;
  22895. xmax: number;
  22896. zmax: number;
  22897. subdivisions?: {
  22898. w: number;
  22899. h: number;
  22900. };
  22901. precision?: {
  22902. w: number;
  22903. h: number;
  22904. };
  22905. }): VertexData;
  22906. /**
  22907. * Creates the VertexData of the Ground designed from a heightmap
  22908. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22909. * * width the width (x direction) of the ground
  22910. * * height the height (z direction) of the ground
  22911. * * subdivisions the number of subdivisions per side
  22912. * * minHeight the minimum altitude on the ground, optional, default 0
  22913. * * maxHeight the maximum altitude on the ground, optional default 1
  22914. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22915. * * buffer the array holding the image color data
  22916. * * bufferWidth the width of image
  22917. * * bufferHeight the height of image
  22918. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22919. * @returns the VertexData of the Ground designed from a heightmap
  22920. */
  22921. static CreateGroundFromHeightMap(options: {
  22922. width: number;
  22923. height: number;
  22924. subdivisions: number;
  22925. minHeight: number;
  22926. maxHeight: number;
  22927. colorFilter: Color3;
  22928. buffer: Uint8Array;
  22929. bufferWidth: number;
  22930. bufferHeight: number;
  22931. alphaFilter: number;
  22932. }): VertexData;
  22933. /**
  22934. * Creates the VertexData for a Plane
  22935. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22936. * * size sets the width and height of the plane to the value of size, optional default 1
  22937. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22938. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22939. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22940. * * 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)
  22941. * * 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)
  22942. * @returns the VertexData of the box
  22943. */
  22944. static CreatePlane(options: {
  22945. size?: number;
  22946. width?: number;
  22947. height?: number;
  22948. sideOrientation?: number;
  22949. frontUVs?: Vector4;
  22950. backUVs?: Vector4;
  22951. }): VertexData;
  22952. /**
  22953. * Creates the VertexData of the Disc or regular Polygon
  22954. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22955. * * radius the radius of the disc, optional default 0.5
  22956. * * tessellation the number of polygon sides, optional, default 64
  22957. * * 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
  22958. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22959. * * 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)
  22960. * * 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)
  22961. * @returns the VertexData of the box
  22962. */
  22963. static CreateDisc(options: {
  22964. radius?: number;
  22965. tessellation?: number;
  22966. arc?: number;
  22967. sideOrientation?: number;
  22968. frontUVs?: Vector4;
  22969. backUVs?: Vector4;
  22970. }): VertexData;
  22971. /**
  22972. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22973. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22974. * @param polygon a mesh built from polygonTriangulation.build()
  22975. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22976. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22977. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22978. * @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)
  22979. * @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)
  22980. * @returns the VertexData of the Polygon
  22981. */
  22982. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22983. /**
  22984. * Creates the VertexData of the IcoSphere
  22985. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22986. * * radius the radius of the IcoSphere, optional default 1
  22987. * * radiusX allows stretching in the x direction, optional, default radius
  22988. * * radiusY allows stretching in the y direction, optional, default radius
  22989. * * radiusZ allows stretching in the z direction, optional, default radius
  22990. * * flat when true creates a flat shaded mesh, optional, default true
  22991. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22993. * * 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)
  22994. * * 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)
  22995. * @returns the VertexData of the IcoSphere
  22996. */
  22997. static CreateIcoSphere(options: {
  22998. radius?: number;
  22999. radiusX?: number;
  23000. radiusY?: number;
  23001. radiusZ?: number;
  23002. flat?: boolean;
  23003. subdivisions?: number;
  23004. sideOrientation?: number;
  23005. frontUVs?: Vector4;
  23006. backUVs?: Vector4;
  23007. }): VertexData;
  23008. /**
  23009. * Creates the VertexData for a Polyhedron
  23010. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23011. * * type provided types are:
  23012. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23013. * * 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)
  23014. * * size the size of the IcoSphere, optional default 1
  23015. * * sizeX allows stretching in the x direction, optional, default size
  23016. * * sizeY allows stretching in the y direction, optional, default size
  23017. * * sizeZ allows stretching in the z direction, optional, default size
  23018. * * 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
  23019. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23020. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23021. * * flat when true creates a flat shaded mesh, optional, default true
  23022. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23023. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23024. * * 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)
  23025. * * 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)
  23026. * @returns the VertexData of the Polyhedron
  23027. */
  23028. static CreatePolyhedron(options: {
  23029. type?: number;
  23030. size?: number;
  23031. sizeX?: number;
  23032. sizeY?: number;
  23033. sizeZ?: number;
  23034. custom?: any;
  23035. faceUV?: Vector4[];
  23036. faceColors?: Color4[];
  23037. flat?: boolean;
  23038. sideOrientation?: number;
  23039. frontUVs?: Vector4;
  23040. backUVs?: Vector4;
  23041. }): VertexData;
  23042. /**
  23043. * Creates the VertexData for a TorusKnot
  23044. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23045. * * radius the radius of the torus knot, optional, default 2
  23046. * * tube the thickness of the tube, optional, default 0.5
  23047. * * radialSegments the number of sides on each tube segments, optional, default 32
  23048. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23049. * * p the number of windings around the z axis, optional, default 2
  23050. * * q the number of windings around the x axis, optional, default 3
  23051. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23052. * * 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)
  23053. * * 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)
  23054. * @returns the VertexData of the Torus Knot
  23055. */
  23056. static CreateTorusKnot(options: {
  23057. radius?: number;
  23058. tube?: number;
  23059. radialSegments?: number;
  23060. tubularSegments?: number;
  23061. p?: number;
  23062. q?: number;
  23063. sideOrientation?: number;
  23064. frontUVs?: Vector4;
  23065. backUVs?: Vector4;
  23066. }): VertexData;
  23067. /**
  23068. * Compute normals for given positions and indices
  23069. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23070. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23071. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23072. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23073. * * facetNormals : optional array of facet normals (vector3)
  23074. * * facetPositions : optional array of facet positions (vector3)
  23075. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23076. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23077. * * bInfo : optional bounding info, required for facetPartitioning computation
  23078. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23079. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23080. * * useRightHandedSystem: optional boolean to for right handed system computation
  23081. * * depthSort : optional boolean to enable the facet depth sort computation
  23082. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23083. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23084. */
  23085. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23086. facetNormals?: any;
  23087. facetPositions?: any;
  23088. facetPartitioning?: any;
  23089. ratio?: number;
  23090. bInfo?: any;
  23091. bbSize?: Vector3;
  23092. subDiv?: any;
  23093. useRightHandedSystem?: boolean;
  23094. depthSort?: boolean;
  23095. distanceTo?: Vector3;
  23096. depthSortedFacets?: any;
  23097. }): void;
  23098. /** @hidden */
  23099. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23100. /**
  23101. * Applies VertexData created from the imported parameters to the geometry
  23102. * @param parsedVertexData the parsed data from an imported file
  23103. * @param geometry the geometry to apply the VertexData to
  23104. */
  23105. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23106. }
  23107. }
  23108. declare module "babylonjs/Morph/morphTarget" {
  23109. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23110. import { Observable } from "babylonjs/Misc/observable";
  23111. import { Nullable, FloatArray } from "babylonjs/types";
  23112. import { Scene } from "babylonjs/scene";
  23113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23114. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23115. /**
  23116. * Defines a target to use with MorphTargetManager
  23117. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23118. */
  23119. export class MorphTarget implements IAnimatable {
  23120. /** defines the name of the target */
  23121. name: string;
  23122. /**
  23123. * Gets or sets the list of animations
  23124. */
  23125. animations: import("babylonjs/Animations/animation").Animation[];
  23126. private _scene;
  23127. private _positions;
  23128. private _normals;
  23129. private _tangents;
  23130. private _uvs;
  23131. private _influence;
  23132. private _uniqueId;
  23133. /**
  23134. * Observable raised when the influence changes
  23135. */
  23136. onInfluenceChanged: Observable<boolean>;
  23137. /** @hidden */
  23138. _onDataLayoutChanged: Observable<void>;
  23139. /**
  23140. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23141. */
  23142. get influence(): number;
  23143. set influence(influence: number);
  23144. /**
  23145. * Gets or sets the id of the morph Target
  23146. */
  23147. id: string;
  23148. private _animationPropertiesOverride;
  23149. /**
  23150. * Gets or sets the animation properties override
  23151. */
  23152. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23153. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23154. /**
  23155. * Creates a new MorphTarget
  23156. * @param name defines the name of the target
  23157. * @param influence defines the influence to use
  23158. * @param scene defines the scene the morphtarget belongs to
  23159. */
  23160. constructor(
  23161. /** defines the name of the target */
  23162. name: string, influence?: number, scene?: Nullable<Scene>);
  23163. /**
  23164. * Gets the unique ID of this manager
  23165. */
  23166. get uniqueId(): number;
  23167. /**
  23168. * Gets a boolean defining if the target contains position data
  23169. */
  23170. get hasPositions(): boolean;
  23171. /**
  23172. * Gets a boolean defining if the target contains normal data
  23173. */
  23174. get hasNormals(): boolean;
  23175. /**
  23176. * Gets a boolean defining if the target contains tangent data
  23177. */
  23178. get hasTangents(): boolean;
  23179. /**
  23180. * Gets a boolean defining if the target contains texture coordinates data
  23181. */
  23182. get hasUVs(): boolean;
  23183. /**
  23184. * Affects position data to this target
  23185. * @param data defines the position data to use
  23186. */
  23187. setPositions(data: Nullable<FloatArray>): void;
  23188. /**
  23189. * Gets the position data stored in this target
  23190. * @returns a FloatArray containing the position data (or null if not present)
  23191. */
  23192. getPositions(): Nullable<FloatArray>;
  23193. /**
  23194. * Affects normal data to this target
  23195. * @param data defines the normal data to use
  23196. */
  23197. setNormals(data: Nullable<FloatArray>): void;
  23198. /**
  23199. * Gets the normal data stored in this target
  23200. * @returns a FloatArray containing the normal data (or null if not present)
  23201. */
  23202. getNormals(): Nullable<FloatArray>;
  23203. /**
  23204. * Affects tangent data to this target
  23205. * @param data defines the tangent data to use
  23206. */
  23207. setTangents(data: Nullable<FloatArray>): void;
  23208. /**
  23209. * Gets the tangent data stored in this target
  23210. * @returns a FloatArray containing the tangent data (or null if not present)
  23211. */
  23212. getTangents(): Nullable<FloatArray>;
  23213. /**
  23214. * Affects texture coordinates data to this target
  23215. * @param data defines the texture coordinates data to use
  23216. */
  23217. setUVs(data: Nullable<FloatArray>): void;
  23218. /**
  23219. * Gets the texture coordinates data stored in this target
  23220. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23221. */
  23222. getUVs(): Nullable<FloatArray>;
  23223. /**
  23224. * Clone the current target
  23225. * @returns a new MorphTarget
  23226. */
  23227. clone(): MorphTarget;
  23228. /**
  23229. * Serializes the current target into a Serialization object
  23230. * @returns the serialized object
  23231. */
  23232. serialize(): any;
  23233. /**
  23234. * Returns the string "MorphTarget"
  23235. * @returns "MorphTarget"
  23236. */
  23237. getClassName(): string;
  23238. /**
  23239. * Creates a new target from serialized data
  23240. * @param serializationObject defines the serialized data to use
  23241. * @returns a new MorphTarget
  23242. */
  23243. static Parse(serializationObject: any): MorphTarget;
  23244. /**
  23245. * Creates a MorphTarget from mesh data
  23246. * @param mesh defines the source mesh
  23247. * @param name defines the name to use for the new target
  23248. * @param influence defines the influence to attach to the target
  23249. * @returns a new MorphTarget
  23250. */
  23251. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23252. }
  23253. }
  23254. declare module "babylonjs/Morph/morphTargetManager" {
  23255. import { Nullable } from "babylonjs/types";
  23256. import { Scene } from "babylonjs/scene";
  23257. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23258. /**
  23259. * This class is used to deform meshes using morphing between different targets
  23260. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23261. */
  23262. export class MorphTargetManager {
  23263. private _targets;
  23264. private _targetInfluenceChangedObservers;
  23265. private _targetDataLayoutChangedObservers;
  23266. private _activeTargets;
  23267. private _scene;
  23268. private _influences;
  23269. private _supportsNormals;
  23270. private _supportsTangents;
  23271. private _supportsUVs;
  23272. private _vertexCount;
  23273. private _uniqueId;
  23274. private _tempInfluences;
  23275. /**
  23276. * Gets or sets a boolean indicating if normals must be morphed
  23277. */
  23278. enableNormalMorphing: boolean;
  23279. /**
  23280. * Gets or sets a boolean indicating if tangents must be morphed
  23281. */
  23282. enableTangentMorphing: boolean;
  23283. /**
  23284. * Gets or sets a boolean indicating if UV must be morphed
  23285. */
  23286. enableUVMorphing: boolean;
  23287. /**
  23288. * Creates a new MorphTargetManager
  23289. * @param scene defines the current scene
  23290. */
  23291. constructor(scene?: Nullable<Scene>);
  23292. /**
  23293. * Gets the unique ID of this manager
  23294. */
  23295. get uniqueId(): number;
  23296. /**
  23297. * Gets the number of vertices handled by this manager
  23298. */
  23299. get vertexCount(): number;
  23300. /**
  23301. * Gets a boolean indicating if this manager supports morphing of normals
  23302. */
  23303. get supportsNormals(): boolean;
  23304. /**
  23305. * Gets a boolean indicating if this manager supports morphing of tangents
  23306. */
  23307. get supportsTangents(): boolean;
  23308. /**
  23309. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23310. */
  23311. get supportsUVs(): boolean;
  23312. /**
  23313. * Gets the number of targets stored in this manager
  23314. */
  23315. get numTargets(): number;
  23316. /**
  23317. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23318. */
  23319. get numInfluencers(): number;
  23320. /**
  23321. * Gets the list of influences (one per target)
  23322. */
  23323. get influences(): Float32Array;
  23324. /**
  23325. * Gets the active target at specified index. An active target is a target with an influence > 0
  23326. * @param index defines the index to check
  23327. * @returns the requested target
  23328. */
  23329. getActiveTarget(index: number): MorphTarget;
  23330. /**
  23331. * Gets the target at specified index
  23332. * @param index defines the index to check
  23333. * @returns the requested target
  23334. */
  23335. getTarget(index: number): MorphTarget;
  23336. /**
  23337. * Add a new target to this manager
  23338. * @param target defines the target to add
  23339. */
  23340. addTarget(target: MorphTarget): void;
  23341. /**
  23342. * Removes a target from the manager
  23343. * @param target defines the target to remove
  23344. */
  23345. removeTarget(target: MorphTarget): void;
  23346. /**
  23347. * Clone the current manager
  23348. * @returns a new MorphTargetManager
  23349. */
  23350. clone(): MorphTargetManager;
  23351. /**
  23352. * Serializes the current manager into a Serialization object
  23353. * @returns the serialized object
  23354. */
  23355. serialize(): any;
  23356. private _syncActiveTargets;
  23357. /**
  23358. * Syncrhonize the targets with all the meshes using this morph target manager
  23359. */
  23360. synchronize(): void;
  23361. /**
  23362. * Creates a new MorphTargetManager from serialized data
  23363. * @param serializationObject defines the serialized data
  23364. * @param scene defines the hosting scene
  23365. * @returns the new MorphTargetManager
  23366. */
  23367. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23368. }
  23369. }
  23370. declare module "babylonjs/Meshes/meshLODLevel" {
  23371. import { Mesh } from "babylonjs/Meshes/mesh";
  23372. import { Nullable } from "babylonjs/types";
  23373. /**
  23374. * Class used to represent a specific level of detail of a mesh
  23375. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23376. */
  23377. export class MeshLODLevel {
  23378. /** Defines the distance where this level should start being displayed */
  23379. distance: number;
  23380. /** Defines the mesh to use to render this level */
  23381. mesh: Nullable<Mesh>;
  23382. /**
  23383. * Creates a new LOD level
  23384. * @param distance defines the distance where this level should star being displayed
  23385. * @param mesh defines the mesh to use to render this level
  23386. */
  23387. constructor(
  23388. /** Defines the distance where this level should start being displayed */
  23389. distance: number,
  23390. /** Defines the mesh to use to render this level */
  23391. mesh: Nullable<Mesh>);
  23392. }
  23393. }
  23394. declare module "babylonjs/Meshes/groundMesh" {
  23395. import { Scene } from "babylonjs/scene";
  23396. import { Vector3 } from "babylonjs/Maths/math.vector";
  23397. import { Mesh } from "babylonjs/Meshes/mesh";
  23398. /**
  23399. * Mesh representing the gorund
  23400. */
  23401. export class GroundMesh extends Mesh {
  23402. /** If octree should be generated */
  23403. generateOctree: boolean;
  23404. private _heightQuads;
  23405. /** @hidden */
  23406. _subdivisionsX: number;
  23407. /** @hidden */
  23408. _subdivisionsY: number;
  23409. /** @hidden */
  23410. _width: number;
  23411. /** @hidden */
  23412. _height: number;
  23413. /** @hidden */
  23414. _minX: number;
  23415. /** @hidden */
  23416. _maxX: number;
  23417. /** @hidden */
  23418. _minZ: number;
  23419. /** @hidden */
  23420. _maxZ: number;
  23421. constructor(name: string, scene: Scene);
  23422. /**
  23423. * "GroundMesh"
  23424. * @returns "GroundMesh"
  23425. */
  23426. getClassName(): string;
  23427. /**
  23428. * The minimum of x and y subdivisions
  23429. */
  23430. get subdivisions(): number;
  23431. /**
  23432. * X subdivisions
  23433. */
  23434. get subdivisionsX(): number;
  23435. /**
  23436. * Y subdivisions
  23437. */
  23438. get subdivisionsY(): number;
  23439. /**
  23440. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23441. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23442. * @param chunksCount the number of subdivisions for x and y
  23443. * @param octreeBlocksSize (Default: 32)
  23444. */
  23445. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23446. /**
  23447. * Returns a height (y) value in the Worl system :
  23448. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23449. * @param x x coordinate
  23450. * @param z z coordinate
  23451. * @returns the ground y position if (x, z) are outside the ground surface.
  23452. */
  23453. getHeightAtCoordinates(x: number, z: number): number;
  23454. /**
  23455. * Returns a normalized vector (Vector3) orthogonal to the ground
  23456. * at the ground coordinates (x, z) expressed in the World system.
  23457. * @param x x coordinate
  23458. * @param z z coordinate
  23459. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23460. */
  23461. getNormalAtCoordinates(x: number, z: number): Vector3;
  23462. /**
  23463. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23464. * at the ground coordinates (x, z) expressed in the World system.
  23465. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23466. * @param x x coordinate
  23467. * @param z z coordinate
  23468. * @param ref vector to store the result
  23469. * @returns the GroundMesh.
  23470. */
  23471. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23472. /**
  23473. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23474. * if the ground has been updated.
  23475. * This can be used in the render loop.
  23476. * @returns the GroundMesh.
  23477. */
  23478. updateCoordinateHeights(): GroundMesh;
  23479. private _getFacetAt;
  23480. private _initHeightQuads;
  23481. private _computeHeightQuads;
  23482. /**
  23483. * Serializes this ground mesh
  23484. * @param serializationObject object to write serialization to
  23485. */
  23486. serialize(serializationObject: any): void;
  23487. /**
  23488. * Parses a serialized ground mesh
  23489. * @param parsedMesh the serialized mesh
  23490. * @param scene the scene to create the ground mesh in
  23491. * @returns the created ground mesh
  23492. */
  23493. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23494. }
  23495. }
  23496. declare module "babylonjs/Physics/physicsJoint" {
  23497. import { Vector3 } from "babylonjs/Maths/math.vector";
  23498. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23499. /**
  23500. * Interface for Physics-Joint data
  23501. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23502. */
  23503. export interface PhysicsJointData {
  23504. /**
  23505. * The main pivot of the joint
  23506. */
  23507. mainPivot?: Vector3;
  23508. /**
  23509. * The connected pivot of the joint
  23510. */
  23511. connectedPivot?: Vector3;
  23512. /**
  23513. * The main axis of the joint
  23514. */
  23515. mainAxis?: Vector3;
  23516. /**
  23517. * The connected axis of the joint
  23518. */
  23519. connectedAxis?: Vector3;
  23520. /**
  23521. * The collision of the joint
  23522. */
  23523. collision?: boolean;
  23524. /**
  23525. * Native Oimo/Cannon/Energy data
  23526. */
  23527. nativeParams?: any;
  23528. }
  23529. /**
  23530. * This is a holder class for the physics joint created by the physics plugin
  23531. * It holds a set of functions to control the underlying joint
  23532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23533. */
  23534. export class PhysicsJoint {
  23535. /**
  23536. * The type of the physics joint
  23537. */
  23538. type: number;
  23539. /**
  23540. * The data for the physics joint
  23541. */
  23542. jointData: PhysicsJointData;
  23543. private _physicsJoint;
  23544. protected _physicsPlugin: IPhysicsEnginePlugin;
  23545. /**
  23546. * Initializes the physics joint
  23547. * @param type The type of the physics joint
  23548. * @param jointData The data for the physics joint
  23549. */
  23550. constructor(
  23551. /**
  23552. * The type of the physics joint
  23553. */
  23554. type: number,
  23555. /**
  23556. * The data for the physics joint
  23557. */
  23558. jointData: PhysicsJointData);
  23559. /**
  23560. * Gets the physics joint
  23561. */
  23562. get physicsJoint(): any;
  23563. /**
  23564. * Sets the physics joint
  23565. */
  23566. set physicsJoint(newJoint: any);
  23567. /**
  23568. * Sets the physics plugin
  23569. */
  23570. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23571. /**
  23572. * Execute a function that is physics-plugin specific.
  23573. * @param {Function} func the function that will be executed.
  23574. * It accepts two parameters: the physics world and the physics joint
  23575. */
  23576. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23577. /**
  23578. * Distance-Joint type
  23579. */
  23580. static DistanceJoint: number;
  23581. /**
  23582. * Hinge-Joint type
  23583. */
  23584. static HingeJoint: number;
  23585. /**
  23586. * Ball-and-Socket joint type
  23587. */
  23588. static BallAndSocketJoint: number;
  23589. /**
  23590. * Wheel-Joint type
  23591. */
  23592. static WheelJoint: number;
  23593. /**
  23594. * Slider-Joint type
  23595. */
  23596. static SliderJoint: number;
  23597. /**
  23598. * Prismatic-Joint type
  23599. */
  23600. static PrismaticJoint: number;
  23601. /**
  23602. * Universal-Joint type
  23603. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23604. */
  23605. static UniversalJoint: number;
  23606. /**
  23607. * Hinge-Joint 2 type
  23608. */
  23609. static Hinge2Joint: number;
  23610. /**
  23611. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23612. */
  23613. static PointToPointJoint: number;
  23614. /**
  23615. * Spring-Joint type
  23616. */
  23617. static SpringJoint: number;
  23618. /**
  23619. * Lock-Joint type
  23620. */
  23621. static LockJoint: number;
  23622. }
  23623. /**
  23624. * A class representing a physics distance joint
  23625. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23626. */
  23627. export class DistanceJoint extends PhysicsJoint {
  23628. /**
  23629. *
  23630. * @param jointData The data for the Distance-Joint
  23631. */
  23632. constructor(jointData: DistanceJointData);
  23633. /**
  23634. * Update the predefined distance.
  23635. * @param maxDistance The maximum preferred distance
  23636. * @param minDistance The minimum preferred distance
  23637. */
  23638. updateDistance(maxDistance: number, minDistance?: number): void;
  23639. }
  23640. /**
  23641. * Represents a Motor-Enabled Joint
  23642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23643. */
  23644. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23645. /**
  23646. * Initializes the Motor-Enabled Joint
  23647. * @param type The type of the joint
  23648. * @param jointData The physica joint data for the joint
  23649. */
  23650. constructor(type: number, jointData: PhysicsJointData);
  23651. /**
  23652. * Set the motor values.
  23653. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23654. * @param force the force to apply
  23655. * @param maxForce max force for this motor.
  23656. */
  23657. setMotor(force?: number, maxForce?: number): void;
  23658. /**
  23659. * Set the motor's limits.
  23660. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23661. * @param upperLimit The upper limit of the motor
  23662. * @param lowerLimit The lower limit of the motor
  23663. */
  23664. setLimit(upperLimit: number, lowerLimit?: number): void;
  23665. }
  23666. /**
  23667. * This class represents a single physics Hinge-Joint
  23668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23669. */
  23670. export class HingeJoint extends MotorEnabledJoint {
  23671. /**
  23672. * Initializes the Hinge-Joint
  23673. * @param jointData The joint data for the Hinge-Joint
  23674. */
  23675. constructor(jointData: PhysicsJointData);
  23676. /**
  23677. * Set the motor values.
  23678. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23679. * @param {number} force the force to apply
  23680. * @param {number} maxForce max force for this motor.
  23681. */
  23682. setMotor(force?: number, maxForce?: number): void;
  23683. /**
  23684. * Set the motor's limits.
  23685. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23686. * @param upperLimit The upper limit of the motor
  23687. * @param lowerLimit The lower limit of the motor
  23688. */
  23689. setLimit(upperLimit: number, lowerLimit?: number): void;
  23690. }
  23691. /**
  23692. * This class represents a dual hinge physics joint (same as wheel joint)
  23693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23694. */
  23695. export class Hinge2Joint extends MotorEnabledJoint {
  23696. /**
  23697. * Initializes the Hinge2-Joint
  23698. * @param jointData The joint data for the Hinge2-Joint
  23699. */
  23700. constructor(jointData: PhysicsJointData);
  23701. /**
  23702. * Set the motor values.
  23703. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23704. * @param {number} targetSpeed the speed the motor is to reach
  23705. * @param {number} maxForce max force for this motor.
  23706. * @param {motorIndex} the motor's index, 0 or 1.
  23707. */
  23708. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23709. /**
  23710. * Set the motor limits.
  23711. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23712. * @param {number} upperLimit the upper limit
  23713. * @param {number} lowerLimit lower limit
  23714. * @param {motorIndex} the motor's index, 0 or 1.
  23715. */
  23716. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23717. }
  23718. /**
  23719. * Interface for a motor enabled joint
  23720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23721. */
  23722. export interface IMotorEnabledJoint {
  23723. /**
  23724. * Physics joint
  23725. */
  23726. physicsJoint: any;
  23727. /**
  23728. * Sets the motor of the motor-enabled joint
  23729. * @param force The force of the motor
  23730. * @param maxForce The maximum force of the motor
  23731. * @param motorIndex The index of the motor
  23732. */
  23733. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23734. /**
  23735. * Sets the limit of the motor
  23736. * @param upperLimit The upper limit of the motor
  23737. * @param lowerLimit The lower limit of the motor
  23738. * @param motorIndex The index of the motor
  23739. */
  23740. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23741. }
  23742. /**
  23743. * Joint data for a Distance-Joint
  23744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23745. */
  23746. export interface DistanceJointData extends PhysicsJointData {
  23747. /**
  23748. * Max distance the 2 joint objects can be apart
  23749. */
  23750. maxDistance: number;
  23751. }
  23752. /**
  23753. * Joint data from a spring joint
  23754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23755. */
  23756. export interface SpringJointData extends PhysicsJointData {
  23757. /**
  23758. * Length of the spring
  23759. */
  23760. length: number;
  23761. /**
  23762. * Stiffness of the spring
  23763. */
  23764. stiffness: number;
  23765. /**
  23766. * Damping of the spring
  23767. */
  23768. damping: number;
  23769. /** this callback will be called when applying the force to the impostors. */
  23770. forceApplicationCallback: () => void;
  23771. }
  23772. }
  23773. declare module "babylonjs/Physics/physicsRaycastResult" {
  23774. import { Vector3 } from "babylonjs/Maths/math.vector";
  23775. /**
  23776. * Holds the data for the raycast result
  23777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23778. */
  23779. export class PhysicsRaycastResult {
  23780. private _hasHit;
  23781. private _hitDistance;
  23782. private _hitNormalWorld;
  23783. private _hitPointWorld;
  23784. private _rayFromWorld;
  23785. private _rayToWorld;
  23786. /**
  23787. * Gets if there was a hit
  23788. */
  23789. get hasHit(): boolean;
  23790. /**
  23791. * Gets the distance from the hit
  23792. */
  23793. get hitDistance(): number;
  23794. /**
  23795. * Gets the hit normal/direction in the world
  23796. */
  23797. get hitNormalWorld(): Vector3;
  23798. /**
  23799. * Gets the hit point in the world
  23800. */
  23801. get hitPointWorld(): Vector3;
  23802. /**
  23803. * Gets the ray "start point" of the ray in the world
  23804. */
  23805. get rayFromWorld(): Vector3;
  23806. /**
  23807. * Gets the ray "end point" of the ray in the world
  23808. */
  23809. get rayToWorld(): Vector3;
  23810. /**
  23811. * Sets the hit data (normal & point in world space)
  23812. * @param hitNormalWorld defines the normal in world space
  23813. * @param hitPointWorld defines the point in world space
  23814. */
  23815. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23816. /**
  23817. * Sets the distance from the start point to the hit point
  23818. * @param distance
  23819. */
  23820. setHitDistance(distance: number): void;
  23821. /**
  23822. * Calculates the distance manually
  23823. */
  23824. calculateHitDistance(): void;
  23825. /**
  23826. * Resets all the values to default
  23827. * @param from The from point on world space
  23828. * @param to The to point on world space
  23829. */
  23830. reset(from?: Vector3, to?: Vector3): void;
  23831. }
  23832. /**
  23833. * Interface for the size containing width and height
  23834. */
  23835. interface IXYZ {
  23836. /**
  23837. * X
  23838. */
  23839. x: number;
  23840. /**
  23841. * Y
  23842. */
  23843. y: number;
  23844. /**
  23845. * Z
  23846. */
  23847. z: number;
  23848. }
  23849. }
  23850. declare module "babylonjs/Physics/IPhysicsEngine" {
  23851. import { Nullable } from "babylonjs/types";
  23852. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23853. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23854. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23855. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23856. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23857. /**
  23858. * Interface used to describe a physics joint
  23859. */
  23860. export interface PhysicsImpostorJoint {
  23861. /** Defines the main impostor to which the joint is linked */
  23862. mainImpostor: PhysicsImpostor;
  23863. /** Defines the impostor that is connected to the main impostor using this joint */
  23864. connectedImpostor: PhysicsImpostor;
  23865. /** Defines the joint itself */
  23866. joint: PhysicsJoint;
  23867. }
  23868. /** @hidden */
  23869. export interface IPhysicsEnginePlugin {
  23870. world: any;
  23871. name: string;
  23872. setGravity(gravity: Vector3): void;
  23873. setTimeStep(timeStep: number): void;
  23874. getTimeStep(): number;
  23875. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23876. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23877. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23878. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23879. removePhysicsBody(impostor: PhysicsImpostor): void;
  23880. generateJoint(joint: PhysicsImpostorJoint): void;
  23881. removeJoint(joint: PhysicsImpostorJoint): void;
  23882. isSupported(): boolean;
  23883. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23884. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23885. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23886. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23887. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23888. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23889. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23890. getBodyMass(impostor: PhysicsImpostor): number;
  23891. getBodyFriction(impostor: PhysicsImpostor): number;
  23892. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23893. getBodyRestitution(impostor: PhysicsImpostor): number;
  23894. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23895. getBodyPressure?(impostor: PhysicsImpostor): number;
  23896. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23897. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23898. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23899. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23900. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23901. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23902. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23903. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23904. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23905. sleepBody(impostor: PhysicsImpostor): void;
  23906. wakeUpBody(impostor: PhysicsImpostor): void;
  23907. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23908. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23909. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23910. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23911. getRadius(impostor: PhysicsImpostor): number;
  23912. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23913. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23914. dispose(): void;
  23915. }
  23916. /**
  23917. * Interface used to define a physics engine
  23918. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23919. */
  23920. export interface IPhysicsEngine {
  23921. /**
  23922. * Gets the gravity vector used by the simulation
  23923. */
  23924. gravity: Vector3;
  23925. /**
  23926. * Sets the gravity vector used by the simulation
  23927. * @param gravity defines the gravity vector to use
  23928. */
  23929. setGravity(gravity: Vector3): void;
  23930. /**
  23931. * Set the time step of the physics engine.
  23932. * Default is 1/60.
  23933. * To slow it down, enter 1/600 for example.
  23934. * To speed it up, 1/30
  23935. * @param newTimeStep the new timestep to apply to this world.
  23936. */
  23937. setTimeStep(newTimeStep: number): void;
  23938. /**
  23939. * Get the time step of the physics engine.
  23940. * @returns the current time step
  23941. */
  23942. getTimeStep(): number;
  23943. /**
  23944. * Set the sub time step of the physics engine.
  23945. * Default is 0 meaning there is no sub steps
  23946. * To increase physics resolution precision, set a small value (like 1 ms)
  23947. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23948. */
  23949. setSubTimeStep(subTimeStep: number): void;
  23950. /**
  23951. * Get the sub time step of the physics engine.
  23952. * @returns the current sub time step
  23953. */
  23954. getSubTimeStep(): number;
  23955. /**
  23956. * Release all resources
  23957. */
  23958. dispose(): void;
  23959. /**
  23960. * Gets the name of the current physics plugin
  23961. * @returns the name of the plugin
  23962. */
  23963. getPhysicsPluginName(): string;
  23964. /**
  23965. * Adding a new impostor for the impostor tracking.
  23966. * This will be done by the impostor itself.
  23967. * @param impostor the impostor to add
  23968. */
  23969. addImpostor(impostor: PhysicsImpostor): void;
  23970. /**
  23971. * Remove an impostor from the engine.
  23972. * This impostor and its mesh will not longer be updated by the physics engine.
  23973. * @param impostor the impostor to remove
  23974. */
  23975. removeImpostor(impostor: PhysicsImpostor): void;
  23976. /**
  23977. * Add a joint to the physics engine
  23978. * @param mainImpostor defines the main impostor to which the joint is added.
  23979. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23980. * @param joint defines the joint that will connect both impostors.
  23981. */
  23982. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23983. /**
  23984. * Removes a joint from the simulation
  23985. * @param mainImpostor defines the impostor used with the joint
  23986. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23987. * @param joint defines the joint to remove
  23988. */
  23989. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23990. /**
  23991. * Gets the current plugin used to run the simulation
  23992. * @returns current plugin
  23993. */
  23994. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23995. /**
  23996. * Gets the list of physic impostors
  23997. * @returns an array of PhysicsImpostor
  23998. */
  23999. getImpostors(): Array<PhysicsImpostor>;
  24000. /**
  24001. * Gets the impostor for a physics enabled object
  24002. * @param object defines the object impersonated by the impostor
  24003. * @returns the PhysicsImpostor or null if not found
  24004. */
  24005. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24006. /**
  24007. * Gets the impostor for a physics body object
  24008. * @param body defines physics body used by the impostor
  24009. * @returns the PhysicsImpostor or null if not found
  24010. */
  24011. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24012. /**
  24013. * Does a raycast in the physics world
  24014. * @param from when should the ray start?
  24015. * @param to when should the ray end?
  24016. * @returns PhysicsRaycastResult
  24017. */
  24018. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24019. /**
  24020. * Called by the scene. No need to call it.
  24021. * @param delta defines the timespam between frames
  24022. */
  24023. _step(delta: number): void;
  24024. }
  24025. }
  24026. declare module "babylonjs/Physics/physicsImpostor" {
  24027. import { Nullable, IndicesArray } from "babylonjs/types";
  24028. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24029. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24031. import { Scene } from "babylonjs/scene";
  24032. import { Bone } from "babylonjs/Bones/bone";
  24033. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24034. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24035. import { Space } from "babylonjs/Maths/math.axis";
  24036. /**
  24037. * The interface for the physics imposter parameters
  24038. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24039. */
  24040. export interface PhysicsImpostorParameters {
  24041. /**
  24042. * The mass of the physics imposter
  24043. */
  24044. mass: number;
  24045. /**
  24046. * The friction of the physics imposter
  24047. */
  24048. friction?: number;
  24049. /**
  24050. * The coefficient of restitution of the physics imposter
  24051. */
  24052. restitution?: number;
  24053. /**
  24054. * The native options of the physics imposter
  24055. */
  24056. nativeOptions?: any;
  24057. /**
  24058. * Specifies if the parent should be ignored
  24059. */
  24060. ignoreParent?: boolean;
  24061. /**
  24062. * Specifies if bi-directional transformations should be disabled
  24063. */
  24064. disableBidirectionalTransformation?: boolean;
  24065. /**
  24066. * The pressure inside the physics imposter, soft object only
  24067. */
  24068. pressure?: number;
  24069. /**
  24070. * The stiffness the physics imposter, soft object only
  24071. */
  24072. stiffness?: number;
  24073. /**
  24074. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24075. */
  24076. velocityIterations?: number;
  24077. /**
  24078. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24079. */
  24080. positionIterations?: number;
  24081. /**
  24082. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24083. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24084. * Add to fix multiple points
  24085. */
  24086. fixedPoints?: number;
  24087. /**
  24088. * The collision margin around a soft object
  24089. */
  24090. margin?: number;
  24091. /**
  24092. * The collision margin around a soft object
  24093. */
  24094. damping?: number;
  24095. /**
  24096. * The path for a rope based on an extrusion
  24097. */
  24098. path?: any;
  24099. /**
  24100. * The shape of an extrusion used for a rope based on an extrusion
  24101. */
  24102. shape?: any;
  24103. }
  24104. /**
  24105. * Interface for a physics-enabled object
  24106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24107. */
  24108. export interface IPhysicsEnabledObject {
  24109. /**
  24110. * The position of the physics-enabled object
  24111. */
  24112. position: Vector3;
  24113. /**
  24114. * The rotation of the physics-enabled object
  24115. */
  24116. rotationQuaternion: Nullable<Quaternion>;
  24117. /**
  24118. * The scale of the physics-enabled object
  24119. */
  24120. scaling: Vector3;
  24121. /**
  24122. * The rotation of the physics-enabled object
  24123. */
  24124. rotation?: Vector3;
  24125. /**
  24126. * The parent of the physics-enabled object
  24127. */
  24128. parent?: any;
  24129. /**
  24130. * The bounding info of the physics-enabled object
  24131. * @returns The bounding info of the physics-enabled object
  24132. */
  24133. getBoundingInfo(): BoundingInfo;
  24134. /**
  24135. * Computes the world matrix
  24136. * @param force Specifies if the world matrix should be computed by force
  24137. * @returns A world matrix
  24138. */
  24139. computeWorldMatrix(force: boolean): Matrix;
  24140. /**
  24141. * Gets the world matrix
  24142. * @returns A world matrix
  24143. */
  24144. getWorldMatrix?(): Matrix;
  24145. /**
  24146. * Gets the child meshes
  24147. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24148. * @returns An array of abstract meshes
  24149. */
  24150. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24151. /**
  24152. * Gets the vertex data
  24153. * @param kind The type of vertex data
  24154. * @returns A nullable array of numbers, or a float32 array
  24155. */
  24156. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24157. /**
  24158. * Gets the indices from the mesh
  24159. * @returns A nullable array of index arrays
  24160. */
  24161. getIndices?(): Nullable<IndicesArray>;
  24162. /**
  24163. * Gets the scene from the mesh
  24164. * @returns the indices array or null
  24165. */
  24166. getScene?(): Scene;
  24167. /**
  24168. * Gets the absolute position from the mesh
  24169. * @returns the absolute position
  24170. */
  24171. getAbsolutePosition(): Vector3;
  24172. /**
  24173. * Gets the absolute pivot point from the mesh
  24174. * @returns the absolute pivot point
  24175. */
  24176. getAbsolutePivotPoint(): Vector3;
  24177. /**
  24178. * Rotates the mesh
  24179. * @param axis The axis of rotation
  24180. * @param amount The amount of rotation
  24181. * @param space The space of the rotation
  24182. * @returns The rotation transform node
  24183. */
  24184. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24185. /**
  24186. * Translates the mesh
  24187. * @param axis The axis of translation
  24188. * @param distance The distance of translation
  24189. * @param space The space of the translation
  24190. * @returns The transform node
  24191. */
  24192. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24193. /**
  24194. * Sets the absolute position of the mesh
  24195. * @param absolutePosition The absolute position of the mesh
  24196. * @returns The transform node
  24197. */
  24198. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24199. /**
  24200. * Gets the class name of the mesh
  24201. * @returns The class name
  24202. */
  24203. getClassName(): string;
  24204. }
  24205. /**
  24206. * Represents a physics imposter
  24207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24208. */
  24209. export class PhysicsImpostor {
  24210. /**
  24211. * The physics-enabled object used as the physics imposter
  24212. */
  24213. object: IPhysicsEnabledObject;
  24214. /**
  24215. * The type of the physics imposter
  24216. */
  24217. type: number;
  24218. private _options;
  24219. private _scene?;
  24220. /**
  24221. * The default object size of the imposter
  24222. */
  24223. static DEFAULT_OBJECT_SIZE: Vector3;
  24224. /**
  24225. * The identity quaternion of the imposter
  24226. */
  24227. static IDENTITY_QUATERNION: Quaternion;
  24228. /** @hidden */
  24229. _pluginData: any;
  24230. private _physicsEngine;
  24231. private _physicsBody;
  24232. private _bodyUpdateRequired;
  24233. private _onBeforePhysicsStepCallbacks;
  24234. private _onAfterPhysicsStepCallbacks;
  24235. /** @hidden */
  24236. _onPhysicsCollideCallbacks: Array<{
  24237. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24238. otherImpostors: Array<PhysicsImpostor>;
  24239. }>;
  24240. private _deltaPosition;
  24241. private _deltaRotation;
  24242. private _deltaRotationConjugated;
  24243. /** @hidden */
  24244. _isFromLine: boolean;
  24245. private _parent;
  24246. private _isDisposed;
  24247. private static _tmpVecs;
  24248. private static _tmpQuat;
  24249. /**
  24250. * Specifies if the physics imposter is disposed
  24251. */
  24252. get isDisposed(): boolean;
  24253. /**
  24254. * Gets the mass of the physics imposter
  24255. */
  24256. get mass(): number;
  24257. set mass(value: number);
  24258. /**
  24259. * Gets the coefficient of friction
  24260. */
  24261. get friction(): number;
  24262. /**
  24263. * Sets the coefficient of friction
  24264. */
  24265. set friction(value: number);
  24266. /**
  24267. * Gets the coefficient of restitution
  24268. */
  24269. get restitution(): number;
  24270. /**
  24271. * Sets the coefficient of restitution
  24272. */
  24273. set restitution(value: number);
  24274. /**
  24275. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24276. */
  24277. get pressure(): number;
  24278. /**
  24279. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24280. */
  24281. set pressure(value: number);
  24282. /**
  24283. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24284. */
  24285. get stiffness(): number;
  24286. /**
  24287. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24288. */
  24289. set stiffness(value: number);
  24290. /**
  24291. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24292. */
  24293. get velocityIterations(): number;
  24294. /**
  24295. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24296. */
  24297. set velocityIterations(value: number);
  24298. /**
  24299. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24300. */
  24301. get positionIterations(): number;
  24302. /**
  24303. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24304. */
  24305. set positionIterations(value: number);
  24306. /**
  24307. * The unique id of the physics imposter
  24308. * set by the physics engine when adding this impostor to the array
  24309. */
  24310. uniqueId: number;
  24311. /**
  24312. * @hidden
  24313. */
  24314. soft: boolean;
  24315. /**
  24316. * @hidden
  24317. */
  24318. segments: number;
  24319. private _joints;
  24320. /**
  24321. * Initializes the physics imposter
  24322. * @param object The physics-enabled object used as the physics imposter
  24323. * @param type The type of the physics imposter
  24324. * @param _options The options for the physics imposter
  24325. * @param _scene The Babylon scene
  24326. */
  24327. constructor(
  24328. /**
  24329. * The physics-enabled object used as the physics imposter
  24330. */
  24331. object: IPhysicsEnabledObject,
  24332. /**
  24333. * The type of the physics imposter
  24334. */
  24335. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24336. /**
  24337. * This function will completly initialize this impostor.
  24338. * It will create a new body - but only if this mesh has no parent.
  24339. * If it has, this impostor will not be used other than to define the impostor
  24340. * of the child mesh.
  24341. * @hidden
  24342. */
  24343. _init(): void;
  24344. private _getPhysicsParent;
  24345. /**
  24346. * Should a new body be generated.
  24347. * @returns boolean specifying if body initialization is required
  24348. */
  24349. isBodyInitRequired(): boolean;
  24350. /**
  24351. * Sets the updated scaling
  24352. * @param updated Specifies if the scaling is updated
  24353. */
  24354. setScalingUpdated(): void;
  24355. /**
  24356. * Force a regeneration of this or the parent's impostor's body.
  24357. * Use under cautious - This will remove all joints already implemented.
  24358. */
  24359. forceUpdate(): void;
  24360. /**
  24361. * Gets the body that holds this impostor. Either its own, or its parent.
  24362. */
  24363. get physicsBody(): any;
  24364. /**
  24365. * Get the parent of the physics imposter
  24366. * @returns Physics imposter or null
  24367. */
  24368. get parent(): Nullable<PhysicsImpostor>;
  24369. /**
  24370. * Sets the parent of the physics imposter
  24371. */
  24372. set parent(value: Nullable<PhysicsImpostor>);
  24373. /**
  24374. * Set the physics body. Used mainly by the physics engine/plugin
  24375. */
  24376. set physicsBody(physicsBody: any);
  24377. /**
  24378. * Resets the update flags
  24379. */
  24380. resetUpdateFlags(): void;
  24381. /**
  24382. * Gets the object extend size
  24383. * @returns the object extend size
  24384. */
  24385. getObjectExtendSize(): Vector3;
  24386. /**
  24387. * Gets the object center
  24388. * @returns The object center
  24389. */
  24390. getObjectCenter(): Vector3;
  24391. /**
  24392. * Get a specific parametes from the options parameter
  24393. * @param paramName The object parameter name
  24394. * @returns The object parameter
  24395. */
  24396. getParam(paramName: string): any;
  24397. /**
  24398. * Sets a specific parameter in the options given to the physics plugin
  24399. * @param paramName The parameter name
  24400. * @param value The value of the parameter
  24401. */
  24402. setParam(paramName: string, value: number): void;
  24403. /**
  24404. * Specifically change the body's mass option. Won't recreate the physics body object
  24405. * @param mass The mass of the physics imposter
  24406. */
  24407. setMass(mass: number): void;
  24408. /**
  24409. * Gets the linear velocity
  24410. * @returns linear velocity or null
  24411. */
  24412. getLinearVelocity(): Nullable<Vector3>;
  24413. /**
  24414. * Sets the linear velocity
  24415. * @param velocity linear velocity or null
  24416. */
  24417. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24418. /**
  24419. * Gets the angular velocity
  24420. * @returns angular velocity or null
  24421. */
  24422. getAngularVelocity(): Nullable<Vector3>;
  24423. /**
  24424. * Sets the angular velocity
  24425. * @param velocity The velocity or null
  24426. */
  24427. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24428. /**
  24429. * Execute a function with the physics plugin native code
  24430. * Provide a function the will have two variables - the world object and the physics body object
  24431. * @param func The function to execute with the physics plugin native code
  24432. */
  24433. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24434. /**
  24435. * Register a function that will be executed before the physics world is stepping forward
  24436. * @param func The function to execute before the physics world is stepped forward
  24437. */
  24438. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24439. /**
  24440. * Unregister a function that will be executed before the physics world is stepping forward
  24441. * @param func The function to execute before the physics world is stepped forward
  24442. */
  24443. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24444. /**
  24445. * Register a function that will be executed after the physics step
  24446. * @param func The function to execute after physics step
  24447. */
  24448. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24449. /**
  24450. * Unregisters a function that will be executed after the physics step
  24451. * @param func The function to execute after physics step
  24452. */
  24453. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24454. /**
  24455. * register a function that will be executed when this impostor collides against a different body
  24456. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24457. * @param func Callback that is executed on collision
  24458. */
  24459. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24460. /**
  24461. * Unregisters the physics imposter on contact
  24462. * @param collideAgainst The physics object to collide against
  24463. * @param func Callback to execute on collision
  24464. */
  24465. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24466. private _tmpQuat;
  24467. private _tmpQuat2;
  24468. /**
  24469. * Get the parent rotation
  24470. * @returns The parent rotation
  24471. */
  24472. getParentsRotation(): Quaternion;
  24473. /**
  24474. * this function is executed by the physics engine.
  24475. */
  24476. beforeStep: () => void;
  24477. /**
  24478. * this function is executed by the physics engine
  24479. */
  24480. afterStep: () => void;
  24481. /**
  24482. * Legacy collision detection event support
  24483. */
  24484. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24485. /**
  24486. * event and body object due to cannon's event-based architecture.
  24487. */
  24488. onCollide: (e: {
  24489. body: any;
  24490. }) => void;
  24491. /**
  24492. * Apply a force
  24493. * @param force The force to apply
  24494. * @param contactPoint The contact point for the force
  24495. * @returns The physics imposter
  24496. */
  24497. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24498. /**
  24499. * Apply an impulse
  24500. * @param force The impulse force
  24501. * @param contactPoint The contact point for the impulse force
  24502. * @returns The physics imposter
  24503. */
  24504. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24505. /**
  24506. * A help function to create a joint
  24507. * @param otherImpostor A physics imposter used to create a joint
  24508. * @param jointType The type of joint
  24509. * @param jointData The data for the joint
  24510. * @returns The physics imposter
  24511. */
  24512. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24513. /**
  24514. * Add a joint to this impostor with a different impostor
  24515. * @param otherImpostor A physics imposter used to add a joint
  24516. * @param joint The joint to add
  24517. * @returns The physics imposter
  24518. */
  24519. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24520. /**
  24521. * Add an anchor to a cloth impostor
  24522. * @param otherImpostor rigid impostor to anchor to
  24523. * @param width ratio across width from 0 to 1
  24524. * @param height ratio up height from 0 to 1
  24525. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24526. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24527. * @returns impostor the soft imposter
  24528. */
  24529. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24530. /**
  24531. * Add a hook to a rope impostor
  24532. * @param otherImpostor rigid impostor to anchor to
  24533. * @param length ratio across rope from 0 to 1
  24534. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24535. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24536. * @returns impostor the rope imposter
  24537. */
  24538. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24539. /**
  24540. * Will keep this body still, in a sleep mode.
  24541. * @returns the physics imposter
  24542. */
  24543. sleep(): PhysicsImpostor;
  24544. /**
  24545. * Wake the body up.
  24546. * @returns The physics imposter
  24547. */
  24548. wakeUp(): PhysicsImpostor;
  24549. /**
  24550. * Clones the physics imposter
  24551. * @param newObject The physics imposter clones to this physics-enabled object
  24552. * @returns A nullable physics imposter
  24553. */
  24554. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24555. /**
  24556. * Disposes the physics imposter
  24557. */
  24558. dispose(): void;
  24559. /**
  24560. * Sets the delta position
  24561. * @param position The delta position amount
  24562. */
  24563. setDeltaPosition(position: Vector3): void;
  24564. /**
  24565. * Sets the delta rotation
  24566. * @param rotation The delta rotation amount
  24567. */
  24568. setDeltaRotation(rotation: Quaternion): void;
  24569. /**
  24570. * Gets the box size of the physics imposter and stores the result in the input parameter
  24571. * @param result Stores the box size
  24572. * @returns The physics imposter
  24573. */
  24574. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24575. /**
  24576. * Gets the radius of the physics imposter
  24577. * @returns Radius of the physics imposter
  24578. */
  24579. getRadius(): number;
  24580. /**
  24581. * Sync a bone with this impostor
  24582. * @param bone The bone to sync to the impostor.
  24583. * @param boneMesh The mesh that the bone is influencing.
  24584. * @param jointPivot The pivot of the joint / bone in local space.
  24585. * @param distToJoint Optional distance from the impostor to the joint.
  24586. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24587. */
  24588. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24589. /**
  24590. * Sync impostor to a bone
  24591. * @param bone The bone that the impostor will be synced to.
  24592. * @param boneMesh The mesh that the bone is influencing.
  24593. * @param jointPivot The pivot of the joint / bone in local space.
  24594. * @param distToJoint Optional distance from the impostor to the joint.
  24595. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24596. * @param boneAxis Optional vector3 axis the bone is aligned with
  24597. */
  24598. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24599. /**
  24600. * No-Imposter type
  24601. */
  24602. static NoImpostor: number;
  24603. /**
  24604. * Sphere-Imposter type
  24605. */
  24606. static SphereImpostor: number;
  24607. /**
  24608. * Box-Imposter type
  24609. */
  24610. static BoxImpostor: number;
  24611. /**
  24612. * Plane-Imposter type
  24613. */
  24614. static PlaneImpostor: number;
  24615. /**
  24616. * Mesh-imposter type
  24617. */
  24618. static MeshImpostor: number;
  24619. /**
  24620. * Capsule-Impostor type (Ammo.js plugin only)
  24621. */
  24622. static CapsuleImpostor: number;
  24623. /**
  24624. * Cylinder-Imposter type
  24625. */
  24626. static CylinderImpostor: number;
  24627. /**
  24628. * Particle-Imposter type
  24629. */
  24630. static ParticleImpostor: number;
  24631. /**
  24632. * Heightmap-Imposter type
  24633. */
  24634. static HeightmapImpostor: number;
  24635. /**
  24636. * ConvexHull-Impostor type (Ammo.js plugin only)
  24637. */
  24638. static ConvexHullImpostor: number;
  24639. /**
  24640. * Custom-Imposter type (Ammo.js plugin only)
  24641. */
  24642. static CustomImpostor: number;
  24643. /**
  24644. * Rope-Imposter type
  24645. */
  24646. static RopeImpostor: number;
  24647. /**
  24648. * Cloth-Imposter type
  24649. */
  24650. static ClothImpostor: number;
  24651. /**
  24652. * Softbody-Imposter type
  24653. */
  24654. static SoftbodyImpostor: number;
  24655. }
  24656. }
  24657. declare module "babylonjs/Meshes/mesh" {
  24658. import { Observable } from "babylonjs/Misc/observable";
  24659. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24660. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24661. import { Camera } from "babylonjs/Cameras/camera";
  24662. import { Scene } from "babylonjs/scene";
  24663. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24664. import { Color4 } from "babylonjs/Maths/math.color";
  24665. import { Engine } from "babylonjs/Engines/engine";
  24666. import { Node } from "babylonjs/node";
  24667. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24668. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24669. import { Buffer } from "babylonjs/Meshes/buffer";
  24670. import { Geometry } from "babylonjs/Meshes/geometry";
  24671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24672. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24673. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24674. import { Effect } from "babylonjs/Materials/effect";
  24675. import { Material } from "babylonjs/Materials/material";
  24676. import { Skeleton } from "babylonjs/Bones/skeleton";
  24677. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24678. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24679. import { Path3D } from "babylonjs/Maths/math.path";
  24680. import { Plane } from "babylonjs/Maths/math.plane";
  24681. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24682. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24683. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24684. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24685. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24686. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24687. /**
  24688. * @hidden
  24689. **/
  24690. export class _CreationDataStorage {
  24691. closePath?: boolean;
  24692. closeArray?: boolean;
  24693. idx: number[];
  24694. dashSize: number;
  24695. gapSize: number;
  24696. path3D: Path3D;
  24697. pathArray: Vector3[][];
  24698. arc: number;
  24699. radius: number;
  24700. cap: number;
  24701. tessellation: number;
  24702. }
  24703. /**
  24704. * @hidden
  24705. **/
  24706. class _InstanceDataStorage {
  24707. visibleInstances: any;
  24708. batchCache: _InstancesBatch;
  24709. instancesBufferSize: number;
  24710. instancesBuffer: Nullable<Buffer>;
  24711. instancesData: Float32Array;
  24712. overridenInstanceCount: number;
  24713. isFrozen: boolean;
  24714. previousBatch: Nullable<_InstancesBatch>;
  24715. hardwareInstancedRendering: boolean;
  24716. sideOrientation: number;
  24717. manualUpdate: boolean;
  24718. }
  24719. /**
  24720. * @hidden
  24721. **/
  24722. export class _InstancesBatch {
  24723. mustReturn: boolean;
  24724. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24725. renderSelf: boolean[];
  24726. hardwareInstancedRendering: boolean[];
  24727. }
  24728. /**
  24729. * Class used to represent renderable models
  24730. */
  24731. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24732. /**
  24733. * Mesh side orientation : usually the external or front surface
  24734. */
  24735. static readonly FRONTSIDE: number;
  24736. /**
  24737. * Mesh side orientation : usually the internal or back surface
  24738. */
  24739. static readonly BACKSIDE: number;
  24740. /**
  24741. * Mesh side orientation : both internal and external or front and back surfaces
  24742. */
  24743. static readonly DOUBLESIDE: number;
  24744. /**
  24745. * Mesh side orientation : by default, `FRONTSIDE`
  24746. */
  24747. static readonly DEFAULTSIDE: number;
  24748. /**
  24749. * Mesh cap setting : no cap
  24750. */
  24751. static readonly NO_CAP: number;
  24752. /**
  24753. * Mesh cap setting : one cap at the beginning of the mesh
  24754. */
  24755. static readonly CAP_START: number;
  24756. /**
  24757. * Mesh cap setting : one cap at the end of the mesh
  24758. */
  24759. static readonly CAP_END: number;
  24760. /**
  24761. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24762. */
  24763. static readonly CAP_ALL: number;
  24764. /**
  24765. * Mesh pattern setting : no flip or rotate
  24766. */
  24767. static readonly NO_FLIP: number;
  24768. /**
  24769. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24770. */
  24771. static readonly FLIP_TILE: number;
  24772. /**
  24773. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24774. */
  24775. static readonly ROTATE_TILE: number;
  24776. /**
  24777. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24778. */
  24779. static readonly FLIP_ROW: number;
  24780. /**
  24781. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24782. */
  24783. static readonly ROTATE_ROW: number;
  24784. /**
  24785. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24786. */
  24787. static readonly FLIP_N_ROTATE_TILE: number;
  24788. /**
  24789. * Mesh pattern setting : rotate pattern and rotate
  24790. */
  24791. static readonly FLIP_N_ROTATE_ROW: number;
  24792. /**
  24793. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24794. */
  24795. static readonly CENTER: number;
  24796. /**
  24797. * Mesh tile positioning : part tiles on left
  24798. */
  24799. static readonly LEFT: number;
  24800. /**
  24801. * Mesh tile positioning : part tiles on right
  24802. */
  24803. static readonly RIGHT: number;
  24804. /**
  24805. * Mesh tile positioning : part tiles on top
  24806. */
  24807. static readonly TOP: number;
  24808. /**
  24809. * Mesh tile positioning : part tiles on bottom
  24810. */
  24811. static readonly BOTTOM: number;
  24812. /**
  24813. * Gets the default side orientation.
  24814. * @param orientation the orientation to value to attempt to get
  24815. * @returns the default orientation
  24816. * @hidden
  24817. */
  24818. static _GetDefaultSideOrientation(orientation?: number): number;
  24819. private _internalMeshDataInfo;
  24820. /**
  24821. * An event triggered before rendering the mesh
  24822. */
  24823. get onBeforeRenderObservable(): Observable<Mesh>;
  24824. /**
  24825. * An event triggered before binding the mesh
  24826. */
  24827. get onBeforeBindObservable(): Observable<Mesh>;
  24828. /**
  24829. * An event triggered after rendering the mesh
  24830. */
  24831. get onAfterRenderObservable(): Observable<Mesh>;
  24832. /**
  24833. * An event triggered before drawing the mesh
  24834. */
  24835. get onBeforeDrawObservable(): Observable<Mesh>;
  24836. private _onBeforeDrawObserver;
  24837. /**
  24838. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24839. */
  24840. set onBeforeDraw(callback: () => void);
  24841. get hasInstances(): boolean;
  24842. /**
  24843. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24844. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24845. */
  24846. delayLoadState: number;
  24847. /**
  24848. * Gets the list of instances created from this mesh
  24849. * it is not supposed to be modified manually.
  24850. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24851. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24852. */
  24853. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24854. /**
  24855. * Gets the file containing delay loading data for this mesh
  24856. */
  24857. delayLoadingFile: string;
  24858. /** @hidden */
  24859. _binaryInfo: any;
  24860. /**
  24861. * User defined function used to change how LOD level selection is done
  24862. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24863. */
  24864. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24865. /**
  24866. * Gets or sets the morph target manager
  24867. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24868. */
  24869. get morphTargetManager(): Nullable<MorphTargetManager>;
  24870. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24871. /** @hidden */
  24872. _creationDataStorage: Nullable<_CreationDataStorage>;
  24873. /** @hidden */
  24874. _geometry: Nullable<Geometry>;
  24875. /** @hidden */
  24876. _delayInfo: Array<string>;
  24877. /** @hidden */
  24878. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24879. /** @hidden */
  24880. _instanceDataStorage: _InstanceDataStorage;
  24881. private _effectiveMaterial;
  24882. /** @hidden */
  24883. _shouldGenerateFlatShading: boolean;
  24884. /** @hidden */
  24885. _originalBuilderSideOrientation: number;
  24886. /**
  24887. * Use this property to change the original side orientation defined at construction time
  24888. */
  24889. overrideMaterialSideOrientation: Nullable<number>;
  24890. /**
  24891. * Gets the source mesh (the one used to clone this one from)
  24892. */
  24893. get source(): Nullable<Mesh>;
  24894. /**
  24895. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24896. */
  24897. get isUnIndexed(): boolean;
  24898. set isUnIndexed(value: boolean);
  24899. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24900. get worldMatrixInstancedBuffer(): Float32Array;
  24901. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24902. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24903. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24904. /**
  24905. * @constructor
  24906. * @param name The value used by scene.getMeshByName() to do a lookup.
  24907. * @param scene The scene to add this mesh to.
  24908. * @param parent The parent of this mesh, if it has one
  24909. * @param source An optional Mesh from which geometry is shared, cloned.
  24910. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24911. * When false, achieved by calling a clone(), also passing False.
  24912. * This will make creation of children, recursive.
  24913. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24914. */
  24915. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24916. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24917. doNotInstantiate: boolean;
  24918. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24919. /**
  24920. * Gets the class name
  24921. * @returns the string "Mesh".
  24922. */
  24923. getClassName(): string;
  24924. /** @hidden */
  24925. get _isMesh(): boolean;
  24926. /**
  24927. * Returns a description of this mesh
  24928. * @param fullDetails define if full details about this mesh must be used
  24929. * @returns a descriptive string representing this mesh
  24930. */
  24931. toString(fullDetails?: boolean): string;
  24932. /** @hidden */
  24933. _unBindEffect(): void;
  24934. /**
  24935. * Gets a boolean indicating if this mesh has LOD
  24936. */
  24937. get hasLODLevels(): boolean;
  24938. /**
  24939. * Gets the list of MeshLODLevel associated with the current mesh
  24940. * @returns an array of MeshLODLevel
  24941. */
  24942. getLODLevels(): MeshLODLevel[];
  24943. private _sortLODLevels;
  24944. /**
  24945. * Add a mesh as LOD level triggered at the given distance.
  24946. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24947. * @param distance The distance from the center of the object to show this level
  24948. * @param mesh The mesh to be added as LOD level (can be null)
  24949. * @return This mesh (for chaining)
  24950. */
  24951. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24952. /**
  24953. * Returns the LOD level mesh at the passed distance or null if not found.
  24954. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24955. * @param distance The distance from the center of the object to show this level
  24956. * @returns a Mesh or `null`
  24957. */
  24958. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24959. /**
  24960. * Remove a mesh from the LOD array
  24961. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24962. * @param mesh defines the mesh to be removed
  24963. * @return This mesh (for chaining)
  24964. */
  24965. removeLODLevel(mesh: Mesh): Mesh;
  24966. /**
  24967. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24968. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24969. * @param camera defines the camera to use to compute distance
  24970. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24971. * @return This mesh (for chaining)
  24972. */
  24973. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24974. /**
  24975. * Gets the mesh internal Geometry object
  24976. */
  24977. get geometry(): Nullable<Geometry>;
  24978. /**
  24979. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24980. * @returns the total number of vertices
  24981. */
  24982. getTotalVertices(): number;
  24983. /**
  24984. * Returns the content of an associated vertex buffer
  24985. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24986. * - VertexBuffer.PositionKind
  24987. * - VertexBuffer.UVKind
  24988. * - VertexBuffer.UV2Kind
  24989. * - VertexBuffer.UV3Kind
  24990. * - VertexBuffer.UV4Kind
  24991. * - VertexBuffer.UV5Kind
  24992. * - VertexBuffer.UV6Kind
  24993. * - VertexBuffer.ColorKind
  24994. * - VertexBuffer.MatricesIndicesKind
  24995. * - VertexBuffer.MatricesIndicesExtraKind
  24996. * - VertexBuffer.MatricesWeightsKind
  24997. * - VertexBuffer.MatricesWeightsExtraKind
  24998. * @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
  24999. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25000. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25001. */
  25002. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25003. /**
  25004. * Returns the mesh VertexBuffer object from the requested `kind`
  25005. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25006. * - VertexBuffer.PositionKind
  25007. * - VertexBuffer.NormalKind
  25008. * - VertexBuffer.UVKind
  25009. * - VertexBuffer.UV2Kind
  25010. * - VertexBuffer.UV3Kind
  25011. * - VertexBuffer.UV4Kind
  25012. * - VertexBuffer.UV5Kind
  25013. * - VertexBuffer.UV6Kind
  25014. * - VertexBuffer.ColorKind
  25015. * - VertexBuffer.MatricesIndicesKind
  25016. * - VertexBuffer.MatricesIndicesExtraKind
  25017. * - VertexBuffer.MatricesWeightsKind
  25018. * - VertexBuffer.MatricesWeightsExtraKind
  25019. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25020. */
  25021. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25022. /**
  25023. * Tests if a specific vertex buffer is associated with this mesh
  25024. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25025. * - VertexBuffer.PositionKind
  25026. * - VertexBuffer.NormalKind
  25027. * - VertexBuffer.UVKind
  25028. * - VertexBuffer.UV2Kind
  25029. * - VertexBuffer.UV3Kind
  25030. * - VertexBuffer.UV4Kind
  25031. * - VertexBuffer.UV5Kind
  25032. * - VertexBuffer.UV6Kind
  25033. * - VertexBuffer.ColorKind
  25034. * - VertexBuffer.MatricesIndicesKind
  25035. * - VertexBuffer.MatricesIndicesExtraKind
  25036. * - VertexBuffer.MatricesWeightsKind
  25037. * - VertexBuffer.MatricesWeightsExtraKind
  25038. * @returns a boolean
  25039. */
  25040. isVerticesDataPresent(kind: string): boolean;
  25041. /**
  25042. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25043. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25044. * - VertexBuffer.PositionKind
  25045. * - VertexBuffer.UVKind
  25046. * - VertexBuffer.UV2Kind
  25047. * - VertexBuffer.UV3Kind
  25048. * - VertexBuffer.UV4Kind
  25049. * - VertexBuffer.UV5Kind
  25050. * - VertexBuffer.UV6Kind
  25051. * - VertexBuffer.ColorKind
  25052. * - VertexBuffer.MatricesIndicesKind
  25053. * - VertexBuffer.MatricesIndicesExtraKind
  25054. * - VertexBuffer.MatricesWeightsKind
  25055. * - VertexBuffer.MatricesWeightsExtraKind
  25056. * @returns a boolean
  25057. */
  25058. isVertexBufferUpdatable(kind: string): boolean;
  25059. /**
  25060. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25061. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25062. * - VertexBuffer.PositionKind
  25063. * - VertexBuffer.NormalKind
  25064. * - VertexBuffer.UVKind
  25065. * - VertexBuffer.UV2Kind
  25066. * - VertexBuffer.UV3Kind
  25067. * - VertexBuffer.UV4Kind
  25068. * - VertexBuffer.UV5Kind
  25069. * - VertexBuffer.UV6Kind
  25070. * - VertexBuffer.ColorKind
  25071. * - VertexBuffer.MatricesIndicesKind
  25072. * - VertexBuffer.MatricesIndicesExtraKind
  25073. * - VertexBuffer.MatricesWeightsKind
  25074. * - VertexBuffer.MatricesWeightsExtraKind
  25075. * @returns an array of strings
  25076. */
  25077. getVerticesDataKinds(): string[];
  25078. /**
  25079. * Returns a positive integer : the total number of indices in this mesh geometry.
  25080. * @returns the numner of indices or zero if the mesh has no geometry.
  25081. */
  25082. getTotalIndices(): number;
  25083. /**
  25084. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25085. * @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.
  25086. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25087. * @returns the indices array or an empty array if the mesh has no geometry
  25088. */
  25089. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25090. get isBlocked(): boolean;
  25091. /**
  25092. * Determine if the current mesh is ready to be rendered
  25093. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25094. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25095. * @returns true if all associated assets are ready (material, textures, shaders)
  25096. */
  25097. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25098. /**
  25099. * 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.
  25100. */
  25101. get areNormalsFrozen(): boolean;
  25102. /**
  25103. * 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.
  25104. * @returns the current mesh
  25105. */
  25106. freezeNormals(): Mesh;
  25107. /**
  25108. * 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
  25109. * @returns the current mesh
  25110. */
  25111. unfreezeNormals(): Mesh;
  25112. /**
  25113. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25114. */
  25115. set overridenInstanceCount(count: number);
  25116. /** @hidden */
  25117. _preActivate(): Mesh;
  25118. /** @hidden */
  25119. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25120. /** @hidden */
  25121. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25122. /**
  25123. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25124. * This means the mesh underlying bounding box and sphere are recomputed.
  25125. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25126. * @returns the current mesh
  25127. */
  25128. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25129. /** @hidden */
  25130. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25131. /**
  25132. * This function will subdivide the mesh into multiple submeshes
  25133. * @param count defines the expected number of submeshes
  25134. */
  25135. subdivide(count: number): void;
  25136. /**
  25137. * Copy a FloatArray into a specific associated vertex buffer
  25138. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25139. * - VertexBuffer.PositionKind
  25140. * - VertexBuffer.UVKind
  25141. * - VertexBuffer.UV2Kind
  25142. * - VertexBuffer.UV3Kind
  25143. * - VertexBuffer.UV4Kind
  25144. * - VertexBuffer.UV5Kind
  25145. * - VertexBuffer.UV6Kind
  25146. * - VertexBuffer.ColorKind
  25147. * - VertexBuffer.MatricesIndicesKind
  25148. * - VertexBuffer.MatricesIndicesExtraKind
  25149. * - VertexBuffer.MatricesWeightsKind
  25150. * - VertexBuffer.MatricesWeightsExtraKind
  25151. * @param data defines the data source
  25152. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25153. * @param stride defines the data stride size (can be null)
  25154. * @returns the current mesh
  25155. */
  25156. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25157. /**
  25158. * Delete a vertex buffer associated with this mesh
  25159. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25160. * - VertexBuffer.PositionKind
  25161. * - VertexBuffer.UVKind
  25162. * - VertexBuffer.UV2Kind
  25163. * - VertexBuffer.UV3Kind
  25164. * - VertexBuffer.UV4Kind
  25165. * - VertexBuffer.UV5Kind
  25166. * - VertexBuffer.UV6Kind
  25167. * - VertexBuffer.ColorKind
  25168. * - VertexBuffer.MatricesIndicesKind
  25169. * - VertexBuffer.MatricesIndicesExtraKind
  25170. * - VertexBuffer.MatricesWeightsKind
  25171. * - VertexBuffer.MatricesWeightsExtraKind
  25172. */
  25173. removeVerticesData(kind: string): void;
  25174. /**
  25175. * Flags an associated vertex buffer as updatable
  25176. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25177. * - VertexBuffer.PositionKind
  25178. * - VertexBuffer.UVKind
  25179. * - VertexBuffer.UV2Kind
  25180. * - VertexBuffer.UV3Kind
  25181. * - VertexBuffer.UV4Kind
  25182. * - VertexBuffer.UV5Kind
  25183. * - VertexBuffer.UV6Kind
  25184. * - VertexBuffer.ColorKind
  25185. * - VertexBuffer.MatricesIndicesKind
  25186. * - VertexBuffer.MatricesIndicesExtraKind
  25187. * - VertexBuffer.MatricesWeightsKind
  25188. * - VertexBuffer.MatricesWeightsExtraKind
  25189. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25190. */
  25191. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25192. /**
  25193. * Sets the mesh global Vertex Buffer
  25194. * @param buffer defines the buffer to use
  25195. * @returns the current mesh
  25196. */
  25197. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25198. /**
  25199. * Update a specific associated vertex buffer
  25200. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25201. * - VertexBuffer.PositionKind
  25202. * - VertexBuffer.UVKind
  25203. * - VertexBuffer.UV2Kind
  25204. * - VertexBuffer.UV3Kind
  25205. * - VertexBuffer.UV4Kind
  25206. * - VertexBuffer.UV5Kind
  25207. * - VertexBuffer.UV6Kind
  25208. * - VertexBuffer.ColorKind
  25209. * - VertexBuffer.MatricesIndicesKind
  25210. * - VertexBuffer.MatricesIndicesExtraKind
  25211. * - VertexBuffer.MatricesWeightsKind
  25212. * - VertexBuffer.MatricesWeightsExtraKind
  25213. * @param data defines the data source
  25214. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25215. * @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)
  25216. * @returns the current mesh
  25217. */
  25218. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25219. /**
  25220. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25221. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25222. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25223. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25224. * @returns the current mesh
  25225. */
  25226. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25227. /**
  25228. * Creates a un-shared specific occurence of the geometry for the mesh.
  25229. * @returns the current mesh
  25230. */
  25231. makeGeometryUnique(): Mesh;
  25232. /**
  25233. * Set the index buffer of this mesh
  25234. * @param indices defines the source data
  25235. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25236. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25237. * @returns the current mesh
  25238. */
  25239. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25240. /**
  25241. * Update the current index buffer
  25242. * @param indices defines the source data
  25243. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25244. * @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)
  25245. * @returns the current mesh
  25246. */
  25247. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25248. /**
  25249. * Invert the geometry to move from a right handed system to a left handed one.
  25250. * @returns the current mesh
  25251. */
  25252. toLeftHanded(): Mesh;
  25253. /** @hidden */
  25254. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25255. /** @hidden */
  25256. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25257. /**
  25258. * Registers for this mesh a javascript function called just before the rendering process
  25259. * @param func defines the function to call before rendering this mesh
  25260. * @returns the current mesh
  25261. */
  25262. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25263. /**
  25264. * Disposes a previously registered javascript function called before the rendering
  25265. * @param func defines the function to remove
  25266. * @returns the current mesh
  25267. */
  25268. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25269. /**
  25270. * Registers for this mesh a javascript function called just after the rendering is complete
  25271. * @param func defines the function to call after rendering this mesh
  25272. * @returns the current mesh
  25273. */
  25274. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25275. /**
  25276. * Disposes a previously registered javascript function called after the rendering.
  25277. * @param func defines the function to remove
  25278. * @returns the current mesh
  25279. */
  25280. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25281. /** @hidden */
  25282. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25283. /** @hidden */
  25284. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25285. /** @hidden */
  25286. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25287. /** @hidden */
  25288. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25289. /** @hidden */
  25290. _rebuild(): void;
  25291. /** @hidden */
  25292. _freeze(): void;
  25293. /** @hidden */
  25294. _unFreeze(): void;
  25295. /**
  25296. * 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
  25297. * @param subMesh defines the subMesh to render
  25298. * @param enableAlphaMode defines if alpha mode can be changed
  25299. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25300. * @returns the current mesh
  25301. */
  25302. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25303. private _onBeforeDraw;
  25304. /**
  25305. * Renormalize the mesh and patch it up if there are no weights
  25306. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25307. * However in the case of zero weights then we set just a single influence to 1.
  25308. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25309. */
  25310. cleanMatrixWeights(): void;
  25311. private normalizeSkinFourWeights;
  25312. private normalizeSkinWeightsAndExtra;
  25313. /**
  25314. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25315. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25316. * the user know there was an issue with importing the mesh
  25317. * @returns a validation object with skinned, valid and report string
  25318. */
  25319. validateSkinning(): {
  25320. skinned: boolean;
  25321. valid: boolean;
  25322. report: string;
  25323. };
  25324. /** @hidden */
  25325. _checkDelayState(): Mesh;
  25326. private _queueLoad;
  25327. /**
  25328. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25329. * A mesh is in the frustum if its bounding box intersects the frustum
  25330. * @param frustumPlanes defines the frustum to test
  25331. * @returns true if the mesh is in the frustum planes
  25332. */
  25333. isInFrustum(frustumPlanes: Plane[]): boolean;
  25334. /**
  25335. * Sets the mesh material by the material or multiMaterial `id` property
  25336. * @param id is a string identifying the material or the multiMaterial
  25337. * @returns the current mesh
  25338. */
  25339. setMaterialByID(id: string): Mesh;
  25340. /**
  25341. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25342. * @returns an array of IAnimatable
  25343. */
  25344. getAnimatables(): IAnimatable[];
  25345. /**
  25346. * Modifies the mesh geometry according to the passed transformation matrix.
  25347. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25348. * The mesh normals are modified using the same transformation.
  25349. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25350. * @param transform defines the transform matrix to use
  25351. * @see http://doc.babylonjs.com/resources/baking_transformations
  25352. * @returns the current mesh
  25353. */
  25354. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25355. /**
  25356. * Modifies the mesh geometry according to its own current World Matrix.
  25357. * The mesh World Matrix is then reset.
  25358. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25359. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25360. * @see http://doc.babylonjs.com/resources/baking_transformations
  25361. * @returns the current mesh
  25362. */
  25363. bakeCurrentTransformIntoVertices(): Mesh;
  25364. /** @hidden */
  25365. get _positions(): Nullable<Vector3[]>;
  25366. /** @hidden */
  25367. _resetPointsArrayCache(): Mesh;
  25368. /** @hidden */
  25369. _generatePointsArray(): boolean;
  25370. /**
  25371. * Returns a new Mesh object generated from the current mesh properties.
  25372. * This method must not get confused with createInstance()
  25373. * @param name is a string, the name given to the new mesh
  25374. * @param newParent can be any Node object (default `null`)
  25375. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25376. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25377. * @returns a new mesh
  25378. */
  25379. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  25380. /**
  25381. * Releases resources associated with this mesh.
  25382. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25383. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25384. */
  25385. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25386. /** @hidden */
  25387. _disposeInstanceSpecificData(): void;
  25388. /**
  25389. * Modifies the mesh geometry according to a displacement map.
  25390. * 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.
  25391. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25392. * @param url is a string, the URL from the image file is to be downloaded.
  25393. * @param minHeight is the lower limit of the displacement.
  25394. * @param maxHeight is the upper limit of the displacement.
  25395. * @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.
  25396. * @param uvOffset is an optional vector2 used to offset UV.
  25397. * @param uvScale is an optional vector2 used to scale UV.
  25398. * @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.
  25399. * @returns the Mesh.
  25400. */
  25401. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25402. /**
  25403. * Modifies the mesh geometry according to a displacementMap buffer.
  25404. * 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.
  25405. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25406. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25407. * @param heightMapWidth is the width of the buffer image.
  25408. * @param heightMapHeight is the height of the buffer image.
  25409. * @param minHeight is the lower limit of the displacement.
  25410. * @param maxHeight is the upper limit of the displacement.
  25411. * @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.
  25412. * @param uvOffset is an optional vector2 used to offset UV.
  25413. * @param uvScale is an optional vector2 used to scale UV.
  25414. * @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.
  25415. * @returns the Mesh.
  25416. */
  25417. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25418. /**
  25419. * Modify the mesh to get a flat shading rendering.
  25420. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25421. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25422. * @returns current mesh
  25423. */
  25424. convertToFlatShadedMesh(): Mesh;
  25425. /**
  25426. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25427. * In other words, more vertices, no more indices and a single bigger VBO.
  25428. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25429. * @returns current mesh
  25430. */
  25431. convertToUnIndexedMesh(): Mesh;
  25432. /**
  25433. * Inverses facet orientations.
  25434. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25435. * @param flipNormals will also inverts the normals
  25436. * @returns current mesh
  25437. */
  25438. flipFaces(flipNormals?: boolean): Mesh;
  25439. /**
  25440. * Increase the number of facets and hence vertices in a mesh
  25441. * Vertex normals are interpolated from existing vertex normals
  25442. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25443. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25444. */
  25445. increaseVertices(numberPerEdge: number): void;
  25446. /**
  25447. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25448. * This will undo any application of covertToFlatShadedMesh
  25449. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25450. */
  25451. forceSharedVertices(): void;
  25452. /** @hidden */
  25453. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25454. /** @hidden */
  25455. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25456. /**
  25457. * Creates a new InstancedMesh object from the mesh model.
  25458. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25459. * @param name defines the name of the new instance
  25460. * @returns a new InstancedMesh
  25461. */
  25462. createInstance(name: string): InstancedMesh;
  25463. /**
  25464. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25465. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25466. * @returns the current mesh
  25467. */
  25468. synchronizeInstances(): Mesh;
  25469. /**
  25470. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25471. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25472. * This should be used together with the simplification to avoid disappearing triangles.
  25473. * @param successCallback an optional success callback to be called after the optimization finished.
  25474. * @returns the current mesh
  25475. */
  25476. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25477. /**
  25478. * Serialize current mesh
  25479. * @param serializationObject defines the object which will receive the serialization data
  25480. */
  25481. serialize(serializationObject: any): void;
  25482. /** @hidden */
  25483. _syncGeometryWithMorphTargetManager(): void;
  25484. /** @hidden */
  25485. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25486. /**
  25487. * Returns a new Mesh object parsed from the source provided.
  25488. * @param parsedMesh is the source
  25489. * @param scene defines the hosting scene
  25490. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25491. * @returns a new Mesh
  25492. */
  25493. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25494. /**
  25495. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25496. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25497. * @param name defines the name of the mesh to create
  25498. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25499. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25500. * @param closePath creates a seam between the first and the last points of each path of the path array
  25501. * @param offset is taken in account only if the `pathArray` is containing a single path
  25502. * @param scene defines the hosting scene
  25503. * @param updatable defines if the mesh must be flagged as updatable
  25504. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25505. * @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)
  25506. * @returns a new Mesh
  25507. */
  25508. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25509. /**
  25510. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25511. * @param name defines the name of the mesh to create
  25512. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25513. * @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
  25514. * @param scene defines the hosting scene
  25515. * @param updatable defines if the mesh must be flagged as updatable
  25516. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25517. * @returns a new Mesh
  25518. */
  25519. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25520. /**
  25521. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25522. * @param name defines the name of the mesh to create
  25523. * @param size sets the size (float) of each box side (default 1)
  25524. * @param scene defines the hosting scene
  25525. * @param updatable defines if the mesh must be flagged as updatable
  25526. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25527. * @returns a new Mesh
  25528. */
  25529. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25530. /**
  25531. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25532. * @param name defines the name of the mesh to create
  25533. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25534. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25535. * @param scene defines the hosting scene
  25536. * @param updatable defines if the mesh must be flagged as updatable
  25537. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25538. * @returns a new Mesh
  25539. */
  25540. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25541. /**
  25542. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25543. * @param name defines the name of the mesh to create
  25544. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25545. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25546. * @param scene defines the hosting scene
  25547. * @returns a new Mesh
  25548. */
  25549. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25550. /**
  25551. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25552. * @param name defines the name of the mesh to create
  25553. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25554. * @param diameterTop set the top cap diameter (floats, default 1)
  25555. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25556. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25557. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25558. * @param scene defines the hosting scene
  25559. * @param updatable defines if the mesh must be flagged as updatable
  25560. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25561. * @returns a new Mesh
  25562. */
  25563. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25564. /**
  25565. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25566. * @param name defines the name of the mesh to create
  25567. * @param diameter sets the diameter size (float) of the torus (default 1)
  25568. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25569. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25570. * @param scene defines the hosting scene
  25571. * @param updatable defines if the mesh must be flagged as updatable
  25572. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25573. * @returns a new Mesh
  25574. */
  25575. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25576. /**
  25577. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25578. * @param name defines the name of the mesh to create
  25579. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25580. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25581. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25582. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25583. * @param p the number of windings on X axis (positive integers, default 2)
  25584. * @param q the number of windings on Y axis (positive integers, default 3)
  25585. * @param scene defines the hosting scene
  25586. * @param updatable defines if the mesh must be flagged as updatable
  25587. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25588. * @returns a new Mesh
  25589. */
  25590. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25591. /**
  25592. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25593. * @param name defines the name of the mesh to create
  25594. * @param points is an array successive Vector3
  25595. * @param scene defines the hosting scene
  25596. * @param updatable defines if the mesh must be flagged as updatable
  25597. * @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).
  25598. * @returns a new Mesh
  25599. */
  25600. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25601. /**
  25602. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25603. * @param name defines the name of the mesh to create
  25604. * @param points is an array successive Vector3
  25605. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25606. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25607. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25608. * @param scene defines the hosting scene
  25609. * @param updatable defines if the mesh must be flagged as updatable
  25610. * @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)
  25611. * @returns a new Mesh
  25612. */
  25613. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25614. /**
  25615. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25616. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25617. * 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.
  25618. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25619. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25620. * Remember you can only change the shape positions, not their number when updating a polygon.
  25621. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25622. * @param name defines the name of the mesh to create
  25623. * @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
  25624. * @param scene defines the hosting scene
  25625. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25626. * @param updatable defines if the mesh must be flagged as updatable
  25627. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25628. * @param earcutInjection can be used to inject your own earcut reference
  25629. * @returns a new Mesh
  25630. */
  25631. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25632. /**
  25633. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25634. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25635. * @param name defines the name of the mesh to create
  25636. * @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
  25637. * @param depth defines the height of extrusion
  25638. * @param scene defines the hosting scene
  25639. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25640. * @param updatable defines if the mesh must be flagged as updatable
  25641. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25642. * @param earcutInjection can be used to inject your own earcut reference
  25643. * @returns a new Mesh
  25644. */
  25645. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25646. /**
  25647. * Creates an extruded shape mesh.
  25648. * 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
  25649. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25650. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25651. * @param name defines the name of the mesh to create
  25652. * @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
  25653. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25654. * @param scale is the value to scale the shape
  25655. * @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
  25656. * @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
  25657. * @param scene defines the hosting scene
  25658. * @param updatable defines if the mesh must be flagged as updatable
  25659. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25660. * @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)
  25661. * @returns a new Mesh
  25662. */
  25663. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25664. /**
  25665. * Creates an custom extruded shape mesh.
  25666. * The custom extrusion is a parametric shape.
  25667. * It has no predefined shape. Its final shape will depend on the input parameters.
  25668. * Please consider using the same method from the MeshBuilder class instead
  25669. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25670. * @param name defines the name of the mesh to create
  25671. * @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
  25672. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25673. * @param scaleFunction is a custom Javascript function called on each path point
  25674. * @param rotationFunction is a custom Javascript function called on each path point
  25675. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25676. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25677. * @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
  25678. * @param scene defines the hosting scene
  25679. * @param updatable defines if the mesh must be flagged as updatable
  25680. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25681. * @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)
  25682. * @returns a new Mesh
  25683. */
  25684. 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;
  25685. /**
  25686. * Creates lathe mesh.
  25687. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25688. * Please consider using the same method from the MeshBuilder class instead
  25689. * @param name defines the name of the mesh to create
  25690. * @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
  25691. * @param radius is the radius value of the lathe
  25692. * @param tessellation is the side number of the lathe.
  25693. * @param scene defines the hosting scene
  25694. * @param updatable defines if the mesh must be flagged as updatable
  25695. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25696. * @returns a new Mesh
  25697. */
  25698. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25699. /**
  25700. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25701. * @param name defines the name of the mesh to create
  25702. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25703. * @param scene defines the hosting scene
  25704. * @param updatable defines if the mesh must be flagged as updatable
  25705. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25706. * @returns a new Mesh
  25707. */
  25708. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25709. /**
  25710. * Creates a ground mesh.
  25711. * Please consider using the same method from the MeshBuilder class instead
  25712. * @param name defines the name of the mesh to create
  25713. * @param width set the width of the ground
  25714. * @param height set the height of the ground
  25715. * @param subdivisions sets the number of subdivisions per side
  25716. * @param scene defines the hosting scene
  25717. * @param updatable defines if the mesh must be flagged as updatable
  25718. * @returns a new Mesh
  25719. */
  25720. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25721. /**
  25722. * Creates a tiled ground mesh.
  25723. * Please consider using the same method from the MeshBuilder class instead
  25724. * @param name defines the name of the mesh to create
  25725. * @param xmin set the ground minimum X coordinate
  25726. * @param zmin set the ground minimum Y coordinate
  25727. * @param xmax set the ground maximum X coordinate
  25728. * @param zmax set the ground maximum Z coordinate
  25729. * @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
  25730. * @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
  25731. * @param scene defines the hosting scene
  25732. * @param updatable defines if the mesh must be flagged as updatable
  25733. * @returns a new Mesh
  25734. */
  25735. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25736. w: number;
  25737. h: number;
  25738. }, precision: {
  25739. w: number;
  25740. h: number;
  25741. }, scene: Scene, updatable?: boolean): Mesh;
  25742. /**
  25743. * Creates a ground mesh from a height map.
  25744. * Please consider using the same method from the MeshBuilder class instead
  25745. * @see http://doc.babylonjs.com/babylon101/height_map
  25746. * @param name defines the name of the mesh to create
  25747. * @param url sets the URL of the height map image resource
  25748. * @param width set the ground width size
  25749. * @param height set the ground height size
  25750. * @param subdivisions sets the number of subdivision per side
  25751. * @param minHeight is the minimum altitude on the ground
  25752. * @param maxHeight is the maximum altitude on the ground
  25753. * @param scene defines the hosting scene
  25754. * @param updatable defines if the mesh must be flagged as updatable
  25755. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25756. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25757. * @returns a new Mesh
  25758. */
  25759. 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;
  25760. /**
  25761. * Creates a tube mesh.
  25762. * The tube is a parametric shape.
  25763. * It has no predefined shape. Its final shape will depend on the input parameters.
  25764. * Please consider using the same method from the MeshBuilder class instead
  25765. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25766. * @param name defines the name of the mesh to create
  25767. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25768. * @param radius sets the tube radius size
  25769. * @param tessellation is the number of sides on the tubular surface
  25770. * @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
  25771. * @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
  25772. * @param scene defines the hosting scene
  25773. * @param updatable defines if the mesh must be flagged as updatable
  25774. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25775. * @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)
  25776. * @returns a new Mesh
  25777. */
  25778. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25779. (i: number, distance: number): number;
  25780. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25781. /**
  25782. * Creates a polyhedron mesh.
  25783. * Please consider using the same method from the MeshBuilder class instead.
  25784. * * 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
  25785. * * The parameter `size` (positive float, default 1) sets the polygon size
  25786. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25787. * * 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`
  25788. * * 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
  25789. * * 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)`)
  25790. * * 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
  25791. * * 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
  25792. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25793. * * If you create a double-sided mesh, you can choose what parts of 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
  25794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25795. * @param name defines the name of the mesh to create
  25796. * @param options defines the options used to create the mesh
  25797. * @param scene defines the hosting scene
  25798. * @returns a new Mesh
  25799. */
  25800. static CreatePolyhedron(name: string, options: {
  25801. type?: number;
  25802. size?: number;
  25803. sizeX?: number;
  25804. sizeY?: number;
  25805. sizeZ?: number;
  25806. custom?: any;
  25807. faceUV?: Vector4[];
  25808. faceColors?: Color4[];
  25809. updatable?: boolean;
  25810. sideOrientation?: number;
  25811. }, scene: Scene): Mesh;
  25812. /**
  25813. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25814. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25815. * * 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`)
  25816. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25817. * * 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
  25818. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25819. * * If you create a double-sided mesh, you can choose what parts of 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
  25820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25821. * @param name defines the name of the mesh
  25822. * @param options defines the options used to create the mesh
  25823. * @param scene defines the hosting scene
  25824. * @returns a new Mesh
  25825. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25826. */
  25827. static CreateIcoSphere(name: string, options: {
  25828. radius?: number;
  25829. flat?: boolean;
  25830. subdivisions?: number;
  25831. sideOrientation?: number;
  25832. updatable?: boolean;
  25833. }, scene: Scene): Mesh;
  25834. /**
  25835. * Creates a decal mesh.
  25836. * Please consider using the same method from the MeshBuilder class instead.
  25837. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25838. * @param name defines the name of the mesh
  25839. * @param sourceMesh defines the mesh receiving the decal
  25840. * @param position sets the position of the decal in world coordinates
  25841. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25842. * @param size sets the decal scaling
  25843. * @param angle sets the angle to rotate the decal
  25844. * @returns a new Mesh
  25845. */
  25846. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25847. /**
  25848. * Prepare internal position array for software CPU skinning
  25849. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25850. */
  25851. setPositionsForCPUSkinning(): Float32Array;
  25852. /**
  25853. * Prepare internal normal array for software CPU skinning
  25854. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25855. */
  25856. setNormalsForCPUSkinning(): Float32Array;
  25857. /**
  25858. * Updates the vertex buffer by applying transformation from the bones
  25859. * @param skeleton defines the skeleton to apply to current mesh
  25860. * @returns the current mesh
  25861. */
  25862. applySkeleton(skeleton: Skeleton): Mesh;
  25863. /**
  25864. * 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
  25865. * @param meshes defines the list of meshes to scan
  25866. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25867. */
  25868. static MinMax(meshes: AbstractMesh[]): {
  25869. min: Vector3;
  25870. max: Vector3;
  25871. };
  25872. /**
  25873. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25874. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25875. * @returns a vector3
  25876. */
  25877. static Center(meshesOrMinMaxVector: {
  25878. min: Vector3;
  25879. max: Vector3;
  25880. } | AbstractMesh[]): Vector3;
  25881. /**
  25882. * Merge the array of meshes into a single mesh for performance reasons.
  25883. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25884. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25885. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25886. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25887. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25888. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25889. * @returns a new mesh
  25890. */
  25891. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25892. /** @hidden */
  25893. addInstance(instance: InstancedMesh): void;
  25894. /** @hidden */
  25895. removeInstance(instance: InstancedMesh): void;
  25896. }
  25897. }
  25898. declare module "babylonjs/Cameras/camera" {
  25899. import { SmartArray } from "babylonjs/Misc/smartArray";
  25900. import { Observable } from "babylonjs/Misc/observable";
  25901. import { Nullable } from "babylonjs/types";
  25902. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25903. import { Scene } from "babylonjs/scene";
  25904. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25905. import { Node } from "babylonjs/node";
  25906. import { Mesh } from "babylonjs/Meshes/mesh";
  25907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25908. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25909. import { Viewport } from "babylonjs/Maths/math.viewport";
  25910. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25911. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25912. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25913. import { Ray } from "babylonjs/Culling/ray";
  25914. /**
  25915. * This is the base class of all the camera used in the application.
  25916. * @see http://doc.babylonjs.com/features/cameras
  25917. */
  25918. export class Camera extends Node {
  25919. /** @hidden */
  25920. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25921. /**
  25922. * This is the default projection mode used by the cameras.
  25923. * It helps recreating a feeling of perspective and better appreciate depth.
  25924. * This is the best way to simulate real life cameras.
  25925. */
  25926. static readonly PERSPECTIVE_CAMERA: number;
  25927. /**
  25928. * This helps creating camera with an orthographic mode.
  25929. * 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.
  25930. */
  25931. static readonly ORTHOGRAPHIC_CAMERA: number;
  25932. /**
  25933. * This is the default FOV mode for perspective cameras.
  25934. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25935. */
  25936. static readonly FOVMODE_VERTICAL_FIXED: number;
  25937. /**
  25938. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25939. */
  25940. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25941. /**
  25942. * This specifies ther is no need for a camera rig.
  25943. * Basically only one eye is rendered corresponding to the camera.
  25944. */
  25945. static readonly RIG_MODE_NONE: number;
  25946. /**
  25947. * Simulates a camera Rig with one blue eye and one red eye.
  25948. * This can be use with 3d blue and red glasses.
  25949. */
  25950. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25951. /**
  25952. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25953. */
  25954. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25955. /**
  25956. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25957. */
  25958. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25959. /**
  25960. * Defines that both eyes of the camera will be rendered over under each other.
  25961. */
  25962. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25963. /**
  25964. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25965. */
  25966. static readonly RIG_MODE_VR: number;
  25967. /**
  25968. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25969. */
  25970. static readonly RIG_MODE_WEBVR: number;
  25971. /**
  25972. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25973. */
  25974. static readonly RIG_MODE_CUSTOM: number;
  25975. /**
  25976. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25977. */
  25978. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25979. /**
  25980. * Define the input manager associated with the camera.
  25981. */
  25982. inputs: CameraInputsManager<Camera>;
  25983. /** @hidden */
  25984. _position: Vector3;
  25985. /**
  25986. * Define the current local position of the camera in the scene
  25987. */
  25988. get position(): Vector3;
  25989. set position(newPosition: Vector3);
  25990. /**
  25991. * The vector the camera should consider as up.
  25992. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25993. */
  25994. upVector: Vector3;
  25995. /**
  25996. * Define the current limit on the left side for an orthographic camera
  25997. * In scene unit
  25998. */
  25999. orthoLeft: Nullable<number>;
  26000. /**
  26001. * Define the current limit on the right side for an orthographic camera
  26002. * In scene unit
  26003. */
  26004. orthoRight: Nullable<number>;
  26005. /**
  26006. * Define the current limit on the bottom side for an orthographic camera
  26007. * In scene unit
  26008. */
  26009. orthoBottom: Nullable<number>;
  26010. /**
  26011. * Define the current limit on the top side for an orthographic camera
  26012. * In scene unit
  26013. */
  26014. orthoTop: Nullable<number>;
  26015. /**
  26016. * Field Of View is set in Radians. (default is 0.8)
  26017. */
  26018. fov: number;
  26019. /**
  26020. * Define the minimum distance the camera can see from.
  26021. * This is important to note that the depth buffer are not infinite and the closer it starts
  26022. * the more your scene might encounter depth fighting issue.
  26023. */
  26024. minZ: number;
  26025. /**
  26026. * Define the maximum distance the camera can see to.
  26027. * This is important to note that the depth buffer are not infinite and the further it end
  26028. * the more your scene might encounter depth fighting issue.
  26029. */
  26030. maxZ: number;
  26031. /**
  26032. * Define the default inertia of the camera.
  26033. * This helps giving a smooth feeling to the camera movement.
  26034. */
  26035. inertia: number;
  26036. /**
  26037. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26038. */
  26039. mode: number;
  26040. /**
  26041. * Define wether the camera is intermediate.
  26042. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26043. */
  26044. isIntermediate: boolean;
  26045. /**
  26046. * Define the viewport of the camera.
  26047. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26048. */
  26049. viewport: Viewport;
  26050. /**
  26051. * Restricts the camera to viewing objects with the same layerMask.
  26052. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26053. */
  26054. layerMask: number;
  26055. /**
  26056. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26057. */
  26058. fovMode: number;
  26059. /**
  26060. * Rig mode of the camera.
  26061. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26062. * This is normally controlled byt the camera themselves as internal use.
  26063. */
  26064. cameraRigMode: number;
  26065. /**
  26066. * Defines the distance between both "eyes" in case of a RIG
  26067. */
  26068. interaxialDistance: number;
  26069. /**
  26070. * Defines if stereoscopic rendering is done side by side or over under.
  26071. */
  26072. isStereoscopicSideBySide: boolean;
  26073. /**
  26074. * 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
  26075. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26076. * else in the scene. (Eg. security camera)
  26077. *
  26078. * 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)
  26079. */
  26080. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26081. /**
  26082. * When set, the camera will render to this render target instead of the default canvas
  26083. *
  26084. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26085. */
  26086. outputRenderTarget: Nullable<RenderTargetTexture>;
  26087. /**
  26088. * Observable triggered when the camera view matrix has changed.
  26089. */
  26090. onViewMatrixChangedObservable: Observable<Camera>;
  26091. /**
  26092. * Observable triggered when the camera Projection matrix has changed.
  26093. */
  26094. onProjectionMatrixChangedObservable: Observable<Camera>;
  26095. /**
  26096. * Observable triggered when the inputs have been processed.
  26097. */
  26098. onAfterCheckInputsObservable: Observable<Camera>;
  26099. /**
  26100. * Observable triggered when reset has been called and applied to the camera.
  26101. */
  26102. onRestoreStateObservable: Observable<Camera>;
  26103. /** @hidden */
  26104. _cameraRigParams: any;
  26105. /** @hidden */
  26106. _rigCameras: Camera[];
  26107. /** @hidden */
  26108. _rigPostProcess: Nullable<PostProcess>;
  26109. protected _webvrViewMatrix: Matrix;
  26110. /** @hidden */
  26111. _skipRendering: boolean;
  26112. /** @hidden */
  26113. _projectionMatrix: Matrix;
  26114. /** @hidden */
  26115. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26116. /** @hidden */
  26117. _activeMeshes: SmartArray<AbstractMesh>;
  26118. protected _globalPosition: Vector3;
  26119. /** @hidden */
  26120. _computedViewMatrix: Matrix;
  26121. private _doNotComputeProjectionMatrix;
  26122. private _transformMatrix;
  26123. private _frustumPlanes;
  26124. private _refreshFrustumPlanes;
  26125. private _storedFov;
  26126. private _stateStored;
  26127. /**
  26128. * Instantiates a new camera object.
  26129. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26130. * @see http://doc.babylonjs.com/features/cameras
  26131. * @param name Defines the name of the camera in the scene
  26132. * @param position Defines the position of the camera
  26133. * @param scene Defines the scene the camera belongs too
  26134. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26135. */
  26136. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26137. /**
  26138. * Store current camera state (fov, position, etc..)
  26139. * @returns the camera
  26140. */
  26141. storeState(): Camera;
  26142. /**
  26143. * Restores the camera state values if it has been stored. You must call storeState() first
  26144. */
  26145. protected _restoreStateValues(): boolean;
  26146. /**
  26147. * Restored camera state. You must call storeState() first.
  26148. * @returns true if restored and false otherwise
  26149. */
  26150. restoreState(): boolean;
  26151. /**
  26152. * Gets the class name of the camera.
  26153. * @returns the class name
  26154. */
  26155. getClassName(): string;
  26156. /** @hidden */
  26157. readonly _isCamera: boolean;
  26158. /**
  26159. * Gets a string representation of the camera useful for debug purpose.
  26160. * @param fullDetails Defines that a more verboe level of logging is required
  26161. * @returns the string representation
  26162. */
  26163. toString(fullDetails?: boolean): string;
  26164. /**
  26165. * Gets the current world space position of the camera.
  26166. */
  26167. get globalPosition(): Vector3;
  26168. /**
  26169. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26170. * @returns the active meshe list
  26171. */
  26172. getActiveMeshes(): SmartArray<AbstractMesh>;
  26173. /**
  26174. * Check wether a mesh is part of the current active mesh list of the camera
  26175. * @param mesh Defines the mesh to check
  26176. * @returns true if active, false otherwise
  26177. */
  26178. isActiveMesh(mesh: Mesh): boolean;
  26179. /**
  26180. * Is this camera ready to be used/rendered
  26181. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26182. * @return true if the camera is ready
  26183. */
  26184. isReady(completeCheck?: boolean): boolean;
  26185. /** @hidden */
  26186. _initCache(): void;
  26187. /** @hidden */
  26188. _updateCache(ignoreParentClass?: boolean): void;
  26189. /** @hidden */
  26190. _isSynchronized(): boolean;
  26191. /** @hidden */
  26192. _isSynchronizedViewMatrix(): boolean;
  26193. /** @hidden */
  26194. _isSynchronizedProjectionMatrix(): boolean;
  26195. /**
  26196. * Attach the input controls to a specific dom element to get the input from.
  26197. * @param element Defines the element the controls should be listened from
  26198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26199. */
  26200. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26201. /**
  26202. * Detach the current controls from the specified dom element.
  26203. * @param element Defines the element to stop listening the inputs from
  26204. */
  26205. detachControl(element: HTMLElement): void;
  26206. /**
  26207. * Update the camera state according to the different inputs gathered during the frame.
  26208. */
  26209. update(): void;
  26210. /** @hidden */
  26211. _checkInputs(): void;
  26212. /** @hidden */
  26213. get rigCameras(): Camera[];
  26214. /**
  26215. * Gets the post process used by the rig cameras
  26216. */
  26217. get rigPostProcess(): Nullable<PostProcess>;
  26218. /**
  26219. * Internal, gets the first post proces.
  26220. * @returns the first post process to be run on this camera.
  26221. */
  26222. _getFirstPostProcess(): Nullable<PostProcess>;
  26223. private _cascadePostProcessesToRigCams;
  26224. /**
  26225. * Attach a post process to the camera.
  26226. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26227. * @param postProcess The post process to attach to the camera
  26228. * @param insertAt The position of the post process in case several of them are in use in the scene
  26229. * @returns the position the post process has been inserted at
  26230. */
  26231. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26232. /**
  26233. * Detach a post process to the camera.
  26234. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26235. * @param postProcess The post process to detach from the camera
  26236. */
  26237. detachPostProcess(postProcess: PostProcess): void;
  26238. /**
  26239. * Gets the current world matrix of the camera
  26240. */
  26241. getWorldMatrix(): Matrix;
  26242. /** @hidden */
  26243. _getViewMatrix(): Matrix;
  26244. /**
  26245. * Gets the current view matrix of the camera.
  26246. * @param force forces the camera to recompute the matrix without looking at the cached state
  26247. * @returns the view matrix
  26248. */
  26249. getViewMatrix(force?: boolean): Matrix;
  26250. /**
  26251. * Freeze the projection matrix.
  26252. * It will prevent the cache check of the camera projection compute and can speed up perf
  26253. * if no parameter of the camera are meant to change
  26254. * @param projection Defines manually a projection if necessary
  26255. */
  26256. freezeProjectionMatrix(projection?: Matrix): void;
  26257. /**
  26258. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26259. */
  26260. unfreezeProjectionMatrix(): void;
  26261. /**
  26262. * Gets the current projection matrix of the camera.
  26263. * @param force forces the camera to recompute the matrix without looking at the cached state
  26264. * @returns the projection matrix
  26265. */
  26266. getProjectionMatrix(force?: boolean): Matrix;
  26267. /**
  26268. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26269. * @returns a Matrix
  26270. */
  26271. getTransformationMatrix(): Matrix;
  26272. private _updateFrustumPlanes;
  26273. /**
  26274. * Checks if a cullable object (mesh...) is in the camera frustum
  26275. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26276. * @param target The object to check
  26277. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26278. * @returns true if the object is in frustum otherwise false
  26279. */
  26280. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26281. /**
  26282. * Checks if a cullable object (mesh...) is in the camera frustum
  26283. * Unlike isInFrustum this cheks the full bounding box
  26284. * @param target The object to check
  26285. * @returns true if the object is in frustum otherwise false
  26286. */
  26287. isCompletelyInFrustum(target: ICullable): boolean;
  26288. /**
  26289. * Gets a ray in the forward direction from the camera.
  26290. * @param length Defines the length of the ray to create
  26291. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26292. * @param origin Defines the start point of the ray which defaults to the camera position
  26293. * @returns the forward ray
  26294. */
  26295. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26296. /**
  26297. * Releases resources associated with this node.
  26298. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26299. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26300. */
  26301. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26302. /** @hidden */
  26303. _isLeftCamera: boolean;
  26304. /**
  26305. * Gets the left camera of a rig setup in case of Rigged Camera
  26306. */
  26307. get isLeftCamera(): boolean;
  26308. /** @hidden */
  26309. _isRightCamera: boolean;
  26310. /**
  26311. * Gets the right camera of a rig setup in case of Rigged Camera
  26312. */
  26313. get isRightCamera(): boolean;
  26314. /**
  26315. * Gets the left camera of a rig setup in case of Rigged Camera
  26316. */
  26317. get leftCamera(): Nullable<FreeCamera>;
  26318. /**
  26319. * Gets the right camera of a rig setup in case of Rigged Camera
  26320. */
  26321. get rightCamera(): Nullable<FreeCamera>;
  26322. /**
  26323. * Gets the left camera target of a rig setup in case of Rigged Camera
  26324. * @returns the target position
  26325. */
  26326. getLeftTarget(): Nullable<Vector3>;
  26327. /**
  26328. * Gets the right camera target of a rig setup in case of Rigged Camera
  26329. * @returns the target position
  26330. */
  26331. getRightTarget(): Nullable<Vector3>;
  26332. /**
  26333. * @hidden
  26334. */
  26335. setCameraRigMode(mode: number, rigParams: any): void;
  26336. /** @hidden */
  26337. static _setStereoscopicRigMode(camera: Camera): void;
  26338. /** @hidden */
  26339. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26340. /** @hidden */
  26341. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26342. /** @hidden */
  26343. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26344. /** @hidden */
  26345. _getVRProjectionMatrix(): Matrix;
  26346. protected _updateCameraRotationMatrix(): void;
  26347. protected _updateWebVRCameraRotationMatrix(): void;
  26348. /**
  26349. * This function MUST be overwritten by the different WebVR cameras available.
  26350. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26351. * @hidden
  26352. */
  26353. _getWebVRProjectionMatrix(): Matrix;
  26354. /**
  26355. * This function MUST be overwritten by the different WebVR cameras available.
  26356. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26357. * @hidden
  26358. */
  26359. _getWebVRViewMatrix(): Matrix;
  26360. /** @hidden */
  26361. setCameraRigParameter(name: string, value: any): void;
  26362. /**
  26363. * needs to be overridden by children so sub has required properties to be copied
  26364. * @hidden
  26365. */
  26366. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26367. /**
  26368. * May need to be overridden by children
  26369. * @hidden
  26370. */
  26371. _updateRigCameras(): void;
  26372. /** @hidden */
  26373. _setupInputs(): void;
  26374. /**
  26375. * Serialiaze the camera setup to a json represention
  26376. * @returns the JSON representation
  26377. */
  26378. serialize(): any;
  26379. /**
  26380. * Clones the current camera.
  26381. * @param name The cloned camera name
  26382. * @returns the cloned camera
  26383. */
  26384. clone(name: string): Camera;
  26385. /**
  26386. * Gets the direction of the camera relative to a given local axis.
  26387. * @param localAxis Defines the reference axis to provide a relative direction.
  26388. * @return the direction
  26389. */
  26390. getDirection(localAxis: Vector3): Vector3;
  26391. /**
  26392. * Returns the current camera absolute rotation
  26393. */
  26394. get absoluteRotation(): Quaternion;
  26395. /**
  26396. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26397. * @param localAxis Defines the reference axis to provide a relative direction.
  26398. * @param result Defines the vector to store the result in
  26399. */
  26400. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26401. /**
  26402. * Gets a camera constructor for a given camera type
  26403. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26404. * @param name The name of the camera the result will be able to instantiate
  26405. * @param scene The scene the result will construct the camera in
  26406. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26407. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26408. * @returns a factory method to construc the camera
  26409. */
  26410. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26411. /**
  26412. * Compute the world matrix of the camera.
  26413. * @returns the camera world matrix
  26414. */
  26415. computeWorldMatrix(): Matrix;
  26416. /**
  26417. * Parse a JSON and creates the camera from the parsed information
  26418. * @param parsedCamera The JSON to parse
  26419. * @param scene The scene to instantiate the camera in
  26420. * @returns the newly constructed camera
  26421. */
  26422. static Parse(parsedCamera: any, scene: Scene): Camera;
  26423. }
  26424. }
  26425. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26426. import { Nullable } from "babylonjs/types";
  26427. import { Scene } from "babylonjs/scene";
  26428. import { Vector4 } from "babylonjs/Maths/math.vector";
  26429. import { Mesh } from "babylonjs/Meshes/mesh";
  26430. /**
  26431. * Class containing static functions to help procedurally build meshes
  26432. */
  26433. export class DiscBuilder {
  26434. /**
  26435. * Creates a plane polygonal mesh. By default, this is a disc
  26436. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26437. * * 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
  26438. * * 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
  26439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26440. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26442. * @param name defines the name of the mesh
  26443. * @param options defines the options used to create the mesh
  26444. * @param scene defines the hosting scene
  26445. * @returns the plane polygonal mesh
  26446. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26447. */
  26448. static CreateDisc(name: string, options: {
  26449. radius?: number;
  26450. tessellation?: number;
  26451. arc?: number;
  26452. updatable?: boolean;
  26453. sideOrientation?: number;
  26454. frontUVs?: Vector4;
  26455. backUVs?: Vector4;
  26456. }, scene?: Nullable<Scene>): Mesh;
  26457. }
  26458. }
  26459. declare module "babylonjs/Materials/fresnelParameters" {
  26460. import { Color3 } from "babylonjs/Maths/math.color";
  26461. /**
  26462. * This represents all the required information to add a fresnel effect on a material:
  26463. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26464. */
  26465. export class FresnelParameters {
  26466. private _isEnabled;
  26467. /**
  26468. * Define if the fresnel effect is enable or not.
  26469. */
  26470. get isEnabled(): boolean;
  26471. set isEnabled(value: boolean);
  26472. /**
  26473. * Define the color used on edges (grazing angle)
  26474. */
  26475. leftColor: Color3;
  26476. /**
  26477. * Define the color used on center
  26478. */
  26479. rightColor: Color3;
  26480. /**
  26481. * Define bias applied to computed fresnel term
  26482. */
  26483. bias: number;
  26484. /**
  26485. * Defined the power exponent applied to fresnel term
  26486. */
  26487. power: number;
  26488. /**
  26489. * Clones the current fresnel and its valuues
  26490. * @returns a clone fresnel configuration
  26491. */
  26492. clone(): FresnelParameters;
  26493. /**
  26494. * Serializes the current fresnel parameters to a JSON representation.
  26495. * @return the JSON serialization
  26496. */
  26497. serialize(): any;
  26498. /**
  26499. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26500. * @param parsedFresnelParameters Define the JSON representation
  26501. * @returns the parsed parameters
  26502. */
  26503. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26504. }
  26505. }
  26506. declare module "babylonjs/Materials/pushMaterial" {
  26507. import { Nullable } from "babylonjs/types";
  26508. import { Scene } from "babylonjs/scene";
  26509. import { Matrix } from "babylonjs/Maths/math.vector";
  26510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26511. import { Mesh } from "babylonjs/Meshes/mesh";
  26512. import { Material } from "babylonjs/Materials/material";
  26513. import { Effect } from "babylonjs/Materials/effect";
  26514. /**
  26515. * Base class of materials working in push mode in babylon JS
  26516. * @hidden
  26517. */
  26518. export class PushMaterial extends Material {
  26519. protected _activeEffect: Effect;
  26520. protected _normalMatrix: Matrix;
  26521. /**
  26522. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26523. * This means that the material can keep using a previous shader while a new one is being compiled.
  26524. * This is mostly used when shader parallel compilation is supported (true by default)
  26525. */
  26526. allowShaderHotSwapping: boolean;
  26527. constructor(name: string, scene: Scene);
  26528. getEffect(): Effect;
  26529. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26530. /**
  26531. * Binds the given world matrix to the active effect
  26532. *
  26533. * @param world the matrix to bind
  26534. */
  26535. bindOnlyWorldMatrix(world: Matrix): void;
  26536. /**
  26537. * Binds the given normal matrix to the active effect
  26538. *
  26539. * @param normalMatrix the matrix to bind
  26540. */
  26541. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26542. bind(world: Matrix, mesh?: Mesh): void;
  26543. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26544. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26545. }
  26546. }
  26547. declare module "babylonjs/Materials/materialFlags" {
  26548. /**
  26549. * This groups all the flags used to control the materials channel.
  26550. */
  26551. export class MaterialFlags {
  26552. private static _DiffuseTextureEnabled;
  26553. /**
  26554. * Are diffuse textures enabled in the application.
  26555. */
  26556. static get DiffuseTextureEnabled(): boolean;
  26557. static set DiffuseTextureEnabled(value: boolean);
  26558. private static _AmbientTextureEnabled;
  26559. /**
  26560. * Are ambient textures enabled in the application.
  26561. */
  26562. static get AmbientTextureEnabled(): boolean;
  26563. static set AmbientTextureEnabled(value: boolean);
  26564. private static _OpacityTextureEnabled;
  26565. /**
  26566. * Are opacity textures enabled in the application.
  26567. */
  26568. static get OpacityTextureEnabled(): boolean;
  26569. static set OpacityTextureEnabled(value: boolean);
  26570. private static _ReflectionTextureEnabled;
  26571. /**
  26572. * Are reflection textures enabled in the application.
  26573. */
  26574. static get ReflectionTextureEnabled(): boolean;
  26575. static set ReflectionTextureEnabled(value: boolean);
  26576. private static _EmissiveTextureEnabled;
  26577. /**
  26578. * Are emissive textures enabled in the application.
  26579. */
  26580. static get EmissiveTextureEnabled(): boolean;
  26581. static set EmissiveTextureEnabled(value: boolean);
  26582. private static _SpecularTextureEnabled;
  26583. /**
  26584. * Are specular textures enabled in the application.
  26585. */
  26586. static get SpecularTextureEnabled(): boolean;
  26587. static set SpecularTextureEnabled(value: boolean);
  26588. private static _BumpTextureEnabled;
  26589. /**
  26590. * Are bump textures enabled in the application.
  26591. */
  26592. static get BumpTextureEnabled(): boolean;
  26593. static set BumpTextureEnabled(value: boolean);
  26594. private static _LightmapTextureEnabled;
  26595. /**
  26596. * Are lightmap textures enabled in the application.
  26597. */
  26598. static get LightmapTextureEnabled(): boolean;
  26599. static set LightmapTextureEnabled(value: boolean);
  26600. private static _RefractionTextureEnabled;
  26601. /**
  26602. * Are refraction textures enabled in the application.
  26603. */
  26604. static get RefractionTextureEnabled(): boolean;
  26605. static set RefractionTextureEnabled(value: boolean);
  26606. private static _ColorGradingTextureEnabled;
  26607. /**
  26608. * Are color grading textures enabled in the application.
  26609. */
  26610. static get ColorGradingTextureEnabled(): boolean;
  26611. static set ColorGradingTextureEnabled(value: boolean);
  26612. private static _FresnelEnabled;
  26613. /**
  26614. * Are fresnels enabled in the application.
  26615. */
  26616. static get FresnelEnabled(): boolean;
  26617. static set FresnelEnabled(value: boolean);
  26618. private static _ClearCoatTextureEnabled;
  26619. /**
  26620. * Are clear coat textures enabled in the application.
  26621. */
  26622. static get ClearCoatTextureEnabled(): boolean;
  26623. static set ClearCoatTextureEnabled(value: boolean);
  26624. private static _ClearCoatBumpTextureEnabled;
  26625. /**
  26626. * Are clear coat bump textures enabled in the application.
  26627. */
  26628. static get ClearCoatBumpTextureEnabled(): boolean;
  26629. static set ClearCoatBumpTextureEnabled(value: boolean);
  26630. private static _ClearCoatTintTextureEnabled;
  26631. /**
  26632. * Are clear coat tint textures enabled in the application.
  26633. */
  26634. static get ClearCoatTintTextureEnabled(): boolean;
  26635. static set ClearCoatTintTextureEnabled(value: boolean);
  26636. private static _SheenTextureEnabled;
  26637. /**
  26638. * Are sheen textures enabled in the application.
  26639. */
  26640. static get SheenTextureEnabled(): boolean;
  26641. static set SheenTextureEnabled(value: boolean);
  26642. private static _AnisotropicTextureEnabled;
  26643. /**
  26644. * Are anisotropic textures enabled in the application.
  26645. */
  26646. static get AnisotropicTextureEnabled(): boolean;
  26647. static set AnisotropicTextureEnabled(value: boolean);
  26648. private static _ThicknessTextureEnabled;
  26649. /**
  26650. * Are thickness textures enabled in the application.
  26651. */
  26652. static get ThicknessTextureEnabled(): boolean;
  26653. static set ThicknessTextureEnabled(value: boolean);
  26654. }
  26655. }
  26656. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26657. /** @hidden */
  26658. export var defaultFragmentDeclaration: {
  26659. name: string;
  26660. shader: string;
  26661. };
  26662. }
  26663. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26664. /** @hidden */
  26665. export var defaultUboDeclaration: {
  26666. name: string;
  26667. shader: string;
  26668. };
  26669. }
  26670. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26671. /** @hidden */
  26672. export var lightFragmentDeclaration: {
  26673. name: string;
  26674. shader: string;
  26675. };
  26676. }
  26677. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26678. /** @hidden */
  26679. export var lightUboDeclaration: {
  26680. name: string;
  26681. shader: string;
  26682. };
  26683. }
  26684. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26685. /** @hidden */
  26686. export var lightsFragmentFunctions: {
  26687. name: string;
  26688. shader: string;
  26689. };
  26690. }
  26691. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26692. /** @hidden */
  26693. export var shadowsFragmentFunctions: {
  26694. name: string;
  26695. shader: string;
  26696. };
  26697. }
  26698. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26699. /** @hidden */
  26700. export var fresnelFunction: {
  26701. name: string;
  26702. shader: string;
  26703. };
  26704. }
  26705. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26706. /** @hidden */
  26707. export var reflectionFunction: {
  26708. name: string;
  26709. shader: string;
  26710. };
  26711. }
  26712. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26713. /** @hidden */
  26714. export var bumpFragmentFunctions: {
  26715. name: string;
  26716. shader: string;
  26717. };
  26718. }
  26719. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26720. /** @hidden */
  26721. export var logDepthDeclaration: {
  26722. name: string;
  26723. shader: string;
  26724. };
  26725. }
  26726. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26727. /** @hidden */
  26728. export var bumpFragment: {
  26729. name: string;
  26730. shader: string;
  26731. };
  26732. }
  26733. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26734. /** @hidden */
  26735. export var depthPrePass: {
  26736. name: string;
  26737. shader: string;
  26738. };
  26739. }
  26740. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26741. /** @hidden */
  26742. export var lightFragment: {
  26743. name: string;
  26744. shader: string;
  26745. };
  26746. }
  26747. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26748. /** @hidden */
  26749. export var logDepthFragment: {
  26750. name: string;
  26751. shader: string;
  26752. };
  26753. }
  26754. declare module "babylonjs/Shaders/default.fragment" {
  26755. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26756. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26757. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26758. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26759. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26760. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26761. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26762. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26763. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26764. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26765. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26766. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26767. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26768. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26769. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26770. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26771. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26772. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26773. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  26774. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  26775. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  26776. /** @hidden */
  26777. export var defaultPixelShader: {
  26778. name: string;
  26779. shader: string;
  26780. };
  26781. }
  26782. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  26783. /** @hidden */
  26784. export var defaultVertexDeclaration: {
  26785. name: string;
  26786. shader: string;
  26787. };
  26788. }
  26789. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  26790. /** @hidden */
  26791. export var bumpVertexDeclaration: {
  26792. name: string;
  26793. shader: string;
  26794. };
  26795. }
  26796. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  26797. /** @hidden */
  26798. export var bumpVertex: {
  26799. name: string;
  26800. shader: string;
  26801. };
  26802. }
  26803. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  26804. /** @hidden */
  26805. export var fogVertex: {
  26806. name: string;
  26807. shader: string;
  26808. };
  26809. }
  26810. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  26811. /** @hidden */
  26812. export var shadowsVertex: {
  26813. name: string;
  26814. shader: string;
  26815. };
  26816. }
  26817. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  26818. /** @hidden */
  26819. export var pointCloudVertex: {
  26820. name: string;
  26821. shader: string;
  26822. };
  26823. }
  26824. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  26825. /** @hidden */
  26826. export var logDepthVertex: {
  26827. name: string;
  26828. shader: string;
  26829. };
  26830. }
  26831. declare module "babylonjs/Shaders/default.vertex" {
  26832. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  26833. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26834. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26835. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  26836. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  26837. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  26838. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  26839. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  26840. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26841. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26842. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  26843. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  26844. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  26846. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  26847. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  26848. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  26849. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  26850. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  26851. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  26852. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  26853. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  26854. /** @hidden */
  26855. export var defaultVertexShader: {
  26856. name: string;
  26857. shader: string;
  26858. };
  26859. }
  26860. declare module "babylonjs/Materials/standardMaterial" {
  26861. import { SmartArray } from "babylonjs/Misc/smartArray";
  26862. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26863. import { Nullable } from "babylonjs/types";
  26864. import { Scene } from "babylonjs/scene";
  26865. import { Matrix } from "babylonjs/Maths/math.vector";
  26866. import { Color3 } from "babylonjs/Maths/math.color";
  26867. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26869. import { Mesh } from "babylonjs/Meshes/mesh";
  26870. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  26871. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  26872. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  26873. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26874. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  26875. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26876. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26877. import "babylonjs/Shaders/default.fragment";
  26878. import "babylonjs/Shaders/default.vertex";
  26879. /** @hidden */
  26880. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26881. MAINUV1: boolean;
  26882. MAINUV2: boolean;
  26883. DIFFUSE: boolean;
  26884. DIFFUSEDIRECTUV: number;
  26885. AMBIENT: boolean;
  26886. AMBIENTDIRECTUV: number;
  26887. OPACITY: boolean;
  26888. OPACITYDIRECTUV: number;
  26889. OPACITYRGB: boolean;
  26890. REFLECTION: boolean;
  26891. EMISSIVE: boolean;
  26892. EMISSIVEDIRECTUV: number;
  26893. SPECULAR: boolean;
  26894. SPECULARDIRECTUV: number;
  26895. BUMP: boolean;
  26896. BUMPDIRECTUV: number;
  26897. PARALLAX: boolean;
  26898. PARALLAXOCCLUSION: boolean;
  26899. SPECULAROVERALPHA: boolean;
  26900. CLIPPLANE: boolean;
  26901. CLIPPLANE2: boolean;
  26902. CLIPPLANE3: boolean;
  26903. CLIPPLANE4: boolean;
  26904. CLIPPLANE5: boolean;
  26905. CLIPPLANE6: boolean;
  26906. ALPHATEST: boolean;
  26907. DEPTHPREPASS: boolean;
  26908. ALPHAFROMDIFFUSE: boolean;
  26909. POINTSIZE: boolean;
  26910. FOG: boolean;
  26911. SPECULARTERM: boolean;
  26912. DIFFUSEFRESNEL: boolean;
  26913. OPACITYFRESNEL: boolean;
  26914. REFLECTIONFRESNEL: boolean;
  26915. REFRACTIONFRESNEL: boolean;
  26916. EMISSIVEFRESNEL: boolean;
  26917. FRESNEL: boolean;
  26918. NORMAL: boolean;
  26919. UV1: boolean;
  26920. UV2: boolean;
  26921. VERTEXCOLOR: boolean;
  26922. VERTEXALPHA: boolean;
  26923. NUM_BONE_INFLUENCERS: number;
  26924. BonesPerMesh: number;
  26925. BONETEXTURE: boolean;
  26926. INSTANCES: boolean;
  26927. GLOSSINESS: boolean;
  26928. ROUGHNESS: boolean;
  26929. EMISSIVEASILLUMINATION: boolean;
  26930. LINKEMISSIVEWITHDIFFUSE: boolean;
  26931. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26932. LIGHTMAP: boolean;
  26933. LIGHTMAPDIRECTUV: number;
  26934. OBJECTSPACE_NORMALMAP: boolean;
  26935. USELIGHTMAPASSHADOWMAP: boolean;
  26936. REFLECTIONMAP_3D: boolean;
  26937. REFLECTIONMAP_SPHERICAL: boolean;
  26938. REFLECTIONMAP_PLANAR: boolean;
  26939. REFLECTIONMAP_CUBIC: boolean;
  26940. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26941. REFLECTIONMAP_PROJECTION: boolean;
  26942. REFLECTIONMAP_SKYBOX: boolean;
  26943. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26944. REFLECTIONMAP_EXPLICIT: boolean;
  26945. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26946. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26947. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26948. INVERTCUBICMAP: boolean;
  26949. LOGARITHMICDEPTH: boolean;
  26950. REFRACTION: boolean;
  26951. REFRACTIONMAP_3D: boolean;
  26952. REFLECTIONOVERALPHA: boolean;
  26953. TWOSIDEDLIGHTING: boolean;
  26954. SHADOWFLOAT: boolean;
  26955. MORPHTARGETS: boolean;
  26956. MORPHTARGETS_NORMAL: boolean;
  26957. MORPHTARGETS_TANGENT: boolean;
  26958. MORPHTARGETS_UV: boolean;
  26959. NUM_MORPH_INFLUENCERS: number;
  26960. NONUNIFORMSCALING: boolean;
  26961. PREMULTIPLYALPHA: boolean;
  26962. IMAGEPROCESSING: boolean;
  26963. VIGNETTE: boolean;
  26964. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26965. VIGNETTEBLENDMODEOPAQUE: boolean;
  26966. TONEMAPPING: boolean;
  26967. TONEMAPPING_ACES: boolean;
  26968. CONTRAST: boolean;
  26969. COLORCURVES: boolean;
  26970. COLORGRADING: boolean;
  26971. COLORGRADING3D: boolean;
  26972. SAMPLER3DGREENDEPTH: boolean;
  26973. SAMPLER3DBGRMAP: boolean;
  26974. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26975. MULTIVIEW: boolean;
  26976. /**
  26977. * If the reflection texture on this material is in linear color space
  26978. * @hidden
  26979. */
  26980. IS_REFLECTION_LINEAR: boolean;
  26981. /**
  26982. * If the refraction texture on this material is in linear color space
  26983. * @hidden
  26984. */
  26985. IS_REFRACTION_LINEAR: boolean;
  26986. EXPOSURE: boolean;
  26987. constructor();
  26988. setReflectionMode(modeToEnable: string): void;
  26989. }
  26990. /**
  26991. * This is the default material used in Babylon. It is the best trade off between quality
  26992. * and performances.
  26993. * @see http://doc.babylonjs.com/babylon101/materials
  26994. */
  26995. export class StandardMaterial extends PushMaterial {
  26996. private _diffuseTexture;
  26997. /**
  26998. * The basic texture of the material as viewed under a light.
  26999. */
  27000. diffuseTexture: Nullable<BaseTexture>;
  27001. private _ambientTexture;
  27002. /**
  27003. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27004. */
  27005. ambientTexture: Nullable<BaseTexture>;
  27006. private _opacityTexture;
  27007. /**
  27008. * Define the transparency of the material from a texture.
  27009. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27010. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27011. */
  27012. opacityTexture: Nullable<BaseTexture>;
  27013. private _reflectionTexture;
  27014. /**
  27015. * Define the texture used to display the reflection.
  27016. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27017. */
  27018. reflectionTexture: Nullable<BaseTexture>;
  27019. private _emissiveTexture;
  27020. /**
  27021. * Define texture of the material as if self lit.
  27022. * This will be mixed in the final result even in the absence of light.
  27023. */
  27024. emissiveTexture: Nullable<BaseTexture>;
  27025. private _specularTexture;
  27026. /**
  27027. * Define how the color and intensity of the highlight given by the light in the material.
  27028. */
  27029. specularTexture: Nullable<BaseTexture>;
  27030. private _bumpTexture;
  27031. /**
  27032. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27033. * 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.
  27034. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27035. */
  27036. bumpTexture: Nullable<BaseTexture>;
  27037. private _lightmapTexture;
  27038. /**
  27039. * Complex lighting can be computationally expensive to compute at runtime.
  27040. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27041. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27042. */
  27043. lightmapTexture: Nullable<BaseTexture>;
  27044. private _refractionTexture;
  27045. /**
  27046. * Define the texture used to display the refraction.
  27047. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27048. */
  27049. refractionTexture: Nullable<BaseTexture>;
  27050. /**
  27051. * The color of the material lit by the environmental background lighting.
  27052. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27053. */
  27054. ambientColor: Color3;
  27055. /**
  27056. * The basic color of the material as viewed under a light.
  27057. */
  27058. diffuseColor: Color3;
  27059. /**
  27060. * Define how the color and intensity of the highlight given by the light in the material.
  27061. */
  27062. specularColor: Color3;
  27063. /**
  27064. * Define the color of the material as if self lit.
  27065. * This will be mixed in the final result even in the absence of light.
  27066. */
  27067. emissiveColor: Color3;
  27068. /**
  27069. * Defines how sharp are the highlights in the material.
  27070. * The bigger the value the sharper giving a more glossy feeling to the result.
  27071. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27072. */
  27073. specularPower: number;
  27074. private _useAlphaFromDiffuseTexture;
  27075. /**
  27076. * Does the transparency come from the diffuse texture alpha channel.
  27077. */
  27078. useAlphaFromDiffuseTexture: boolean;
  27079. private _useEmissiveAsIllumination;
  27080. /**
  27081. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27082. */
  27083. useEmissiveAsIllumination: boolean;
  27084. private _linkEmissiveWithDiffuse;
  27085. /**
  27086. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27087. * the emissive level when the final color is close to one.
  27088. */
  27089. linkEmissiveWithDiffuse: boolean;
  27090. private _useSpecularOverAlpha;
  27091. /**
  27092. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27093. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27094. */
  27095. useSpecularOverAlpha: boolean;
  27096. private _useReflectionOverAlpha;
  27097. /**
  27098. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27099. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27100. */
  27101. useReflectionOverAlpha: boolean;
  27102. private _disableLighting;
  27103. /**
  27104. * Does lights from the scene impacts this material.
  27105. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27106. */
  27107. disableLighting: boolean;
  27108. private _useObjectSpaceNormalMap;
  27109. /**
  27110. * Allows using an object space normal map (instead of tangent space).
  27111. */
  27112. useObjectSpaceNormalMap: boolean;
  27113. private _useParallax;
  27114. /**
  27115. * Is parallax enabled or not.
  27116. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27117. */
  27118. useParallax: boolean;
  27119. private _useParallaxOcclusion;
  27120. /**
  27121. * Is parallax occlusion enabled or not.
  27122. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27123. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27124. */
  27125. useParallaxOcclusion: boolean;
  27126. /**
  27127. * 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.
  27128. */
  27129. parallaxScaleBias: number;
  27130. private _roughness;
  27131. /**
  27132. * Helps to define how blurry the reflections should appears in the material.
  27133. */
  27134. roughness: number;
  27135. /**
  27136. * In case of refraction, define the value of the index of refraction.
  27137. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27138. */
  27139. indexOfRefraction: number;
  27140. /**
  27141. * Invert the refraction texture alongside the y axis.
  27142. * It can be useful with procedural textures or probe for instance.
  27143. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27144. */
  27145. invertRefractionY: boolean;
  27146. /**
  27147. * Defines the alpha limits in alpha test mode.
  27148. */
  27149. alphaCutOff: number;
  27150. private _useLightmapAsShadowmap;
  27151. /**
  27152. * In case of light mapping, define whether the map contains light or shadow informations.
  27153. */
  27154. useLightmapAsShadowmap: boolean;
  27155. private _diffuseFresnelParameters;
  27156. /**
  27157. * Define the diffuse fresnel parameters of the material.
  27158. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27159. */
  27160. diffuseFresnelParameters: FresnelParameters;
  27161. private _opacityFresnelParameters;
  27162. /**
  27163. * Define the opacity fresnel parameters of the material.
  27164. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27165. */
  27166. opacityFresnelParameters: FresnelParameters;
  27167. private _reflectionFresnelParameters;
  27168. /**
  27169. * Define the reflection fresnel parameters of the material.
  27170. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27171. */
  27172. reflectionFresnelParameters: FresnelParameters;
  27173. private _refractionFresnelParameters;
  27174. /**
  27175. * Define the refraction fresnel parameters of the material.
  27176. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27177. */
  27178. refractionFresnelParameters: FresnelParameters;
  27179. private _emissiveFresnelParameters;
  27180. /**
  27181. * Define the emissive fresnel parameters of the material.
  27182. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27183. */
  27184. emissiveFresnelParameters: FresnelParameters;
  27185. private _useReflectionFresnelFromSpecular;
  27186. /**
  27187. * If true automatically deducts the fresnels values from the material specularity.
  27188. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27189. */
  27190. useReflectionFresnelFromSpecular: boolean;
  27191. private _useGlossinessFromSpecularMapAlpha;
  27192. /**
  27193. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27194. */
  27195. useGlossinessFromSpecularMapAlpha: boolean;
  27196. private _maxSimultaneousLights;
  27197. /**
  27198. * Defines the maximum number of lights that can be used in the material
  27199. */
  27200. maxSimultaneousLights: number;
  27201. private _invertNormalMapX;
  27202. /**
  27203. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27204. */
  27205. invertNormalMapX: boolean;
  27206. private _invertNormalMapY;
  27207. /**
  27208. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27209. */
  27210. invertNormalMapY: boolean;
  27211. private _twoSidedLighting;
  27212. /**
  27213. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27214. */
  27215. twoSidedLighting: boolean;
  27216. /**
  27217. * Default configuration related to image processing available in the standard Material.
  27218. */
  27219. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27220. /**
  27221. * Gets the image processing configuration used either in this material.
  27222. */
  27223. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27224. /**
  27225. * Sets the Default image processing configuration used either in the this material.
  27226. *
  27227. * If sets to null, the scene one is in use.
  27228. */
  27229. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27230. /**
  27231. * Keep track of the image processing observer to allow dispose and replace.
  27232. */
  27233. private _imageProcessingObserver;
  27234. /**
  27235. * Attaches a new image processing configuration to the Standard Material.
  27236. * @param configuration
  27237. */
  27238. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27239. /**
  27240. * Gets wether the color curves effect is enabled.
  27241. */
  27242. get cameraColorCurvesEnabled(): boolean;
  27243. /**
  27244. * Sets wether the color curves effect is enabled.
  27245. */
  27246. set cameraColorCurvesEnabled(value: boolean);
  27247. /**
  27248. * Gets wether the color grading effect is enabled.
  27249. */
  27250. get cameraColorGradingEnabled(): boolean;
  27251. /**
  27252. * Gets wether the color grading effect is enabled.
  27253. */
  27254. set cameraColorGradingEnabled(value: boolean);
  27255. /**
  27256. * Gets wether tonemapping is enabled or not.
  27257. */
  27258. get cameraToneMappingEnabled(): boolean;
  27259. /**
  27260. * Sets wether tonemapping is enabled or not
  27261. */
  27262. set cameraToneMappingEnabled(value: boolean);
  27263. /**
  27264. * The camera exposure used on this material.
  27265. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27266. * This corresponds to a photographic exposure.
  27267. */
  27268. get cameraExposure(): number;
  27269. /**
  27270. * The camera exposure used on this material.
  27271. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27272. * This corresponds to a photographic exposure.
  27273. */
  27274. set cameraExposure(value: number);
  27275. /**
  27276. * Gets The camera contrast used on this material.
  27277. */
  27278. get cameraContrast(): number;
  27279. /**
  27280. * Sets The camera contrast used on this material.
  27281. */
  27282. set cameraContrast(value: number);
  27283. /**
  27284. * Gets the Color Grading 2D Lookup Texture.
  27285. */
  27286. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27287. /**
  27288. * Sets the Color Grading 2D Lookup Texture.
  27289. */
  27290. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27291. /**
  27292. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27293. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27294. * 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;
  27295. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27296. */
  27297. get cameraColorCurves(): Nullable<ColorCurves>;
  27298. /**
  27299. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27300. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27301. * 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;
  27302. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27303. */
  27304. set cameraColorCurves(value: Nullable<ColorCurves>);
  27305. /**
  27306. * Custom callback helping to override the default shader used in the material.
  27307. */
  27308. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27309. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27310. protected _worldViewProjectionMatrix: Matrix;
  27311. protected _globalAmbientColor: Color3;
  27312. protected _useLogarithmicDepth: boolean;
  27313. protected _rebuildInParallel: boolean;
  27314. /**
  27315. * Instantiates a new standard material.
  27316. * This is the default material used in Babylon. It is the best trade off between quality
  27317. * and performances.
  27318. * @see http://doc.babylonjs.com/babylon101/materials
  27319. * @param name Define the name of the material in the scene
  27320. * @param scene Define the scene the material belong to
  27321. */
  27322. constructor(name: string, scene: Scene);
  27323. /**
  27324. * Gets a boolean indicating that current material needs to register RTT
  27325. */
  27326. get hasRenderTargetTextures(): boolean;
  27327. /**
  27328. * Gets the current class name of the material e.g. "StandardMaterial"
  27329. * Mainly use in serialization.
  27330. * @returns the class name
  27331. */
  27332. getClassName(): string;
  27333. /**
  27334. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27335. * You can try switching to logarithmic depth.
  27336. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27337. */
  27338. get useLogarithmicDepth(): boolean;
  27339. set useLogarithmicDepth(value: boolean);
  27340. /**
  27341. * Specifies if the material will require alpha blending
  27342. * @returns a boolean specifying if alpha blending is needed
  27343. */
  27344. needAlphaBlending(): boolean;
  27345. /**
  27346. * Specifies if this material should be rendered in alpha test mode
  27347. * @returns a boolean specifying if an alpha test is needed.
  27348. */
  27349. needAlphaTesting(): boolean;
  27350. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27351. /**
  27352. * Get the texture used for alpha test purpose.
  27353. * @returns the diffuse texture in case of the standard material.
  27354. */
  27355. getAlphaTestTexture(): Nullable<BaseTexture>;
  27356. /**
  27357. * Get if the submesh is ready to be used and all its information available.
  27358. * Child classes can use it to update shaders
  27359. * @param mesh defines the mesh to check
  27360. * @param subMesh defines which submesh to check
  27361. * @param useInstances specifies that instances should be used
  27362. * @returns a boolean indicating that the submesh is ready or not
  27363. */
  27364. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27365. /**
  27366. * Builds the material UBO layouts.
  27367. * Used internally during the effect preparation.
  27368. */
  27369. buildUniformLayout(): void;
  27370. /**
  27371. * Unbinds the material from the mesh
  27372. */
  27373. unbind(): void;
  27374. /**
  27375. * Binds the submesh to this material by preparing the effect and shader to draw
  27376. * @param world defines the world transformation matrix
  27377. * @param mesh defines the mesh containing the submesh
  27378. * @param subMesh defines the submesh to bind the material to
  27379. */
  27380. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27381. /**
  27382. * Get the list of animatables in the material.
  27383. * @returns the list of animatables object used in the material
  27384. */
  27385. getAnimatables(): IAnimatable[];
  27386. /**
  27387. * Gets the active textures from the material
  27388. * @returns an array of textures
  27389. */
  27390. getActiveTextures(): BaseTexture[];
  27391. /**
  27392. * Specifies if the material uses a texture
  27393. * @param texture defines the texture to check against the material
  27394. * @returns a boolean specifying if the material uses the texture
  27395. */
  27396. hasTexture(texture: BaseTexture): boolean;
  27397. /**
  27398. * Disposes the material
  27399. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27400. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27401. */
  27402. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27403. /**
  27404. * Makes a duplicate of the material, and gives it a new name
  27405. * @param name defines the new name for the duplicated material
  27406. * @returns the cloned material
  27407. */
  27408. clone(name: string): StandardMaterial;
  27409. /**
  27410. * Serializes this material in a JSON representation
  27411. * @returns the serialized material object
  27412. */
  27413. serialize(): any;
  27414. /**
  27415. * Creates a standard material from parsed material data
  27416. * @param source defines the JSON representation of the material
  27417. * @param scene defines the hosting scene
  27418. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27419. * @returns a new standard material
  27420. */
  27421. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27422. /**
  27423. * Are diffuse textures enabled in the application.
  27424. */
  27425. static get DiffuseTextureEnabled(): boolean;
  27426. static set DiffuseTextureEnabled(value: boolean);
  27427. /**
  27428. * Are ambient textures enabled in the application.
  27429. */
  27430. static get AmbientTextureEnabled(): boolean;
  27431. static set AmbientTextureEnabled(value: boolean);
  27432. /**
  27433. * Are opacity textures enabled in the application.
  27434. */
  27435. static get OpacityTextureEnabled(): boolean;
  27436. static set OpacityTextureEnabled(value: boolean);
  27437. /**
  27438. * Are reflection textures enabled in the application.
  27439. */
  27440. static get ReflectionTextureEnabled(): boolean;
  27441. static set ReflectionTextureEnabled(value: boolean);
  27442. /**
  27443. * Are emissive textures enabled in the application.
  27444. */
  27445. static get EmissiveTextureEnabled(): boolean;
  27446. static set EmissiveTextureEnabled(value: boolean);
  27447. /**
  27448. * Are specular textures enabled in the application.
  27449. */
  27450. static get SpecularTextureEnabled(): boolean;
  27451. static set SpecularTextureEnabled(value: boolean);
  27452. /**
  27453. * Are bump textures enabled in the application.
  27454. */
  27455. static get BumpTextureEnabled(): boolean;
  27456. static set BumpTextureEnabled(value: boolean);
  27457. /**
  27458. * Are lightmap textures enabled in the application.
  27459. */
  27460. static get LightmapTextureEnabled(): boolean;
  27461. static set LightmapTextureEnabled(value: boolean);
  27462. /**
  27463. * Are refraction textures enabled in the application.
  27464. */
  27465. static get RefractionTextureEnabled(): boolean;
  27466. static set RefractionTextureEnabled(value: boolean);
  27467. /**
  27468. * Are color grading textures enabled in the application.
  27469. */
  27470. static get ColorGradingTextureEnabled(): boolean;
  27471. static set ColorGradingTextureEnabled(value: boolean);
  27472. /**
  27473. * Are fresnels enabled in the application.
  27474. */
  27475. static get FresnelEnabled(): boolean;
  27476. static set FresnelEnabled(value: boolean);
  27477. }
  27478. }
  27479. declare module "babylonjs/Particles/solidParticleSystem" {
  27480. import { Nullable } from "babylonjs/types";
  27481. import { Vector3 } from "babylonjs/Maths/math.vector";
  27482. import { Mesh } from "babylonjs/Meshes/mesh";
  27483. import { Scene, IDisposable } from "babylonjs/scene";
  27484. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27485. import { Material } from "babylonjs/Materials/material";
  27486. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27487. /**
  27488. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27489. *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.
  27490. * The SPS is also a particle system. It provides some methods to manage the particles.
  27491. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27492. *
  27493. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27494. */
  27495. export class SolidParticleSystem implements IDisposable {
  27496. /**
  27497. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27498. * Example : var p = SPS.particles[i];
  27499. */
  27500. particles: SolidParticle[];
  27501. /**
  27502. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27503. */
  27504. nbParticles: number;
  27505. /**
  27506. * If the particles must ever face the camera (default false). Useful for planar particles.
  27507. */
  27508. billboard: boolean;
  27509. /**
  27510. * Recompute normals when adding a shape
  27511. */
  27512. recomputeNormals: boolean;
  27513. /**
  27514. * This a counter ofr your own usage. It's not set by any SPS functions.
  27515. */
  27516. counter: number;
  27517. /**
  27518. * The SPS name. This name is also given to the underlying mesh.
  27519. */
  27520. name: string;
  27521. /**
  27522. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27523. */
  27524. mesh: Mesh;
  27525. /**
  27526. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27527. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27528. */
  27529. vars: any;
  27530. /**
  27531. * This array is populated when the SPS is set as 'pickable'.
  27532. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27533. * Each element of this array is an object `{idx: int, faceId: int}`.
  27534. * `idx` is the picked particle index in the `SPS.particles` array
  27535. * `faceId` is the picked face index counted within this particle.
  27536. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27537. */
  27538. pickedParticles: {
  27539. idx: number;
  27540. faceId: number;
  27541. }[];
  27542. /**
  27543. * This array is populated when `enableDepthSort` is set to true.
  27544. * Each element of this array is an instance of the class DepthSortedParticle.
  27545. */
  27546. depthSortedParticles: DepthSortedParticle[];
  27547. /**
  27548. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27549. * @hidden
  27550. */
  27551. _bSphereOnly: boolean;
  27552. /**
  27553. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27554. * @hidden
  27555. */
  27556. _bSphereRadiusFactor: number;
  27557. private _scene;
  27558. private _positions;
  27559. private _indices;
  27560. private _normals;
  27561. private _colors;
  27562. private _uvs;
  27563. private _indices32;
  27564. private _positions32;
  27565. private _normals32;
  27566. private _fixedNormal32;
  27567. private _colors32;
  27568. private _uvs32;
  27569. private _index;
  27570. private _updatable;
  27571. private _pickable;
  27572. private _isVisibilityBoxLocked;
  27573. private _alwaysVisible;
  27574. private _depthSort;
  27575. private _expandable;
  27576. private _shapeCounter;
  27577. private _copy;
  27578. private _color;
  27579. private _computeParticleColor;
  27580. private _computeParticleTexture;
  27581. private _computeParticleRotation;
  27582. private _computeParticleVertex;
  27583. private _computeBoundingBox;
  27584. private _depthSortParticles;
  27585. private _camera;
  27586. private _mustUnrotateFixedNormals;
  27587. private _particlesIntersect;
  27588. private _needs32Bits;
  27589. private _isNotBuilt;
  27590. private _lastParticleId;
  27591. private _idxOfId;
  27592. private _multimaterialEnabled;
  27593. private _useModelMaterial;
  27594. private _indicesByMaterial;
  27595. private _materialIndexes;
  27596. private _depthSortFunction;
  27597. private _materialSortFunction;
  27598. private _materials;
  27599. private _multimaterial;
  27600. private _materialIndexesById;
  27601. private _defaultMaterial;
  27602. private _autoUpdateSubMeshes;
  27603. /**
  27604. * Creates a SPS (Solid Particle System) object.
  27605. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27606. * @param scene (Scene) is the scene in which the SPS is added.
  27607. * @param options defines the options of the sps e.g.
  27608. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27609. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27610. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27611. * * 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.
  27612. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27613. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27614. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27615. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27616. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27617. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27618. */
  27619. constructor(name: string, scene: Scene, options?: {
  27620. updatable?: boolean;
  27621. isPickable?: boolean;
  27622. enableDepthSort?: boolean;
  27623. particleIntersection?: boolean;
  27624. boundingSphereOnly?: boolean;
  27625. bSphereRadiusFactor?: number;
  27626. expandable?: boolean;
  27627. useModelMaterial?: boolean;
  27628. enableMultiMaterial?: boolean;
  27629. });
  27630. /**
  27631. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27632. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27633. * @returns the created mesh
  27634. */
  27635. buildMesh(): Mesh;
  27636. /**
  27637. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27638. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27639. * Thus the particles generated from `digest()` have their property `position` set yet.
  27640. * @param mesh ( Mesh ) is the mesh to be digested
  27641. * @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
  27642. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27643. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27644. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27645. * @returns the current SPS
  27646. */
  27647. digest(mesh: Mesh, options?: {
  27648. facetNb?: number;
  27649. number?: number;
  27650. delta?: number;
  27651. storage?: [];
  27652. }): SolidParticleSystem;
  27653. /**
  27654. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27655. * @hidden
  27656. */
  27657. private _unrotateFixedNormals;
  27658. /**
  27659. * Resets the temporary working copy particle
  27660. * @hidden
  27661. */
  27662. private _resetCopy;
  27663. /**
  27664. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27665. * @param p the current index in the positions array to be updated
  27666. * @param ind the current index in the indices array
  27667. * @param shape a Vector3 array, the shape geometry
  27668. * @param positions the positions array to be updated
  27669. * @param meshInd the shape indices array
  27670. * @param indices the indices array to be updated
  27671. * @param meshUV the shape uv array
  27672. * @param uvs the uv array to be updated
  27673. * @param meshCol the shape color array
  27674. * @param colors the color array to be updated
  27675. * @param meshNor the shape normals array
  27676. * @param normals the normals array to be updated
  27677. * @param idx the particle index
  27678. * @param idxInShape the particle index in its shape
  27679. * @param options the addShape() method passed options
  27680. * @model the particle model
  27681. * @hidden
  27682. */
  27683. private _meshBuilder;
  27684. /**
  27685. * Returns a shape Vector3 array from positions float array
  27686. * @param positions float array
  27687. * @returns a vector3 array
  27688. * @hidden
  27689. */
  27690. private _posToShape;
  27691. /**
  27692. * Returns a shapeUV array from a float uvs (array deep copy)
  27693. * @param uvs as a float array
  27694. * @returns a shapeUV array
  27695. * @hidden
  27696. */
  27697. private _uvsToShapeUV;
  27698. /**
  27699. * Adds a new particle object in the particles array
  27700. * @param idx particle index in particles array
  27701. * @param id particle id
  27702. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27703. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27704. * @param model particle ModelShape object
  27705. * @param shapeId model shape identifier
  27706. * @param idxInShape index of the particle in the current model
  27707. * @param bInfo model bounding info object
  27708. * @param storage target storage array, if any
  27709. * @hidden
  27710. */
  27711. private _addParticle;
  27712. /**
  27713. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27714. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27715. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27716. * @param nb (positive integer) the number of particles to be created from this model
  27717. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27718. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27719. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27720. * @returns the number of shapes in the system
  27721. */
  27722. addShape(mesh: Mesh, nb: number, options?: {
  27723. positionFunction?: any;
  27724. vertexFunction?: any;
  27725. storage?: [];
  27726. }): number;
  27727. /**
  27728. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27729. * @hidden
  27730. */
  27731. private _rebuildParticle;
  27732. /**
  27733. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27734. * @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.
  27735. * @returns the SPS.
  27736. */
  27737. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27738. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27739. * Returns an array with the removed particles.
  27740. * 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.
  27741. * The SPS can't be empty so at least one particle needs to remain in place.
  27742. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27743. * @param start index of the first particle to remove
  27744. * @param end index of the last particle to remove (included)
  27745. * @returns an array populated with the removed particles
  27746. */
  27747. removeParticles(start: number, end: number): SolidParticle[];
  27748. /**
  27749. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27750. * @param solidParticleArray an array populated with Solid Particles objects
  27751. * @returns the SPS
  27752. */
  27753. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27754. /**
  27755. * Creates a new particle and modifies the SPS mesh geometry :
  27756. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27757. * - calls _addParticle() to populate the particle array
  27758. * factorized code from addShape() and insertParticlesFromArray()
  27759. * @param idx particle index in the particles array
  27760. * @param i particle index in its shape
  27761. * @param modelShape particle ModelShape object
  27762. * @param shape shape vertex array
  27763. * @param meshInd shape indices array
  27764. * @param meshUV shape uv array
  27765. * @param meshCol shape color array
  27766. * @param meshNor shape normals array
  27767. * @param bbInfo shape bounding info
  27768. * @param storage target particle storage
  27769. * @options addShape() passed options
  27770. * @hidden
  27771. */
  27772. private _insertNewParticle;
  27773. /**
  27774. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27775. * This method calls `updateParticle()` for each particle of the SPS.
  27776. * For an animated SPS, it is usually called within the render loop.
  27777. * 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.
  27778. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27779. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27780. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27781. * @returns the SPS.
  27782. */
  27783. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27784. /**
  27785. * Disposes the SPS.
  27786. */
  27787. dispose(): void;
  27788. /**
  27789. * Returns a SolidParticle object from its identifier : particle.id
  27790. * @param id (integer) the particle Id
  27791. * @returns the searched particle or null if not found in the SPS.
  27792. */
  27793. getParticleById(id: number): Nullable<SolidParticle>;
  27794. /**
  27795. * Returns a new array populated with the particles having the passed shapeId.
  27796. * @param shapeId (integer) the shape identifier
  27797. * @returns a new solid particle array
  27798. */
  27799. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27800. /**
  27801. * Populates the passed array "ref" with the particles having the passed shapeId.
  27802. * @param shapeId the shape identifier
  27803. * @returns the SPS
  27804. * @param ref
  27805. */
  27806. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27807. /**
  27808. * Computes the required SubMeshes according the materials assigned to the particles.
  27809. * @returns the solid particle system.
  27810. * Does nothing if called before the SPS mesh is built.
  27811. */
  27812. computeSubMeshes(): SolidParticleSystem;
  27813. /**
  27814. * Sorts the solid particles by material when MultiMaterial is enabled.
  27815. * Updates the indices32 array.
  27816. * Updates the indicesByMaterial array.
  27817. * Updates the mesh indices array.
  27818. * @returns the SPS
  27819. * @hidden
  27820. */
  27821. private _sortParticlesByMaterial;
  27822. /**
  27823. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27824. * @hidden
  27825. */
  27826. private _setMaterialIndexesById;
  27827. /**
  27828. * Returns an array with unique values of Materials from the passed array
  27829. * @param array the material array to be checked and filtered
  27830. * @hidden
  27831. */
  27832. private _filterUniqueMaterialId;
  27833. /**
  27834. * Sets a new Standard Material as _defaultMaterial if not already set.
  27835. * @hidden
  27836. */
  27837. private _setDefaultMaterial;
  27838. /**
  27839. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27840. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27841. * @returns the SPS.
  27842. */
  27843. refreshVisibleSize(): SolidParticleSystem;
  27844. /**
  27845. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27846. * @param size the size (float) of the visibility box
  27847. * note : this doesn't lock the SPS mesh bounding box.
  27848. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27849. */
  27850. setVisibilityBox(size: number): void;
  27851. /**
  27852. * Gets whether the SPS as always visible or not
  27853. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27854. */
  27855. get isAlwaysVisible(): boolean;
  27856. /**
  27857. * Sets the SPS as always visible or not
  27858. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27859. */
  27860. set isAlwaysVisible(val: boolean);
  27861. /**
  27862. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27863. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27864. */
  27865. set isVisibilityBoxLocked(val: boolean);
  27866. /**
  27867. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27868. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27869. */
  27870. get isVisibilityBoxLocked(): boolean;
  27871. /**
  27872. * Tells to `setParticles()` to compute the particle rotations or not.
  27873. * Default value : true. The SPS is faster when it's set to false.
  27874. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27875. */
  27876. set computeParticleRotation(val: boolean);
  27877. /**
  27878. * Tells to `setParticles()` to compute the particle colors or not.
  27879. * Default value : true. The SPS is faster when it's set to false.
  27880. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27881. */
  27882. set computeParticleColor(val: boolean);
  27883. set computeParticleTexture(val: boolean);
  27884. /**
  27885. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27886. * Default value : false. The SPS is faster when it's set to false.
  27887. * Note : the particle custom vertex positions aren't stored values.
  27888. */
  27889. set computeParticleVertex(val: boolean);
  27890. /**
  27891. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27892. */
  27893. set computeBoundingBox(val: boolean);
  27894. /**
  27895. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27896. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27897. * Default : `true`
  27898. */
  27899. set depthSortParticles(val: boolean);
  27900. /**
  27901. * Gets if `setParticles()` computes the particle rotations or not.
  27902. * Default value : true. The SPS is faster when it's set to false.
  27903. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27904. */
  27905. get computeParticleRotation(): boolean;
  27906. /**
  27907. * Gets if `setParticles()` computes the particle colors or not.
  27908. * Default value : true. The SPS is faster when it's set to false.
  27909. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27910. */
  27911. get computeParticleColor(): boolean;
  27912. /**
  27913. * Gets if `setParticles()` computes the particle textures or not.
  27914. * Default value : true. The SPS is faster when it's set to false.
  27915. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27916. */
  27917. get computeParticleTexture(): boolean;
  27918. /**
  27919. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27920. * Default value : false. The SPS is faster when it's set to false.
  27921. * Note : the particle custom vertex positions aren't stored values.
  27922. */
  27923. get computeParticleVertex(): boolean;
  27924. /**
  27925. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27926. */
  27927. get computeBoundingBox(): boolean;
  27928. /**
  27929. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27930. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27931. * Default : `true`
  27932. */
  27933. get depthSortParticles(): boolean;
  27934. /**
  27935. * Gets if the SPS is created as expandable at construction time.
  27936. * Default : `false`
  27937. */
  27938. get expandable(): boolean;
  27939. /**
  27940. * Gets if the SPS supports the Multi Materials
  27941. */
  27942. get multimaterialEnabled(): boolean;
  27943. /**
  27944. * Gets if the SPS uses the model materials for its own multimaterial.
  27945. */
  27946. get useModelMaterial(): boolean;
  27947. /**
  27948. * The SPS used material array.
  27949. */
  27950. get materials(): Material[];
  27951. /**
  27952. * Sets the SPS MultiMaterial from the passed materials.
  27953. * Note : the passed array is internally copied and not used then by reference.
  27954. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27955. */
  27956. setMultiMaterial(materials: Material[]): void;
  27957. /**
  27958. * The SPS computed multimaterial object
  27959. */
  27960. get multimaterial(): MultiMaterial;
  27961. set multimaterial(mm: MultiMaterial);
  27962. /**
  27963. * If the subMeshes must be updated on the next call to setParticles()
  27964. */
  27965. get autoUpdateSubMeshes(): boolean;
  27966. set autoUpdateSubMeshes(val: boolean);
  27967. /**
  27968. * This function does nothing. It may be overwritten to set all the particle first values.
  27969. * The SPS doesn't call this function, you may have to call it by your own.
  27970. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27971. */
  27972. initParticles(): void;
  27973. /**
  27974. * This function does nothing. It may be overwritten to recycle a particle.
  27975. * The SPS doesn't call this function, you may have to call it by your own.
  27976. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27977. * @param particle The particle to recycle
  27978. * @returns the recycled particle
  27979. */
  27980. recycleParticle(particle: SolidParticle): SolidParticle;
  27981. /**
  27982. * Updates a particle : this function should be overwritten by the user.
  27983. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27984. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27985. * @example : just set a particle position or velocity and recycle conditions
  27986. * @param particle The particle to update
  27987. * @returns the updated particle
  27988. */
  27989. updateParticle(particle: SolidParticle): SolidParticle;
  27990. /**
  27991. * Updates a vertex of a particle : it can be overwritten by the user.
  27992. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27993. * @param particle the current particle
  27994. * @param vertex the current index of the current particle
  27995. * @param pt the index of the current vertex in the particle shape
  27996. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27997. * @example : just set a vertex particle position
  27998. * @returns the updated vertex
  27999. */
  28000. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28001. /**
  28002. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28003. * This does nothing and may be overwritten by the user.
  28004. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28005. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28006. * @param update the boolean update value actually passed to setParticles()
  28007. */
  28008. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28009. /**
  28010. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28011. * This will be passed three parameters.
  28012. * This does nothing and may be overwritten by the user.
  28013. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28014. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28015. * @param update the boolean update value actually passed to setParticles()
  28016. */
  28017. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28018. }
  28019. }
  28020. declare module "babylonjs/Particles/solidParticle" {
  28021. import { Nullable } from "babylonjs/types";
  28022. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28023. import { Color4 } from "babylonjs/Maths/math.color";
  28024. import { Mesh } from "babylonjs/Meshes/mesh";
  28025. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28026. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28027. import { Plane } from "babylonjs/Maths/math.plane";
  28028. import { Material } from "babylonjs/Materials/material";
  28029. /**
  28030. * Represents one particle of a solid particle system.
  28031. */
  28032. export class SolidParticle {
  28033. /**
  28034. * particle global index
  28035. */
  28036. idx: number;
  28037. /**
  28038. * particle identifier
  28039. */
  28040. id: number;
  28041. /**
  28042. * The color of the particle
  28043. */
  28044. color: Nullable<Color4>;
  28045. /**
  28046. * The world space position of the particle.
  28047. */
  28048. position: Vector3;
  28049. /**
  28050. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28051. */
  28052. rotation: Vector3;
  28053. /**
  28054. * The world space rotation quaternion of the particle.
  28055. */
  28056. rotationQuaternion: Nullable<Quaternion>;
  28057. /**
  28058. * The scaling of the particle.
  28059. */
  28060. scaling: Vector3;
  28061. /**
  28062. * The uvs of the particle.
  28063. */
  28064. uvs: Vector4;
  28065. /**
  28066. * The current speed of the particle.
  28067. */
  28068. velocity: Vector3;
  28069. /**
  28070. * The pivot point in the particle local space.
  28071. */
  28072. pivot: Vector3;
  28073. /**
  28074. * Must the particle be translated from its pivot point in its local space ?
  28075. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28076. * Default : false
  28077. */
  28078. translateFromPivot: boolean;
  28079. /**
  28080. * Is the particle active or not ?
  28081. */
  28082. alive: boolean;
  28083. /**
  28084. * Is the particle visible or not ?
  28085. */
  28086. isVisible: boolean;
  28087. /**
  28088. * Index of this particle in the global "positions" array (Internal use)
  28089. * @hidden
  28090. */
  28091. _pos: number;
  28092. /**
  28093. * @hidden Index of this particle in the global "indices" array (Internal use)
  28094. */
  28095. _ind: number;
  28096. /**
  28097. * @hidden ModelShape of this particle (Internal use)
  28098. */
  28099. _model: ModelShape;
  28100. /**
  28101. * ModelShape id of this particle
  28102. */
  28103. shapeId: number;
  28104. /**
  28105. * Index of the particle in its shape id
  28106. */
  28107. idxInShape: number;
  28108. /**
  28109. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28110. */
  28111. _modelBoundingInfo: BoundingInfo;
  28112. /**
  28113. * @hidden Particle BoundingInfo object (Internal use)
  28114. */
  28115. _boundingInfo: BoundingInfo;
  28116. /**
  28117. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28118. */
  28119. _sps: SolidParticleSystem;
  28120. /**
  28121. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28122. */
  28123. _stillInvisible: boolean;
  28124. /**
  28125. * @hidden Last computed particle rotation matrix
  28126. */
  28127. _rotationMatrix: number[];
  28128. /**
  28129. * Parent particle Id, if any.
  28130. * Default null.
  28131. */
  28132. parentId: Nullable<number>;
  28133. /**
  28134. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28135. */
  28136. materialIndex: Nullable<number>;
  28137. /**
  28138. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28139. * The possible values are :
  28140. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28141. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28142. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28143. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28144. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28145. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28146. * */
  28147. cullingStrategy: number;
  28148. /**
  28149. * @hidden Internal global position in the SPS.
  28150. */
  28151. _globalPosition: Vector3;
  28152. /**
  28153. * Creates a Solid Particle object.
  28154. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28155. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28156. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28157. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28158. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28159. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28160. * @param shapeId (integer) is the model shape identifier in the SPS.
  28161. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28162. * @param sps defines the sps it is associated to
  28163. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28164. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28165. */
  28166. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28167. /**
  28168. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28169. * @param target the particle target
  28170. * @returns the current particle
  28171. */
  28172. copyToRef(target: SolidParticle): SolidParticle;
  28173. /**
  28174. * Legacy support, changed scale to scaling
  28175. */
  28176. get scale(): Vector3;
  28177. /**
  28178. * Legacy support, changed scale to scaling
  28179. */
  28180. set scale(scale: Vector3);
  28181. /**
  28182. * Legacy support, changed quaternion to rotationQuaternion
  28183. */
  28184. get quaternion(): Nullable<Quaternion>;
  28185. /**
  28186. * Legacy support, changed quaternion to rotationQuaternion
  28187. */
  28188. set quaternion(q: Nullable<Quaternion>);
  28189. /**
  28190. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28191. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28192. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28193. * @returns true if it intersects
  28194. */
  28195. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28196. /**
  28197. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28198. * A particle is in the frustum if its bounding box intersects the frustum
  28199. * @param frustumPlanes defines the frustum to test
  28200. * @returns true if the particle is in the frustum planes
  28201. */
  28202. isInFrustum(frustumPlanes: Plane[]): boolean;
  28203. /**
  28204. * get the rotation matrix of the particle
  28205. * @hidden
  28206. */
  28207. getRotationMatrix(m: Matrix): void;
  28208. }
  28209. /**
  28210. * Represents the shape of the model used by one particle of a solid particle system.
  28211. * SPS internal tool, don't use it manually.
  28212. */
  28213. export class ModelShape {
  28214. /**
  28215. * The shape id
  28216. * @hidden
  28217. */
  28218. shapeID: number;
  28219. /**
  28220. * flat array of model positions (internal use)
  28221. * @hidden
  28222. */
  28223. _shape: Vector3[];
  28224. /**
  28225. * flat array of model UVs (internal use)
  28226. * @hidden
  28227. */
  28228. _shapeUV: number[];
  28229. /**
  28230. * color array of the model
  28231. * @hidden
  28232. */
  28233. _shapeColors: number[];
  28234. /**
  28235. * indices array of the model
  28236. * @hidden
  28237. */
  28238. _indices: number[];
  28239. /**
  28240. * normals array of the model
  28241. * @hidden
  28242. */
  28243. _normals: number[];
  28244. /**
  28245. * length of the shape in the model indices array (internal use)
  28246. * @hidden
  28247. */
  28248. _indicesLength: number;
  28249. /**
  28250. * Custom position function (internal use)
  28251. * @hidden
  28252. */
  28253. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28254. /**
  28255. * Custom vertex function (internal use)
  28256. * @hidden
  28257. */
  28258. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28259. /**
  28260. * Model material (internal use)
  28261. * @hidden
  28262. */
  28263. _material: Nullable<Material>;
  28264. /**
  28265. * 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.
  28266. * SPS internal tool, don't use it manually.
  28267. * @hidden
  28268. */
  28269. 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>);
  28270. }
  28271. /**
  28272. * Represents a Depth Sorted Particle in the solid particle system.
  28273. * @hidden
  28274. */
  28275. export class DepthSortedParticle {
  28276. /**
  28277. * Index of the particle in the "indices" array
  28278. */
  28279. ind: number;
  28280. /**
  28281. * Length of the particle shape in the "indices" array
  28282. */
  28283. indicesLength: number;
  28284. /**
  28285. * Squared distance from the particle to the camera
  28286. */
  28287. sqDistance: number;
  28288. /**
  28289. * Material index when used with MultiMaterials
  28290. */
  28291. materialIndex: number;
  28292. /**
  28293. * Creates a new sorted particle
  28294. * @param materialIndex
  28295. */
  28296. constructor(ind: number, indLength: number, materialIndex: number);
  28297. }
  28298. }
  28299. declare module "babylonjs/Collisions/meshCollisionData" {
  28300. import { Collider } from "babylonjs/Collisions/collider";
  28301. import { Vector3 } from "babylonjs/Maths/math.vector";
  28302. import { Nullable } from "babylonjs/types";
  28303. import { Observer } from "babylonjs/Misc/observable";
  28304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28305. /**
  28306. * @hidden
  28307. */
  28308. export class _MeshCollisionData {
  28309. _checkCollisions: boolean;
  28310. _collisionMask: number;
  28311. _collisionGroup: number;
  28312. _collider: Nullable<Collider>;
  28313. _oldPositionForCollisions: Vector3;
  28314. _diffPositionForCollisions: Vector3;
  28315. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28316. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28317. }
  28318. }
  28319. declare module "babylonjs/Meshes/abstractMesh" {
  28320. import { Observable } from "babylonjs/Misc/observable";
  28321. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28322. import { Camera } from "babylonjs/Cameras/camera";
  28323. import { Scene, IDisposable } from "babylonjs/scene";
  28324. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28325. import { Node } from "babylonjs/node";
  28326. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28327. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28328. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28329. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28330. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28331. import { Material } from "babylonjs/Materials/material";
  28332. import { Light } from "babylonjs/Lights/light";
  28333. import { Skeleton } from "babylonjs/Bones/skeleton";
  28334. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28335. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28336. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28337. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28338. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28339. import { Plane } from "babylonjs/Maths/math.plane";
  28340. import { Ray } from "babylonjs/Culling/ray";
  28341. import { Collider } from "babylonjs/Collisions/collider";
  28342. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28343. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28344. /** @hidden */
  28345. class _FacetDataStorage {
  28346. facetPositions: Vector3[];
  28347. facetNormals: Vector3[];
  28348. facetPartitioning: number[][];
  28349. facetNb: number;
  28350. partitioningSubdivisions: number;
  28351. partitioningBBoxRatio: number;
  28352. facetDataEnabled: boolean;
  28353. facetParameters: any;
  28354. bbSize: Vector3;
  28355. subDiv: {
  28356. max: number;
  28357. X: number;
  28358. Y: number;
  28359. Z: number;
  28360. };
  28361. facetDepthSort: boolean;
  28362. facetDepthSortEnabled: boolean;
  28363. depthSortedIndices: IndicesArray;
  28364. depthSortedFacets: {
  28365. ind: number;
  28366. sqDistance: number;
  28367. }[];
  28368. facetDepthSortFunction: (f1: {
  28369. ind: number;
  28370. sqDistance: number;
  28371. }, f2: {
  28372. ind: number;
  28373. sqDistance: number;
  28374. }) => number;
  28375. facetDepthSortFrom: Vector3;
  28376. facetDepthSortOrigin: Vector3;
  28377. invertedMatrix: Matrix;
  28378. }
  28379. /**
  28380. * @hidden
  28381. **/
  28382. class _InternalAbstractMeshDataInfo {
  28383. _hasVertexAlpha: boolean;
  28384. _useVertexColors: boolean;
  28385. _numBoneInfluencers: number;
  28386. _applyFog: boolean;
  28387. _receiveShadows: boolean;
  28388. _facetData: _FacetDataStorage;
  28389. _visibility: number;
  28390. _skeleton: Nullable<Skeleton>;
  28391. _layerMask: number;
  28392. _computeBonesUsingShaders: boolean;
  28393. _isActive: boolean;
  28394. _onlyForInstances: boolean;
  28395. _isActiveIntermediate: boolean;
  28396. _onlyForInstancesIntermediate: boolean;
  28397. _actAsRegularMesh: boolean;
  28398. }
  28399. /**
  28400. * Class used to store all common mesh properties
  28401. */
  28402. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28403. /** No occlusion */
  28404. static OCCLUSION_TYPE_NONE: number;
  28405. /** Occlusion set to optimisitic */
  28406. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28407. /** Occlusion set to strict */
  28408. static OCCLUSION_TYPE_STRICT: number;
  28409. /** Use an accurante occlusion algorithm */
  28410. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28411. /** Use a conservative occlusion algorithm */
  28412. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28413. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28414. * Test order :
  28415. * Is the bounding sphere outside the frustum ?
  28416. * If not, are the bounding box vertices outside the frustum ?
  28417. * It not, then the cullable object is in the frustum.
  28418. */
  28419. static readonly CULLINGSTRATEGY_STANDARD: number;
  28420. /** Culling strategy : Bounding Sphere Only.
  28421. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28422. * It's also less accurate than the standard because some not visible objects can still be selected.
  28423. * Test : is the bounding sphere outside the frustum ?
  28424. * If not, then the cullable object is in the frustum.
  28425. */
  28426. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28427. /** Culling strategy : Optimistic Inclusion.
  28428. * This in an inclusion test first, then the standard exclusion test.
  28429. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28430. * 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.
  28431. * Anyway, it's as accurate as the standard strategy.
  28432. * Test :
  28433. * Is the cullable object bounding sphere center in the frustum ?
  28434. * If not, apply the default culling strategy.
  28435. */
  28436. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28437. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28438. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28439. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28440. * 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.
  28441. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28442. * Test :
  28443. * Is the cullable object bounding sphere center in the frustum ?
  28444. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28445. */
  28446. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28447. /**
  28448. * No billboard
  28449. */
  28450. static get BILLBOARDMODE_NONE(): number;
  28451. /** Billboard on X axis */
  28452. static get BILLBOARDMODE_X(): number;
  28453. /** Billboard on Y axis */
  28454. static get BILLBOARDMODE_Y(): number;
  28455. /** Billboard on Z axis */
  28456. static get BILLBOARDMODE_Z(): number;
  28457. /** Billboard on all axes */
  28458. static get BILLBOARDMODE_ALL(): number;
  28459. /** Billboard on using position instead of orientation */
  28460. static get BILLBOARDMODE_USE_POSITION(): number;
  28461. /** @hidden */
  28462. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28463. /**
  28464. * The culling strategy to use to check whether the mesh must be rendered or not.
  28465. * This value can be changed at any time and will be used on the next render mesh selection.
  28466. * The possible values are :
  28467. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28468. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28469. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28470. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28471. * Please read each static variable documentation to get details about the culling process.
  28472. * */
  28473. cullingStrategy: number;
  28474. /**
  28475. * Gets the number of facets in the mesh
  28476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28477. */
  28478. get facetNb(): number;
  28479. /**
  28480. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28481. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28482. */
  28483. get partitioningSubdivisions(): number;
  28484. set partitioningSubdivisions(nb: number);
  28485. /**
  28486. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28487. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28489. */
  28490. get partitioningBBoxRatio(): number;
  28491. set partitioningBBoxRatio(ratio: number);
  28492. /**
  28493. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28494. * Works only for updatable meshes.
  28495. * Doesn't work with multi-materials
  28496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28497. */
  28498. get mustDepthSortFacets(): boolean;
  28499. set mustDepthSortFacets(sort: boolean);
  28500. /**
  28501. * The location (Vector3) where the facet depth sort must be computed from.
  28502. * By default, the active camera position.
  28503. * Used only when facet depth sort is enabled
  28504. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28505. */
  28506. get facetDepthSortFrom(): Vector3;
  28507. set facetDepthSortFrom(location: Vector3);
  28508. /**
  28509. * gets a boolean indicating if facetData is enabled
  28510. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28511. */
  28512. get isFacetDataEnabled(): boolean;
  28513. /** @hidden */
  28514. _updateNonUniformScalingState(value: boolean): boolean;
  28515. /**
  28516. * An event triggered when this mesh collides with another one
  28517. */
  28518. onCollideObservable: Observable<AbstractMesh>;
  28519. /** Set a function to call when this mesh collides with another one */
  28520. set onCollide(callback: () => void);
  28521. /**
  28522. * An event triggered when the collision's position changes
  28523. */
  28524. onCollisionPositionChangeObservable: Observable<Vector3>;
  28525. /** Set a function to call when the collision's position changes */
  28526. set onCollisionPositionChange(callback: () => void);
  28527. /**
  28528. * An event triggered when material is changed
  28529. */
  28530. onMaterialChangedObservable: Observable<AbstractMesh>;
  28531. /**
  28532. * Gets or sets the orientation for POV movement & rotation
  28533. */
  28534. definedFacingForward: boolean;
  28535. /** @hidden */
  28536. _occlusionQuery: Nullable<WebGLQuery>;
  28537. /** @hidden */
  28538. _renderingGroup: Nullable<RenderingGroup>;
  28539. /**
  28540. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28541. */
  28542. get visibility(): number;
  28543. /**
  28544. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28545. */
  28546. set visibility(value: number);
  28547. /** Gets or sets the alpha index used to sort transparent meshes
  28548. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28549. */
  28550. alphaIndex: number;
  28551. /**
  28552. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28553. */
  28554. isVisible: boolean;
  28555. /**
  28556. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28557. */
  28558. isPickable: boolean;
  28559. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28560. showSubMeshesBoundingBox: boolean;
  28561. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28562. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28563. */
  28564. isBlocker: boolean;
  28565. /**
  28566. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28567. */
  28568. enablePointerMoveEvents: boolean;
  28569. /**
  28570. * Specifies the rendering group id for this mesh (0 by default)
  28571. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28572. */
  28573. renderingGroupId: number;
  28574. private _material;
  28575. /** Gets or sets current material */
  28576. get material(): Nullable<Material>;
  28577. set material(value: Nullable<Material>);
  28578. /**
  28579. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28580. * @see http://doc.babylonjs.com/babylon101/shadows
  28581. */
  28582. get receiveShadows(): boolean;
  28583. set receiveShadows(value: boolean);
  28584. /** Defines color to use when rendering outline */
  28585. outlineColor: Color3;
  28586. /** Define width to use when rendering outline */
  28587. outlineWidth: number;
  28588. /** Defines color to use when rendering overlay */
  28589. overlayColor: Color3;
  28590. /** Defines alpha to use when rendering overlay */
  28591. overlayAlpha: number;
  28592. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28593. get hasVertexAlpha(): boolean;
  28594. set hasVertexAlpha(value: boolean);
  28595. /** 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) */
  28596. get useVertexColors(): boolean;
  28597. set useVertexColors(value: boolean);
  28598. /**
  28599. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28600. */
  28601. get computeBonesUsingShaders(): boolean;
  28602. set computeBonesUsingShaders(value: boolean);
  28603. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28604. get numBoneInfluencers(): number;
  28605. set numBoneInfluencers(value: number);
  28606. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28607. get applyFog(): boolean;
  28608. set applyFog(value: boolean);
  28609. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28610. useOctreeForRenderingSelection: boolean;
  28611. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28612. useOctreeForPicking: boolean;
  28613. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28614. useOctreeForCollisions: boolean;
  28615. /**
  28616. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28617. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28618. */
  28619. get layerMask(): number;
  28620. set layerMask(value: number);
  28621. /**
  28622. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28623. */
  28624. alwaysSelectAsActiveMesh: boolean;
  28625. /**
  28626. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28627. */
  28628. doNotSyncBoundingInfo: boolean;
  28629. /**
  28630. * Gets or sets the current action manager
  28631. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28632. */
  28633. actionManager: Nullable<AbstractActionManager>;
  28634. private _meshCollisionData;
  28635. /**
  28636. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28637. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28638. */
  28639. ellipsoid: Vector3;
  28640. /**
  28641. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28642. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28643. */
  28644. ellipsoidOffset: Vector3;
  28645. /**
  28646. * Gets or sets a collision mask used to mask collisions (default is -1).
  28647. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28648. */
  28649. get collisionMask(): number;
  28650. set collisionMask(mask: number);
  28651. /**
  28652. * Gets or sets the current collision group mask (-1 by default).
  28653. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28654. */
  28655. get collisionGroup(): number;
  28656. set collisionGroup(mask: number);
  28657. /**
  28658. * Defines edge width used when edgesRenderer is enabled
  28659. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28660. */
  28661. edgesWidth: number;
  28662. /**
  28663. * Defines edge color used when edgesRenderer is enabled
  28664. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28665. */
  28666. edgesColor: Color4;
  28667. /** @hidden */
  28668. _edgesRenderer: Nullable<IEdgesRenderer>;
  28669. /** @hidden */
  28670. _masterMesh: Nullable<AbstractMesh>;
  28671. /** @hidden */
  28672. _boundingInfo: Nullable<BoundingInfo>;
  28673. /** @hidden */
  28674. _renderId: number;
  28675. /**
  28676. * Gets or sets the list of subMeshes
  28677. * @see http://doc.babylonjs.com/how_to/multi_materials
  28678. */
  28679. subMeshes: SubMesh[];
  28680. /** @hidden */
  28681. _intersectionsInProgress: AbstractMesh[];
  28682. /** @hidden */
  28683. _unIndexed: boolean;
  28684. /** @hidden */
  28685. _lightSources: Light[];
  28686. /** Gets the list of lights affecting that mesh */
  28687. get lightSources(): Light[];
  28688. /** @hidden */
  28689. get _positions(): Nullable<Vector3[]>;
  28690. /** @hidden */
  28691. _waitingData: {
  28692. lods: Nullable<any>;
  28693. actions: Nullable<any>;
  28694. freezeWorldMatrix: Nullable<boolean>;
  28695. };
  28696. /** @hidden */
  28697. _bonesTransformMatrices: Nullable<Float32Array>;
  28698. /** @hidden */
  28699. _transformMatrixTexture: Nullable<RawTexture>;
  28700. /**
  28701. * Gets or sets a skeleton to apply skining transformations
  28702. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28703. */
  28704. set skeleton(value: Nullable<Skeleton>);
  28705. get skeleton(): Nullable<Skeleton>;
  28706. /**
  28707. * An event triggered when the mesh is rebuilt.
  28708. */
  28709. onRebuildObservable: Observable<AbstractMesh>;
  28710. /**
  28711. * Creates a new AbstractMesh
  28712. * @param name defines the name of the mesh
  28713. * @param scene defines the hosting scene
  28714. */
  28715. constructor(name: string, scene?: Nullable<Scene>);
  28716. /**
  28717. * Returns the string "AbstractMesh"
  28718. * @returns "AbstractMesh"
  28719. */
  28720. getClassName(): string;
  28721. /**
  28722. * Gets a string representation of the current mesh
  28723. * @param fullDetails defines a boolean indicating if full details must be included
  28724. * @returns a string representation of the current mesh
  28725. */
  28726. toString(fullDetails?: boolean): string;
  28727. /**
  28728. * @hidden
  28729. */
  28730. protected _getEffectiveParent(): Nullable<Node>;
  28731. /** @hidden */
  28732. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28733. /** @hidden */
  28734. _rebuild(): void;
  28735. /** @hidden */
  28736. _resyncLightSources(): void;
  28737. /** @hidden */
  28738. _resyncLightSource(light: Light): void;
  28739. /** @hidden */
  28740. _unBindEffect(): void;
  28741. /** @hidden */
  28742. _removeLightSource(light: Light, dispose: boolean): void;
  28743. private _markSubMeshesAsDirty;
  28744. /** @hidden */
  28745. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28746. /** @hidden */
  28747. _markSubMeshesAsAttributesDirty(): void;
  28748. /** @hidden */
  28749. _markSubMeshesAsMiscDirty(): void;
  28750. /**
  28751. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28752. */
  28753. get scaling(): Vector3;
  28754. set scaling(newScaling: Vector3);
  28755. /**
  28756. * Returns true if the mesh is blocked. Implemented by child classes
  28757. */
  28758. get isBlocked(): boolean;
  28759. /**
  28760. * Returns the mesh itself by default. Implemented by child classes
  28761. * @param camera defines the camera to use to pick the right LOD level
  28762. * @returns the currentAbstractMesh
  28763. */
  28764. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28765. /**
  28766. * Returns 0 by default. Implemented by child classes
  28767. * @returns an integer
  28768. */
  28769. getTotalVertices(): number;
  28770. /**
  28771. * Returns a positive integer : the total number of indices in this mesh geometry.
  28772. * @returns the numner of indices or zero if the mesh has no geometry.
  28773. */
  28774. getTotalIndices(): number;
  28775. /**
  28776. * Returns null by default. Implemented by child classes
  28777. * @returns null
  28778. */
  28779. getIndices(): Nullable<IndicesArray>;
  28780. /**
  28781. * Returns the array of the requested vertex data kind. Implemented by child classes
  28782. * @param kind defines the vertex data kind to use
  28783. * @returns null
  28784. */
  28785. getVerticesData(kind: string): Nullable<FloatArray>;
  28786. /**
  28787. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28788. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28789. * Note that a new underlying VertexBuffer object is created each call.
  28790. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28791. * @param kind defines vertex data kind:
  28792. * * VertexBuffer.PositionKind
  28793. * * VertexBuffer.UVKind
  28794. * * VertexBuffer.UV2Kind
  28795. * * VertexBuffer.UV3Kind
  28796. * * VertexBuffer.UV4Kind
  28797. * * VertexBuffer.UV5Kind
  28798. * * VertexBuffer.UV6Kind
  28799. * * VertexBuffer.ColorKind
  28800. * * VertexBuffer.MatricesIndicesKind
  28801. * * VertexBuffer.MatricesIndicesExtraKind
  28802. * * VertexBuffer.MatricesWeightsKind
  28803. * * VertexBuffer.MatricesWeightsExtraKind
  28804. * @param data defines the data source
  28805. * @param updatable defines if the data must be flagged as updatable (or static)
  28806. * @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
  28807. * @returns the current mesh
  28808. */
  28809. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28810. /**
  28811. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28812. * If the mesh has no geometry, it is simply returned as it is.
  28813. * @param kind defines vertex data kind:
  28814. * * VertexBuffer.PositionKind
  28815. * * VertexBuffer.UVKind
  28816. * * VertexBuffer.UV2Kind
  28817. * * VertexBuffer.UV3Kind
  28818. * * VertexBuffer.UV4Kind
  28819. * * VertexBuffer.UV5Kind
  28820. * * VertexBuffer.UV6Kind
  28821. * * VertexBuffer.ColorKind
  28822. * * VertexBuffer.MatricesIndicesKind
  28823. * * VertexBuffer.MatricesIndicesExtraKind
  28824. * * VertexBuffer.MatricesWeightsKind
  28825. * * VertexBuffer.MatricesWeightsExtraKind
  28826. * @param data defines the data source
  28827. * @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
  28828. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28829. * @returns the current mesh
  28830. */
  28831. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28832. /**
  28833. * Sets the mesh indices,
  28834. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28835. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28836. * @param totalVertices Defines the total number of vertices
  28837. * @returns the current mesh
  28838. */
  28839. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28840. /**
  28841. * Gets a boolean indicating if specific vertex data is present
  28842. * @param kind defines the vertex data kind to use
  28843. * @returns true is data kind is present
  28844. */
  28845. isVerticesDataPresent(kind: string): boolean;
  28846. /**
  28847. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28848. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28849. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28850. * @returns a BoundingInfo
  28851. */
  28852. getBoundingInfo(): BoundingInfo;
  28853. /**
  28854. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28855. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28856. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28857. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28858. * @returns the current mesh
  28859. */
  28860. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28861. /**
  28862. * Overwrite the current bounding info
  28863. * @param boundingInfo defines the new bounding info
  28864. * @returns the current mesh
  28865. */
  28866. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28867. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28868. get useBones(): boolean;
  28869. /** @hidden */
  28870. _preActivate(): void;
  28871. /** @hidden */
  28872. _preActivateForIntermediateRendering(renderId: number): void;
  28873. /** @hidden */
  28874. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28875. /** @hidden */
  28876. _postActivate(): void;
  28877. /** @hidden */
  28878. _freeze(): void;
  28879. /** @hidden */
  28880. _unFreeze(): void;
  28881. /**
  28882. * Gets the current world matrix
  28883. * @returns a Matrix
  28884. */
  28885. getWorldMatrix(): Matrix;
  28886. /** @hidden */
  28887. _getWorldMatrixDeterminant(): number;
  28888. /**
  28889. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28890. */
  28891. get isAnInstance(): boolean;
  28892. /**
  28893. * Gets a boolean indicating if this mesh has instances
  28894. */
  28895. get hasInstances(): boolean;
  28896. /**
  28897. * Perform relative position change from the point of view of behind the front of the mesh.
  28898. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28899. * Supports definition of mesh facing forward or backward
  28900. * @param amountRight defines the distance on the right axis
  28901. * @param amountUp defines the distance on the up axis
  28902. * @param amountForward defines the distance on the forward axis
  28903. * @returns the current mesh
  28904. */
  28905. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28906. /**
  28907. * Calculate relative position change from the point of view of behind the front of the mesh.
  28908. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28909. * Supports definition of mesh facing forward or backward
  28910. * @param amountRight defines the distance on the right axis
  28911. * @param amountUp defines the distance on the up axis
  28912. * @param amountForward defines the distance on the forward axis
  28913. * @returns the new displacement vector
  28914. */
  28915. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28916. /**
  28917. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28918. * Supports definition of mesh facing forward or backward
  28919. * @param flipBack defines the flip
  28920. * @param twirlClockwise defines the twirl
  28921. * @param tiltRight defines the tilt
  28922. * @returns the current mesh
  28923. */
  28924. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28925. /**
  28926. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28927. * Supports definition of mesh facing forward or backward.
  28928. * @param flipBack defines the flip
  28929. * @param twirlClockwise defines the twirl
  28930. * @param tiltRight defines the tilt
  28931. * @returns the new rotation vector
  28932. */
  28933. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28934. /**
  28935. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28936. * This means the mesh underlying bounding box and sphere are recomputed.
  28937. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28938. * @returns the current mesh
  28939. */
  28940. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28941. /** @hidden */
  28942. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28943. /** @hidden */
  28944. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28945. /** @hidden */
  28946. _updateBoundingInfo(): AbstractMesh;
  28947. /** @hidden */
  28948. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28949. /** @hidden */
  28950. protected _afterComputeWorldMatrix(): void;
  28951. /** @hidden */
  28952. get _effectiveMesh(): AbstractMesh;
  28953. /**
  28954. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28955. * A mesh is in the frustum if its bounding box intersects the frustum
  28956. * @param frustumPlanes defines the frustum to test
  28957. * @returns true if the mesh is in the frustum planes
  28958. */
  28959. isInFrustum(frustumPlanes: Plane[]): boolean;
  28960. /**
  28961. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28962. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28963. * @param frustumPlanes defines the frustum to test
  28964. * @returns true if the mesh is completely in the frustum planes
  28965. */
  28966. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28967. /**
  28968. * True if the mesh intersects another mesh or a SolidParticle object
  28969. * @param mesh defines a target mesh or SolidParticle to test
  28970. * @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)
  28971. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28972. * @returns true if there is an intersection
  28973. */
  28974. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28975. /**
  28976. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28977. * @param point defines the point to test
  28978. * @returns true if there is an intersection
  28979. */
  28980. intersectsPoint(point: Vector3): boolean;
  28981. /**
  28982. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28983. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28984. */
  28985. get checkCollisions(): boolean;
  28986. set checkCollisions(collisionEnabled: boolean);
  28987. /**
  28988. * Gets Collider object used to compute collisions (not physics)
  28989. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28990. */
  28991. get collider(): Nullable<Collider>;
  28992. /**
  28993. * Move the mesh using collision engine
  28994. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28995. * @param displacement defines the requested displacement vector
  28996. * @returns the current mesh
  28997. */
  28998. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28999. private _onCollisionPositionChange;
  29000. /** @hidden */
  29001. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29002. /** @hidden */
  29003. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29004. /** @hidden */
  29005. _checkCollision(collider: Collider): AbstractMesh;
  29006. /** @hidden */
  29007. _generatePointsArray(): boolean;
  29008. /**
  29009. * Checks if the passed Ray intersects with the mesh
  29010. * @param ray defines the ray to use
  29011. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29012. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29013. * @returns the picking info
  29014. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29015. */
  29016. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29017. /**
  29018. * Clones the current mesh
  29019. * @param name defines the mesh name
  29020. * @param newParent defines the new mesh parent
  29021. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29022. * @returns the new mesh
  29023. */
  29024. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29025. /**
  29026. * Disposes all the submeshes of the current meshnp
  29027. * @returns the current mesh
  29028. */
  29029. releaseSubMeshes(): AbstractMesh;
  29030. /**
  29031. * Releases resources associated with this abstract mesh.
  29032. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29033. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29034. */
  29035. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29036. /**
  29037. * Adds the passed mesh as a child to the current mesh
  29038. * @param mesh defines the child mesh
  29039. * @returns the current mesh
  29040. */
  29041. addChild(mesh: AbstractMesh): AbstractMesh;
  29042. /**
  29043. * Removes the passed mesh from the current mesh children list
  29044. * @param mesh defines the child mesh
  29045. * @returns the current mesh
  29046. */
  29047. removeChild(mesh: AbstractMesh): AbstractMesh;
  29048. /** @hidden */
  29049. private _initFacetData;
  29050. /**
  29051. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29052. * This method can be called within the render loop.
  29053. * 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
  29054. * @returns the current mesh
  29055. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29056. */
  29057. updateFacetData(): AbstractMesh;
  29058. /**
  29059. * Returns the facetLocalNormals array.
  29060. * The normals are expressed in the mesh local spac
  29061. * @returns an array of Vector3
  29062. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29063. */
  29064. getFacetLocalNormals(): Vector3[];
  29065. /**
  29066. * Returns the facetLocalPositions array.
  29067. * The facet positions are expressed in the mesh local space
  29068. * @returns an array of Vector3
  29069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29070. */
  29071. getFacetLocalPositions(): Vector3[];
  29072. /**
  29073. * Returns the facetLocalPartioning array
  29074. * @returns an array of array of numbers
  29075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29076. */
  29077. getFacetLocalPartitioning(): number[][];
  29078. /**
  29079. * Returns the i-th facet position in the world system.
  29080. * This method allocates a new Vector3 per call
  29081. * @param i defines the facet index
  29082. * @returns a new Vector3
  29083. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29084. */
  29085. getFacetPosition(i: number): Vector3;
  29086. /**
  29087. * Sets the reference Vector3 with the i-th facet position in the world system
  29088. * @param i defines the facet index
  29089. * @param ref defines the target vector
  29090. * @returns the current mesh
  29091. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29092. */
  29093. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29094. /**
  29095. * Returns the i-th facet normal in the world system.
  29096. * This method allocates a new Vector3 per call
  29097. * @param i defines the facet index
  29098. * @returns a new Vector3
  29099. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29100. */
  29101. getFacetNormal(i: number): Vector3;
  29102. /**
  29103. * Sets the reference Vector3 with the i-th facet normal in the world system
  29104. * @param i defines the facet index
  29105. * @param ref defines the target vector
  29106. * @returns the current mesh
  29107. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29108. */
  29109. getFacetNormalToRef(i: number, ref: Vector3): this;
  29110. /**
  29111. * 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)
  29112. * @param x defines x coordinate
  29113. * @param y defines y coordinate
  29114. * @param z defines z coordinate
  29115. * @returns the array of facet indexes
  29116. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29117. */
  29118. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29119. /**
  29120. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29121. * @param projected sets as the (x,y,z) world projection on the facet
  29122. * @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
  29123. * @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
  29124. * @param x defines x coordinate
  29125. * @param y defines y coordinate
  29126. * @param z defines z coordinate
  29127. * @returns the face index if found (or null instead)
  29128. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29129. */
  29130. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29131. /**
  29132. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29133. * @param projected sets as the (x,y,z) local projection on the facet
  29134. * @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
  29135. * @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
  29136. * @param x defines x coordinate
  29137. * @param y defines y coordinate
  29138. * @param z defines z coordinate
  29139. * @returns the face index if found (or null instead)
  29140. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29141. */
  29142. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29143. /**
  29144. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29145. * @returns the parameters
  29146. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29147. */
  29148. getFacetDataParameters(): any;
  29149. /**
  29150. * Disables the feature FacetData and frees the related memory
  29151. * @returns the current mesh
  29152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29153. */
  29154. disableFacetData(): AbstractMesh;
  29155. /**
  29156. * Updates the AbstractMesh indices array
  29157. * @param indices defines the data source
  29158. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29159. * @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)
  29160. * @returns the current mesh
  29161. */
  29162. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29163. /**
  29164. * Creates new normals data for the mesh
  29165. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29166. * @returns the current mesh
  29167. */
  29168. createNormals(updatable: boolean): AbstractMesh;
  29169. /**
  29170. * Align the mesh with a normal
  29171. * @param normal defines the normal to use
  29172. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29173. * @returns the current mesh
  29174. */
  29175. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29176. /** @hidden */
  29177. _checkOcclusionQuery(): boolean;
  29178. /**
  29179. * Disables the mesh edge rendering mode
  29180. * @returns the currentAbstractMesh
  29181. */
  29182. disableEdgesRendering(): AbstractMesh;
  29183. /**
  29184. * Enables the edge rendering mode on the mesh.
  29185. * This mode makes the mesh edges visible
  29186. * @param epsilon defines the maximal distance between two angles to detect a face
  29187. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29188. * @returns the currentAbstractMesh
  29189. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29190. */
  29191. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29192. }
  29193. }
  29194. declare module "babylonjs/Actions/actionEvent" {
  29195. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29196. import { Nullable } from "babylonjs/types";
  29197. import { Sprite } from "babylonjs/Sprites/sprite";
  29198. import { Scene } from "babylonjs/scene";
  29199. import { Vector2 } from "babylonjs/Maths/math.vector";
  29200. /**
  29201. * Interface used to define ActionEvent
  29202. */
  29203. export interface IActionEvent {
  29204. /** The mesh or sprite that triggered the action */
  29205. source: any;
  29206. /** The X mouse cursor position at the time of the event */
  29207. pointerX: number;
  29208. /** The Y mouse cursor position at the time of the event */
  29209. pointerY: number;
  29210. /** The mesh that is currently pointed at (can be null) */
  29211. meshUnderPointer: Nullable<AbstractMesh>;
  29212. /** the original (browser) event that triggered the ActionEvent */
  29213. sourceEvent?: any;
  29214. /** additional data for the event */
  29215. additionalData?: any;
  29216. }
  29217. /**
  29218. * ActionEvent is the event being sent when an action is triggered.
  29219. */
  29220. export class ActionEvent implements IActionEvent {
  29221. /** The mesh or sprite that triggered the action */
  29222. source: any;
  29223. /** The X mouse cursor position at the time of the event */
  29224. pointerX: number;
  29225. /** The Y mouse cursor position at the time of the event */
  29226. pointerY: number;
  29227. /** The mesh that is currently pointed at (can be null) */
  29228. meshUnderPointer: Nullable<AbstractMesh>;
  29229. /** the original (browser) event that triggered the ActionEvent */
  29230. sourceEvent?: any;
  29231. /** additional data for the event */
  29232. additionalData?: any;
  29233. /**
  29234. * Creates a new ActionEvent
  29235. * @param source The mesh or sprite that triggered the action
  29236. * @param pointerX The X mouse cursor position at the time of the event
  29237. * @param pointerY The Y mouse cursor position at the time of the event
  29238. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29239. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29240. * @param additionalData additional data for the event
  29241. */
  29242. constructor(
  29243. /** The mesh or sprite that triggered the action */
  29244. source: any,
  29245. /** The X mouse cursor position at the time of the event */
  29246. pointerX: number,
  29247. /** The Y mouse cursor position at the time of the event */
  29248. pointerY: number,
  29249. /** The mesh that is currently pointed at (can be null) */
  29250. meshUnderPointer: Nullable<AbstractMesh>,
  29251. /** the original (browser) event that triggered the ActionEvent */
  29252. sourceEvent?: any,
  29253. /** additional data for the event */
  29254. additionalData?: any);
  29255. /**
  29256. * Helper function to auto-create an ActionEvent from a source mesh.
  29257. * @param source The source mesh that triggered the event
  29258. * @param evt The original (browser) event
  29259. * @param additionalData additional data for the event
  29260. * @returns the new ActionEvent
  29261. */
  29262. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29263. /**
  29264. * Helper function to auto-create an ActionEvent from a source sprite
  29265. * @param source The source sprite that triggered the event
  29266. * @param scene Scene associated with the sprite
  29267. * @param evt The original (browser) event
  29268. * @param additionalData additional data for the event
  29269. * @returns the new ActionEvent
  29270. */
  29271. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29272. /**
  29273. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29274. * @param scene the scene where the event occurred
  29275. * @param evt The original (browser) event
  29276. * @returns the new ActionEvent
  29277. */
  29278. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29279. /**
  29280. * Helper function to auto-create an ActionEvent from a primitive
  29281. * @param prim defines the target primitive
  29282. * @param pointerPos defines the pointer position
  29283. * @param evt The original (browser) event
  29284. * @param additionalData additional data for the event
  29285. * @returns the new ActionEvent
  29286. */
  29287. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29288. }
  29289. }
  29290. declare module "babylonjs/Actions/abstractActionManager" {
  29291. import { IDisposable } from "babylonjs/scene";
  29292. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29293. import { IAction } from "babylonjs/Actions/action";
  29294. import { Nullable } from "babylonjs/types";
  29295. /**
  29296. * Abstract class used to decouple action Manager from scene and meshes.
  29297. * Do not instantiate.
  29298. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29299. */
  29300. export abstract class AbstractActionManager implements IDisposable {
  29301. /** Gets the list of active triggers */
  29302. static Triggers: {
  29303. [key: string]: number;
  29304. };
  29305. /** Gets the cursor to use when hovering items */
  29306. hoverCursor: string;
  29307. /** Gets the list of actions */
  29308. actions: IAction[];
  29309. /**
  29310. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29311. */
  29312. isRecursive: boolean;
  29313. /**
  29314. * Releases all associated resources
  29315. */
  29316. abstract dispose(): void;
  29317. /**
  29318. * Does this action manager has pointer triggers
  29319. */
  29320. abstract get hasPointerTriggers(): boolean;
  29321. /**
  29322. * Does this action manager has pick triggers
  29323. */
  29324. abstract get hasPickTriggers(): boolean;
  29325. /**
  29326. * Process a specific trigger
  29327. * @param trigger defines the trigger to process
  29328. * @param evt defines the event details to be processed
  29329. */
  29330. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29331. /**
  29332. * Does this action manager handles actions of any of the given triggers
  29333. * @param triggers defines the triggers to be tested
  29334. * @return a boolean indicating whether one (or more) of the triggers is handled
  29335. */
  29336. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29337. /**
  29338. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29339. * speed.
  29340. * @param triggerA defines the trigger to be tested
  29341. * @param triggerB defines the trigger to be tested
  29342. * @return a boolean indicating whether one (or more) of the triggers is handled
  29343. */
  29344. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29345. /**
  29346. * Does this action manager handles actions of a given trigger
  29347. * @param trigger defines the trigger to be tested
  29348. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29349. * @return whether the trigger is handled
  29350. */
  29351. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29352. /**
  29353. * Serialize this manager to a JSON object
  29354. * @param name defines the property name to store this manager
  29355. * @returns a JSON representation of this manager
  29356. */
  29357. abstract serialize(name: string): any;
  29358. /**
  29359. * Registers an action to this action manager
  29360. * @param action defines the action to be registered
  29361. * @return the action amended (prepared) after registration
  29362. */
  29363. abstract registerAction(action: IAction): Nullable<IAction>;
  29364. /**
  29365. * Unregisters an action to this action manager
  29366. * @param action defines the action to be unregistered
  29367. * @return a boolean indicating whether the action has been unregistered
  29368. */
  29369. abstract unregisterAction(action: IAction): Boolean;
  29370. /**
  29371. * Does exist one action manager with at least one trigger
  29372. **/
  29373. static get HasTriggers(): boolean;
  29374. /**
  29375. * Does exist one action manager with at least one pick trigger
  29376. **/
  29377. static get HasPickTriggers(): boolean;
  29378. /**
  29379. * Does exist one action manager that handles actions of a given trigger
  29380. * @param trigger defines the trigger to be tested
  29381. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29382. **/
  29383. static HasSpecificTrigger(trigger: number): boolean;
  29384. }
  29385. }
  29386. declare module "babylonjs/node" {
  29387. import { Scene } from "babylonjs/scene";
  29388. import { Nullable } from "babylonjs/types";
  29389. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29390. import { Engine } from "babylonjs/Engines/engine";
  29391. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29392. import { Observable } from "babylonjs/Misc/observable";
  29393. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29394. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29395. import { Animatable } from "babylonjs/Animations/animatable";
  29396. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29397. import { Animation } from "babylonjs/Animations/animation";
  29398. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29400. /**
  29401. * Defines how a node can be built from a string name.
  29402. */
  29403. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29404. /**
  29405. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29406. */
  29407. export class Node implements IBehaviorAware<Node> {
  29408. /** @hidden */
  29409. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29410. private static _NodeConstructors;
  29411. /**
  29412. * Add a new node constructor
  29413. * @param type defines the type name of the node to construct
  29414. * @param constructorFunc defines the constructor function
  29415. */
  29416. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29417. /**
  29418. * Returns a node constructor based on type name
  29419. * @param type defines the type name
  29420. * @param name defines the new node name
  29421. * @param scene defines the hosting scene
  29422. * @param options defines optional options to transmit to constructors
  29423. * @returns the new constructor or null
  29424. */
  29425. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29426. /**
  29427. * Gets or sets the name of the node
  29428. */
  29429. name: string;
  29430. /**
  29431. * Gets or sets the id of the node
  29432. */
  29433. id: string;
  29434. /**
  29435. * Gets or sets the unique id of the node
  29436. */
  29437. uniqueId: number;
  29438. /**
  29439. * Gets or sets a string used to store user defined state for the node
  29440. */
  29441. state: string;
  29442. /**
  29443. * Gets or sets an object used to store user defined information for the node
  29444. */
  29445. metadata: any;
  29446. /**
  29447. * For internal use only. Please do not use.
  29448. */
  29449. reservedDataStore: any;
  29450. /**
  29451. * List of inspectable custom properties (used by the Inspector)
  29452. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29453. */
  29454. inspectableCustomProperties: IInspectable[];
  29455. private _doNotSerialize;
  29456. /**
  29457. * Gets or sets a boolean used to define if the node must be serialized
  29458. */
  29459. get doNotSerialize(): boolean;
  29460. set doNotSerialize(value: boolean);
  29461. /** @hidden */
  29462. _isDisposed: boolean;
  29463. /**
  29464. * Gets a list of Animations associated with the node
  29465. */
  29466. animations: import("babylonjs/Animations/animation").Animation[];
  29467. protected _ranges: {
  29468. [name: string]: Nullable<AnimationRange>;
  29469. };
  29470. /**
  29471. * Callback raised when the node is ready to be used
  29472. */
  29473. onReady: Nullable<(node: Node) => void>;
  29474. private _isEnabled;
  29475. private _isParentEnabled;
  29476. private _isReady;
  29477. /** @hidden */
  29478. _currentRenderId: number;
  29479. private _parentUpdateId;
  29480. /** @hidden */
  29481. _childUpdateId: number;
  29482. /** @hidden */
  29483. _waitingParentId: Nullable<string>;
  29484. /** @hidden */
  29485. _scene: Scene;
  29486. /** @hidden */
  29487. _cache: any;
  29488. private _parentNode;
  29489. private _children;
  29490. /** @hidden */
  29491. _worldMatrix: Matrix;
  29492. /** @hidden */
  29493. _worldMatrixDeterminant: number;
  29494. /** @hidden */
  29495. _worldMatrixDeterminantIsDirty: boolean;
  29496. /** @hidden */
  29497. private _sceneRootNodesIndex;
  29498. /**
  29499. * Gets a boolean indicating if the node has been disposed
  29500. * @returns true if the node was disposed
  29501. */
  29502. isDisposed(): boolean;
  29503. /**
  29504. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29505. * @see https://doc.babylonjs.com/how_to/parenting
  29506. */
  29507. set parent(parent: Nullable<Node>);
  29508. get parent(): Nullable<Node>;
  29509. /** @hidden */
  29510. _addToSceneRootNodes(): void;
  29511. /** @hidden */
  29512. _removeFromSceneRootNodes(): void;
  29513. private _animationPropertiesOverride;
  29514. /**
  29515. * Gets or sets the animation properties override
  29516. */
  29517. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29518. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29519. /**
  29520. * Gets a string idenfifying the name of the class
  29521. * @returns "Node" string
  29522. */
  29523. getClassName(): string;
  29524. /** @hidden */
  29525. readonly _isNode: boolean;
  29526. /**
  29527. * An event triggered when the mesh is disposed
  29528. */
  29529. onDisposeObservable: Observable<Node>;
  29530. private _onDisposeObserver;
  29531. /**
  29532. * Sets a callback that will be raised when the node will be disposed
  29533. */
  29534. set onDispose(callback: () => void);
  29535. /**
  29536. * Creates a new Node
  29537. * @param name the name and id to be given to this node
  29538. * @param scene the scene this node will be added to
  29539. */
  29540. constructor(name: string, scene?: Nullable<Scene>);
  29541. /**
  29542. * Gets the scene of the node
  29543. * @returns a scene
  29544. */
  29545. getScene(): Scene;
  29546. /**
  29547. * Gets the engine of the node
  29548. * @returns a Engine
  29549. */
  29550. getEngine(): Engine;
  29551. private _behaviors;
  29552. /**
  29553. * Attach a behavior to the node
  29554. * @see http://doc.babylonjs.com/features/behaviour
  29555. * @param behavior defines the behavior to attach
  29556. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29557. * @returns the current Node
  29558. */
  29559. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29560. /**
  29561. * Remove an attached behavior
  29562. * @see http://doc.babylonjs.com/features/behaviour
  29563. * @param behavior defines the behavior to attach
  29564. * @returns the current Node
  29565. */
  29566. removeBehavior(behavior: Behavior<Node>): Node;
  29567. /**
  29568. * Gets the list of attached behaviors
  29569. * @see http://doc.babylonjs.com/features/behaviour
  29570. */
  29571. get behaviors(): Behavior<Node>[];
  29572. /**
  29573. * Gets an attached behavior by name
  29574. * @param name defines the name of the behavior to look for
  29575. * @see http://doc.babylonjs.com/features/behaviour
  29576. * @returns null if behavior was not found else the requested behavior
  29577. */
  29578. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29579. /**
  29580. * Returns the latest update of the World matrix
  29581. * @returns a Matrix
  29582. */
  29583. getWorldMatrix(): Matrix;
  29584. /** @hidden */
  29585. _getWorldMatrixDeterminant(): number;
  29586. /**
  29587. * Returns directly the latest state of the mesh World matrix.
  29588. * A Matrix is returned.
  29589. */
  29590. get worldMatrixFromCache(): Matrix;
  29591. /** @hidden */
  29592. _initCache(): void;
  29593. /** @hidden */
  29594. updateCache(force?: boolean): void;
  29595. /** @hidden */
  29596. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29597. /** @hidden */
  29598. _updateCache(ignoreParentClass?: boolean): void;
  29599. /** @hidden */
  29600. _isSynchronized(): boolean;
  29601. /** @hidden */
  29602. _markSyncedWithParent(): void;
  29603. /** @hidden */
  29604. isSynchronizedWithParent(): boolean;
  29605. /** @hidden */
  29606. isSynchronized(): boolean;
  29607. /**
  29608. * Is this node ready to be used/rendered
  29609. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29610. * @return true if the node is ready
  29611. */
  29612. isReady(completeCheck?: boolean): boolean;
  29613. /**
  29614. * Is this node enabled?
  29615. * 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
  29616. * @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
  29617. * @return whether this node (and its parent) is enabled
  29618. */
  29619. isEnabled(checkAncestors?: boolean): boolean;
  29620. /** @hidden */
  29621. protected _syncParentEnabledState(): void;
  29622. /**
  29623. * Set the enabled state of this node
  29624. * @param value defines the new enabled state
  29625. */
  29626. setEnabled(value: boolean): void;
  29627. /**
  29628. * Is this node a descendant of the given node?
  29629. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29630. * @param ancestor defines the parent node to inspect
  29631. * @returns a boolean indicating if this node is a descendant of the given node
  29632. */
  29633. isDescendantOf(ancestor: Node): boolean;
  29634. /** @hidden */
  29635. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29636. /**
  29637. * Will return all nodes that have this node as ascendant
  29638. * @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
  29639. * @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
  29640. * @return all children nodes of all types
  29641. */
  29642. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29643. /**
  29644. * Get all child-meshes of this node
  29645. * @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)
  29646. * @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
  29647. * @returns an array of AbstractMesh
  29648. */
  29649. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29650. /**
  29651. * Get all direct children of this node
  29652. * @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
  29653. * @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)
  29654. * @returns an array of Node
  29655. */
  29656. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29657. /** @hidden */
  29658. _setReady(state: boolean): void;
  29659. /**
  29660. * Get an animation by name
  29661. * @param name defines the name of the animation to look for
  29662. * @returns null if not found else the requested animation
  29663. */
  29664. getAnimationByName(name: string): Nullable<Animation>;
  29665. /**
  29666. * Creates an animation range for this node
  29667. * @param name defines the name of the range
  29668. * @param from defines the starting key
  29669. * @param to defines the end key
  29670. */
  29671. createAnimationRange(name: string, from: number, to: number): void;
  29672. /**
  29673. * Delete a specific animation range
  29674. * @param name defines the name of the range to delete
  29675. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29676. */
  29677. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29678. /**
  29679. * Get an animation range by name
  29680. * @param name defines the name of the animation range to look for
  29681. * @returns null if not found else the requested animation range
  29682. */
  29683. getAnimationRange(name: string): Nullable<AnimationRange>;
  29684. /**
  29685. * Gets the list of all animation ranges defined on this node
  29686. * @returns an array
  29687. */
  29688. getAnimationRanges(): Nullable<AnimationRange>[];
  29689. /**
  29690. * Will start the animation sequence
  29691. * @param name defines the range frames for animation sequence
  29692. * @param loop defines if the animation should loop (false by default)
  29693. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29694. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29695. * @returns the object created for this animation. If range does not exist, it will return null
  29696. */
  29697. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29698. /**
  29699. * Serialize animation ranges into a JSON compatible object
  29700. * @returns serialization object
  29701. */
  29702. serializeAnimationRanges(): any;
  29703. /**
  29704. * Computes the world matrix of the node
  29705. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29706. * @returns the world matrix
  29707. */
  29708. computeWorldMatrix(force?: boolean): Matrix;
  29709. /**
  29710. * Releases resources associated with this node.
  29711. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29712. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29713. */
  29714. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29715. /**
  29716. * Parse animation range data from a serialization object and store them into a given node
  29717. * @param node defines where to store the animation ranges
  29718. * @param parsedNode defines the serialization object to read data from
  29719. * @param scene defines the hosting scene
  29720. */
  29721. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29722. /**
  29723. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29724. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29725. * @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
  29726. * @returns the new bounding vectors
  29727. */
  29728. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29729. min: Vector3;
  29730. max: Vector3;
  29731. };
  29732. }
  29733. }
  29734. declare module "babylonjs/Animations/animation" {
  29735. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29736. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29737. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29738. import { Nullable } from "babylonjs/types";
  29739. import { Scene } from "babylonjs/scene";
  29740. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29741. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29742. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29743. import { Node } from "babylonjs/node";
  29744. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29745. import { Size } from "babylonjs/Maths/math.size";
  29746. import { Animatable } from "babylonjs/Animations/animatable";
  29747. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29748. /**
  29749. * @hidden
  29750. */
  29751. export class _IAnimationState {
  29752. key: number;
  29753. repeatCount: number;
  29754. workValue?: any;
  29755. loopMode?: number;
  29756. offsetValue?: any;
  29757. highLimitValue?: any;
  29758. }
  29759. /**
  29760. * Class used to store any kind of animation
  29761. */
  29762. export class Animation {
  29763. /**Name of the animation */
  29764. name: string;
  29765. /**Property to animate */
  29766. targetProperty: string;
  29767. /**The frames per second of the animation */
  29768. framePerSecond: number;
  29769. /**The data type of the animation */
  29770. dataType: number;
  29771. /**The loop mode of the animation */
  29772. loopMode?: number | undefined;
  29773. /**Specifies if blending should be enabled */
  29774. enableBlending?: boolean | undefined;
  29775. /**
  29776. * Use matrix interpolation instead of using direct key value when animating matrices
  29777. */
  29778. static AllowMatricesInterpolation: boolean;
  29779. /**
  29780. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29781. */
  29782. static AllowMatrixDecomposeForInterpolation: boolean;
  29783. /**
  29784. * Stores the key frames of the animation
  29785. */
  29786. private _keys;
  29787. /**
  29788. * Stores the easing function of the animation
  29789. */
  29790. private _easingFunction;
  29791. /**
  29792. * @hidden Internal use only
  29793. */
  29794. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  29795. /**
  29796. * The set of event that will be linked to this animation
  29797. */
  29798. private _events;
  29799. /**
  29800. * Stores an array of target property paths
  29801. */
  29802. targetPropertyPath: string[];
  29803. /**
  29804. * Stores the blending speed of the animation
  29805. */
  29806. blendingSpeed: number;
  29807. /**
  29808. * Stores the animation ranges for the animation
  29809. */
  29810. private _ranges;
  29811. /**
  29812. * @hidden Internal use
  29813. */
  29814. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29815. /**
  29816. * Sets up an animation
  29817. * @param property The property to animate
  29818. * @param animationType The animation type to apply
  29819. * @param framePerSecond The frames per second of the animation
  29820. * @param easingFunction The easing function used in the animation
  29821. * @returns The created animation
  29822. */
  29823. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29824. /**
  29825. * Create and start an animation on a node
  29826. * @param name defines the name of the global animation that will be run on all nodes
  29827. * @param node defines the root node where the animation will take place
  29828. * @param targetProperty defines property to animate
  29829. * @param framePerSecond defines the number of frame per second yo use
  29830. * @param totalFrame defines the number of frames in total
  29831. * @param from defines the initial value
  29832. * @param to defines the final value
  29833. * @param loopMode defines which loop mode you want to use (off by default)
  29834. * @param easingFunction defines the easing function to use (linear by default)
  29835. * @param onAnimationEnd defines the callback to call when animation end
  29836. * @returns the animatable created for this animation
  29837. */
  29838. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29839. /**
  29840. * Create and start an animation on a node and its descendants
  29841. * @param name defines the name of the global animation that will be run on all nodes
  29842. * @param node defines the root node where the animation will take place
  29843. * @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
  29844. * @param targetProperty defines property to animate
  29845. * @param framePerSecond defines the number of frame per second to use
  29846. * @param totalFrame defines the number of frames in total
  29847. * @param from defines the initial value
  29848. * @param to defines the final value
  29849. * @param loopMode defines which loop mode you want to use (off by default)
  29850. * @param easingFunction defines the easing function to use (linear by default)
  29851. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29852. * @returns the list of animatables created for all nodes
  29853. * @example https://www.babylonjs-playground.com/#MH0VLI
  29854. */
  29855. 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[]>;
  29856. /**
  29857. * Creates a new animation, merges it with the existing animations and starts it
  29858. * @param name Name of the animation
  29859. * @param node Node which contains the scene that begins the animations
  29860. * @param targetProperty Specifies which property to animate
  29861. * @param framePerSecond The frames per second of the animation
  29862. * @param totalFrame The total number of frames
  29863. * @param from The frame at the beginning of the animation
  29864. * @param to The frame at the end of the animation
  29865. * @param loopMode Specifies the loop mode of the animation
  29866. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29867. * @param onAnimationEnd Callback to run once the animation is complete
  29868. * @returns Nullable animation
  29869. */
  29870. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29871. /**
  29872. * Transition property of an host to the target Value
  29873. * @param property The property to transition
  29874. * @param targetValue The target Value of the property
  29875. * @param host The object where the property to animate belongs
  29876. * @param scene Scene used to run the animation
  29877. * @param frameRate Framerate (in frame/s) to use
  29878. * @param transition The transition type we want to use
  29879. * @param duration The duration of the animation, in milliseconds
  29880. * @param onAnimationEnd Callback trigger at the end of the animation
  29881. * @returns Nullable animation
  29882. */
  29883. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29884. /**
  29885. * Return the array of runtime animations currently using this animation
  29886. */
  29887. get runtimeAnimations(): RuntimeAnimation[];
  29888. /**
  29889. * Specifies if any of the runtime animations are currently running
  29890. */
  29891. get hasRunningRuntimeAnimations(): boolean;
  29892. /**
  29893. * Initializes the animation
  29894. * @param name Name of the animation
  29895. * @param targetProperty Property to animate
  29896. * @param framePerSecond The frames per second of the animation
  29897. * @param dataType The data type of the animation
  29898. * @param loopMode The loop mode of the animation
  29899. * @param enableBlending Specifies if blending should be enabled
  29900. */
  29901. constructor(
  29902. /**Name of the animation */
  29903. name: string,
  29904. /**Property to animate */
  29905. targetProperty: string,
  29906. /**The frames per second of the animation */
  29907. framePerSecond: number,
  29908. /**The data type of the animation */
  29909. dataType: number,
  29910. /**The loop mode of the animation */
  29911. loopMode?: number | undefined,
  29912. /**Specifies if blending should be enabled */
  29913. enableBlending?: boolean | undefined);
  29914. /**
  29915. * Converts the animation to a string
  29916. * @param fullDetails support for multiple levels of logging within scene loading
  29917. * @returns String form of the animation
  29918. */
  29919. toString(fullDetails?: boolean): string;
  29920. /**
  29921. * Add an event to this animation
  29922. * @param event Event to add
  29923. */
  29924. addEvent(event: AnimationEvent): void;
  29925. /**
  29926. * Remove all events found at the given frame
  29927. * @param frame The frame to remove events from
  29928. */
  29929. removeEvents(frame: number): void;
  29930. /**
  29931. * Retrieves all the events from the animation
  29932. * @returns Events from the animation
  29933. */
  29934. getEvents(): AnimationEvent[];
  29935. /**
  29936. * Creates an animation range
  29937. * @param name Name of the animation range
  29938. * @param from Starting frame of the animation range
  29939. * @param to Ending frame of the animation
  29940. */
  29941. createRange(name: string, from: number, to: number): void;
  29942. /**
  29943. * Deletes an animation range by name
  29944. * @param name Name of the animation range to delete
  29945. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29946. */
  29947. deleteRange(name: string, deleteFrames?: boolean): void;
  29948. /**
  29949. * Gets the animation range by name, or null if not defined
  29950. * @param name Name of the animation range
  29951. * @returns Nullable animation range
  29952. */
  29953. getRange(name: string): Nullable<AnimationRange>;
  29954. /**
  29955. * Gets the key frames from the animation
  29956. * @returns The key frames of the animation
  29957. */
  29958. getKeys(): Array<IAnimationKey>;
  29959. /**
  29960. * Gets the highest frame rate of the animation
  29961. * @returns Highest frame rate of the animation
  29962. */
  29963. getHighestFrame(): number;
  29964. /**
  29965. * Gets the easing function of the animation
  29966. * @returns Easing function of the animation
  29967. */
  29968. getEasingFunction(): IEasingFunction;
  29969. /**
  29970. * Sets the easing function of the animation
  29971. * @param easingFunction A custom mathematical formula for animation
  29972. */
  29973. setEasingFunction(easingFunction: EasingFunction): void;
  29974. /**
  29975. * Interpolates a scalar linearly
  29976. * @param startValue Start value of the animation curve
  29977. * @param endValue End value of the animation curve
  29978. * @param gradient Scalar amount to interpolate
  29979. * @returns Interpolated scalar value
  29980. */
  29981. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29982. /**
  29983. * Interpolates a scalar cubically
  29984. * @param startValue Start value of the animation curve
  29985. * @param outTangent End tangent of the animation
  29986. * @param endValue End value of the animation curve
  29987. * @param inTangent Start tangent of the animation curve
  29988. * @param gradient Scalar amount to interpolate
  29989. * @returns Interpolated scalar value
  29990. */
  29991. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29992. /**
  29993. * Interpolates a quaternion using a spherical linear interpolation
  29994. * @param startValue Start value of the animation curve
  29995. * @param endValue End value of the animation curve
  29996. * @param gradient Scalar amount to interpolate
  29997. * @returns Interpolated quaternion value
  29998. */
  29999. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30000. /**
  30001. * Interpolates a quaternion cubically
  30002. * @param startValue Start value of the animation curve
  30003. * @param outTangent End tangent of the animation curve
  30004. * @param endValue End value of the animation curve
  30005. * @param inTangent Start tangent of the animation curve
  30006. * @param gradient Scalar amount to interpolate
  30007. * @returns Interpolated quaternion value
  30008. */
  30009. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30010. /**
  30011. * Interpolates a Vector3 linearl
  30012. * @param startValue Start value of the animation curve
  30013. * @param endValue End value of the animation curve
  30014. * @param gradient Scalar amount to interpolate
  30015. * @returns Interpolated scalar value
  30016. */
  30017. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30018. /**
  30019. * Interpolates a Vector3 cubically
  30020. * @param startValue Start value of the animation curve
  30021. * @param outTangent End tangent of the animation
  30022. * @param endValue End value of the animation curve
  30023. * @param inTangent Start tangent of the animation curve
  30024. * @param gradient Scalar amount to interpolate
  30025. * @returns InterpolatedVector3 value
  30026. */
  30027. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30028. /**
  30029. * Interpolates a Vector2 linearly
  30030. * @param startValue Start value of the animation curve
  30031. * @param endValue End value of the animation curve
  30032. * @param gradient Scalar amount to interpolate
  30033. * @returns Interpolated Vector2 value
  30034. */
  30035. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30036. /**
  30037. * Interpolates a Vector2 cubically
  30038. * @param startValue Start value of the animation curve
  30039. * @param outTangent End tangent of the animation
  30040. * @param endValue End value of the animation curve
  30041. * @param inTangent Start tangent of the animation curve
  30042. * @param gradient Scalar amount to interpolate
  30043. * @returns Interpolated Vector2 value
  30044. */
  30045. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30046. /**
  30047. * Interpolates a size linearly
  30048. * @param startValue Start value of the animation curve
  30049. * @param endValue End value of the animation curve
  30050. * @param gradient Scalar amount to interpolate
  30051. * @returns Interpolated Size value
  30052. */
  30053. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30054. /**
  30055. * Interpolates a Color3 linearly
  30056. * @param startValue Start value of the animation curve
  30057. * @param endValue End value of the animation curve
  30058. * @param gradient Scalar amount to interpolate
  30059. * @returns Interpolated Color3 value
  30060. */
  30061. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30062. /**
  30063. * Interpolates a Color4 linearly
  30064. * @param startValue Start value of the animation curve
  30065. * @param endValue End value of the animation curve
  30066. * @param gradient Scalar amount to interpolate
  30067. * @returns Interpolated Color3 value
  30068. */
  30069. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30070. /**
  30071. * @hidden Internal use only
  30072. */
  30073. _getKeyValue(value: any): any;
  30074. /**
  30075. * @hidden Internal use only
  30076. */
  30077. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30078. /**
  30079. * Defines the function to use to interpolate matrices
  30080. * @param startValue defines the start matrix
  30081. * @param endValue defines the end matrix
  30082. * @param gradient defines the gradient between both matrices
  30083. * @param result defines an optional target matrix where to store the interpolation
  30084. * @returns the interpolated matrix
  30085. */
  30086. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30087. /**
  30088. * Makes a copy of the animation
  30089. * @returns Cloned animation
  30090. */
  30091. clone(): Animation;
  30092. /**
  30093. * Sets the key frames of the animation
  30094. * @param values The animation key frames to set
  30095. */
  30096. setKeys(values: Array<IAnimationKey>): void;
  30097. /**
  30098. * Serializes the animation to an object
  30099. * @returns Serialized object
  30100. */
  30101. serialize(): any;
  30102. /**
  30103. * Float animation type
  30104. */
  30105. static readonly ANIMATIONTYPE_FLOAT: number;
  30106. /**
  30107. * Vector3 animation type
  30108. */
  30109. static readonly ANIMATIONTYPE_VECTOR3: number;
  30110. /**
  30111. * Quaternion animation type
  30112. */
  30113. static readonly ANIMATIONTYPE_QUATERNION: number;
  30114. /**
  30115. * Matrix animation type
  30116. */
  30117. static readonly ANIMATIONTYPE_MATRIX: number;
  30118. /**
  30119. * Color3 animation type
  30120. */
  30121. static readonly ANIMATIONTYPE_COLOR3: number;
  30122. /**
  30123. * Color3 animation type
  30124. */
  30125. static readonly ANIMATIONTYPE_COLOR4: number;
  30126. /**
  30127. * Vector2 animation type
  30128. */
  30129. static readonly ANIMATIONTYPE_VECTOR2: number;
  30130. /**
  30131. * Size animation type
  30132. */
  30133. static readonly ANIMATIONTYPE_SIZE: number;
  30134. /**
  30135. * Relative Loop Mode
  30136. */
  30137. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30138. /**
  30139. * Cycle Loop Mode
  30140. */
  30141. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30142. /**
  30143. * Constant Loop Mode
  30144. */
  30145. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30146. /** @hidden */
  30147. static _UniversalLerp(left: any, right: any, amount: number): any;
  30148. /**
  30149. * Parses an animation object and creates an animation
  30150. * @param parsedAnimation Parsed animation object
  30151. * @returns Animation object
  30152. */
  30153. static Parse(parsedAnimation: any): Animation;
  30154. /**
  30155. * Appends the serialized animations from the source animations
  30156. * @param source Source containing the animations
  30157. * @param destination Target to store the animations
  30158. */
  30159. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30160. }
  30161. }
  30162. declare module "babylonjs/Animations/animatable.interface" {
  30163. import { Nullable } from "babylonjs/types";
  30164. import { Animation } from "babylonjs/Animations/animation";
  30165. /**
  30166. * Interface containing an array of animations
  30167. */
  30168. export interface IAnimatable {
  30169. /**
  30170. * Array of animations
  30171. */
  30172. animations: Nullable<Array<Animation>>;
  30173. }
  30174. }
  30175. declare module "babylonjs/Misc/decorators" {
  30176. import { Nullable } from "babylonjs/types";
  30177. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30178. import { Scene } from "babylonjs/scene";
  30179. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30180. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30181. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30182. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30183. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30184. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30185. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30186. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30187. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30188. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30189. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30190. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30191. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30192. /**
  30193. * Decorator used to define property that can be serialized as reference to a camera
  30194. * @param sourceName defines the name of the property to decorate
  30195. */
  30196. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30197. /**
  30198. * Class used to help serialization objects
  30199. */
  30200. export class SerializationHelper {
  30201. /** @hidden */
  30202. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30203. /** @hidden */
  30204. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30205. /** @hidden */
  30206. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30207. /** @hidden */
  30208. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30209. /**
  30210. * Appends the serialized animations from the source animations
  30211. * @param source Source containing the animations
  30212. * @param destination Target to store the animations
  30213. */
  30214. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30215. /**
  30216. * Static function used to serialized a specific entity
  30217. * @param entity defines the entity to serialize
  30218. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30219. * @returns a JSON compatible object representing the serialization of the entity
  30220. */
  30221. static Serialize<T>(entity: T, serializationObject?: any): any;
  30222. /**
  30223. * Creates a new entity from a serialization data object
  30224. * @param creationFunction defines a function used to instanciated the new entity
  30225. * @param source defines the source serialization data
  30226. * @param scene defines the hosting scene
  30227. * @param rootUrl defines the root url for resources
  30228. * @returns a new entity
  30229. */
  30230. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30231. /**
  30232. * Clones an object
  30233. * @param creationFunction defines the function used to instanciate the new object
  30234. * @param source defines the source object
  30235. * @returns the cloned object
  30236. */
  30237. static Clone<T>(creationFunction: () => T, source: T): T;
  30238. /**
  30239. * Instanciates a new object based on a source one (some data will be shared between both object)
  30240. * @param creationFunction defines the function used to instanciate the new object
  30241. * @param source defines the source object
  30242. * @returns the new object
  30243. */
  30244. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30245. }
  30246. }
  30247. declare module "babylonjs/Misc/guid" {
  30248. /**
  30249. * Class used to manipulate GUIDs
  30250. */
  30251. export class GUID {
  30252. /**
  30253. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30254. * Be aware Math.random() could cause collisions, but:
  30255. * "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"
  30256. * @returns a pseudo random id
  30257. */
  30258. static RandomId(): string;
  30259. }
  30260. }
  30261. declare module "babylonjs/Materials/Textures/baseTexture" {
  30262. import { Observable } from "babylonjs/Misc/observable";
  30263. import { Nullable } from "babylonjs/types";
  30264. import { Scene } from "babylonjs/scene";
  30265. import { Matrix } from "babylonjs/Maths/math.vector";
  30266. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30267. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30268. import { ISize } from "babylonjs/Maths/math.size";
  30269. import "babylonjs/Misc/fileTools";
  30270. /**
  30271. * Base class of all the textures in babylon.
  30272. * It groups all the common properties the materials, post process, lights... might need
  30273. * in order to make a correct use of the texture.
  30274. */
  30275. export class BaseTexture implements IAnimatable {
  30276. /**
  30277. * Default anisotropic filtering level for the application.
  30278. * It is set to 4 as a good tradeoff between perf and quality.
  30279. */
  30280. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30281. /**
  30282. * Gets or sets the unique id of the texture
  30283. */
  30284. uniqueId: number;
  30285. /**
  30286. * Define the name of the texture.
  30287. */
  30288. name: string;
  30289. /**
  30290. * Gets or sets an object used to store user defined information.
  30291. */
  30292. metadata: any;
  30293. /**
  30294. * For internal use only. Please do not use.
  30295. */
  30296. reservedDataStore: any;
  30297. private _hasAlpha;
  30298. /**
  30299. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30300. */
  30301. set hasAlpha(value: boolean);
  30302. get hasAlpha(): boolean;
  30303. /**
  30304. * Defines if the alpha value should be determined via the rgb values.
  30305. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30306. */
  30307. getAlphaFromRGB: boolean;
  30308. /**
  30309. * Intensity or strength of the texture.
  30310. * It is commonly used by materials to fine tune the intensity of the texture
  30311. */
  30312. level: number;
  30313. /**
  30314. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30315. * This is part of the texture as textures usually maps to one uv set.
  30316. */
  30317. coordinatesIndex: number;
  30318. private _coordinatesMode;
  30319. /**
  30320. * How a texture is mapped.
  30321. *
  30322. * | Value | Type | Description |
  30323. * | ----- | ----------------------------------- | ----------- |
  30324. * | 0 | EXPLICIT_MODE | |
  30325. * | 1 | SPHERICAL_MODE | |
  30326. * | 2 | PLANAR_MODE | |
  30327. * | 3 | CUBIC_MODE | |
  30328. * | 4 | PROJECTION_MODE | |
  30329. * | 5 | SKYBOX_MODE | |
  30330. * | 6 | INVCUBIC_MODE | |
  30331. * | 7 | EQUIRECTANGULAR_MODE | |
  30332. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30333. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30334. */
  30335. set coordinatesMode(value: number);
  30336. get coordinatesMode(): number;
  30337. /**
  30338. * | Value | Type | Description |
  30339. * | ----- | ------------------ | ----------- |
  30340. * | 0 | CLAMP_ADDRESSMODE | |
  30341. * | 1 | WRAP_ADDRESSMODE | |
  30342. * | 2 | MIRROR_ADDRESSMODE | |
  30343. */
  30344. wrapU: number;
  30345. /**
  30346. * | Value | Type | Description |
  30347. * | ----- | ------------------ | ----------- |
  30348. * | 0 | CLAMP_ADDRESSMODE | |
  30349. * | 1 | WRAP_ADDRESSMODE | |
  30350. * | 2 | MIRROR_ADDRESSMODE | |
  30351. */
  30352. wrapV: number;
  30353. /**
  30354. * | Value | Type | Description |
  30355. * | ----- | ------------------ | ----------- |
  30356. * | 0 | CLAMP_ADDRESSMODE | |
  30357. * | 1 | WRAP_ADDRESSMODE | |
  30358. * | 2 | MIRROR_ADDRESSMODE | |
  30359. */
  30360. wrapR: number;
  30361. /**
  30362. * With compliant hardware and browser (supporting anisotropic filtering)
  30363. * this defines the level of anisotropic filtering in the texture.
  30364. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30365. */
  30366. anisotropicFilteringLevel: number;
  30367. /**
  30368. * Define if the texture is a cube texture or if false a 2d texture.
  30369. */
  30370. get isCube(): boolean;
  30371. set isCube(value: boolean);
  30372. /**
  30373. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30374. */
  30375. get is3D(): boolean;
  30376. set is3D(value: boolean);
  30377. /**
  30378. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30379. */
  30380. get is2DArray(): boolean;
  30381. set is2DArray(value: boolean);
  30382. /**
  30383. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30384. * HDR texture are usually stored in linear space.
  30385. * This only impacts the PBR and Background materials
  30386. */
  30387. gammaSpace: boolean;
  30388. /**
  30389. * Gets or sets whether or not the texture contains RGBD data.
  30390. */
  30391. get isRGBD(): boolean;
  30392. set isRGBD(value: boolean);
  30393. /**
  30394. * Is Z inverted in the texture (useful in a cube texture).
  30395. */
  30396. invertZ: boolean;
  30397. /**
  30398. * Are mip maps generated for this texture or not.
  30399. */
  30400. get noMipmap(): boolean;
  30401. /**
  30402. * @hidden
  30403. */
  30404. lodLevelInAlpha: boolean;
  30405. /**
  30406. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30407. */
  30408. get lodGenerationOffset(): number;
  30409. set lodGenerationOffset(value: number);
  30410. /**
  30411. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30412. */
  30413. get lodGenerationScale(): number;
  30414. set lodGenerationScale(value: number);
  30415. /**
  30416. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30417. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30418. * average roughness values.
  30419. */
  30420. get linearSpecularLOD(): boolean;
  30421. set linearSpecularLOD(value: boolean);
  30422. /**
  30423. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30424. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30425. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30426. */
  30427. get irradianceTexture(): Nullable<BaseTexture>;
  30428. set irradianceTexture(value: Nullable<BaseTexture>);
  30429. /**
  30430. * Define if the texture is a render target.
  30431. */
  30432. isRenderTarget: boolean;
  30433. /**
  30434. * Define the unique id of the texture in the scene.
  30435. */
  30436. get uid(): string;
  30437. /**
  30438. * Return a string representation of the texture.
  30439. * @returns the texture as a string
  30440. */
  30441. toString(): string;
  30442. /**
  30443. * Get the class name of the texture.
  30444. * @returns "BaseTexture"
  30445. */
  30446. getClassName(): string;
  30447. /**
  30448. * Define the list of animation attached to the texture.
  30449. */
  30450. animations: import("babylonjs/Animations/animation").Animation[];
  30451. /**
  30452. * An event triggered when the texture is disposed.
  30453. */
  30454. onDisposeObservable: Observable<BaseTexture>;
  30455. private _onDisposeObserver;
  30456. /**
  30457. * Callback triggered when the texture has been disposed.
  30458. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30459. */
  30460. set onDispose(callback: () => void);
  30461. /**
  30462. * Define the current state of the loading sequence when in delayed load mode.
  30463. */
  30464. delayLoadState: number;
  30465. private _scene;
  30466. /** @hidden */
  30467. _texture: Nullable<InternalTexture>;
  30468. private _uid;
  30469. /**
  30470. * Define if the texture is preventinga material to render or not.
  30471. * If not and the texture is not ready, the engine will use a default black texture instead.
  30472. */
  30473. get isBlocking(): boolean;
  30474. /**
  30475. * Instantiates a new BaseTexture.
  30476. * Base class of all the textures in babylon.
  30477. * It groups all the common properties the materials, post process, lights... might need
  30478. * in order to make a correct use of the texture.
  30479. * @param scene Define the scene the texture blongs to
  30480. */
  30481. constructor(scene: Nullable<Scene>);
  30482. /**
  30483. * Get the scene the texture belongs to.
  30484. * @returns the scene or null if undefined
  30485. */
  30486. getScene(): Nullable<Scene>;
  30487. /**
  30488. * Get the texture transform matrix used to offset tile the texture for istance.
  30489. * @returns the transformation matrix
  30490. */
  30491. getTextureMatrix(): Matrix;
  30492. /**
  30493. * Get the texture reflection matrix used to rotate/transform the reflection.
  30494. * @returns the reflection matrix
  30495. */
  30496. getReflectionTextureMatrix(): Matrix;
  30497. /**
  30498. * Get the underlying lower level texture from Babylon.
  30499. * @returns the insternal texture
  30500. */
  30501. getInternalTexture(): Nullable<InternalTexture>;
  30502. /**
  30503. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30504. * @returns true if ready or not blocking
  30505. */
  30506. isReadyOrNotBlocking(): boolean;
  30507. /**
  30508. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30509. * @returns true if fully ready
  30510. */
  30511. isReady(): boolean;
  30512. private _cachedSize;
  30513. /**
  30514. * Get the size of the texture.
  30515. * @returns the texture size.
  30516. */
  30517. getSize(): ISize;
  30518. /**
  30519. * Get the base size of the texture.
  30520. * It can be different from the size if the texture has been resized for POT for instance
  30521. * @returns the base size
  30522. */
  30523. getBaseSize(): ISize;
  30524. /**
  30525. * Update the sampling mode of the texture.
  30526. * Default is Trilinear mode.
  30527. *
  30528. * | Value | Type | Description |
  30529. * | ----- | ------------------ | ----------- |
  30530. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30531. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30532. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30533. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30534. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30535. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30536. * | 7 | NEAREST_LINEAR | |
  30537. * | 8 | NEAREST_NEAREST | |
  30538. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30539. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30540. * | 11 | LINEAR_LINEAR | |
  30541. * | 12 | LINEAR_NEAREST | |
  30542. *
  30543. * > _mag_: magnification filter (close to the viewer)
  30544. * > _min_: minification filter (far from the viewer)
  30545. * > _mip_: filter used between mip map levels
  30546. *@param samplingMode Define the new sampling mode of the texture
  30547. */
  30548. updateSamplingMode(samplingMode: number): void;
  30549. /**
  30550. * Scales the texture if is `canRescale()`
  30551. * @param ratio the resize factor we want to use to rescale
  30552. */
  30553. scale(ratio: number): void;
  30554. /**
  30555. * Get if the texture can rescale.
  30556. */
  30557. get canRescale(): boolean;
  30558. /** @hidden */
  30559. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30560. /** @hidden */
  30561. _rebuild(): void;
  30562. /**
  30563. * Triggers the load sequence in delayed load mode.
  30564. */
  30565. delayLoad(): void;
  30566. /**
  30567. * Clones the texture.
  30568. * @returns the cloned texture
  30569. */
  30570. clone(): Nullable<BaseTexture>;
  30571. /**
  30572. * Get the texture underlying type (INT, FLOAT...)
  30573. */
  30574. get textureType(): number;
  30575. /**
  30576. * Get the texture underlying format (RGB, RGBA...)
  30577. */
  30578. get textureFormat(): number;
  30579. /**
  30580. * Indicates that textures need to be re-calculated for all materials
  30581. */
  30582. protected _markAllSubMeshesAsTexturesDirty(): void;
  30583. /**
  30584. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30585. * This will returns an RGBA array buffer containing either in values (0-255) or
  30586. * float values (0-1) depending of the underlying buffer type.
  30587. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30588. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30589. * @param buffer defines a user defined buffer to fill with data (can be null)
  30590. * @returns The Array buffer containing the pixels data.
  30591. */
  30592. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30593. /**
  30594. * Release and destroy the underlying lower level texture aka internalTexture.
  30595. */
  30596. releaseInternalTexture(): void;
  30597. /** @hidden */
  30598. get _lodTextureHigh(): Nullable<BaseTexture>;
  30599. /** @hidden */
  30600. get _lodTextureMid(): Nullable<BaseTexture>;
  30601. /** @hidden */
  30602. get _lodTextureLow(): Nullable<BaseTexture>;
  30603. /**
  30604. * Dispose the texture and release its associated resources.
  30605. */
  30606. dispose(): void;
  30607. /**
  30608. * Serialize the texture into a JSON representation that can be parsed later on.
  30609. * @returns the JSON representation of the texture
  30610. */
  30611. serialize(): any;
  30612. /**
  30613. * Helper function to be called back once a list of texture contains only ready textures.
  30614. * @param textures Define the list of textures to wait for
  30615. * @param callback Define the callback triggered once the entire list will be ready
  30616. */
  30617. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30618. }
  30619. }
  30620. declare module "babylonjs/Materials/effect" {
  30621. import { Observable } from "babylonjs/Misc/observable";
  30622. import { Nullable } from "babylonjs/types";
  30623. import { IDisposable } from "babylonjs/scene";
  30624. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30625. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30626. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30627. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30628. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30629. import { Engine } from "babylonjs/Engines/engine";
  30630. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30631. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30632. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30633. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30634. /**
  30635. * Options to be used when creating an effect.
  30636. */
  30637. export interface IEffectCreationOptions {
  30638. /**
  30639. * Atrributes that will be used in the shader.
  30640. */
  30641. attributes: string[];
  30642. /**
  30643. * Uniform varible names that will be set in the shader.
  30644. */
  30645. uniformsNames: string[];
  30646. /**
  30647. * Uniform buffer variable names that will be set in the shader.
  30648. */
  30649. uniformBuffersNames: string[];
  30650. /**
  30651. * Sampler texture variable names that will be set in the shader.
  30652. */
  30653. samplers: string[];
  30654. /**
  30655. * Define statements that will be set in the shader.
  30656. */
  30657. defines: any;
  30658. /**
  30659. * Possible fallbacks for this effect to improve performance when needed.
  30660. */
  30661. fallbacks: Nullable<IEffectFallbacks>;
  30662. /**
  30663. * Callback that will be called when the shader is compiled.
  30664. */
  30665. onCompiled: Nullable<(effect: Effect) => void>;
  30666. /**
  30667. * Callback that will be called if an error occurs during shader compilation.
  30668. */
  30669. onError: Nullable<(effect: Effect, errors: string) => void>;
  30670. /**
  30671. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30672. */
  30673. indexParameters?: any;
  30674. /**
  30675. * Max number of lights that can be used in the shader.
  30676. */
  30677. maxSimultaneousLights?: number;
  30678. /**
  30679. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30680. */
  30681. transformFeedbackVaryings?: Nullable<string[]>;
  30682. }
  30683. /**
  30684. * Effect containing vertex and fragment shader that can be executed on an object.
  30685. */
  30686. export class Effect implements IDisposable {
  30687. /**
  30688. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30689. */
  30690. static ShadersRepository: string;
  30691. /**
  30692. * Name of the effect.
  30693. */
  30694. name: any;
  30695. /**
  30696. * String container all the define statements that should be set on the shader.
  30697. */
  30698. defines: string;
  30699. /**
  30700. * Callback that will be called when the shader is compiled.
  30701. */
  30702. onCompiled: Nullable<(effect: Effect) => void>;
  30703. /**
  30704. * Callback that will be called if an error occurs during shader compilation.
  30705. */
  30706. onError: Nullable<(effect: Effect, errors: string) => void>;
  30707. /**
  30708. * Callback that will be called when effect is bound.
  30709. */
  30710. onBind: Nullable<(effect: Effect) => void>;
  30711. /**
  30712. * Unique ID of the effect.
  30713. */
  30714. uniqueId: number;
  30715. /**
  30716. * Observable that will be called when the shader is compiled.
  30717. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30718. */
  30719. onCompileObservable: Observable<Effect>;
  30720. /**
  30721. * Observable that will be called if an error occurs during shader compilation.
  30722. */
  30723. onErrorObservable: Observable<Effect>;
  30724. /** @hidden */
  30725. _onBindObservable: Nullable<Observable<Effect>>;
  30726. /**
  30727. * @hidden
  30728. * Specifies if the effect was previously ready
  30729. */
  30730. _wasPreviouslyReady: boolean;
  30731. /**
  30732. * Observable that will be called when effect is bound.
  30733. */
  30734. get onBindObservable(): Observable<Effect>;
  30735. /** @hidden */
  30736. _bonesComputationForcedToCPU: boolean;
  30737. private static _uniqueIdSeed;
  30738. private _engine;
  30739. private _uniformBuffersNames;
  30740. private _uniformsNames;
  30741. private _samplerList;
  30742. private _samplers;
  30743. private _isReady;
  30744. private _compilationError;
  30745. private _allFallbacksProcessed;
  30746. private _attributesNames;
  30747. private _attributes;
  30748. private _attributeLocationByName;
  30749. private _uniforms;
  30750. /**
  30751. * Key for the effect.
  30752. * @hidden
  30753. */
  30754. _key: string;
  30755. private _indexParameters;
  30756. private _fallbacks;
  30757. private _vertexSourceCode;
  30758. private _fragmentSourceCode;
  30759. private _vertexSourceCodeOverride;
  30760. private _fragmentSourceCodeOverride;
  30761. private _transformFeedbackVaryings;
  30762. /**
  30763. * Compiled shader to webGL program.
  30764. * @hidden
  30765. */
  30766. _pipelineContext: Nullable<IPipelineContext>;
  30767. private _valueCache;
  30768. private static _baseCache;
  30769. /**
  30770. * Instantiates an effect.
  30771. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30772. * @param baseName Name of the effect.
  30773. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30774. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30775. * @param samplers List of sampler variables that will be passed to the shader.
  30776. * @param engine Engine to be used to render the effect
  30777. * @param defines Define statements to be added to the shader.
  30778. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30779. * @param onCompiled Callback that will be called when the shader is compiled.
  30780. * @param onError Callback that will be called if an error occurs during shader compilation.
  30781. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30782. */
  30783. 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);
  30784. private _useFinalCode;
  30785. /**
  30786. * Unique key for this effect
  30787. */
  30788. get key(): string;
  30789. /**
  30790. * If the effect has been compiled and prepared.
  30791. * @returns if the effect is compiled and prepared.
  30792. */
  30793. isReady(): boolean;
  30794. private _isReadyInternal;
  30795. /**
  30796. * The engine the effect was initialized with.
  30797. * @returns the engine.
  30798. */
  30799. getEngine(): Engine;
  30800. /**
  30801. * The pipeline context for this effect
  30802. * @returns the associated pipeline context
  30803. */
  30804. getPipelineContext(): Nullable<IPipelineContext>;
  30805. /**
  30806. * The set of names of attribute variables for the shader.
  30807. * @returns An array of attribute names.
  30808. */
  30809. getAttributesNames(): string[];
  30810. /**
  30811. * Returns the attribute at the given index.
  30812. * @param index The index of the attribute.
  30813. * @returns The location of the attribute.
  30814. */
  30815. getAttributeLocation(index: number): number;
  30816. /**
  30817. * Returns the attribute based on the name of the variable.
  30818. * @param name of the attribute to look up.
  30819. * @returns the attribute location.
  30820. */
  30821. getAttributeLocationByName(name: string): number;
  30822. /**
  30823. * The number of attributes.
  30824. * @returns the numnber of attributes.
  30825. */
  30826. getAttributesCount(): number;
  30827. /**
  30828. * Gets the index of a uniform variable.
  30829. * @param uniformName of the uniform to look up.
  30830. * @returns the index.
  30831. */
  30832. getUniformIndex(uniformName: string): number;
  30833. /**
  30834. * Returns the attribute based on the name of the variable.
  30835. * @param uniformName of the uniform to look up.
  30836. * @returns the location of the uniform.
  30837. */
  30838. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30839. /**
  30840. * Returns an array of sampler variable names
  30841. * @returns The array of sampler variable neames.
  30842. */
  30843. getSamplers(): string[];
  30844. /**
  30845. * The error from the last compilation.
  30846. * @returns the error string.
  30847. */
  30848. getCompilationError(): string;
  30849. /**
  30850. * Gets a boolean indicating that all fallbacks were used during compilation
  30851. * @returns true if all fallbacks were used
  30852. */
  30853. allFallbacksProcessed(): boolean;
  30854. /**
  30855. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30856. * @param func The callback to be used.
  30857. */
  30858. executeWhenCompiled(func: (effect: Effect) => void): void;
  30859. private _checkIsReady;
  30860. private _loadShader;
  30861. /**
  30862. * Recompiles the webGL program
  30863. * @param vertexSourceCode The source code for the vertex shader.
  30864. * @param fragmentSourceCode The source code for the fragment shader.
  30865. * @param onCompiled Callback called when completed.
  30866. * @param onError Callback called on error.
  30867. * @hidden
  30868. */
  30869. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30870. /**
  30871. * Prepares the effect
  30872. * @hidden
  30873. */
  30874. _prepareEffect(): void;
  30875. private _processCompilationErrors;
  30876. /**
  30877. * Checks if the effect is supported. (Must be called after compilation)
  30878. */
  30879. get isSupported(): boolean;
  30880. /**
  30881. * Binds a texture to the engine to be used as output of the shader.
  30882. * @param channel Name of the output variable.
  30883. * @param texture Texture to bind.
  30884. * @hidden
  30885. */
  30886. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30887. /**
  30888. * Sets a texture on the engine to be used in the shader.
  30889. * @param channel Name of the sampler variable.
  30890. * @param texture Texture to set.
  30891. */
  30892. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30893. /**
  30894. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30895. * @param channel Name of the sampler variable.
  30896. * @param texture Texture to set.
  30897. */
  30898. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30899. /**
  30900. * Sets an array of textures on the engine to be used in the shader.
  30901. * @param channel Name of the variable.
  30902. * @param textures Textures to set.
  30903. */
  30904. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30905. /**
  30906. * 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)
  30907. * @param channel Name of the sampler variable.
  30908. * @param postProcess Post process to get the input texture from.
  30909. */
  30910. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30911. /**
  30912. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30913. * 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)
  30914. * @param channel Name of the sampler variable.
  30915. * @param postProcess Post process to get the output texture from.
  30916. */
  30917. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30918. /** @hidden */
  30919. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30920. /** @hidden */
  30921. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30922. /** @hidden */
  30923. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30924. /** @hidden */
  30925. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30926. /**
  30927. * Binds a buffer to a uniform.
  30928. * @param buffer Buffer to bind.
  30929. * @param name Name of the uniform variable to bind to.
  30930. */
  30931. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30932. /**
  30933. * Binds block to a uniform.
  30934. * @param blockName Name of the block to bind.
  30935. * @param index Index to bind.
  30936. */
  30937. bindUniformBlock(blockName: string, index: number): void;
  30938. /**
  30939. * Sets an interger value on a uniform variable.
  30940. * @param uniformName Name of the variable.
  30941. * @param value Value to be set.
  30942. * @returns this effect.
  30943. */
  30944. setInt(uniformName: string, value: number): Effect;
  30945. /**
  30946. * Sets an int array on a uniform variable.
  30947. * @param uniformName Name of the variable.
  30948. * @param array array to be set.
  30949. * @returns this effect.
  30950. */
  30951. setIntArray(uniformName: string, array: Int32Array): Effect;
  30952. /**
  30953. * 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)
  30954. * @param uniformName Name of the variable.
  30955. * @param array array to be set.
  30956. * @returns this effect.
  30957. */
  30958. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30959. /**
  30960. * 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)
  30961. * @param uniformName Name of the variable.
  30962. * @param array array to be set.
  30963. * @returns this effect.
  30964. */
  30965. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30966. /**
  30967. * 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)
  30968. * @param uniformName Name of the variable.
  30969. * @param array array to be set.
  30970. * @returns this effect.
  30971. */
  30972. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30973. /**
  30974. * Sets an float array on a uniform variable.
  30975. * @param uniformName Name of the variable.
  30976. * @param array array to be set.
  30977. * @returns this effect.
  30978. */
  30979. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30980. /**
  30981. * 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)
  30982. * @param uniformName Name of the variable.
  30983. * @param array array to be set.
  30984. * @returns this effect.
  30985. */
  30986. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30987. /**
  30988. * 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)
  30989. * @param uniformName Name of the variable.
  30990. * @param array array to be set.
  30991. * @returns this effect.
  30992. */
  30993. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30994. /**
  30995. * 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)
  30996. * @param uniformName Name of the variable.
  30997. * @param array array to be set.
  30998. * @returns this effect.
  30999. */
  31000. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31001. /**
  31002. * Sets an array on a uniform variable.
  31003. * @param uniformName Name of the variable.
  31004. * @param array array to be set.
  31005. * @returns this effect.
  31006. */
  31007. setArray(uniformName: string, array: number[]): Effect;
  31008. /**
  31009. * 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)
  31010. * @param uniformName Name of the variable.
  31011. * @param array array to be set.
  31012. * @returns this effect.
  31013. */
  31014. setArray2(uniformName: string, array: number[]): Effect;
  31015. /**
  31016. * 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)
  31017. * @param uniformName Name of the variable.
  31018. * @param array array to be set.
  31019. * @returns this effect.
  31020. */
  31021. setArray3(uniformName: string, array: number[]): Effect;
  31022. /**
  31023. * 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)
  31024. * @param uniformName Name of the variable.
  31025. * @param array array to be set.
  31026. * @returns this effect.
  31027. */
  31028. setArray4(uniformName: string, array: number[]): Effect;
  31029. /**
  31030. * Sets matrices on a uniform variable.
  31031. * @param uniformName Name of the variable.
  31032. * @param matrices matrices to be set.
  31033. * @returns this effect.
  31034. */
  31035. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31036. /**
  31037. * Sets matrix on a uniform variable.
  31038. * @param uniformName Name of the variable.
  31039. * @param matrix matrix to be set.
  31040. * @returns this effect.
  31041. */
  31042. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31043. /**
  31044. * 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)
  31045. * @param uniformName Name of the variable.
  31046. * @param matrix matrix to be set.
  31047. * @returns this effect.
  31048. */
  31049. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31050. /**
  31051. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31052. * @param uniformName Name of the variable.
  31053. * @param matrix matrix to be set.
  31054. * @returns this effect.
  31055. */
  31056. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31057. /**
  31058. * Sets a float on a uniform variable.
  31059. * @param uniformName Name of the variable.
  31060. * @param value value to be set.
  31061. * @returns this effect.
  31062. */
  31063. setFloat(uniformName: string, value: number): Effect;
  31064. /**
  31065. * Sets a boolean on a uniform variable.
  31066. * @param uniformName Name of the variable.
  31067. * @param bool value to be set.
  31068. * @returns this effect.
  31069. */
  31070. setBool(uniformName: string, bool: boolean): Effect;
  31071. /**
  31072. * Sets a Vector2 on a uniform variable.
  31073. * @param uniformName Name of the variable.
  31074. * @param vector2 vector2 to be set.
  31075. * @returns this effect.
  31076. */
  31077. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31078. /**
  31079. * Sets a float2 on a uniform variable.
  31080. * @param uniformName Name of the variable.
  31081. * @param x First float in float2.
  31082. * @param y Second float in float2.
  31083. * @returns this effect.
  31084. */
  31085. setFloat2(uniformName: string, x: number, y: number): Effect;
  31086. /**
  31087. * Sets a Vector3 on a uniform variable.
  31088. * @param uniformName Name of the variable.
  31089. * @param vector3 Value to be set.
  31090. * @returns this effect.
  31091. */
  31092. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31093. /**
  31094. * Sets a float3 on a uniform variable.
  31095. * @param uniformName Name of the variable.
  31096. * @param x First float in float3.
  31097. * @param y Second float in float3.
  31098. * @param z Third float in float3.
  31099. * @returns this effect.
  31100. */
  31101. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31102. /**
  31103. * Sets a Vector4 on a uniform variable.
  31104. * @param uniformName Name of the variable.
  31105. * @param vector4 Value to be set.
  31106. * @returns this effect.
  31107. */
  31108. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31109. /**
  31110. * Sets a float4 on a uniform variable.
  31111. * @param uniformName Name of the variable.
  31112. * @param x First float in float4.
  31113. * @param y Second float in float4.
  31114. * @param z Third float in float4.
  31115. * @param w Fourth float in float4.
  31116. * @returns this effect.
  31117. */
  31118. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31119. /**
  31120. * Sets a Color3 on a uniform variable.
  31121. * @param uniformName Name of the variable.
  31122. * @param color3 Value to be set.
  31123. * @returns this effect.
  31124. */
  31125. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31126. /**
  31127. * Sets a Color4 on a uniform variable.
  31128. * @param uniformName Name of the variable.
  31129. * @param color3 Value to be set.
  31130. * @param alpha Alpha value to be set.
  31131. * @returns this effect.
  31132. */
  31133. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31134. /**
  31135. * Sets a Color4 on a uniform variable
  31136. * @param uniformName defines the name of the variable
  31137. * @param color4 defines the value to be set
  31138. * @returns this effect.
  31139. */
  31140. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31141. /** Release all associated resources */
  31142. dispose(): void;
  31143. /**
  31144. * This function will add a new shader to the shader store
  31145. * @param name the name of the shader
  31146. * @param pixelShader optional pixel shader content
  31147. * @param vertexShader optional vertex shader content
  31148. */
  31149. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31150. /**
  31151. * Store of each shader (The can be looked up using effect.key)
  31152. */
  31153. static ShadersStore: {
  31154. [key: string]: string;
  31155. };
  31156. /**
  31157. * Store of each included file for a shader (The can be looked up using effect.key)
  31158. */
  31159. static IncludesShadersStore: {
  31160. [key: string]: string;
  31161. };
  31162. /**
  31163. * Resets the cache of effects.
  31164. */
  31165. static ResetCache(): void;
  31166. }
  31167. }
  31168. declare module "babylonjs/Engines/engineCapabilities" {
  31169. /**
  31170. * Interface used to describe the capabilities of the engine relatively to the current browser
  31171. */
  31172. export interface EngineCapabilities {
  31173. /** Maximum textures units per fragment shader */
  31174. maxTexturesImageUnits: number;
  31175. /** Maximum texture units per vertex shader */
  31176. maxVertexTextureImageUnits: number;
  31177. /** Maximum textures units in the entire pipeline */
  31178. maxCombinedTexturesImageUnits: number;
  31179. /** Maximum texture size */
  31180. maxTextureSize: number;
  31181. /** Maximum texture samples */
  31182. maxSamples?: number;
  31183. /** Maximum cube texture size */
  31184. maxCubemapTextureSize: number;
  31185. /** Maximum render texture size */
  31186. maxRenderTextureSize: number;
  31187. /** Maximum number of vertex attributes */
  31188. maxVertexAttribs: number;
  31189. /** Maximum number of varyings */
  31190. maxVaryingVectors: number;
  31191. /** Maximum number of uniforms per vertex shader */
  31192. maxVertexUniformVectors: number;
  31193. /** Maximum number of uniforms per fragment shader */
  31194. maxFragmentUniformVectors: number;
  31195. /** Defines if standard derivates (dx/dy) are supported */
  31196. standardDerivatives: boolean;
  31197. /** Defines if s3tc texture compression is supported */
  31198. s3tc?: WEBGL_compressed_texture_s3tc;
  31199. /** Defines if pvrtc texture compression is supported */
  31200. pvrtc: any;
  31201. /** Defines if etc1 texture compression is supported */
  31202. etc1: any;
  31203. /** Defines if etc2 texture compression is supported */
  31204. etc2: any;
  31205. /** Defines if astc texture compression is supported */
  31206. astc: any;
  31207. /** Defines if float textures are supported */
  31208. textureFloat: boolean;
  31209. /** Defines if vertex array objects are supported */
  31210. vertexArrayObject: boolean;
  31211. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31212. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31213. /** Gets the maximum level of anisotropy supported */
  31214. maxAnisotropy: number;
  31215. /** Defines if instancing is supported */
  31216. instancedArrays: boolean;
  31217. /** Defines if 32 bits indices are supported */
  31218. uintIndices: boolean;
  31219. /** Defines if high precision shaders are supported */
  31220. highPrecisionShaderSupported: boolean;
  31221. /** Defines if depth reading in the fragment shader is supported */
  31222. fragmentDepthSupported: boolean;
  31223. /** Defines if float texture linear filtering is supported*/
  31224. textureFloatLinearFiltering: boolean;
  31225. /** Defines if rendering to float textures is supported */
  31226. textureFloatRender: boolean;
  31227. /** Defines if half float textures are supported*/
  31228. textureHalfFloat: boolean;
  31229. /** Defines if half float texture linear filtering is supported*/
  31230. textureHalfFloatLinearFiltering: boolean;
  31231. /** Defines if rendering to half float textures is supported */
  31232. textureHalfFloatRender: boolean;
  31233. /** Defines if textureLOD shader command is supported */
  31234. textureLOD: boolean;
  31235. /** Defines if draw buffers extension is supported */
  31236. drawBuffersExtension: boolean;
  31237. /** Defines if depth textures are supported */
  31238. depthTextureExtension: boolean;
  31239. /** Defines if float color buffer are supported */
  31240. colorBufferFloat: boolean;
  31241. /** Gets disjoint timer query extension (null if not supported) */
  31242. timerQuery?: EXT_disjoint_timer_query;
  31243. /** Defines if timestamp can be used with timer query */
  31244. canUseTimestampForTimerQuery: boolean;
  31245. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31246. multiview?: any;
  31247. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31248. oculusMultiview?: any;
  31249. /** Function used to let the system compiles shaders in background */
  31250. parallelShaderCompile?: {
  31251. COMPLETION_STATUS_KHR: number;
  31252. };
  31253. /** Max number of texture samples for MSAA */
  31254. maxMSAASamples: number;
  31255. /** Defines if the blend min max extension is supported */
  31256. blendMinMax: boolean;
  31257. }
  31258. }
  31259. declare module "babylonjs/States/depthCullingState" {
  31260. import { Nullable } from "babylonjs/types";
  31261. /**
  31262. * @hidden
  31263. **/
  31264. export class DepthCullingState {
  31265. private _isDepthTestDirty;
  31266. private _isDepthMaskDirty;
  31267. private _isDepthFuncDirty;
  31268. private _isCullFaceDirty;
  31269. private _isCullDirty;
  31270. private _isZOffsetDirty;
  31271. private _isFrontFaceDirty;
  31272. private _depthTest;
  31273. private _depthMask;
  31274. private _depthFunc;
  31275. private _cull;
  31276. private _cullFace;
  31277. private _zOffset;
  31278. private _frontFace;
  31279. /**
  31280. * Initializes the state.
  31281. */
  31282. constructor();
  31283. get isDirty(): boolean;
  31284. get zOffset(): number;
  31285. set zOffset(value: number);
  31286. get cullFace(): Nullable<number>;
  31287. set cullFace(value: Nullable<number>);
  31288. get cull(): Nullable<boolean>;
  31289. set cull(value: Nullable<boolean>);
  31290. get depthFunc(): Nullable<number>;
  31291. set depthFunc(value: Nullable<number>);
  31292. get depthMask(): boolean;
  31293. set depthMask(value: boolean);
  31294. get depthTest(): boolean;
  31295. set depthTest(value: boolean);
  31296. get frontFace(): Nullable<number>;
  31297. set frontFace(value: Nullable<number>);
  31298. reset(): void;
  31299. apply(gl: WebGLRenderingContext): void;
  31300. }
  31301. }
  31302. declare module "babylonjs/States/stencilState" {
  31303. /**
  31304. * @hidden
  31305. **/
  31306. export class StencilState {
  31307. /** 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 */
  31308. static readonly ALWAYS: number;
  31309. /** Passed to stencilOperation to specify that stencil value must be kept */
  31310. static readonly KEEP: number;
  31311. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31312. static readonly REPLACE: number;
  31313. private _isStencilTestDirty;
  31314. private _isStencilMaskDirty;
  31315. private _isStencilFuncDirty;
  31316. private _isStencilOpDirty;
  31317. private _stencilTest;
  31318. private _stencilMask;
  31319. private _stencilFunc;
  31320. private _stencilFuncRef;
  31321. private _stencilFuncMask;
  31322. private _stencilOpStencilFail;
  31323. private _stencilOpDepthFail;
  31324. private _stencilOpStencilDepthPass;
  31325. get isDirty(): boolean;
  31326. get stencilFunc(): number;
  31327. set stencilFunc(value: number);
  31328. get stencilFuncRef(): number;
  31329. set stencilFuncRef(value: number);
  31330. get stencilFuncMask(): number;
  31331. set stencilFuncMask(value: number);
  31332. get stencilOpStencilFail(): number;
  31333. set stencilOpStencilFail(value: number);
  31334. get stencilOpDepthFail(): number;
  31335. set stencilOpDepthFail(value: number);
  31336. get stencilOpStencilDepthPass(): number;
  31337. set stencilOpStencilDepthPass(value: number);
  31338. get stencilMask(): number;
  31339. set stencilMask(value: number);
  31340. get stencilTest(): boolean;
  31341. set stencilTest(value: boolean);
  31342. constructor();
  31343. reset(): void;
  31344. apply(gl: WebGLRenderingContext): void;
  31345. }
  31346. }
  31347. declare module "babylonjs/States/alphaCullingState" {
  31348. /**
  31349. * @hidden
  31350. **/
  31351. export class AlphaState {
  31352. private _isAlphaBlendDirty;
  31353. private _isBlendFunctionParametersDirty;
  31354. private _isBlendEquationParametersDirty;
  31355. private _isBlendConstantsDirty;
  31356. private _alphaBlend;
  31357. private _blendFunctionParameters;
  31358. private _blendEquationParameters;
  31359. private _blendConstants;
  31360. /**
  31361. * Initializes the state.
  31362. */
  31363. constructor();
  31364. get isDirty(): boolean;
  31365. get alphaBlend(): boolean;
  31366. set alphaBlend(value: boolean);
  31367. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31368. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31369. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31370. reset(): void;
  31371. apply(gl: WebGLRenderingContext): void;
  31372. }
  31373. }
  31374. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31375. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31376. /** @hidden */
  31377. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31378. attributeProcessor(attribute: string): string;
  31379. varyingProcessor(varying: string, isFragment: boolean): string;
  31380. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31381. }
  31382. }
  31383. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31384. /**
  31385. * Interface for attribute information associated with buffer instanciation
  31386. */
  31387. export interface InstancingAttributeInfo {
  31388. /**
  31389. * Name of the GLSL attribute
  31390. * if attribute index is not specified, this is used to retrieve the index from the effect
  31391. */
  31392. attributeName: string;
  31393. /**
  31394. * Index/offset of the attribute in the vertex shader
  31395. * if not specified, this will be computes from the name.
  31396. */
  31397. index?: number;
  31398. /**
  31399. * size of the attribute, 1, 2, 3 or 4
  31400. */
  31401. attributeSize: number;
  31402. /**
  31403. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31404. */
  31405. offset: number;
  31406. /**
  31407. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31408. * default to 1
  31409. */
  31410. divisor?: number;
  31411. /**
  31412. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31413. * default is FLOAT
  31414. */
  31415. attributeType?: number;
  31416. /**
  31417. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31418. */
  31419. normalized?: boolean;
  31420. }
  31421. }
  31422. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31423. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31424. import { Nullable } from "babylonjs/types";
  31425. module "babylonjs/Engines/thinEngine" {
  31426. interface ThinEngine {
  31427. /**
  31428. * Update a video texture
  31429. * @param texture defines the texture to update
  31430. * @param video defines the video element to use
  31431. * @param invertY defines if data must be stored with Y axis inverted
  31432. */
  31433. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31434. }
  31435. }
  31436. }
  31437. declare module "babylonjs/Materials/Textures/videoTexture" {
  31438. import { Observable } from "babylonjs/Misc/observable";
  31439. import { Nullable } from "babylonjs/types";
  31440. import { Scene } from "babylonjs/scene";
  31441. import { Texture } from "babylonjs/Materials/Textures/texture";
  31442. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31443. /**
  31444. * Settings for finer control over video usage
  31445. */
  31446. export interface VideoTextureSettings {
  31447. /**
  31448. * Applies `autoplay` to video, if specified
  31449. */
  31450. autoPlay?: boolean;
  31451. /**
  31452. * Applies `loop` to video, if specified
  31453. */
  31454. loop?: boolean;
  31455. /**
  31456. * Automatically updates internal texture from video at every frame in the render loop
  31457. */
  31458. autoUpdateTexture: boolean;
  31459. /**
  31460. * Image src displayed during the video loading or until the user interacts with the video.
  31461. */
  31462. poster?: string;
  31463. }
  31464. /**
  31465. * If you want to display a video in your scene, this is the special texture for that.
  31466. * This special texture works similar to other textures, with the exception of a few parameters.
  31467. * @see https://doc.babylonjs.com/how_to/video_texture
  31468. */
  31469. export class VideoTexture extends Texture {
  31470. /**
  31471. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31472. */
  31473. readonly autoUpdateTexture: boolean;
  31474. /**
  31475. * The video instance used by the texture internally
  31476. */
  31477. readonly video: HTMLVideoElement;
  31478. private _onUserActionRequestedObservable;
  31479. /**
  31480. * Event triggerd when a dom action is required by the user to play the video.
  31481. * This happens due to recent changes in browser policies preventing video to auto start.
  31482. */
  31483. get onUserActionRequestedObservable(): Observable<Texture>;
  31484. private _generateMipMaps;
  31485. private _engine;
  31486. private _stillImageCaptured;
  31487. private _displayingPosterTexture;
  31488. private _settings;
  31489. private _createInternalTextureOnEvent;
  31490. private _frameId;
  31491. private _currentSrc;
  31492. /**
  31493. * Creates a video texture.
  31494. * If you want to display a video in your scene, this is the special texture for that.
  31495. * This special texture works similar to other textures, with the exception of a few parameters.
  31496. * @see https://doc.babylonjs.com/how_to/video_texture
  31497. * @param name optional name, will detect from video source, if not defined
  31498. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31499. * @param scene is obviously the current scene.
  31500. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31501. * @param invertY is false by default but can be used to invert video on Y axis
  31502. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31503. * @param settings allows finer control over video usage
  31504. */
  31505. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31506. private _getName;
  31507. private _getVideo;
  31508. private _createInternalTexture;
  31509. private reset;
  31510. /**
  31511. * @hidden Internal method to initiate `update`.
  31512. */
  31513. _rebuild(): void;
  31514. /**
  31515. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31516. */
  31517. update(): void;
  31518. /**
  31519. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31520. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31521. */
  31522. updateTexture(isVisible: boolean): void;
  31523. protected _updateInternalTexture: () => void;
  31524. /**
  31525. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31526. * @param url New url.
  31527. */
  31528. updateURL(url: string): void;
  31529. /**
  31530. * Clones the texture.
  31531. * @returns the cloned texture
  31532. */
  31533. clone(): VideoTexture;
  31534. /**
  31535. * Dispose the texture and release its associated resources.
  31536. */
  31537. dispose(): void;
  31538. /**
  31539. * Creates a video texture straight from a stream.
  31540. * @param scene Define the scene the texture should be created in
  31541. * @param stream Define the stream the texture should be created from
  31542. * @returns The created video texture as a promise
  31543. */
  31544. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31545. /**
  31546. * Creates a video texture straight from your WebCam video feed.
  31547. * @param scene Define the scene the texture should be created in
  31548. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31549. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31550. * @returns The created video texture as a promise
  31551. */
  31552. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31553. minWidth: number;
  31554. maxWidth: number;
  31555. minHeight: number;
  31556. maxHeight: number;
  31557. deviceId: string;
  31558. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31559. /**
  31560. * Creates a video texture straight from your WebCam video feed.
  31561. * @param scene Define the scene the texture should be created in
  31562. * @param onReady Define a callback to triggered once the texture will be ready
  31563. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31564. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31565. */
  31566. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31567. minWidth: number;
  31568. maxWidth: number;
  31569. minHeight: number;
  31570. maxHeight: number;
  31571. deviceId: string;
  31572. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31573. }
  31574. }
  31575. declare module "babylonjs/Engines/thinEngine" {
  31576. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31577. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31578. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31579. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31580. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31581. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31582. import { Observable } from "babylonjs/Misc/observable";
  31583. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31584. import { StencilState } from "babylonjs/States/stencilState";
  31585. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31586. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31587. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31588. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31589. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31590. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31591. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31592. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31593. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31594. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31595. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31596. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31597. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31598. import { WebRequest } from "babylonjs/Misc/webRequest";
  31599. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31600. /**
  31601. * Defines the interface used by objects working like Scene
  31602. * @hidden
  31603. */
  31604. interface ISceneLike {
  31605. _addPendingData(data: any): void;
  31606. _removePendingData(data: any): void;
  31607. offlineProvider: IOfflineProvider;
  31608. }
  31609. /** Interface defining initialization parameters for Engine class */
  31610. export interface EngineOptions extends WebGLContextAttributes {
  31611. /**
  31612. * Defines if the engine should no exceed a specified device ratio
  31613. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31614. */
  31615. limitDeviceRatio?: number;
  31616. /**
  31617. * Defines if webvr should be enabled automatically
  31618. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31619. */
  31620. autoEnableWebVR?: boolean;
  31621. /**
  31622. * Defines if webgl2 should be turned off even if supported
  31623. * @see http://doc.babylonjs.com/features/webgl2
  31624. */
  31625. disableWebGL2Support?: boolean;
  31626. /**
  31627. * Defines if webaudio should be initialized as well
  31628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31629. */
  31630. audioEngine?: boolean;
  31631. /**
  31632. * Defines if animations should run using a deterministic lock step
  31633. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31634. */
  31635. deterministicLockstep?: boolean;
  31636. /** Defines the maximum steps to use with deterministic lock step mode */
  31637. lockstepMaxSteps?: number;
  31638. /** Defines the seconds between each deterministic lock step */
  31639. timeStep?: number;
  31640. /**
  31641. * Defines that engine should ignore context lost events
  31642. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31643. */
  31644. doNotHandleContextLost?: boolean;
  31645. /**
  31646. * Defines that engine should ignore modifying touch action attribute and style
  31647. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31648. */
  31649. doNotHandleTouchAction?: boolean;
  31650. /**
  31651. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31652. */
  31653. useHighPrecisionFloats?: boolean;
  31654. }
  31655. /**
  31656. * The base engine class (root of all engines)
  31657. */
  31658. export class ThinEngine {
  31659. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31660. static ExceptionList: ({
  31661. key: string;
  31662. capture: string;
  31663. captureConstraint: number;
  31664. targets: string[];
  31665. } | {
  31666. key: string;
  31667. capture: null;
  31668. captureConstraint: null;
  31669. targets: string[];
  31670. })[];
  31671. /** @hidden */
  31672. static _TextureLoaders: IInternalTextureLoader[];
  31673. /**
  31674. * Returns the current npm package of the sdk
  31675. */
  31676. static get NpmPackage(): string;
  31677. /**
  31678. * Returns the current version of the framework
  31679. */
  31680. static get Version(): string;
  31681. /**
  31682. * Returns a string describing the current engine
  31683. */
  31684. get description(): string;
  31685. /**
  31686. * Gets or sets the epsilon value used by collision engine
  31687. */
  31688. static CollisionsEpsilon: number;
  31689. /**
  31690. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31691. */
  31692. static get ShadersRepository(): string;
  31693. static set ShadersRepository(value: string);
  31694. /**
  31695. * Gets or sets the textures that the engine should not attempt to load as compressed
  31696. */
  31697. protected _excludedCompressedTextures: string[];
  31698. /**
  31699. * Filters the compressed texture formats to only include
  31700. * files that are not included in the skippable list
  31701. *
  31702. * @param url the current extension
  31703. * @param textureFormatInUse the current compressed texture format
  31704. * @returns "format" string
  31705. */
  31706. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31707. /** @hidden */
  31708. _shaderProcessor: IShaderProcessor;
  31709. /**
  31710. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31711. */
  31712. forcePOTTextures: boolean;
  31713. /**
  31714. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31715. */
  31716. isFullscreen: boolean;
  31717. /**
  31718. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31719. */
  31720. cullBackFaces: boolean;
  31721. /**
  31722. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31723. */
  31724. renderEvenInBackground: boolean;
  31725. /**
  31726. * Gets or sets a boolean indicating that cache can be kept between frames
  31727. */
  31728. preventCacheWipeBetweenFrames: boolean;
  31729. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31730. validateShaderPrograms: boolean;
  31731. /**
  31732. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31733. * This can provide greater z depth for distant objects.
  31734. */
  31735. useReverseDepthBuffer: boolean;
  31736. /**
  31737. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31738. */
  31739. disableUniformBuffers: boolean;
  31740. /** @hidden */
  31741. _uniformBuffers: UniformBuffer[];
  31742. /**
  31743. * Gets a boolean indicating that the engine supports uniform buffers
  31744. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31745. */
  31746. get supportsUniformBuffers(): boolean;
  31747. /** @hidden */
  31748. _gl: WebGLRenderingContext;
  31749. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31750. protected _windowIsBackground: boolean;
  31751. protected _webGLVersion: number;
  31752. protected _creationOptions: EngineOptions;
  31753. protected _highPrecisionShadersAllowed: boolean;
  31754. /** @hidden */
  31755. get _shouldUseHighPrecisionShader(): boolean;
  31756. /**
  31757. * Gets a boolean indicating that only power of 2 textures are supported
  31758. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31759. */
  31760. get needPOTTextures(): boolean;
  31761. /** @hidden */
  31762. _badOS: boolean;
  31763. /** @hidden */
  31764. _badDesktopOS: boolean;
  31765. private _hardwareScalingLevel;
  31766. /** @hidden */
  31767. _caps: EngineCapabilities;
  31768. private _isStencilEnable;
  31769. private _glVersion;
  31770. private _glRenderer;
  31771. private _glVendor;
  31772. /** @hidden */
  31773. _videoTextureSupported: boolean;
  31774. protected _renderingQueueLaunched: boolean;
  31775. protected _activeRenderLoops: (() => void)[];
  31776. /**
  31777. * Observable signaled when a context lost event is raised
  31778. */
  31779. onContextLostObservable: Observable<ThinEngine>;
  31780. /**
  31781. * Observable signaled when a context restored event is raised
  31782. */
  31783. onContextRestoredObservable: Observable<ThinEngine>;
  31784. private _onContextLost;
  31785. private _onContextRestored;
  31786. protected _contextWasLost: boolean;
  31787. /** @hidden */
  31788. _doNotHandleContextLost: boolean;
  31789. /**
  31790. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31791. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31792. */
  31793. get doNotHandleContextLost(): boolean;
  31794. set doNotHandleContextLost(value: boolean);
  31795. /**
  31796. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31797. */
  31798. disableVertexArrayObjects: boolean;
  31799. /** @hidden */
  31800. protected _colorWrite: boolean;
  31801. /** @hidden */
  31802. protected _colorWriteChanged: boolean;
  31803. /** @hidden */
  31804. protected _depthCullingState: DepthCullingState;
  31805. /** @hidden */
  31806. protected _stencilState: StencilState;
  31807. /** @hidden */
  31808. _alphaState: AlphaState;
  31809. /** @hidden */
  31810. _alphaMode: number;
  31811. /** @hidden */
  31812. _alphaEquation: number;
  31813. /** @hidden */
  31814. _internalTexturesCache: InternalTexture[];
  31815. /** @hidden */
  31816. protected _activeChannel: number;
  31817. private _currentTextureChannel;
  31818. /** @hidden */
  31819. protected _boundTexturesCache: {
  31820. [key: string]: Nullable<InternalTexture>;
  31821. };
  31822. /** @hidden */
  31823. protected _currentEffect: Nullable<Effect>;
  31824. /** @hidden */
  31825. protected _currentProgram: Nullable<WebGLProgram>;
  31826. private _compiledEffects;
  31827. private _vertexAttribArraysEnabled;
  31828. /** @hidden */
  31829. protected _cachedViewport: Nullable<IViewportLike>;
  31830. private _cachedVertexArrayObject;
  31831. /** @hidden */
  31832. protected _cachedVertexBuffers: any;
  31833. /** @hidden */
  31834. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31835. /** @hidden */
  31836. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31837. /** @hidden */
  31838. _currentRenderTarget: Nullable<InternalTexture>;
  31839. private _uintIndicesCurrentlySet;
  31840. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31841. /** @hidden */
  31842. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31843. private _currentBufferPointers;
  31844. private _currentInstanceLocations;
  31845. private _currentInstanceBuffers;
  31846. private _textureUnits;
  31847. /** @hidden */
  31848. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31849. /** @hidden */
  31850. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31851. /** @hidden */
  31852. _boundRenderFunction: any;
  31853. private _vaoRecordInProgress;
  31854. private _mustWipeVertexAttributes;
  31855. private _emptyTexture;
  31856. private _emptyCubeTexture;
  31857. private _emptyTexture3D;
  31858. private _emptyTexture2DArray;
  31859. /** @hidden */
  31860. _frameHandler: number;
  31861. private _nextFreeTextureSlots;
  31862. private _maxSimultaneousTextures;
  31863. private _activeRequests;
  31864. protected _texturesSupported: string[];
  31865. /** @hidden */
  31866. _textureFormatInUse: Nullable<string>;
  31867. protected get _supportsHardwareTextureRescaling(): boolean;
  31868. /**
  31869. * Gets the list of texture formats supported
  31870. */
  31871. get texturesSupported(): Array<string>;
  31872. /**
  31873. * Gets the list of texture formats in use
  31874. */
  31875. get textureFormatInUse(): Nullable<string>;
  31876. /**
  31877. * Gets the current viewport
  31878. */
  31879. get currentViewport(): Nullable<IViewportLike>;
  31880. /**
  31881. * Gets the default empty texture
  31882. */
  31883. get emptyTexture(): InternalTexture;
  31884. /**
  31885. * Gets the default empty 3D texture
  31886. */
  31887. get emptyTexture3D(): InternalTexture;
  31888. /**
  31889. * Gets the default empty 2D array texture
  31890. */
  31891. get emptyTexture2DArray(): InternalTexture;
  31892. /**
  31893. * Gets the default empty cube texture
  31894. */
  31895. get emptyCubeTexture(): InternalTexture;
  31896. /**
  31897. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31898. */
  31899. readonly premultipliedAlpha: boolean;
  31900. /**
  31901. * Observable event triggered before each texture is initialized
  31902. */
  31903. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  31904. /**
  31905. * Creates a new engine
  31906. * @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
  31907. * @param antialias defines enable antialiasing (default: false)
  31908. * @param options defines further options to be sent to the getContext() function
  31909. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31910. */
  31911. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31912. private _rebuildInternalTextures;
  31913. private _rebuildEffects;
  31914. /**
  31915. * Gets a boolean indicating if all created effects are ready
  31916. * @returns true if all effects are ready
  31917. */
  31918. areAllEffectsReady(): boolean;
  31919. protected _rebuildBuffers(): void;
  31920. private _initGLContext;
  31921. /**
  31922. * Gets version of the current webGL context
  31923. */
  31924. get webGLVersion(): number;
  31925. /**
  31926. * Gets a string idenfifying the name of the class
  31927. * @returns "Engine" string
  31928. */
  31929. getClassName(): string;
  31930. /**
  31931. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31932. */
  31933. get isStencilEnable(): boolean;
  31934. /** @hidden */
  31935. _prepareWorkingCanvas(): void;
  31936. /**
  31937. * Reset the texture cache to empty state
  31938. */
  31939. resetTextureCache(): void;
  31940. /**
  31941. * Gets an object containing information about the current webGL context
  31942. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31943. */
  31944. getGlInfo(): {
  31945. vendor: string;
  31946. renderer: string;
  31947. version: string;
  31948. };
  31949. /**
  31950. * Defines the hardware scaling level.
  31951. * By default the hardware scaling level is computed from the window device ratio.
  31952. * 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.
  31953. * @param level defines the level to use
  31954. */
  31955. setHardwareScalingLevel(level: number): void;
  31956. /**
  31957. * Gets the current hardware scaling level.
  31958. * By default the hardware scaling level is computed from the window device ratio.
  31959. * 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.
  31960. * @returns a number indicating the current hardware scaling level
  31961. */
  31962. getHardwareScalingLevel(): number;
  31963. /**
  31964. * Gets the list of loaded textures
  31965. * @returns an array containing all loaded textures
  31966. */
  31967. getLoadedTexturesCache(): InternalTexture[];
  31968. /**
  31969. * Gets the object containing all engine capabilities
  31970. * @returns the EngineCapabilities object
  31971. */
  31972. getCaps(): EngineCapabilities;
  31973. /**
  31974. * stop executing a render loop function and remove it from the execution array
  31975. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31976. */
  31977. stopRenderLoop(renderFunction?: () => void): void;
  31978. /** @hidden */
  31979. _renderLoop(): void;
  31980. /**
  31981. * Gets the HTML canvas attached with the current webGL context
  31982. * @returns a HTML canvas
  31983. */
  31984. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31985. /**
  31986. * Gets host window
  31987. * @returns the host window object
  31988. */
  31989. getHostWindow(): Nullable<Window>;
  31990. /**
  31991. * Gets the current render width
  31992. * @param useScreen defines if screen size must be used (or the current render target if any)
  31993. * @returns a number defining the current render width
  31994. */
  31995. getRenderWidth(useScreen?: boolean): number;
  31996. /**
  31997. * Gets the current render height
  31998. * @param useScreen defines if screen size must be used (or the current render target if any)
  31999. * @returns a number defining the current render height
  32000. */
  32001. getRenderHeight(useScreen?: boolean): number;
  32002. /**
  32003. * Can be used to override the current requestAnimationFrame requester.
  32004. * @hidden
  32005. */
  32006. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32007. /**
  32008. * Register and execute a render loop. The engine can have more than one render function
  32009. * @param renderFunction defines the function to continuously execute
  32010. */
  32011. runRenderLoop(renderFunction: () => void): void;
  32012. /**
  32013. * Clear the current render buffer or the current render target (if any is set up)
  32014. * @param color defines the color to use
  32015. * @param backBuffer defines if the back buffer must be cleared
  32016. * @param depth defines if the depth buffer must be cleared
  32017. * @param stencil defines if the stencil buffer must be cleared
  32018. */
  32019. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32020. private _viewportCached;
  32021. /** @hidden */
  32022. _viewport(x: number, y: number, width: number, height: number): void;
  32023. /**
  32024. * Set the WebGL's viewport
  32025. * @param viewport defines the viewport element to be used
  32026. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32027. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32028. */
  32029. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32030. /**
  32031. * Begin a new frame
  32032. */
  32033. beginFrame(): void;
  32034. /**
  32035. * Enf the current frame
  32036. */
  32037. endFrame(): void;
  32038. /**
  32039. * Resize the view according to the canvas' size
  32040. */
  32041. resize(): void;
  32042. /**
  32043. * Force a specific size of the canvas
  32044. * @param width defines the new canvas' width
  32045. * @param height defines the new canvas' height
  32046. */
  32047. setSize(width: number, height: number): void;
  32048. /**
  32049. * Binds the frame buffer to the specified texture.
  32050. * @param texture The texture to render to or null for the default canvas
  32051. * @param faceIndex The face of the texture to render to in case of cube texture
  32052. * @param requiredWidth The width of the target to render to
  32053. * @param requiredHeight The height of the target to render to
  32054. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32055. * @param depthStencilTexture The depth stencil texture to use to render
  32056. * @param lodLevel defines le lod level to bind to the frame buffer
  32057. */
  32058. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  32059. /** @hidden */
  32060. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32061. /**
  32062. * Unbind the current render target texture from the webGL context
  32063. * @param texture defines the render target texture to unbind
  32064. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32065. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32066. */
  32067. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32068. /**
  32069. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32070. */
  32071. flushFramebuffer(): void;
  32072. /**
  32073. * Unbind the current render target and bind the default framebuffer
  32074. */
  32075. restoreDefaultFramebuffer(): void;
  32076. /** @hidden */
  32077. protected _resetVertexBufferBinding(): void;
  32078. /**
  32079. * Creates a vertex buffer
  32080. * @param data the data for the vertex buffer
  32081. * @returns the new WebGL static buffer
  32082. */
  32083. createVertexBuffer(data: DataArray): DataBuffer;
  32084. private _createVertexBuffer;
  32085. /**
  32086. * Creates a dynamic vertex buffer
  32087. * @param data the data for the dynamic vertex buffer
  32088. * @returns the new WebGL dynamic buffer
  32089. */
  32090. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32091. protected _resetIndexBufferBinding(): void;
  32092. /**
  32093. * Creates a new index buffer
  32094. * @param indices defines the content of the index buffer
  32095. * @param updatable defines if the index buffer must be updatable
  32096. * @returns a new webGL buffer
  32097. */
  32098. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32099. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32100. /**
  32101. * Bind a webGL buffer to the webGL context
  32102. * @param buffer defines the buffer to bind
  32103. */
  32104. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32105. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32106. private bindBuffer;
  32107. /**
  32108. * update the bound buffer with the given data
  32109. * @param data defines the data to update
  32110. */
  32111. updateArrayBuffer(data: Float32Array): void;
  32112. private _vertexAttribPointer;
  32113. private _bindIndexBufferWithCache;
  32114. private _bindVertexBuffersAttributes;
  32115. /**
  32116. * Records a vertex array object
  32117. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32118. * @param vertexBuffers defines the list of vertex buffers to store
  32119. * @param indexBuffer defines the index buffer to store
  32120. * @param effect defines the effect to store
  32121. * @returns the new vertex array object
  32122. */
  32123. recordVertexArrayObject(vertexBuffers: {
  32124. [key: string]: VertexBuffer;
  32125. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32126. /**
  32127. * Bind a specific vertex array object
  32128. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32129. * @param vertexArrayObject defines the vertex array object to bind
  32130. * @param indexBuffer defines the index buffer to bind
  32131. */
  32132. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32133. /**
  32134. * Bind webGl buffers directly to the webGL context
  32135. * @param vertexBuffer defines the vertex buffer to bind
  32136. * @param indexBuffer defines the index buffer to bind
  32137. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32138. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32139. * @param effect defines the effect associated with the vertex buffer
  32140. */
  32141. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32142. private _unbindVertexArrayObject;
  32143. /**
  32144. * Bind a list of vertex buffers to the webGL context
  32145. * @param vertexBuffers defines the list of vertex buffers to bind
  32146. * @param indexBuffer defines the index buffer to bind
  32147. * @param effect defines the effect associated with the vertex buffers
  32148. */
  32149. bindBuffers(vertexBuffers: {
  32150. [key: string]: Nullable<VertexBuffer>;
  32151. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32152. /**
  32153. * Unbind all instance attributes
  32154. */
  32155. unbindInstanceAttributes(): void;
  32156. /**
  32157. * Release and free the memory of a vertex array object
  32158. * @param vao defines the vertex array object to delete
  32159. */
  32160. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32161. /** @hidden */
  32162. _releaseBuffer(buffer: DataBuffer): boolean;
  32163. protected _deleteBuffer(buffer: DataBuffer): void;
  32164. /**
  32165. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32166. * @param instancesBuffer defines the webGL buffer to update and bind
  32167. * @param data defines the data to store in the buffer
  32168. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32169. */
  32170. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32171. /**
  32172. * Bind the content of a webGL buffer used with instanciation
  32173. * @param instancesBuffer defines the webGL buffer to bind
  32174. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32175. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  32176. */
  32177. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32178. /**
  32179. * Disable the instance attribute corresponding to the name in parameter
  32180. * @param name defines the name of the attribute to disable
  32181. */
  32182. disableInstanceAttributeByName(name: string): void;
  32183. /**
  32184. * Disable the instance attribute corresponding to the location in parameter
  32185. * @param attributeLocation defines the attribute location of the attribute to disable
  32186. */
  32187. disableInstanceAttribute(attributeLocation: number): void;
  32188. /**
  32189. * Disable the attribute corresponding to the location in parameter
  32190. * @param attributeLocation defines the attribute location of the attribute to disable
  32191. */
  32192. disableAttributeByIndex(attributeLocation: number): void;
  32193. /**
  32194. * Send a draw order
  32195. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32196. * @param indexStart defines the starting index
  32197. * @param indexCount defines the number of index to draw
  32198. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32199. */
  32200. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32201. /**
  32202. * Draw a list of points
  32203. * @param verticesStart defines the index of first vertex to draw
  32204. * @param verticesCount defines the count of vertices to draw
  32205. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32206. */
  32207. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32208. /**
  32209. * Draw a list of unindexed primitives
  32210. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32211. * @param verticesStart defines the index of first vertex to draw
  32212. * @param verticesCount defines the count of vertices to draw
  32213. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32214. */
  32215. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32216. /**
  32217. * Draw a list of indexed primitives
  32218. * @param fillMode defines the primitive to use
  32219. * @param indexStart defines the starting index
  32220. * @param indexCount defines the number of index to draw
  32221. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32222. */
  32223. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32224. /**
  32225. * Draw a list of unindexed primitives
  32226. * @param fillMode defines the primitive to use
  32227. * @param verticesStart defines the index of first vertex to draw
  32228. * @param verticesCount defines the count of vertices to draw
  32229. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32230. */
  32231. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32232. private _drawMode;
  32233. /** @hidden */
  32234. protected _reportDrawCall(): void;
  32235. /** @hidden */
  32236. _releaseEffect(effect: Effect): void;
  32237. /** @hidden */
  32238. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32239. /**
  32240. * Create a new effect (used to store vertex/fragment shaders)
  32241. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32242. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32243. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32244. * @param samplers defines an array of string used to represent textures
  32245. * @param defines defines the string containing the defines to use to compile the shaders
  32246. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32247. * @param onCompiled defines a function to call when the effect creation is successful
  32248. * @param onError defines a function to call when the effect creation has failed
  32249. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32250. * @returns the new Effect
  32251. */
  32252. 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;
  32253. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32254. private _compileShader;
  32255. private _compileRawShader;
  32256. /**
  32257. * Directly creates a webGL program
  32258. * @param pipelineContext defines the pipeline context to attach to
  32259. * @param vertexCode defines the vertex shader code to use
  32260. * @param fragmentCode defines the fragment shader code to use
  32261. * @param context defines the webGL context to use (if not set, the current one will be used)
  32262. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32263. * @returns the new webGL program
  32264. */
  32265. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32266. /**
  32267. * Creates a webGL program
  32268. * @param pipelineContext defines the pipeline context to attach to
  32269. * @param vertexCode defines the vertex shader code to use
  32270. * @param fragmentCode defines the fragment shader code to use
  32271. * @param defines defines the string containing the defines to use to compile the shaders
  32272. * @param context defines the webGL context to use (if not set, the current one will be used)
  32273. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32274. * @returns the new webGL program
  32275. */
  32276. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32277. /**
  32278. * Creates a new pipeline context
  32279. * @returns the new pipeline
  32280. */
  32281. createPipelineContext(): IPipelineContext;
  32282. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32283. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32284. /** @hidden */
  32285. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32286. /** @hidden */
  32287. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32288. /** @hidden */
  32289. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32290. /**
  32291. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32292. * @param pipelineContext defines the pipeline context to use
  32293. * @param uniformsNames defines the list of uniform names
  32294. * @returns an array of webGL uniform locations
  32295. */
  32296. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32297. /**
  32298. * Gets the lsit of active attributes for a given webGL program
  32299. * @param pipelineContext defines the pipeline context to use
  32300. * @param attributesNames defines the list of attribute names to get
  32301. * @returns an array of indices indicating the offset of each attribute
  32302. */
  32303. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32304. /**
  32305. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32306. * @param effect defines the effect to activate
  32307. */
  32308. enableEffect(effect: Nullable<Effect>): void;
  32309. /**
  32310. * Set the value of an uniform to a number (int)
  32311. * @param uniform defines the webGL uniform location where to store the value
  32312. * @param value defines the int number to store
  32313. */
  32314. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32315. /**
  32316. * Set the value of an uniform to an array of int32
  32317. * @param uniform defines the webGL uniform location where to store the value
  32318. * @param array defines the array of int32 to store
  32319. */
  32320. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32321. /**
  32322. * Set the value of an uniform to an array of int32 (stored as vec2)
  32323. * @param uniform defines the webGL uniform location where to store the value
  32324. * @param array defines the array of int32 to store
  32325. */
  32326. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32327. /**
  32328. * Set the value of an uniform to an array of int32 (stored as vec3)
  32329. * @param uniform defines the webGL uniform location where to store the value
  32330. * @param array defines the array of int32 to store
  32331. */
  32332. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32333. /**
  32334. * Set the value of an uniform to an array of int32 (stored as vec4)
  32335. * @param uniform defines the webGL uniform location where to store the value
  32336. * @param array defines the array of int32 to store
  32337. */
  32338. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32339. /**
  32340. * Set the value of an uniform to an array of number
  32341. * @param uniform defines the webGL uniform location where to store the value
  32342. * @param array defines the array of number to store
  32343. */
  32344. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32345. /**
  32346. * Set the value of an uniform to an array of number (stored as vec2)
  32347. * @param uniform defines the webGL uniform location where to store the value
  32348. * @param array defines the array of number to store
  32349. */
  32350. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32351. /**
  32352. * Set the value of an uniform to an array of number (stored as vec3)
  32353. * @param uniform defines the webGL uniform location where to store the value
  32354. * @param array defines the array of number to store
  32355. */
  32356. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32357. /**
  32358. * Set the value of an uniform to an array of number (stored as vec4)
  32359. * @param uniform defines the webGL uniform location where to store the value
  32360. * @param array defines the array of number to store
  32361. */
  32362. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32363. /**
  32364. * Set the value of an uniform to an array of float32 (stored as matrices)
  32365. * @param uniform defines the webGL uniform location where to store the value
  32366. * @param matrices defines the array of float32 to store
  32367. */
  32368. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32369. /**
  32370. * Set the value of an uniform to a matrix (3x3)
  32371. * @param uniform defines the webGL uniform location where to store the value
  32372. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32373. */
  32374. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32375. /**
  32376. * Set the value of an uniform to a matrix (2x2)
  32377. * @param uniform defines the webGL uniform location where to store the value
  32378. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32379. */
  32380. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32381. /**
  32382. * Set the value of an uniform to a number (float)
  32383. * @param uniform defines the webGL uniform location where to store the value
  32384. * @param value defines the float number to store
  32385. */
  32386. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32387. /**
  32388. * Set the value of an uniform to a vec2
  32389. * @param uniform defines the webGL uniform location where to store the value
  32390. * @param x defines the 1st component of the value
  32391. * @param y defines the 2nd component of the value
  32392. */
  32393. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32394. /**
  32395. * Set the value of an uniform to a vec3
  32396. * @param uniform defines the webGL uniform location where to store the value
  32397. * @param x defines the 1st component of the value
  32398. * @param y defines the 2nd component of the value
  32399. * @param z defines the 3rd component of the value
  32400. */
  32401. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32402. /**
  32403. * Set the value of an uniform to a vec4
  32404. * @param uniform defines the webGL uniform location where to store the value
  32405. * @param x defines the 1st component of the value
  32406. * @param y defines the 2nd component of the value
  32407. * @param z defines the 3rd component of the value
  32408. * @param w defines the 4th component of the value
  32409. */
  32410. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32411. /**
  32412. * Apply all cached states (depth, culling, stencil and alpha)
  32413. */
  32414. applyStates(): void;
  32415. /**
  32416. * Enable or disable color writing
  32417. * @param enable defines the state to set
  32418. */
  32419. setColorWrite(enable: boolean): void;
  32420. /**
  32421. * Gets a boolean indicating if color writing is enabled
  32422. * @returns the current color writing state
  32423. */
  32424. getColorWrite(): boolean;
  32425. /**
  32426. * Gets the depth culling state manager
  32427. */
  32428. get depthCullingState(): DepthCullingState;
  32429. /**
  32430. * Gets the alpha state manager
  32431. */
  32432. get alphaState(): AlphaState;
  32433. /**
  32434. * Gets the stencil state manager
  32435. */
  32436. get stencilState(): StencilState;
  32437. /**
  32438. * Clears the list of texture accessible through engine.
  32439. * This can help preventing texture load conflict due to name collision.
  32440. */
  32441. clearInternalTexturesCache(): void;
  32442. /**
  32443. * Force the entire cache to be cleared
  32444. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32445. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32446. */
  32447. wipeCaches(bruteForce?: boolean): void;
  32448. /** @hidden */
  32449. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32450. min: number;
  32451. mag: number;
  32452. };
  32453. /** @hidden */
  32454. _createTexture(): WebGLTexture;
  32455. /**
  32456. * Usually called from Texture.ts.
  32457. * Passed information to create a WebGLTexture
  32458. * @param urlArg defines a value which contains one of the following:
  32459. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32460. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32461. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32462. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32463. * @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)
  32464. * @param scene needed for loading to the correct scene
  32465. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32466. * @param onLoad optional callback to be called upon successful completion
  32467. * @param onError optional callback to be called upon failure
  32468. * @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
  32469. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32470. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32471. * @param forcedExtension defines the extension to use to pick the right loader
  32472. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32473. * @param mimeType defines an optional mime type
  32474. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32475. */
  32476. 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>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32477. /**
  32478. * Loads an image as an HTMLImageElement.
  32479. * @param input url string, ArrayBuffer, or Blob to load
  32480. * @param onLoad callback called when the image successfully loads
  32481. * @param onError callback called when the image fails to load
  32482. * @param offlineProvider offline provider for caching
  32483. * @param mimeType optional mime type
  32484. * @returns the HTMLImageElement of the loaded image
  32485. * @hidden
  32486. */
  32487. 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>;
  32488. /**
  32489. * @hidden
  32490. */
  32491. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32492. /**
  32493. * Creates a raw texture
  32494. * @param data defines the data to store in the texture
  32495. * @param width defines the width of the texture
  32496. * @param height defines the height of the texture
  32497. * @param format defines the format of the data
  32498. * @param generateMipMaps defines if the engine should generate the mip levels
  32499. * @param invertY defines if data must be stored with Y axis inverted
  32500. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32501. * @param compression defines the compression used (null by default)
  32502. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32503. * @returns the raw texture inside an InternalTexture
  32504. */
  32505. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32506. /**
  32507. * Creates a new raw cube texture
  32508. * @param data defines the array of data to use to create each face
  32509. * @param size defines the size of the textures
  32510. * @param format defines the format of the data
  32511. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32512. * @param generateMipMaps defines if the engine should generate the mip levels
  32513. * @param invertY defines if data must be stored with Y axis inverted
  32514. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32515. * @param compression defines the compression used (null by default)
  32516. * @returns the cube texture as an InternalTexture
  32517. */
  32518. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32519. /**
  32520. * Creates a new raw 3D texture
  32521. * @param data defines the data used to create the texture
  32522. * @param width defines the width of the texture
  32523. * @param height defines the height of the texture
  32524. * @param depth defines the depth of the texture
  32525. * @param format defines the format of the texture
  32526. * @param generateMipMaps defines if the engine must generate mip levels
  32527. * @param invertY defines if data must be stored with Y axis inverted
  32528. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32529. * @param compression defines the compressed used (can be null)
  32530. * @param textureType defines the compressed used (can be null)
  32531. * @returns a new raw 3D texture (stored in an InternalTexture)
  32532. */
  32533. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32534. /**
  32535. * Creates a new raw 2D array texture
  32536. * @param data defines the data used to create the texture
  32537. * @param width defines the width of the texture
  32538. * @param height defines the height of the texture
  32539. * @param depth defines the number of layers of the texture
  32540. * @param format defines the format of the texture
  32541. * @param generateMipMaps defines if the engine must generate mip levels
  32542. * @param invertY defines if data must be stored with Y axis inverted
  32543. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32544. * @param compression defines the compressed used (can be null)
  32545. * @param textureType defines the compressed used (can be null)
  32546. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32547. */
  32548. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32549. private _unpackFlipYCached;
  32550. /**
  32551. * In case you are sharing the context with other applications, it might
  32552. * be interested to not cache the unpack flip y state to ensure a consistent
  32553. * value would be set.
  32554. */
  32555. enableUnpackFlipYCached: boolean;
  32556. /** @hidden */
  32557. _unpackFlipY(value: boolean): void;
  32558. /** @hidden */
  32559. _getUnpackAlignement(): number;
  32560. private _getTextureTarget;
  32561. /**
  32562. * Update the sampling mode of a given texture
  32563. * @param samplingMode defines the required sampling mode
  32564. * @param texture defines the texture to update
  32565. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32566. */
  32567. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32568. /**
  32569. * Update the sampling mode of a given texture
  32570. * @param texture defines the texture to update
  32571. * @param wrapU defines the texture wrap mode of the u coordinates
  32572. * @param wrapV defines the texture wrap mode of the v coordinates
  32573. * @param wrapR defines the texture wrap mode of the r coordinates
  32574. */
  32575. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32576. /** @hidden */
  32577. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32578. width: number;
  32579. height: number;
  32580. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32581. /** @hidden */
  32582. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32583. /** @hidden */
  32584. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32585. /** @hidden */
  32586. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32587. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32588. private _prepareWebGLTexture;
  32589. /** @hidden */
  32590. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32591. private _getDepthStencilBuffer;
  32592. /** @hidden */
  32593. _releaseFramebufferObjects(texture: InternalTexture): void;
  32594. /** @hidden */
  32595. _releaseTexture(texture: InternalTexture): void;
  32596. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32597. protected _setProgram(program: WebGLProgram): void;
  32598. protected _boundUniforms: {
  32599. [key: number]: WebGLUniformLocation;
  32600. };
  32601. /**
  32602. * Binds an effect to the webGL context
  32603. * @param effect defines the effect to bind
  32604. */
  32605. bindSamplers(effect: Effect): void;
  32606. private _activateCurrentTexture;
  32607. /** @hidden */
  32608. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32609. /** @hidden */
  32610. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32611. /**
  32612. * Unbind all textures from the webGL context
  32613. */
  32614. unbindAllTextures(): void;
  32615. /**
  32616. * Sets a texture to the according uniform.
  32617. * @param channel The texture channel
  32618. * @param uniform The uniform to set
  32619. * @param texture The texture to apply
  32620. */
  32621. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32622. private _bindSamplerUniformToChannel;
  32623. private _getTextureWrapMode;
  32624. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32625. /**
  32626. * Sets an array of texture to the webGL context
  32627. * @param channel defines the channel where the texture array must be set
  32628. * @param uniform defines the associated uniform location
  32629. * @param textures defines the array of textures to bind
  32630. */
  32631. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32632. /** @hidden */
  32633. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32634. private _setTextureParameterFloat;
  32635. private _setTextureParameterInteger;
  32636. /**
  32637. * Unbind all vertex attributes from the webGL context
  32638. */
  32639. unbindAllAttributes(): void;
  32640. /**
  32641. * 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
  32642. */
  32643. releaseEffects(): void;
  32644. /**
  32645. * Dispose and release all associated resources
  32646. */
  32647. dispose(): void;
  32648. /**
  32649. * Attach a new callback raised when context lost event is fired
  32650. * @param callback defines the callback to call
  32651. */
  32652. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32653. /**
  32654. * Attach a new callback raised when context restored event is fired
  32655. * @param callback defines the callback to call
  32656. */
  32657. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32658. /**
  32659. * Get the current error code of the webGL context
  32660. * @returns the error code
  32661. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32662. */
  32663. getError(): number;
  32664. private _canRenderToFloatFramebuffer;
  32665. private _canRenderToHalfFloatFramebuffer;
  32666. private _canRenderToFramebuffer;
  32667. /** @hidden */
  32668. _getWebGLTextureType(type: number): number;
  32669. /** @hidden */
  32670. _getInternalFormat(format: number): number;
  32671. /** @hidden */
  32672. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32673. /** @hidden */
  32674. _getRGBAMultiSampleBufferFormat(type: number): number;
  32675. /** @hidden */
  32676. _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;
  32677. /**
  32678. * Loads a file from a url
  32679. * @param url url to load
  32680. * @param onSuccess callback called when the file successfully loads
  32681. * @param onProgress callback called while file is loading (if the server supports this mode)
  32682. * @param offlineProvider defines the offline provider for caching
  32683. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32684. * @param onError callback called when the file fails to load
  32685. * @returns a file request object
  32686. * @hidden
  32687. */
  32688. 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;
  32689. /**
  32690. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32691. * @param x defines the x coordinate of the rectangle where pixels must be read
  32692. * @param y defines the y coordinate of the rectangle where pixels must be read
  32693. * @param width defines the width of the rectangle where pixels must be read
  32694. * @param height defines the height of the rectangle where pixels must be read
  32695. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  32696. * @returns a Uint8Array containing RGBA colors
  32697. */
  32698. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32699. private static _isSupported;
  32700. /**
  32701. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32702. * @returns true if the engine can be created
  32703. * @ignorenaming
  32704. */
  32705. static isSupported(): boolean;
  32706. /**
  32707. * Find the next highest power of two.
  32708. * @param x Number to start search from.
  32709. * @return Next highest power of two.
  32710. */
  32711. static CeilingPOT(x: number): number;
  32712. /**
  32713. * Find the next lowest power of two.
  32714. * @param x Number to start search from.
  32715. * @return Next lowest power of two.
  32716. */
  32717. static FloorPOT(x: number): number;
  32718. /**
  32719. * Find the nearest power of two.
  32720. * @param x Number to start search from.
  32721. * @return Next nearest power of two.
  32722. */
  32723. static NearestPOT(x: number): number;
  32724. /**
  32725. * Get the closest exponent of two
  32726. * @param value defines the value to approximate
  32727. * @param max defines the maximum value to return
  32728. * @param mode defines how to define the closest value
  32729. * @returns closest exponent of two of the given value
  32730. */
  32731. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32732. /**
  32733. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32734. * @param func - the function to be called
  32735. * @param requester - the object that will request the next frame. Falls back to window.
  32736. * @returns frame number
  32737. */
  32738. static QueueNewFrame(func: () => void, requester?: any): number;
  32739. /**
  32740. * Gets host document
  32741. * @returns the host document object
  32742. */
  32743. getHostDocument(): Nullable<Document>;
  32744. }
  32745. }
  32746. declare module "babylonjs/Maths/sphericalPolynomial" {
  32747. import { Vector3 } from "babylonjs/Maths/math.vector";
  32748. import { Color3 } from "babylonjs/Maths/math.color";
  32749. /**
  32750. * Class representing spherical harmonics coefficients to the 3rd degree
  32751. */
  32752. export class SphericalHarmonics {
  32753. /**
  32754. * Defines whether or not the harmonics have been prescaled for rendering.
  32755. */
  32756. preScaled: boolean;
  32757. /**
  32758. * The l0,0 coefficients of the spherical harmonics
  32759. */
  32760. l00: Vector3;
  32761. /**
  32762. * The l1,-1 coefficients of the spherical harmonics
  32763. */
  32764. l1_1: Vector3;
  32765. /**
  32766. * The l1,0 coefficients of the spherical harmonics
  32767. */
  32768. l10: Vector3;
  32769. /**
  32770. * The l1,1 coefficients of the spherical harmonics
  32771. */
  32772. l11: Vector3;
  32773. /**
  32774. * The l2,-2 coefficients of the spherical harmonics
  32775. */
  32776. l2_2: Vector3;
  32777. /**
  32778. * The l2,-1 coefficients of the spherical harmonics
  32779. */
  32780. l2_1: Vector3;
  32781. /**
  32782. * The l2,0 coefficients of the spherical harmonics
  32783. */
  32784. l20: Vector3;
  32785. /**
  32786. * The l2,1 coefficients of the spherical harmonics
  32787. */
  32788. l21: Vector3;
  32789. /**
  32790. * The l2,2 coefficients of the spherical harmonics
  32791. */
  32792. l22: Vector3;
  32793. /**
  32794. * Adds a light to the spherical harmonics
  32795. * @param direction the direction of the light
  32796. * @param color the color of the light
  32797. * @param deltaSolidAngle the delta solid angle of the light
  32798. */
  32799. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32800. /**
  32801. * Scales the spherical harmonics by the given amount
  32802. * @param scale the amount to scale
  32803. */
  32804. scaleInPlace(scale: number): void;
  32805. /**
  32806. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32807. *
  32808. * ```
  32809. * E_lm = A_l * L_lm
  32810. * ```
  32811. *
  32812. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32813. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32814. * the scaling factors are given in equation 9.
  32815. */
  32816. convertIncidentRadianceToIrradiance(): void;
  32817. /**
  32818. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32819. *
  32820. * ```
  32821. * L = (1/pi) * E * rho
  32822. * ```
  32823. *
  32824. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32825. */
  32826. convertIrradianceToLambertianRadiance(): void;
  32827. /**
  32828. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32829. * required operations at run time.
  32830. *
  32831. * This is simply done by scaling back the SH with Ylm constants parameter.
  32832. * The trigonometric part being applied by the shader at run time.
  32833. */
  32834. preScaleForRendering(): void;
  32835. /**
  32836. * Constructs a spherical harmonics from an array.
  32837. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32838. * @returns the spherical harmonics
  32839. */
  32840. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32841. /**
  32842. * Gets the spherical harmonics from polynomial
  32843. * @param polynomial the spherical polynomial
  32844. * @returns the spherical harmonics
  32845. */
  32846. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32847. }
  32848. /**
  32849. * Class representing spherical polynomial coefficients to the 3rd degree
  32850. */
  32851. export class SphericalPolynomial {
  32852. private _harmonics;
  32853. /**
  32854. * The spherical harmonics used to create the polynomials.
  32855. */
  32856. get preScaledHarmonics(): SphericalHarmonics;
  32857. /**
  32858. * The x coefficients of the spherical polynomial
  32859. */
  32860. x: Vector3;
  32861. /**
  32862. * The y coefficients of the spherical polynomial
  32863. */
  32864. y: Vector3;
  32865. /**
  32866. * The z coefficients of the spherical polynomial
  32867. */
  32868. z: Vector3;
  32869. /**
  32870. * The xx coefficients of the spherical polynomial
  32871. */
  32872. xx: Vector3;
  32873. /**
  32874. * The yy coefficients of the spherical polynomial
  32875. */
  32876. yy: Vector3;
  32877. /**
  32878. * The zz coefficients of the spherical polynomial
  32879. */
  32880. zz: Vector3;
  32881. /**
  32882. * The xy coefficients of the spherical polynomial
  32883. */
  32884. xy: Vector3;
  32885. /**
  32886. * The yz coefficients of the spherical polynomial
  32887. */
  32888. yz: Vector3;
  32889. /**
  32890. * The zx coefficients of the spherical polynomial
  32891. */
  32892. zx: Vector3;
  32893. /**
  32894. * Adds an ambient color to the spherical polynomial
  32895. * @param color the color to add
  32896. */
  32897. addAmbient(color: Color3): void;
  32898. /**
  32899. * Scales the spherical polynomial by the given amount
  32900. * @param scale the amount to scale
  32901. */
  32902. scaleInPlace(scale: number): void;
  32903. /**
  32904. * Gets the spherical polynomial from harmonics
  32905. * @param harmonics the spherical harmonics
  32906. * @returns the spherical polynomial
  32907. */
  32908. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32909. /**
  32910. * Constructs a spherical polynomial from an array.
  32911. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32912. * @returns the spherical polynomial
  32913. */
  32914. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32915. }
  32916. }
  32917. declare module "babylonjs/Materials/Textures/internalTexture" {
  32918. import { Observable } from "babylonjs/Misc/observable";
  32919. import { Nullable, int } from "babylonjs/types";
  32920. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  32921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32922. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  32923. /**
  32924. * Defines the source of the internal texture
  32925. */
  32926. export enum InternalTextureSource {
  32927. /**
  32928. * The source of the texture data is unknown
  32929. */
  32930. Unknown = 0,
  32931. /**
  32932. * Texture data comes from an URL
  32933. */
  32934. Url = 1,
  32935. /**
  32936. * Texture data is only used for temporary storage
  32937. */
  32938. Temp = 2,
  32939. /**
  32940. * Texture data comes from raw data (ArrayBuffer)
  32941. */
  32942. Raw = 3,
  32943. /**
  32944. * Texture content is dynamic (video or dynamic texture)
  32945. */
  32946. Dynamic = 4,
  32947. /**
  32948. * Texture content is generated by rendering to it
  32949. */
  32950. RenderTarget = 5,
  32951. /**
  32952. * Texture content is part of a multi render target process
  32953. */
  32954. MultiRenderTarget = 6,
  32955. /**
  32956. * Texture data comes from a cube data file
  32957. */
  32958. Cube = 7,
  32959. /**
  32960. * Texture data comes from a raw cube data
  32961. */
  32962. CubeRaw = 8,
  32963. /**
  32964. * Texture data come from a prefiltered cube data file
  32965. */
  32966. CubePrefiltered = 9,
  32967. /**
  32968. * Texture content is raw 3D data
  32969. */
  32970. Raw3D = 10,
  32971. /**
  32972. * Texture content is raw 2D array data
  32973. */
  32974. Raw2DArray = 11,
  32975. /**
  32976. * Texture content is a depth texture
  32977. */
  32978. Depth = 12,
  32979. /**
  32980. * Texture data comes from a raw cube data encoded with RGBD
  32981. */
  32982. CubeRawRGBD = 13
  32983. }
  32984. /**
  32985. * Class used to store data associated with WebGL texture data for the engine
  32986. * This class should not be used directly
  32987. */
  32988. export class InternalTexture {
  32989. /** @hidden */
  32990. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32991. /**
  32992. * Defines if the texture is ready
  32993. */
  32994. isReady: boolean;
  32995. /**
  32996. * Defines if the texture is a cube texture
  32997. */
  32998. isCube: boolean;
  32999. /**
  33000. * Defines if the texture contains 3D data
  33001. */
  33002. is3D: boolean;
  33003. /**
  33004. * Defines if the texture contains 2D array data
  33005. */
  33006. is2DArray: boolean;
  33007. /**
  33008. * Defines if the texture contains multiview data
  33009. */
  33010. isMultiview: boolean;
  33011. /**
  33012. * Gets the URL used to load this texture
  33013. */
  33014. url: string;
  33015. /**
  33016. * Gets the sampling mode of the texture
  33017. */
  33018. samplingMode: number;
  33019. /**
  33020. * Gets a boolean indicating if the texture needs mipmaps generation
  33021. */
  33022. generateMipMaps: boolean;
  33023. /**
  33024. * Gets the number of samples used by the texture (WebGL2+ only)
  33025. */
  33026. samples: number;
  33027. /**
  33028. * Gets the type of the texture (int, float...)
  33029. */
  33030. type: number;
  33031. /**
  33032. * Gets the format of the texture (RGB, RGBA...)
  33033. */
  33034. format: number;
  33035. /**
  33036. * Observable called when the texture is loaded
  33037. */
  33038. onLoadedObservable: Observable<InternalTexture>;
  33039. /**
  33040. * Gets the width of the texture
  33041. */
  33042. width: number;
  33043. /**
  33044. * Gets the height of the texture
  33045. */
  33046. height: number;
  33047. /**
  33048. * Gets the depth of the texture
  33049. */
  33050. depth: number;
  33051. /**
  33052. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33053. */
  33054. baseWidth: number;
  33055. /**
  33056. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33057. */
  33058. baseHeight: number;
  33059. /**
  33060. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33061. */
  33062. baseDepth: number;
  33063. /**
  33064. * Gets a boolean indicating if the texture is inverted on Y axis
  33065. */
  33066. invertY: boolean;
  33067. /** @hidden */
  33068. _invertVScale: boolean;
  33069. /** @hidden */
  33070. _associatedChannel: number;
  33071. /** @hidden */
  33072. _source: InternalTextureSource;
  33073. /** @hidden */
  33074. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33075. /** @hidden */
  33076. _bufferView: Nullable<ArrayBufferView>;
  33077. /** @hidden */
  33078. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33079. /** @hidden */
  33080. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33081. /** @hidden */
  33082. _size: number;
  33083. /** @hidden */
  33084. _extension: string;
  33085. /** @hidden */
  33086. _files: Nullable<string[]>;
  33087. /** @hidden */
  33088. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33089. /** @hidden */
  33090. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33091. /** @hidden */
  33092. _framebuffer: Nullable<WebGLFramebuffer>;
  33093. /** @hidden */
  33094. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33095. /** @hidden */
  33096. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33097. /** @hidden */
  33098. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33099. /** @hidden */
  33100. _attachments: Nullable<number[]>;
  33101. /** @hidden */
  33102. _cachedCoordinatesMode: Nullable<number>;
  33103. /** @hidden */
  33104. _cachedWrapU: Nullable<number>;
  33105. /** @hidden */
  33106. _cachedWrapV: Nullable<number>;
  33107. /** @hidden */
  33108. _cachedWrapR: Nullable<number>;
  33109. /** @hidden */
  33110. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33111. /** @hidden */
  33112. _isDisabled: boolean;
  33113. /** @hidden */
  33114. _compression: Nullable<string>;
  33115. /** @hidden */
  33116. _generateStencilBuffer: boolean;
  33117. /** @hidden */
  33118. _generateDepthBuffer: boolean;
  33119. /** @hidden */
  33120. _comparisonFunction: number;
  33121. /** @hidden */
  33122. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33123. /** @hidden */
  33124. _lodGenerationScale: number;
  33125. /** @hidden */
  33126. _lodGenerationOffset: number;
  33127. /** @hidden */
  33128. _colorTextureArray: Nullable<WebGLTexture>;
  33129. /** @hidden */
  33130. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33131. /** @hidden */
  33132. _lodTextureHigh: Nullable<BaseTexture>;
  33133. /** @hidden */
  33134. _lodTextureMid: Nullable<BaseTexture>;
  33135. /** @hidden */
  33136. _lodTextureLow: Nullable<BaseTexture>;
  33137. /** @hidden */
  33138. _isRGBD: boolean;
  33139. /** @hidden */
  33140. _linearSpecularLOD: boolean;
  33141. /** @hidden */
  33142. _irradianceTexture: Nullable<BaseTexture>;
  33143. /** @hidden */
  33144. _webGLTexture: Nullable<WebGLTexture>;
  33145. /** @hidden */
  33146. _references: number;
  33147. private _engine;
  33148. /**
  33149. * Gets the Engine the texture belongs to.
  33150. * @returns The babylon engine
  33151. */
  33152. getEngine(): ThinEngine;
  33153. /**
  33154. * Gets the data source type of the texture
  33155. */
  33156. get source(): InternalTextureSource;
  33157. /**
  33158. * Creates a new InternalTexture
  33159. * @param engine defines the engine to use
  33160. * @param source defines the type of data that will be used
  33161. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33162. */
  33163. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33164. /**
  33165. * Increments the number of references (ie. the number of Texture that point to it)
  33166. */
  33167. incrementReferences(): void;
  33168. /**
  33169. * Change the size of the texture (not the size of the content)
  33170. * @param width defines the new width
  33171. * @param height defines the new height
  33172. * @param depth defines the new depth (1 by default)
  33173. */
  33174. updateSize(width: int, height: int, depth?: int): void;
  33175. /** @hidden */
  33176. _rebuild(): void;
  33177. /** @hidden */
  33178. _swapAndDie(target: InternalTexture): void;
  33179. /**
  33180. * Dispose the current allocated resources
  33181. */
  33182. dispose(): void;
  33183. }
  33184. }
  33185. declare module "babylonjs/Audio/analyser" {
  33186. import { Scene } from "babylonjs/scene";
  33187. /**
  33188. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33190. */
  33191. export class Analyser {
  33192. /**
  33193. * Gets or sets the smoothing
  33194. * @ignorenaming
  33195. */
  33196. SMOOTHING: number;
  33197. /**
  33198. * Gets or sets the FFT table size
  33199. * @ignorenaming
  33200. */
  33201. FFT_SIZE: number;
  33202. /**
  33203. * Gets or sets the bar graph amplitude
  33204. * @ignorenaming
  33205. */
  33206. BARGRAPHAMPLITUDE: number;
  33207. /**
  33208. * Gets or sets the position of the debug canvas
  33209. * @ignorenaming
  33210. */
  33211. DEBUGCANVASPOS: {
  33212. x: number;
  33213. y: number;
  33214. };
  33215. /**
  33216. * Gets or sets the debug canvas size
  33217. * @ignorenaming
  33218. */
  33219. DEBUGCANVASSIZE: {
  33220. width: number;
  33221. height: number;
  33222. };
  33223. private _byteFreqs;
  33224. private _byteTime;
  33225. private _floatFreqs;
  33226. private _webAudioAnalyser;
  33227. private _debugCanvas;
  33228. private _debugCanvasContext;
  33229. private _scene;
  33230. private _registerFunc;
  33231. private _audioEngine;
  33232. /**
  33233. * Creates a new analyser
  33234. * @param scene defines hosting scene
  33235. */
  33236. constructor(scene: Scene);
  33237. /**
  33238. * Get the number of data values you will have to play with for the visualization
  33239. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33240. * @returns a number
  33241. */
  33242. getFrequencyBinCount(): number;
  33243. /**
  33244. * Gets the current frequency data as a byte array
  33245. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33246. * @returns a Uint8Array
  33247. */
  33248. getByteFrequencyData(): Uint8Array;
  33249. /**
  33250. * Gets the current waveform as a byte array
  33251. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33252. * @returns a Uint8Array
  33253. */
  33254. getByteTimeDomainData(): Uint8Array;
  33255. /**
  33256. * Gets the current frequency data as a float array
  33257. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33258. * @returns a Float32Array
  33259. */
  33260. getFloatFrequencyData(): Float32Array;
  33261. /**
  33262. * Renders the debug canvas
  33263. */
  33264. drawDebugCanvas(): void;
  33265. /**
  33266. * Stops rendering the debug canvas and removes it
  33267. */
  33268. stopDebugCanvas(): void;
  33269. /**
  33270. * Connects two audio nodes
  33271. * @param inputAudioNode defines first node to connect
  33272. * @param outputAudioNode defines second node to connect
  33273. */
  33274. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33275. /**
  33276. * Releases all associated resources
  33277. */
  33278. dispose(): void;
  33279. }
  33280. }
  33281. declare module "babylonjs/Audio/audioEngine" {
  33282. import { IDisposable } from "babylonjs/scene";
  33283. import { Analyser } from "babylonjs/Audio/analyser";
  33284. import { Nullable } from "babylonjs/types";
  33285. import { Observable } from "babylonjs/Misc/observable";
  33286. /**
  33287. * This represents an audio engine and it is responsible
  33288. * to play, synchronize and analyse sounds throughout the application.
  33289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33290. */
  33291. export interface IAudioEngine extends IDisposable {
  33292. /**
  33293. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33294. */
  33295. readonly canUseWebAudio: boolean;
  33296. /**
  33297. * Gets the current AudioContext if available.
  33298. */
  33299. readonly audioContext: Nullable<AudioContext>;
  33300. /**
  33301. * The master gain node defines the global audio volume of your audio engine.
  33302. */
  33303. readonly masterGain: GainNode;
  33304. /**
  33305. * Gets whether or not mp3 are supported by your browser.
  33306. */
  33307. readonly isMP3supported: boolean;
  33308. /**
  33309. * Gets whether or not ogg are supported by your browser.
  33310. */
  33311. readonly isOGGsupported: boolean;
  33312. /**
  33313. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33314. * @ignoreNaming
  33315. */
  33316. WarnedWebAudioUnsupported: boolean;
  33317. /**
  33318. * Defines if the audio engine relies on a custom unlocked button.
  33319. * In this case, the embedded button will not be displayed.
  33320. */
  33321. useCustomUnlockedButton: boolean;
  33322. /**
  33323. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33324. */
  33325. readonly unlocked: boolean;
  33326. /**
  33327. * Event raised when audio has been unlocked on the browser.
  33328. */
  33329. onAudioUnlockedObservable: Observable<AudioEngine>;
  33330. /**
  33331. * Event raised when audio has been locked on the browser.
  33332. */
  33333. onAudioLockedObservable: Observable<AudioEngine>;
  33334. /**
  33335. * Flags the audio engine in Locked state.
  33336. * This happens due to new browser policies preventing audio to autoplay.
  33337. */
  33338. lock(): void;
  33339. /**
  33340. * Unlocks the audio engine once a user action has been done on the dom.
  33341. * This is helpful to resume play once browser policies have been satisfied.
  33342. */
  33343. unlock(): void;
  33344. }
  33345. /**
  33346. * This represents the default audio engine used in babylon.
  33347. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33349. */
  33350. export class AudioEngine implements IAudioEngine {
  33351. private _audioContext;
  33352. private _audioContextInitialized;
  33353. private _muteButton;
  33354. private _hostElement;
  33355. /**
  33356. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33357. */
  33358. canUseWebAudio: boolean;
  33359. /**
  33360. * The master gain node defines the global audio volume of your audio engine.
  33361. */
  33362. masterGain: GainNode;
  33363. /**
  33364. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33365. * @ignoreNaming
  33366. */
  33367. WarnedWebAudioUnsupported: boolean;
  33368. /**
  33369. * Gets whether or not mp3 are supported by your browser.
  33370. */
  33371. isMP3supported: boolean;
  33372. /**
  33373. * Gets whether or not ogg are supported by your browser.
  33374. */
  33375. isOGGsupported: boolean;
  33376. /**
  33377. * Gets whether audio has been unlocked on the device.
  33378. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33379. * a user interaction has happened.
  33380. */
  33381. unlocked: boolean;
  33382. /**
  33383. * Defines if the audio engine relies on a custom unlocked button.
  33384. * In this case, the embedded button will not be displayed.
  33385. */
  33386. useCustomUnlockedButton: boolean;
  33387. /**
  33388. * Event raised when audio has been unlocked on the browser.
  33389. */
  33390. onAudioUnlockedObservable: Observable<AudioEngine>;
  33391. /**
  33392. * Event raised when audio has been locked on the browser.
  33393. */
  33394. onAudioLockedObservable: Observable<AudioEngine>;
  33395. /**
  33396. * Gets the current AudioContext if available.
  33397. */
  33398. get audioContext(): Nullable<AudioContext>;
  33399. private _connectedAnalyser;
  33400. /**
  33401. * Instantiates a new audio engine.
  33402. *
  33403. * There should be only one per page as some browsers restrict the number
  33404. * of audio contexts you can create.
  33405. * @param hostElement defines the host element where to display the mute icon if necessary
  33406. */
  33407. constructor(hostElement?: Nullable<HTMLElement>);
  33408. /**
  33409. * Flags the audio engine in Locked state.
  33410. * This happens due to new browser policies preventing audio to autoplay.
  33411. */
  33412. lock(): void;
  33413. /**
  33414. * Unlocks the audio engine once a user action has been done on the dom.
  33415. * This is helpful to resume play once browser policies have been satisfied.
  33416. */
  33417. unlock(): void;
  33418. private _resumeAudioContext;
  33419. private _initializeAudioContext;
  33420. private _tryToRun;
  33421. private _triggerRunningState;
  33422. private _triggerSuspendedState;
  33423. private _displayMuteButton;
  33424. private _moveButtonToTopLeft;
  33425. private _onResize;
  33426. private _hideMuteButton;
  33427. /**
  33428. * Destroy and release the resources associated with the audio ccontext.
  33429. */
  33430. dispose(): void;
  33431. /**
  33432. * Gets the global volume sets on the master gain.
  33433. * @returns the global volume if set or -1 otherwise
  33434. */
  33435. getGlobalVolume(): number;
  33436. /**
  33437. * Sets the global volume of your experience (sets on the master gain).
  33438. * @param newVolume Defines the new global volume of the application
  33439. */
  33440. setGlobalVolume(newVolume: number): void;
  33441. /**
  33442. * Connect the audio engine to an audio analyser allowing some amazing
  33443. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33445. * @param analyser The analyser to connect to the engine
  33446. */
  33447. connectToAnalyser(analyser: Analyser): void;
  33448. }
  33449. }
  33450. declare module "babylonjs/Loading/loadingScreen" {
  33451. /**
  33452. * Interface used to present a loading screen while loading a scene
  33453. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33454. */
  33455. export interface ILoadingScreen {
  33456. /**
  33457. * Function called to display the loading screen
  33458. */
  33459. displayLoadingUI: () => void;
  33460. /**
  33461. * Function called to hide the loading screen
  33462. */
  33463. hideLoadingUI: () => void;
  33464. /**
  33465. * Gets or sets the color to use for the background
  33466. */
  33467. loadingUIBackgroundColor: string;
  33468. /**
  33469. * Gets or sets the text to display while loading
  33470. */
  33471. loadingUIText: string;
  33472. }
  33473. /**
  33474. * Class used for the default loading screen
  33475. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33476. */
  33477. export class DefaultLoadingScreen implements ILoadingScreen {
  33478. private _renderingCanvas;
  33479. private _loadingText;
  33480. private _loadingDivBackgroundColor;
  33481. private _loadingDiv;
  33482. private _loadingTextDiv;
  33483. /** Gets or sets the logo url to use for the default loading screen */
  33484. static DefaultLogoUrl: string;
  33485. /** Gets or sets the spinner url to use for the default loading screen */
  33486. static DefaultSpinnerUrl: string;
  33487. /**
  33488. * Creates a new default loading screen
  33489. * @param _renderingCanvas defines the canvas used to render the scene
  33490. * @param _loadingText defines the default text to display
  33491. * @param _loadingDivBackgroundColor defines the default background color
  33492. */
  33493. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33494. /**
  33495. * Function called to display the loading screen
  33496. */
  33497. displayLoadingUI(): void;
  33498. /**
  33499. * Function called to hide the loading screen
  33500. */
  33501. hideLoadingUI(): void;
  33502. /**
  33503. * Gets or sets the text to display while loading
  33504. */
  33505. set loadingUIText(text: string);
  33506. get loadingUIText(): string;
  33507. /**
  33508. * Gets or sets the color to use for the background
  33509. */
  33510. get loadingUIBackgroundColor(): string;
  33511. set loadingUIBackgroundColor(color: string);
  33512. private _resizeLoadingUI;
  33513. }
  33514. }
  33515. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33516. /**
  33517. * Interface for any object that can request an animation frame
  33518. */
  33519. export interface ICustomAnimationFrameRequester {
  33520. /**
  33521. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33522. */
  33523. renderFunction?: Function;
  33524. /**
  33525. * Called to request the next frame to render to
  33526. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33527. */
  33528. requestAnimationFrame: Function;
  33529. /**
  33530. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33531. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33532. */
  33533. requestID?: number;
  33534. }
  33535. }
  33536. declare module "babylonjs/Misc/performanceMonitor" {
  33537. /**
  33538. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33539. */
  33540. export class PerformanceMonitor {
  33541. private _enabled;
  33542. private _rollingFrameTime;
  33543. private _lastFrameTimeMs;
  33544. /**
  33545. * constructor
  33546. * @param frameSampleSize The number of samples required to saturate the sliding window
  33547. */
  33548. constructor(frameSampleSize?: number);
  33549. /**
  33550. * Samples current frame
  33551. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33552. */
  33553. sampleFrame(timeMs?: number): void;
  33554. /**
  33555. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33556. */
  33557. get averageFrameTime(): number;
  33558. /**
  33559. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33560. */
  33561. get averageFrameTimeVariance(): number;
  33562. /**
  33563. * Returns the frame time of the most recent frame
  33564. */
  33565. get instantaneousFrameTime(): number;
  33566. /**
  33567. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33568. */
  33569. get averageFPS(): number;
  33570. /**
  33571. * Returns the average framerate in frames per second using the most recent frame time
  33572. */
  33573. get instantaneousFPS(): number;
  33574. /**
  33575. * Returns true if enough samples have been taken to completely fill the sliding window
  33576. */
  33577. get isSaturated(): boolean;
  33578. /**
  33579. * Enables contributions to the sliding window sample set
  33580. */
  33581. enable(): void;
  33582. /**
  33583. * Disables contributions to the sliding window sample set
  33584. * Samples will not be interpolated over the disabled period
  33585. */
  33586. disable(): void;
  33587. /**
  33588. * Returns true if sampling is enabled
  33589. */
  33590. get isEnabled(): boolean;
  33591. /**
  33592. * Resets performance monitor
  33593. */
  33594. reset(): void;
  33595. }
  33596. /**
  33597. * RollingAverage
  33598. *
  33599. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33600. */
  33601. export class RollingAverage {
  33602. /**
  33603. * Current average
  33604. */
  33605. average: number;
  33606. /**
  33607. * Current variance
  33608. */
  33609. variance: number;
  33610. protected _samples: Array<number>;
  33611. protected _sampleCount: number;
  33612. protected _pos: number;
  33613. protected _m2: number;
  33614. /**
  33615. * constructor
  33616. * @param length The number of samples required to saturate the sliding window
  33617. */
  33618. constructor(length: number);
  33619. /**
  33620. * Adds a sample to the sample set
  33621. * @param v The sample value
  33622. */
  33623. add(v: number): void;
  33624. /**
  33625. * Returns previously added values or null if outside of history or outside the sliding window domain
  33626. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33627. * @return Value previously recorded with add() or null if outside of range
  33628. */
  33629. history(i: number): number;
  33630. /**
  33631. * Returns true if enough samples have been taken to completely fill the sliding window
  33632. * @return true if sample-set saturated
  33633. */
  33634. isSaturated(): boolean;
  33635. /**
  33636. * Resets the rolling average (equivalent to 0 samples taken so far)
  33637. */
  33638. reset(): void;
  33639. /**
  33640. * Wraps a value around the sample range boundaries
  33641. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33642. * @return Wrapped position in sample range
  33643. */
  33644. protected _wrapPosition(i: number): number;
  33645. }
  33646. }
  33647. declare module "babylonjs/Misc/perfCounter" {
  33648. /**
  33649. * This class is used to track a performance counter which is number based.
  33650. * The user has access to many properties which give statistics of different nature.
  33651. *
  33652. * The implementer can track two kinds of Performance Counter: time and count.
  33653. * 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.
  33654. * 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.
  33655. */
  33656. export class PerfCounter {
  33657. /**
  33658. * Gets or sets a global boolean to turn on and off all the counters
  33659. */
  33660. static Enabled: boolean;
  33661. /**
  33662. * Returns the smallest value ever
  33663. */
  33664. get min(): number;
  33665. /**
  33666. * Returns the biggest value ever
  33667. */
  33668. get max(): number;
  33669. /**
  33670. * Returns the average value since the performance counter is running
  33671. */
  33672. get average(): number;
  33673. /**
  33674. * Returns the average value of the last second the counter was monitored
  33675. */
  33676. get lastSecAverage(): number;
  33677. /**
  33678. * Returns the current value
  33679. */
  33680. get current(): number;
  33681. /**
  33682. * Gets the accumulated total
  33683. */
  33684. get total(): number;
  33685. /**
  33686. * Gets the total value count
  33687. */
  33688. get count(): number;
  33689. /**
  33690. * Creates a new counter
  33691. */
  33692. constructor();
  33693. /**
  33694. * Call this method to start monitoring a new frame.
  33695. * 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.
  33696. */
  33697. fetchNewFrame(): void;
  33698. /**
  33699. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33700. * @param newCount the count value to add to the monitored count
  33701. * @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.
  33702. */
  33703. addCount(newCount: number, fetchResult: boolean): void;
  33704. /**
  33705. * Start monitoring this performance counter
  33706. */
  33707. beginMonitoring(): void;
  33708. /**
  33709. * Compute the time lapsed since the previous beginMonitoring() call.
  33710. * @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
  33711. */
  33712. endMonitoring(newFrame?: boolean): void;
  33713. private _fetchResult;
  33714. private _startMonitoringTime;
  33715. private _min;
  33716. private _max;
  33717. private _average;
  33718. private _current;
  33719. private _totalValueCount;
  33720. private _totalAccumulated;
  33721. private _lastSecAverage;
  33722. private _lastSecAccumulated;
  33723. private _lastSecTime;
  33724. private _lastSecValueCount;
  33725. }
  33726. }
  33727. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33728. module "babylonjs/Engines/thinEngine" {
  33729. interface ThinEngine {
  33730. /**
  33731. * Sets alpha constants used by some alpha blending modes
  33732. * @param r defines the red component
  33733. * @param g defines the green component
  33734. * @param b defines the blue component
  33735. * @param a defines the alpha component
  33736. */
  33737. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33738. /**
  33739. * Sets the current alpha mode
  33740. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33741. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33742. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33743. */
  33744. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33745. /**
  33746. * Gets the current alpha mode
  33747. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33748. * @returns the current alpha mode
  33749. */
  33750. getAlphaMode(): number;
  33751. /**
  33752. * Sets the current alpha equation
  33753. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33754. */
  33755. setAlphaEquation(equation: number): void;
  33756. /**
  33757. * Gets the current alpha equation.
  33758. * @returns the current alpha equation
  33759. */
  33760. getAlphaEquation(): number;
  33761. }
  33762. }
  33763. }
  33764. declare module "babylonjs/Engines/engine" {
  33765. import { Observable } from "babylonjs/Misc/observable";
  33766. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33767. import { Scene } from "babylonjs/scene";
  33768. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33769. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33770. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33771. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  33772. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  33773. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  33774. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  33775. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  33776. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  33777. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33778. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  33779. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  33780. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33781. import "babylonjs/Engines/Extensions/engine.alpha";
  33782. import { Material } from "babylonjs/Materials/material";
  33783. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33784. /**
  33785. * Defines the interface used by display changed events
  33786. */
  33787. export interface IDisplayChangedEventArgs {
  33788. /** Gets the vrDisplay object (if any) */
  33789. vrDisplay: Nullable<any>;
  33790. /** Gets a boolean indicating if webVR is supported */
  33791. vrSupported: boolean;
  33792. }
  33793. /**
  33794. * Defines the interface used by objects containing a viewport (like a camera)
  33795. */
  33796. interface IViewportOwnerLike {
  33797. /**
  33798. * Gets or sets the viewport
  33799. */
  33800. viewport: IViewportLike;
  33801. }
  33802. /**
  33803. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33804. */
  33805. export class Engine extends ThinEngine {
  33806. /** Defines that alpha blending is disabled */
  33807. static readonly ALPHA_DISABLE: number;
  33808. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33809. static readonly ALPHA_ADD: number;
  33810. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33811. static readonly ALPHA_COMBINE: number;
  33812. /** Defines that alpha blending to DEST - SRC * DEST */
  33813. static readonly ALPHA_SUBTRACT: number;
  33814. /** Defines that alpha blending to SRC * DEST */
  33815. static readonly ALPHA_MULTIPLY: number;
  33816. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33817. static readonly ALPHA_MAXIMIZED: number;
  33818. /** Defines that alpha blending to SRC + DEST */
  33819. static readonly ALPHA_ONEONE: number;
  33820. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33821. static readonly ALPHA_PREMULTIPLIED: number;
  33822. /**
  33823. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33824. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33825. */
  33826. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33827. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33828. static readonly ALPHA_INTERPOLATE: number;
  33829. /**
  33830. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33831. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33832. */
  33833. static readonly ALPHA_SCREENMODE: number;
  33834. /** Defines that the ressource is not delayed*/
  33835. static readonly DELAYLOADSTATE_NONE: number;
  33836. /** Defines that the ressource was successfully delay loaded */
  33837. static readonly DELAYLOADSTATE_LOADED: number;
  33838. /** Defines that the ressource is currently delay loading */
  33839. static readonly DELAYLOADSTATE_LOADING: number;
  33840. /** Defines that the ressource is delayed and has not started loading */
  33841. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33842. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33843. static readonly NEVER: number;
  33844. /** 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 */
  33845. static readonly ALWAYS: number;
  33846. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33847. static readonly LESS: number;
  33848. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33849. static readonly EQUAL: number;
  33850. /** 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 */
  33851. static readonly LEQUAL: number;
  33852. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33853. static readonly GREATER: number;
  33854. /** 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 */
  33855. static readonly GEQUAL: number;
  33856. /** 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 */
  33857. static readonly NOTEQUAL: number;
  33858. /** Passed to stencilOperation to specify that stencil value must be kept */
  33859. static readonly KEEP: number;
  33860. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33861. static readonly REPLACE: number;
  33862. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33863. static readonly INCR: number;
  33864. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33865. static readonly DECR: number;
  33866. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33867. static readonly INVERT: number;
  33868. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33869. static readonly INCR_WRAP: number;
  33870. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33871. static readonly DECR_WRAP: number;
  33872. /** Texture is not repeating outside of 0..1 UVs */
  33873. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33874. /** Texture is repeating outside of 0..1 UVs */
  33875. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33876. /** Texture is repeating and mirrored */
  33877. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33878. /** ALPHA */
  33879. static readonly TEXTUREFORMAT_ALPHA: number;
  33880. /** LUMINANCE */
  33881. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33882. /** LUMINANCE_ALPHA */
  33883. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33884. /** RGB */
  33885. static readonly TEXTUREFORMAT_RGB: number;
  33886. /** RGBA */
  33887. static readonly TEXTUREFORMAT_RGBA: number;
  33888. /** RED */
  33889. static readonly TEXTUREFORMAT_RED: number;
  33890. /** RED (2nd reference) */
  33891. static readonly TEXTUREFORMAT_R: number;
  33892. /** RG */
  33893. static readonly TEXTUREFORMAT_RG: number;
  33894. /** RED_INTEGER */
  33895. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33896. /** RED_INTEGER (2nd reference) */
  33897. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33898. /** RG_INTEGER */
  33899. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33900. /** RGB_INTEGER */
  33901. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33902. /** RGBA_INTEGER */
  33903. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33904. /** UNSIGNED_BYTE */
  33905. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33906. /** UNSIGNED_BYTE (2nd reference) */
  33907. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33908. /** FLOAT */
  33909. static readonly TEXTURETYPE_FLOAT: number;
  33910. /** HALF_FLOAT */
  33911. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33912. /** BYTE */
  33913. static readonly TEXTURETYPE_BYTE: number;
  33914. /** SHORT */
  33915. static readonly TEXTURETYPE_SHORT: number;
  33916. /** UNSIGNED_SHORT */
  33917. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33918. /** INT */
  33919. static readonly TEXTURETYPE_INT: number;
  33920. /** UNSIGNED_INT */
  33921. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33922. /** UNSIGNED_SHORT_4_4_4_4 */
  33923. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33924. /** UNSIGNED_SHORT_5_5_5_1 */
  33925. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33926. /** UNSIGNED_SHORT_5_6_5 */
  33927. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33928. /** UNSIGNED_INT_2_10_10_10_REV */
  33929. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33930. /** UNSIGNED_INT_24_8 */
  33931. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33932. /** UNSIGNED_INT_10F_11F_11F_REV */
  33933. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33934. /** UNSIGNED_INT_5_9_9_9_REV */
  33935. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33936. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33937. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33938. /** nearest is mag = nearest and min = nearest and mip = linear */
  33939. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33940. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33941. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33942. /** Trilinear is mag = linear and min = linear and mip = linear */
  33943. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33944. /** nearest is mag = nearest and min = nearest and mip = linear */
  33945. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33946. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33947. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33948. /** Trilinear is mag = linear and min = linear and mip = linear */
  33949. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33950. /** mag = nearest and min = nearest and mip = nearest */
  33951. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33952. /** mag = nearest and min = linear and mip = nearest */
  33953. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33954. /** mag = nearest and min = linear and mip = linear */
  33955. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33956. /** mag = nearest and min = linear and mip = none */
  33957. static readonly TEXTURE_NEAREST_LINEAR: number;
  33958. /** mag = nearest and min = nearest and mip = none */
  33959. static readonly TEXTURE_NEAREST_NEAREST: number;
  33960. /** mag = linear and min = nearest and mip = nearest */
  33961. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33962. /** mag = linear and min = nearest and mip = linear */
  33963. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33964. /** mag = linear and min = linear and mip = none */
  33965. static readonly TEXTURE_LINEAR_LINEAR: number;
  33966. /** mag = linear and min = nearest and mip = none */
  33967. static readonly TEXTURE_LINEAR_NEAREST: number;
  33968. /** Explicit coordinates mode */
  33969. static readonly TEXTURE_EXPLICIT_MODE: number;
  33970. /** Spherical coordinates mode */
  33971. static readonly TEXTURE_SPHERICAL_MODE: number;
  33972. /** Planar coordinates mode */
  33973. static readonly TEXTURE_PLANAR_MODE: number;
  33974. /** Cubic coordinates mode */
  33975. static readonly TEXTURE_CUBIC_MODE: number;
  33976. /** Projection coordinates mode */
  33977. static readonly TEXTURE_PROJECTION_MODE: number;
  33978. /** Skybox coordinates mode */
  33979. static readonly TEXTURE_SKYBOX_MODE: number;
  33980. /** Inverse Cubic coordinates mode */
  33981. static readonly TEXTURE_INVCUBIC_MODE: number;
  33982. /** Equirectangular coordinates mode */
  33983. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33984. /** Equirectangular Fixed coordinates mode */
  33985. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33986. /** Equirectangular Fixed Mirrored coordinates mode */
  33987. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33988. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33989. static readonly SCALEMODE_FLOOR: number;
  33990. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33991. static readonly SCALEMODE_NEAREST: number;
  33992. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33993. static readonly SCALEMODE_CEILING: number;
  33994. /**
  33995. * Returns the current npm package of the sdk
  33996. */
  33997. static get NpmPackage(): string;
  33998. /**
  33999. * Returns the current version of the framework
  34000. */
  34001. static get Version(): string;
  34002. /** Gets the list of created engines */
  34003. static get Instances(): Engine[];
  34004. /**
  34005. * Gets the latest created engine
  34006. */
  34007. static get LastCreatedEngine(): Nullable<Engine>;
  34008. /**
  34009. * Gets the latest created scene
  34010. */
  34011. static get LastCreatedScene(): Nullable<Scene>;
  34012. /**
  34013. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34014. * @param flag defines which part of the materials must be marked as dirty
  34015. * @param predicate defines a predicate used to filter which materials should be affected
  34016. */
  34017. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34018. /**
  34019. * Method called to create the default loading screen.
  34020. * This can be overriden in your own app.
  34021. * @param canvas The rendering canvas element
  34022. * @returns The loading screen
  34023. */
  34024. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34025. /**
  34026. * Method called to create the default rescale post process on each engine.
  34027. */
  34028. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34029. /**
  34030. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34031. **/
  34032. enableOfflineSupport: boolean;
  34033. /**
  34034. * 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)
  34035. **/
  34036. disableManifestCheck: boolean;
  34037. /**
  34038. * Gets the list of created scenes
  34039. */
  34040. scenes: Scene[];
  34041. /**
  34042. * Event raised when a new scene is created
  34043. */
  34044. onNewSceneAddedObservable: Observable<Scene>;
  34045. /**
  34046. * Gets the list of created postprocesses
  34047. */
  34048. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34049. /**
  34050. * Gets a boolean indicating if the pointer is currently locked
  34051. */
  34052. isPointerLock: boolean;
  34053. /**
  34054. * Observable event triggered each time the rendering canvas is resized
  34055. */
  34056. onResizeObservable: Observable<Engine>;
  34057. /**
  34058. * Observable event triggered each time the canvas loses focus
  34059. */
  34060. onCanvasBlurObservable: Observable<Engine>;
  34061. /**
  34062. * Observable event triggered each time the canvas gains focus
  34063. */
  34064. onCanvasFocusObservable: Observable<Engine>;
  34065. /**
  34066. * Observable event triggered each time the canvas receives pointerout event
  34067. */
  34068. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34069. /**
  34070. * Observable raised when the engine begins a new frame
  34071. */
  34072. onBeginFrameObservable: Observable<Engine>;
  34073. /**
  34074. * If set, will be used to request the next animation frame for the render loop
  34075. */
  34076. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34077. /**
  34078. * Observable raised when the engine ends the current frame
  34079. */
  34080. onEndFrameObservable: Observable<Engine>;
  34081. /**
  34082. * Observable raised when the engine is about to compile a shader
  34083. */
  34084. onBeforeShaderCompilationObservable: Observable<Engine>;
  34085. /**
  34086. * Observable raised when the engine has jsut compiled a shader
  34087. */
  34088. onAfterShaderCompilationObservable: Observable<Engine>;
  34089. /**
  34090. * Gets the audio engine
  34091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34092. * @ignorenaming
  34093. */
  34094. static audioEngine: IAudioEngine;
  34095. /**
  34096. * Default AudioEngine factory responsible of creating the Audio Engine.
  34097. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34098. */
  34099. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34100. /**
  34101. * Default offline support factory responsible of creating a tool used to store data locally.
  34102. * By default, this will create a Database object if the workload has been embedded.
  34103. */
  34104. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34105. private _loadingScreen;
  34106. private _pointerLockRequested;
  34107. private _dummyFramebuffer;
  34108. private _rescalePostProcess;
  34109. private _deterministicLockstep;
  34110. private _lockstepMaxSteps;
  34111. private _timeStep;
  34112. protected get _supportsHardwareTextureRescaling(): boolean;
  34113. private _fps;
  34114. private _deltaTime;
  34115. /** @hidden */
  34116. _drawCalls: PerfCounter;
  34117. /**
  34118. * Turn this value on if you want to pause FPS computation when in background
  34119. */
  34120. disablePerformanceMonitorInBackground: boolean;
  34121. private _performanceMonitor;
  34122. /**
  34123. * Gets the performance monitor attached to this engine
  34124. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34125. */
  34126. get performanceMonitor(): PerformanceMonitor;
  34127. private _onFocus;
  34128. private _onBlur;
  34129. private _onCanvasPointerOut;
  34130. private _onCanvasBlur;
  34131. private _onCanvasFocus;
  34132. private _onFullscreenChange;
  34133. private _onPointerLockChange;
  34134. /**
  34135. * Gets the HTML element used to attach event listeners
  34136. * @returns a HTML element
  34137. */
  34138. getInputElement(): Nullable<HTMLElement>;
  34139. /**
  34140. * Creates a new engine
  34141. * @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
  34142. * @param antialias defines enable antialiasing (default: false)
  34143. * @param options defines further options to be sent to the getContext() function
  34144. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34145. */
  34146. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34147. /**
  34148. * Gets current aspect ratio
  34149. * @param viewportOwner defines the camera to use to get the aspect ratio
  34150. * @param useScreen defines if screen size must be used (or the current render target if any)
  34151. * @returns a number defining the aspect ratio
  34152. */
  34153. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34154. /**
  34155. * Gets current screen aspect ratio
  34156. * @returns a number defining the aspect ratio
  34157. */
  34158. getScreenAspectRatio(): number;
  34159. /**
  34160. * Gets the client rect of the HTML canvas attached with the current webGL context
  34161. * @returns a client rectanglee
  34162. */
  34163. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34164. /**
  34165. * Gets the client rect of the HTML element used for events
  34166. * @returns a client rectanglee
  34167. */
  34168. getInputElementClientRect(): Nullable<ClientRect>;
  34169. /**
  34170. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34171. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34172. * @returns true if engine is in deterministic lock step mode
  34173. */
  34174. isDeterministicLockStep(): boolean;
  34175. /**
  34176. * Gets the max steps when engine is running in deterministic lock step
  34177. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34178. * @returns the max steps
  34179. */
  34180. getLockstepMaxSteps(): number;
  34181. /**
  34182. * Returns the time in ms between steps when using deterministic lock step.
  34183. * @returns time step in (ms)
  34184. */
  34185. getTimeStep(): number;
  34186. /**
  34187. * Force the mipmap generation for the given render target texture
  34188. * @param texture defines the render target texture to use
  34189. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34190. */
  34191. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34192. /** States */
  34193. /**
  34194. * Set various states to the webGL context
  34195. * @param culling defines backface culling state
  34196. * @param zOffset defines the value to apply to zOffset (0 by default)
  34197. * @param force defines if states must be applied even if cache is up to date
  34198. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34199. */
  34200. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34201. /**
  34202. * Set the z offset to apply to current rendering
  34203. * @param value defines the offset to apply
  34204. */
  34205. setZOffset(value: number): void;
  34206. /**
  34207. * Gets the current value of the zOffset
  34208. * @returns the current zOffset state
  34209. */
  34210. getZOffset(): number;
  34211. /**
  34212. * Enable or disable depth buffering
  34213. * @param enable defines the state to set
  34214. */
  34215. setDepthBuffer(enable: boolean): void;
  34216. /**
  34217. * Gets a boolean indicating if depth writing is enabled
  34218. * @returns the current depth writing state
  34219. */
  34220. getDepthWrite(): boolean;
  34221. /**
  34222. * Enable or disable depth writing
  34223. * @param enable defines the state to set
  34224. */
  34225. setDepthWrite(enable: boolean): void;
  34226. /**
  34227. * Gets a boolean indicating if stencil buffer is enabled
  34228. * @returns the current stencil buffer state
  34229. */
  34230. getStencilBuffer(): boolean;
  34231. /**
  34232. * Enable or disable the stencil buffer
  34233. * @param enable defines if the stencil buffer must be enabled or disabled
  34234. */
  34235. setStencilBuffer(enable: boolean): void;
  34236. /**
  34237. * Gets the current stencil mask
  34238. * @returns a number defining the new stencil mask to use
  34239. */
  34240. getStencilMask(): number;
  34241. /**
  34242. * Sets the current stencil mask
  34243. * @param mask defines the new stencil mask to use
  34244. */
  34245. setStencilMask(mask: number): void;
  34246. /**
  34247. * Gets the current stencil function
  34248. * @returns a number defining the stencil function to use
  34249. */
  34250. getStencilFunction(): number;
  34251. /**
  34252. * Gets the current stencil reference value
  34253. * @returns a number defining the stencil reference value to use
  34254. */
  34255. getStencilFunctionReference(): number;
  34256. /**
  34257. * Gets the current stencil mask
  34258. * @returns a number defining the stencil mask to use
  34259. */
  34260. getStencilFunctionMask(): number;
  34261. /**
  34262. * Sets the current stencil function
  34263. * @param stencilFunc defines the new stencil function to use
  34264. */
  34265. setStencilFunction(stencilFunc: number): void;
  34266. /**
  34267. * Sets the current stencil reference
  34268. * @param reference defines the new stencil reference to use
  34269. */
  34270. setStencilFunctionReference(reference: number): void;
  34271. /**
  34272. * Sets the current stencil mask
  34273. * @param mask defines the new stencil mask to use
  34274. */
  34275. setStencilFunctionMask(mask: number): void;
  34276. /**
  34277. * Gets the current stencil operation when stencil fails
  34278. * @returns a number defining stencil operation to use when stencil fails
  34279. */
  34280. getStencilOperationFail(): number;
  34281. /**
  34282. * Gets the current stencil operation when depth fails
  34283. * @returns a number defining stencil operation to use when depth fails
  34284. */
  34285. getStencilOperationDepthFail(): number;
  34286. /**
  34287. * Gets the current stencil operation when stencil passes
  34288. * @returns a number defining stencil operation to use when stencil passes
  34289. */
  34290. getStencilOperationPass(): number;
  34291. /**
  34292. * Sets the stencil operation to use when stencil fails
  34293. * @param operation defines the stencil operation to use when stencil fails
  34294. */
  34295. setStencilOperationFail(operation: number): void;
  34296. /**
  34297. * Sets the stencil operation to use when depth fails
  34298. * @param operation defines the stencil operation to use when depth fails
  34299. */
  34300. setStencilOperationDepthFail(operation: number): void;
  34301. /**
  34302. * Sets the stencil operation to use when stencil passes
  34303. * @param operation defines the stencil operation to use when stencil passes
  34304. */
  34305. setStencilOperationPass(operation: number): void;
  34306. /**
  34307. * Sets a boolean indicating if the dithering state is enabled or disabled
  34308. * @param value defines the dithering state
  34309. */
  34310. setDitheringState(value: boolean): void;
  34311. /**
  34312. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34313. * @param value defines the rasterizer state
  34314. */
  34315. setRasterizerState(value: boolean): void;
  34316. /**
  34317. * Gets the current depth function
  34318. * @returns a number defining the depth function
  34319. */
  34320. getDepthFunction(): Nullable<number>;
  34321. /**
  34322. * Sets the current depth function
  34323. * @param depthFunc defines the function to use
  34324. */
  34325. setDepthFunction(depthFunc: number): void;
  34326. /**
  34327. * Sets the current depth function to GREATER
  34328. */
  34329. setDepthFunctionToGreater(): void;
  34330. /**
  34331. * Sets the current depth function to GEQUAL
  34332. */
  34333. setDepthFunctionToGreaterOrEqual(): void;
  34334. /**
  34335. * Sets the current depth function to LESS
  34336. */
  34337. setDepthFunctionToLess(): void;
  34338. /**
  34339. * Sets the current depth function to LEQUAL
  34340. */
  34341. setDepthFunctionToLessOrEqual(): void;
  34342. private _cachedStencilBuffer;
  34343. private _cachedStencilFunction;
  34344. private _cachedStencilMask;
  34345. private _cachedStencilOperationPass;
  34346. private _cachedStencilOperationFail;
  34347. private _cachedStencilOperationDepthFail;
  34348. private _cachedStencilReference;
  34349. /**
  34350. * Caches the the state of the stencil buffer
  34351. */
  34352. cacheStencilState(): void;
  34353. /**
  34354. * Restores the state of the stencil buffer
  34355. */
  34356. restoreStencilState(): void;
  34357. /**
  34358. * Directly set the WebGL Viewport
  34359. * @param x defines the x coordinate of the viewport (in screen space)
  34360. * @param y defines the y coordinate of the viewport (in screen space)
  34361. * @param width defines the width of the viewport (in screen space)
  34362. * @param height defines the height of the viewport (in screen space)
  34363. * @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
  34364. */
  34365. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34366. /**
  34367. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34368. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34369. * @param y defines the y-coordinate of the corner of the clear rectangle
  34370. * @param width defines the width of the clear rectangle
  34371. * @param height defines the height of the clear rectangle
  34372. * @param clearColor defines the clear color
  34373. */
  34374. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34375. /**
  34376. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34377. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34378. * @param y defines the y-coordinate of the corner of the clear rectangle
  34379. * @param width defines the width of the clear rectangle
  34380. * @param height defines the height of the clear rectangle
  34381. */
  34382. enableScissor(x: number, y: number, width: number, height: number): void;
  34383. /**
  34384. * Disable previously set scissor test rectangle
  34385. */
  34386. disableScissor(): void;
  34387. protected _reportDrawCall(): void;
  34388. /**
  34389. * Initializes a webVR display and starts listening to display change events
  34390. * The onVRDisplayChangedObservable will be notified upon these changes
  34391. * @returns The onVRDisplayChangedObservable
  34392. */
  34393. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34394. /** @hidden */
  34395. _prepareVRComponent(): void;
  34396. /** @hidden */
  34397. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34398. /** @hidden */
  34399. _submitVRFrame(): void;
  34400. /**
  34401. * Call this function to leave webVR mode
  34402. * Will do nothing if webVR is not supported or if there is no webVR device
  34403. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34404. */
  34405. disableVR(): void;
  34406. /**
  34407. * Gets a boolean indicating that the system is in VR mode and is presenting
  34408. * @returns true if VR mode is engaged
  34409. */
  34410. isVRPresenting(): boolean;
  34411. /** @hidden */
  34412. _requestVRFrame(): void;
  34413. /** @hidden */
  34414. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34415. /**
  34416. * Gets the source code of the vertex shader associated with a specific webGL program
  34417. * @param program defines the program to use
  34418. * @returns a string containing the source code of the vertex shader associated with the program
  34419. */
  34420. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34421. /**
  34422. * Gets the source code of the fragment shader associated with a specific webGL program
  34423. * @param program defines the program to use
  34424. * @returns a string containing the source code of the fragment shader associated with the program
  34425. */
  34426. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34427. /**
  34428. * Sets a depth stencil texture from a render target to the according uniform.
  34429. * @param channel The texture channel
  34430. * @param uniform The uniform to set
  34431. * @param texture The render target texture containing the depth stencil texture to apply
  34432. */
  34433. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34434. /**
  34435. * Sets a texture to the webGL context from a postprocess
  34436. * @param channel defines the channel to use
  34437. * @param postProcess defines the source postprocess
  34438. */
  34439. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34440. /**
  34441. * Binds the output of the passed in post process to the texture channel specified
  34442. * @param channel The channel the texture should be bound to
  34443. * @param postProcess The post process which's output should be bound
  34444. */
  34445. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34446. /** @hidden */
  34447. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34448. protected _rebuildBuffers(): void;
  34449. /** @hidden */
  34450. _renderFrame(): void;
  34451. _renderLoop(): void;
  34452. /** @hidden */
  34453. _renderViews(): boolean;
  34454. /**
  34455. * Toggle full screen mode
  34456. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34457. */
  34458. switchFullscreen(requestPointerLock: boolean): void;
  34459. /**
  34460. * Enters full screen mode
  34461. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34462. */
  34463. enterFullscreen(requestPointerLock: boolean): void;
  34464. /**
  34465. * Exits full screen mode
  34466. */
  34467. exitFullscreen(): void;
  34468. /**
  34469. * Enters Pointerlock mode
  34470. */
  34471. enterPointerlock(): void;
  34472. /**
  34473. * Exits Pointerlock mode
  34474. */
  34475. exitPointerlock(): void;
  34476. /**
  34477. * Begin a new frame
  34478. */
  34479. beginFrame(): void;
  34480. /**
  34481. * Enf the current frame
  34482. */
  34483. endFrame(): void;
  34484. resize(): void;
  34485. /**
  34486. * Set the compressed texture format to use, based on the formats you have, and the formats
  34487. * supported by the hardware / browser.
  34488. *
  34489. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34490. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34491. * to API arguments needed to compressed textures. This puts the burden on the container
  34492. * generator to house the arcane code for determining these for current & future formats.
  34493. *
  34494. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34495. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34496. *
  34497. * Note: The result of this call is not taken into account when a texture is base64.
  34498. *
  34499. * @param formatsAvailable defines the list of those format families you have created
  34500. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34501. *
  34502. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34503. * @returns The extension selected.
  34504. */
  34505. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34506. /**
  34507. * Set the compressed texture extensions or file names to skip.
  34508. *
  34509. * @param skippedFiles defines the list of those texture files you want to skip
  34510. * Example: [".dds", ".env", "myfile.png"]
  34511. */
  34512. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34513. /**
  34514. * Force a specific size of the canvas
  34515. * @param width defines the new canvas' width
  34516. * @param height defines the new canvas' height
  34517. */
  34518. setSize(width: number, height: number): void;
  34519. /**
  34520. * Updates a dynamic vertex buffer.
  34521. * @param vertexBuffer the vertex buffer to update
  34522. * @param data the data used to update the vertex buffer
  34523. * @param byteOffset the byte offset of the data
  34524. * @param byteLength the byte length of the data
  34525. */
  34526. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34527. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34528. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34529. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34530. _releaseTexture(texture: InternalTexture): void;
  34531. /**
  34532. * @hidden
  34533. * Rescales a texture
  34534. * @param source input texutre
  34535. * @param destination destination texture
  34536. * @param scene scene to use to render the resize
  34537. * @param internalFormat format to use when resizing
  34538. * @param onComplete callback to be called when resize has completed
  34539. */
  34540. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34541. /**
  34542. * Gets the current framerate
  34543. * @returns a number representing the framerate
  34544. */
  34545. getFps(): number;
  34546. /**
  34547. * Gets the time spent between current and previous frame
  34548. * @returns a number representing the delta time in ms
  34549. */
  34550. getDeltaTime(): number;
  34551. private _measureFps;
  34552. /** @hidden */
  34553. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34554. /**
  34555. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  34556. * @param renderTarget The render target to set the frame buffer for
  34557. */
  34558. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  34559. /**
  34560. * Update a dynamic index buffer
  34561. * @param indexBuffer defines the target index buffer
  34562. * @param indices defines the data to update
  34563. * @param offset defines the offset in the target index buffer where update should start
  34564. */
  34565. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34566. /**
  34567. * Updates the sample count of a render target texture
  34568. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34569. * @param texture defines the texture to update
  34570. * @param samples defines the sample count to set
  34571. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34572. */
  34573. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34574. /**
  34575. * Updates a depth texture Comparison Mode and Function.
  34576. * If the comparison Function is equal to 0, the mode will be set to none.
  34577. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34578. * @param texture The texture to set the comparison function for
  34579. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34580. */
  34581. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34582. /**
  34583. * Creates a webGL buffer to use with instanciation
  34584. * @param capacity defines the size of the buffer
  34585. * @returns the webGL buffer
  34586. */
  34587. createInstancesBuffer(capacity: number): DataBuffer;
  34588. /**
  34589. * Delete a webGL buffer used with instanciation
  34590. * @param buffer defines the webGL buffer to delete
  34591. */
  34592. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34593. /** @hidden */
  34594. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34595. dispose(): void;
  34596. private _disableTouchAction;
  34597. /**
  34598. * Display the loading screen
  34599. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34600. */
  34601. displayLoadingUI(): void;
  34602. /**
  34603. * Hide the loading screen
  34604. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34605. */
  34606. hideLoadingUI(): void;
  34607. /**
  34608. * Gets the current loading screen object
  34609. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34610. */
  34611. get loadingScreen(): ILoadingScreen;
  34612. /**
  34613. * Sets the current loading screen object
  34614. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34615. */
  34616. set loadingScreen(loadingScreen: ILoadingScreen);
  34617. /**
  34618. * Sets the current loading screen text
  34619. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34620. */
  34621. set loadingUIText(text: string);
  34622. /**
  34623. * Sets the current loading screen background color
  34624. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34625. */
  34626. set loadingUIBackgroundColor(color: string);
  34627. /** Pointerlock and fullscreen */
  34628. /**
  34629. * Ask the browser to promote the current element to pointerlock mode
  34630. * @param element defines the DOM element to promote
  34631. */
  34632. static _RequestPointerlock(element: HTMLElement): void;
  34633. /**
  34634. * Asks the browser to exit pointerlock mode
  34635. */
  34636. static _ExitPointerlock(): void;
  34637. /**
  34638. * Ask the browser to promote the current element to fullscreen rendering mode
  34639. * @param element defines the DOM element to promote
  34640. */
  34641. static _RequestFullscreen(element: HTMLElement): void;
  34642. /**
  34643. * Asks the browser to exit fullscreen mode
  34644. */
  34645. static _ExitFullscreen(): void;
  34646. }
  34647. }
  34648. declare module "babylonjs/Engines/engineStore" {
  34649. import { Nullable } from "babylonjs/types";
  34650. import { Engine } from "babylonjs/Engines/engine";
  34651. import { Scene } from "babylonjs/scene";
  34652. /**
  34653. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34654. * during the life time of the application.
  34655. */
  34656. export class EngineStore {
  34657. /** Gets the list of created engines */
  34658. static Instances: import("babylonjs/Engines/engine").Engine[];
  34659. /** @hidden */
  34660. static _LastCreatedScene: Nullable<Scene>;
  34661. /**
  34662. * Gets the latest created engine
  34663. */
  34664. static get LastCreatedEngine(): Nullable<Engine>;
  34665. /**
  34666. * Gets the latest created scene
  34667. */
  34668. static get LastCreatedScene(): Nullable<Scene>;
  34669. /**
  34670. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34671. * @ignorenaming
  34672. */
  34673. static UseFallbackTexture: boolean;
  34674. /**
  34675. * Texture content used if a texture cannot loaded
  34676. * @ignorenaming
  34677. */
  34678. static FallbackTexture: string;
  34679. }
  34680. }
  34681. declare module "babylonjs/Misc/promise" {
  34682. /**
  34683. * Helper class that provides a small promise polyfill
  34684. */
  34685. export class PromisePolyfill {
  34686. /**
  34687. * Static function used to check if the polyfill is required
  34688. * If this is the case then the function will inject the polyfill to window.Promise
  34689. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34690. */
  34691. static Apply(force?: boolean): void;
  34692. }
  34693. }
  34694. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34695. /**
  34696. * Interface for screenshot methods with describe argument called `size` as object with options
  34697. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34698. */
  34699. export interface IScreenshotSize {
  34700. /**
  34701. * number in pixels for canvas height
  34702. */
  34703. height?: number;
  34704. /**
  34705. * multiplier allowing render at a higher or lower resolution
  34706. * If value is defined then height and width will be ignored and taken from camera
  34707. */
  34708. precision?: number;
  34709. /**
  34710. * number in pixels for canvas width
  34711. */
  34712. width?: number;
  34713. }
  34714. }
  34715. declare module "babylonjs/Misc/tools" {
  34716. import { Nullable, float } from "babylonjs/types";
  34717. import { DomManagement } from "babylonjs/Misc/domManagement";
  34718. import { WebRequest } from "babylonjs/Misc/webRequest";
  34719. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34720. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34721. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34722. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34723. import { Camera } from "babylonjs/Cameras/camera";
  34724. import { Engine } from "babylonjs/Engines/engine";
  34725. interface IColor4Like {
  34726. r: float;
  34727. g: float;
  34728. b: float;
  34729. a: float;
  34730. }
  34731. /**
  34732. * Class containing a set of static utilities functions
  34733. */
  34734. export class Tools {
  34735. /**
  34736. * Gets or sets the base URL to use to load assets
  34737. */
  34738. static get BaseUrl(): string;
  34739. static set BaseUrl(value: string);
  34740. /**
  34741. * Enable/Disable Custom HTTP Request Headers globally.
  34742. * default = false
  34743. * @see CustomRequestHeaders
  34744. */
  34745. static UseCustomRequestHeaders: boolean;
  34746. /**
  34747. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34748. * i.e. when loading files, where the server/service expects an Authorization header
  34749. */
  34750. static CustomRequestHeaders: {
  34751. [key: string]: string;
  34752. };
  34753. /**
  34754. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34755. */
  34756. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34757. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34758. /**
  34759. * Default behaviour for cors in the application.
  34760. * It can be a string if the expected behavior is identical in the entire app.
  34761. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34762. */
  34763. static CorsBehavior: string | ((url: string | string[]) => string);
  34764. /**
  34765. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34766. * @ignorenaming
  34767. */
  34768. static get UseFallbackTexture(): boolean;
  34769. static set UseFallbackTexture(value: boolean);
  34770. /**
  34771. * Use this object to register external classes like custom textures or material
  34772. * to allow the laoders to instantiate them
  34773. */
  34774. static get RegisteredExternalClasses(): {
  34775. [key: string]: Object;
  34776. };
  34777. static set RegisteredExternalClasses(classes: {
  34778. [key: string]: Object;
  34779. });
  34780. /**
  34781. * Texture content used if a texture cannot loaded
  34782. * @ignorenaming
  34783. */
  34784. static get fallbackTexture(): string;
  34785. static set fallbackTexture(value: string);
  34786. /**
  34787. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34788. * @param u defines the coordinate on X axis
  34789. * @param v defines the coordinate on Y axis
  34790. * @param width defines the width of the source data
  34791. * @param height defines the height of the source data
  34792. * @param pixels defines the source byte array
  34793. * @param color defines the output color
  34794. */
  34795. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34796. /**
  34797. * Interpolates between a and b via alpha
  34798. * @param a The lower value (returned when alpha = 0)
  34799. * @param b The upper value (returned when alpha = 1)
  34800. * @param alpha The interpolation-factor
  34801. * @return The mixed value
  34802. */
  34803. static Mix(a: number, b: number, alpha: number): number;
  34804. /**
  34805. * Tries to instantiate a new object from a given class name
  34806. * @param className defines the class name to instantiate
  34807. * @returns the new object or null if the system was not able to do the instantiation
  34808. */
  34809. static Instantiate(className: string): any;
  34810. /**
  34811. * Provides a slice function that will work even on IE
  34812. * @param data defines the array to slice
  34813. * @param start defines the start of the data (optional)
  34814. * @param end defines the end of the data (optional)
  34815. * @returns the new sliced array
  34816. */
  34817. static Slice<T>(data: T, start?: number, end?: number): T;
  34818. /**
  34819. * Polyfill for setImmediate
  34820. * @param action defines the action to execute after the current execution block
  34821. */
  34822. static SetImmediate(action: () => void): void;
  34823. /**
  34824. * Function indicating if a number is an exponent of 2
  34825. * @param value defines the value to test
  34826. * @returns true if the value is an exponent of 2
  34827. */
  34828. static IsExponentOfTwo(value: number): boolean;
  34829. private static _tmpFloatArray;
  34830. /**
  34831. * Returns the nearest 32-bit single precision float representation of a Number
  34832. * @param value A Number. If the parameter is of a different type, it will get converted
  34833. * to a number or to NaN if it cannot be converted
  34834. * @returns number
  34835. */
  34836. static FloatRound(value: number): number;
  34837. /**
  34838. * Extracts the filename from a path
  34839. * @param path defines the path to use
  34840. * @returns the filename
  34841. */
  34842. static GetFilename(path: string): string;
  34843. /**
  34844. * Extracts the "folder" part of a path (everything before the filename).
  34845. * @param uri The URI to extract the info from
  34846. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34847. * @returns The "folder" part of the path
  34848. */
  34849. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34850. /**
  34851. * Extracts text content from a DOM element hierarchy
  34852. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34853. */
  34854. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34855. /**
  34856. * Convert an angle in radians to degrees
  34857. * @param angle defines the angle to convert
  34858. * @returns the angle in degrees
  34859. */
  34860. static ToDegrees(angle: number): number;
  34861. /**
  34862. * Convert an angle in degrees to radians
  34863. * @param angle defines the angle to convert
  34864. * @returns the angle in radians
  34865. */
  34866. static ToRadians(angle: number): number;
  34867. /**
  34868. * Returns an array if obj is not an array
  34869. * @param obj defines the object to evaluate as an array
  34870. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34871. * @returns either obj directly if obj is an array or a new array containing obj
  34872. */
  34873. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34874. /**
  34875. * Gets the pointer prefix to use
  34876. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34877. */
  34878. static GetPointerPrefix(): string;
  34879. /**
  34880. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34881. * @param url define the url we are trying
  34882. * @param element define the dom element where to configure the cors policy
  34883. */
  34884. static SetCorsBehavior(url: string | string[], element: {
  34885. crossOrigin: string | null;
  34886. }): void;
  34887. /**
  34888. * Removes unwanted characters from an url
  34889. * @param url defines the url to clean
  34890. * @returns the cleaned url
  34891. */
  34892. static CleanUrl(url: string): string;
  34893. /**
  34894. * Gets or sets a function used to pre-process url before using them to load assets
  34895. */
  34896. static get PreprocessUrl(): (url: string) => string;
  34897. static set PreprocessUrl(processor: (url: string) => string);
  34898. /**
  34899. * Loads an image as an HTMLImageElement.
  34900. * @param input url string, ArrayBuffer, or Blob to load
  34901. * @param onLoad callback called when the image successfully loads
  34902. * @param onError callback called when the image fails to load
  34903. * @param offlineProvider offline provider for caching
  34904. * @param mimeType optional mime type
  34905. * @returns the HTMLImageElement of the loaded image
  34906. */
  34907. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34908. /**
  34909. * Loads a file from a url
  34910. * @param url url string, ArrayBuffer, or Blob to load
  34911. * @param onSuccess callback called when the file successfully loads
  34912. * @param onProgress callback called while file is loading (if the server supports this mode)
  34913. * @param offlineProvider defines the offline provider for caching
  34914. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34915. * @param onError callback called when the file fails to load
  34916. * @returns a file request object
  34917. */
  34918. 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;
  34919. /**
  34920. * Loads a file from a url
  34921. * @param url the file url to load
  34922. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34923. */
  34924. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34925. /**
  34926. * Load a script (identified by an url). When the url returns, the
  34927. * content of this file is added into a new script element, attached to the DOM (body element)
  34928. * @param scriptUrl defines the url of the script to laod
  34929. * @param onSuccess defines the callback called when the script is loaded
  34930. * @param onError defines the callback to call if an error occurs
  34931. * @param scriptId defines the id of the script element
  34932. */
  34933. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34934. /**
  34935. * Load an asynchronous script (identified by an url). When the url returns, the
  34936. * content of this file is added into a new script element, attached to the DOM (body element)
  34937. * @param scriptUrl defines the url of the script to laod
  34938. * @param scriptId defines the id of the script element
  34939. * @returns a promise request object
  34940. */
  34941. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34942. /**
  34943. * Loads a file from a blob
  34944. * @param fileToLoad defines the blob to use
  34945. * @param callback defines the callback to call when data is loaded
  34946. * @param progressCallback defines the callback to call during loading process
  34947. * @returns a file request object
  34948. */
  34949. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34950. /**
  34951. * Reads a file from a File object
  34952. * @param file defines the file to load
  34953. * @param onSuccess defines the callback to call when data is loaded
  34954. * @param onProgress defines the callback to call during loading process
  34955. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34956. * @param onError defines the callback to call when an error occurs
  34957. * @returns a file request object
  34958. */
  34959. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34960. /**
  34961. * Creates a data url from a given string content
  34962. * @param content defines the content to convert
  34963. * @returns the new data url link
  34964. */
  34965. static FileAsURL(content: string): string;
  34966. /**
  34967. * Format the given number to a specific decimal format
  34968. * @param value defines the number to format
  34969. * @param decimals defines the number of decimals to use
  34970. * @returns the formatted string
  34971. */
  34972. static Format(value: number, decimals?: number): string;
  34973. /**
  34974. * Tries to copy an object by duplicating every property
  34975. * @param source defines the source object
  34976. * @param destination defines the target object
  34977. * @param doNotCopyList defines a list of properties to avoid
  34978. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34979. */
  34980. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34981. /**
  34982. * Gets a boolean indicating if the given object has no own property
  34983. * @param obj defines the object to test
  34984. * @returns true if object has no own property
  34985. */
  34986. static IsEmpty(obj: any): boolean;
  34987. /**
  34988. * Function used to register events at window level
  34989. * @param windowElement defines the Window object to use
  34990. * @param events defines the events to register
  34991. */
  34992. static RegisterTopRootEvents(windowElement: Window, events: {
  34993. name: string;
  34994. handler: Nullable<(e: FocusEvent) => any>;
  34995. }[]): void;
  34996. /**
  34997. * Function used to unregister events from window level
  34998. * @param windowElement defines the Window object to use
  34999. * @param events defines the events to unregister
  35000. */
  35001. static UnregisterTopRootEvents(windowElement: Window, events: {
  35002. name: string;
  35003. handler: Nullable<(e: FocusEvent) => any>;
  35004. }[]): void;
  35005. /**
  35006. * @ignore
  35007. */
  35008. static _ScreenshotCanvas: HTMLCanvasElement;
  35009. /**
  35010. * Dumps the current bound framebuffer
  35011. * @param width defines the rendering width
  35012. * @param height defines the rendering height
  35013. * @param engine defines the hosting engine
  35014. * @param successCallback defines the callback triggered once the data are available
  35015. * @param mimeType defines the mime type of the result
  35016. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35017. */
  35018. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35019. /**
  35020. * Converts the canvas data to blob.
  35021. * This acts as a polyfill for browsers not supporting the to blob function.
  35022. * @param canvas Defines the canvas to extract the data from
  35023. * @param successCallback Defines the callback triggered once the data are available
  35024. * @param mimeType Defines the mime type of the result
  35025. */
  35026. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35027. /**
  35028. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35029. * @param successCallback defines the callback triggered once the data are available
  35030. * @param mimeType defines the mime type of the result
  35031. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35032. */
  35033. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35034. /**
  35035. * Downloads a blob in the browser
  35036. * @param blob defines the blob to download
  35037. * @param fileName defines the name of the downloaded file
  35038. */
  35039. static Download(blob: Blob, fileName: string): void;
  35040. /**
  35041. * Captures a screenshot of the current rendering
  35042. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35043. * @param engine defines the rendering engine
  35044. * @param camera defines the source camera
  35045. * @param size This parameter can be set to a single number or to an object with the
  35046. * following (optional) properties: precision, width, height. If a single number is passed,
  35047. * it will be used for both width and height. If an object is passed, the screenshot size
  35048. * will be derived from the parameters. The precision property is a multiplier allowing
  35049. * rendering at a higher or lower resolution
  35050. * @param successCallback defines the callback receives a single parameter which contains the
  35051. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35052. * src parameter of an <img> to display it
  35053. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35054. * Check your browser for supported MIME types
  35055. */
  35056. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35057. /**
  35058. * Captures a screenshot of the current rendering
  35059. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35060. * @param engine defines the rendering engine
  35061. * @param camera defines the source camera
  35062. * @param size This parameter can be set to a single number or to an object with the
  35063. * following (optional) properties: precision, width, height. If a single number is passed,
  35064. * it will be used for both width and height. If an object is passed, the screenshot size
  35065. * will be derived from the parameters. The precision property is a multiplier allowing
  35066. * rendering at a higher or lower resolution
  35067. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35068. * Check your browser for supported MIME types
  35069. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35070. * to the src parameter of an <img> to display it
  35071. */
  35072. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35073. /**
  35074. * Generates an image screenshot from the specified camera.
  35075. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35076. * @param engine The engine to use for rendering
  35077. * @param camera The camera to use for rendering
  35078. * @param size This parameter can be set to a single number or to an object with the
  35079. * following (optional) properties: precision, width, height. If a single number is passed,
  35080. * it will be used for both width and height. If an object is passed, the screenshot size
  35081. * will be derived from the parameters. The precision property is a multiplier allowing
  35082. * rendering at a higher or lower resolution
  35083. * @param successCallback The callback receives a single parameter which contains the
  35084. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35085. * src parameter of an <img> to display it
  35086. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35087. * Check your browser for supported MIME types
  35088. * @param samples Texture samples (default: 1)
  35089. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35090. * @param fileName A name for for the downloaded file.
  35091. */
  35092. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35093. /**
  35094. * Generates an image screenshot from the specified camera.
  35095. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35096. * @param engine The engine to use for rendering
  35097. * @param camera The camera to use for rendering
  35098. * @param size This parameter can be set to a single number or to an object with the
  35099. * following (optional) properties: precision, width, height. If a single number is passed,
  35100. * it will be used for both width and height. If an object is passed, the screenshot size
  35101. * will be derived from the parameters. The precision property is a multiplier allowing
  35102. * rendering at a higher or lower resolution
  35103. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35104. * Check your browser for supported MIME types
  35105. * @param samples Texture samples (default: 1)
  35106. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35107. * @param fileName A name for for the downloaded file.
  35108. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35109. * to the src parameter of an <img> to display it
  35110. */
  35111. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35112. /**
  35113. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35114. * Be aware Math.random() could cause collisions, but:
  35115. * "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"
  35116. * @returns a pseudo random id
  35117. */
  35118. static RandomId(): string;
  35119. /**
  35120. * Test if the given uri is a base64 string
  35121. * @param uri The uri to test
  35122. * @return True if the uri is a base64 string or false otherwise
  35123. */
  35124. static IsBase64(uri: string): boolean;
  35125. /**
  35126. * Decode the given base64 uri.
  35127. * @param uri The uri to decode
  35128. * @return The decoded base64 data.
  35129. */
  35130. static DecodeBase64(uri: string): ArrayBuffer;
  35131. /**
  35132. * Gets the absolute url.
  35133. * @param url the input url
  35134. * @return the absolute url
  35135. */
  35136. static GetAbsoluteUrl(url: string): string;
  35137. /**
  35138. * No log
  35139. */
  35140. static readonly NoneLogLevel: number;
  35141. /**
  35142. * Only message logs
  35143. */
  35144. static readonly MessageLogLevel: number;
  35145. /**
  35146. * Only warning logs
  35147. */
  35148. static readonly WarningLogLevel: number;
  35149. /**
  35150. * Only error logs
  35151. */
  35152. static readonly ErrorLogLevel: number;
  35153. /**
  35154. * All logs
  35155. */
  35156. static readonly AllLogLevel: number;
  35157. /**
  35158. * Gets a value indicating the number of loading errors
  35159. * @ignorenaming
  35160. */
  35161. static get errorsCount(): number;
  35162. /**
  35163. * Callback called when a new log is added
  35164. */
  35165. static OnNewCacheEntry: (entry: string) => void;
  35166. /**
  35167. * Log a message to the console
  35168. * @param message defines the message to log
  35169. */
  35170. static Log(message: string): void;
  35171. /**
  35172. * Write a warning message to the console
  35173. * @param message defines the message to log
  35174. */
  35175. static Warn(message: string): void;
  35176. /**
  35177. * Write an error message to the console
  35178. * @param message defines the message to log
  35179. */
  35180. static Error(message: string): void;
  35181. /**
  35182. * Gets current log cache (list of logs)
  35183. */
  35184. static get LogCache(): string;
  35185. /**
  35186. * Clears the log cache
  35187. */
  35188. static ClearLogCache(): void;
  35189. /**
  35190. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35191. */
  35192. static set LogLevels(level: number);
  35193. /**
  35194. * Checks if the window object exists
  35195. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35196. */
  35197. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35198. /**
  35199. * No performance log
  35200. */
  35201. static readonly PerformanceNoneLogLevel: number;
  35202. /**
  35203. * Use user marks to log performance
  35204. */
  35205. static readonly PerformanceUserMarkLogLevel: number;
  35206. /**
  35207. * Log performance to the console
  35208. */
  35209. static readonly PerformanceConsoleLogLevel: number;
  35210. private static _performance;
  35211. /**
  35212. * Sets the current performance log level
  35213. */
  35214. static set PerformanceLogLevel(level: number);
  35215. private static _StartPerformanceCounterDisabled;
  35216. private static _EndPerformanceCounterDisabled;
  35217. private static _StartUserMark;
  35218. private static _EndUserMark;
  35219. private static _StartPerformanceConsole;
  35220. private static _EndPerformanceConsole;
  35221. /**
  35222. * Starts a performance counter
  35223. */
  35224. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35225. /**
  35226. * Ends a specific performance coutner
  35227. */
  35228. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35229. /**
  35230. * Gets either window.performance.now() if supported or Date.now() else
  35231. */
  35232. static get Now(): number;
  35233. /**
  35234. * This method will return the name of the class used to create the instance of the given object.
  35235. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35236. * @param object the object to get the class name from
  35237. * @param isType defines if the object is actually a type
  35238. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35239. */
  35240. static GetClassName(object: any, isType?: boolean): string;
  35241. /**
  35242. * Gets the first element of an array satisfying a given predicate
  35243. * @param array defines the array to browse
  35244. * @param predicate defines the predicate to use
  35245. * @returns null if not found or the element
  35246. */
  35247. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35248. /**
  35249. * This method will return the name of the full name of the class, including its owning module (if any).
  35250. * 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).
  35251. * @param object the object to get the class name from
  35252. * @param isType defines if the object is actually a type
  35253. * @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.
  35254. * @ignorenaming
  35255. */
  35256. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35257. /**
  35258. * Returns a promise that resolves after the given amount of time.
  35259. * @param delay Number of milliseconds to delay
  35260. * @returns Promise that resolves after the given amount of time
  35261. */
  35262. static DelayAsync(delay: number): Promise<void>;
  35263. /**
  35264. * Utility function to detect if the current user agent is Safari
  35265. * @returns whether or not the current user agent is safari
  35266. */
  35267. static IsSafari(): boolean;
  35268. }
  35269. /**
  35270. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35271. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35272. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35273. * @param name The name of the class, case should be preserved
  35274. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35275. */
  35276. export function className(name: string, module?: string): (target: Object) => void;
  35277. /**
  35278. * An implementation of a loop for asynchronous functions.
  35279. */
  35280. export class AsyncLoop {
  35281. /**
  35282. * Defines the number of iterations for the loop
  35283. */
  35284. iterations: number;
  35285. /**
  35286. * Defines the current index of the loop.
  35287. */
  35288. index: number;
  35289. private _done;
  35290. private _fn;
  35291. private _successCallback;
  35292. /**
  35293. * Constructor.
  35294. * @param iterations the number of iterations.
  35295. * @param func the function to run each iteration
  35296. * @param successCallback the callback that will be called upon succesful execution
  35297. * @param offset starting offset.
  35298. */
  35299. constructor(
  35300. /**
  35301. * Defines the number of iterations for the loop
  35302. */
  35303. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35304. /**
  35305. * Execute the next iteration. Must be called after the last iteration was finished.
  35306. */
  35307. executeNext(): void;
  35308. /**
  35309. * Break the loop and run the success callback.
  35310. */
  35311. breakLoop(): void;
  35312. /**
  35313. * Create and run an async loop.
  35314. * @param iterations the number of iterations.
  35315. * @param fn the function to run each iteration
  35316. * @param successCallback the callback that will be called upon succesful execution
  35317. * @param offset starting offset.
  35318. * @returns the created async loop object
  35319. */
  35320. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35321. /**
  35322. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35323. * @param iterations total number of iterations
  35324. * @param syncedIterations number of synchronous iterations in each async iteration.
  35325. * @param fn the function to call each iteration.
  35326. * @param callback a success call back that will be called when iterating stops.
  35327. * @param breakFunction a break condition (optional)
  35328. * @param timeout timeout settings for the setTimeout function. default - 0.
  35329. * @returns the created async loop object
  35330. */
  35331. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35332. }
  35333. }
  35334. declare module "babylonjs/Misc/stringDictionary" {
  35335. import { Nullable } from "babylonjs/types";
  35336. /**
  35337. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35338. * The underlying implementation relies on an associative array to ensure the best performances.
  35339. * The value can be anything including 'null' but except 'undefined'
  35340. */
  35341. export class StringDictionary<T> {
  35342. /**
  35343. * This will clear this dictionary and copy the content from the 'source' one.
  35344. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35345. * @param source the dictionary to take the content from and copy to this dictionary
  35346. */
  35347. copyFrom(source: StringDictionary<T>): void;
  35348. /**
  35349. * Get a value based from its key
  35350. * @param key the given key to get the matching value from
  35351. * @return the value if found, otherwise undefined is returned
  35352. */
  35353. get(key: string): T | undefined;
  35354. /**
  35355. * Get a value from its key or add it if it doesn't exist.
  35356. * This method will ensure you that a given key/data will be present in the dictionary.
  35357. * @param key the given key to get the matching value from
  35358. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35359. * The factory will only be invoked if there's no data for the given key.
  35360. * @return the value corresponding to the key.
  35361. */
  35362. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35363. /**
  35364. * Get a value from its key if present in the dictionary otherwise add it
  35365. * @param key the key to get the value from
  35366. * @param val if there's no such key/value pair in the dictionary add it with this value
  35367. * @return the value corresponding to the key
  35368. */
  35369. getOrAdd(key: string, val: T): T;
  35370. /**
  35371. * Check if there's a given key in the dictionary
  35372. * @param key the key to check for
  35373. * @return true if the key is present, false otherwise
  35374. */
  35375. contains(key: string): boolean;
  35376. /**
  35377. * Add a new key and its corresponding value
  35378. * @param key the key to add
  35379. * @param value the value corresponding to the key
  35380. * @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
  35381. */
  35382. add(key: string, value: T): boolean;
  35383. /**
  35384. * Update a specific value associated to a key
  35385. * @param key defines the key to use
  35386. * @param value defines the value to store
  35387. * @returns true if the value was updated (or false if the key was not found)
  35388. */
  35389. set(key: string, value: T): boolean;
  35390. /**
  35391. * Get the element of the given key and remove it from the dictionary
  35392. * @param key defines the key to search
  35393. * @returns the value associated with the key or null if not found
  35394. */
  35395. getAndRemove(key: string): Nullable<T>;
  35396. /**
  35397. * Remove a key/value from the dictionary.
  35398. * @param key the key to remove
  35399. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35400. */
  35401. remove(key: string): boolean;
  35402. /**
  35403. * Clear the whole content of the dictionary
  35404. */
  35405. clear(): void;
  35406. /**
  35407. * Gets the current count
  35408. */
  35409. get count(): number;
  35410. /**
  35411. * Execute a callback on each key/val of the dictionary.
  35412. * Note that you can remove any element in this dictionary in the callback implementation
  35413. * @param callback the callback to execute on a given key/value pair
  35414. */
  35415. forEach(callback: (key: string, val: T) => void): void;
  35416. /**
  35417. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35418. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35419. * Note that you can remove any element in this dictionary in the callback implementation
  35420. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35421. * @returns the first item
  35422. */
  35423. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35424. private _count;
  35425. private _data;
  35426. }
  35427. }
  35428. declare module "babylonjs/Collisions/collisionCoordinator" {
  35429. import { Nullable } from "babylonjs/types";
  35430. import { Scene } from "babylonjs/scene";
  35431. import { Vector3 } from "babylonjs/Maths/math.vector";
  35432. import { Collider } from "babylonjs/Collisions/collider";
  35433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35434. /** @hidden */
  35435. export interface ICollisionCoordinator {
  35436. createCollider(): Collider;
  35437. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35438. init(scene: Scene): void;
  35439. }
  35440. /** @hidden */
  35441. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35442. private _scene;
  35443. private _scaledPosition;
  35444. private _scaledVelocity;
  35445. private _finalPosition;
  35446. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35447. createCollider(): Collider;
  35448. init(scene: Scene): void;
  35449. private _collideWithWorld;
  35450. }
  35451. }
  35452. declare module "babylonjs/Inputs/scene.inputManager" {
  35453. import { Nullable } from "babylonjs/types";
  35454. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35455. import { Vector2 } from "babylonjs/Maths/math.vector";
  35456. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35457. import { Scene } from "babylonjs/scene";
  35458. /**
  35459. * Class used to manage all inputs for the scene.
  35460. */
  35461. export class InputManager {
  35462. /** The distance in pixel that you have to move to prevent some events */
  35463. static DragMovementThreshold: number;
  35464. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35465. static LongPressDelay: number;
  35466. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35467. static DoubleClickDelay: number;
  35468. /** If you need to check double click without raising a single click at first click, enable this flag */
  35469. static ExclusiveDoubleClickMode: boolean;
  35470. private _wheelEventName;
  35471. private _onPointerMove;
  35472. private _onPointerDown;
  35473. private _onPointerUp;
  35474. private _initClickEvent;
  35475. private _initActionManager;
  35476. private _delayedSimpleClick;
  35477. private _delayedSimpleClickTimeout;
  35478. private _previousDelayedSimpleClickTimeout;
  35479. private _meshPickProceed;
  35480. private _previousButtonPressed;
  35481. private _currentPickResult;
  35482. private _previousPickResult;
  35483. private _totalPointersPressed;
  35484. private _doubleClickOccured;
  35485. private _pointerOverMesh;
  35486. private _pickedDownMesh;
  35487. private _pickedUpMesh;
  35488. private _pointerX;
  35489. private _pointerY;
  35490. private _unTranslatedPointerX;
  35491. private _unTranslatedPointerY;
  35492. private _startingPointerPosition;
  35493. private _previousStartingPointerPosition;
  35494. private _startingPointerTime;
  35495. private _previousStartingPointerTime;
  35496. private _pointerCaptures;
  35497. private _onKeyDown;
  35498. private _onKeyUp;
  35499. private _onCanvasFocusObserver;
  35500. private _onCanvasBlurObserver;
  35501. private _scene;
  35502. /**
  35503. * Creates a new InputManager
  35504. * @param scene defines the hosting scene
  35505. */
  35506. constructor(scene: Scene);
  35507. /**
  35508. * Gets the mesh that is currently under the pointer
  35509. */
  35510. get meshUnderPointer(): Nullable<AbstractMesh>;
  35511. /**
  35512. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35513. */
  35514. get unTranslatedPointer(): Vector2;
  35515. /**
  35516. * Gets or sets the current on-screen X position of the pointer
  35517. */
  35518. get pointerX(): number;
  35519. set pointerX(value: number);
  35520. /**
  35521. * Gets or sets the current on-screen Y position of the pointer
  35522. */
  35523. get pointerY(): number;
  35524. set pointerY(value: number);
  35525. private _updatePointerPosition;
  35526. private _processPointerMove;
  35527. private _setRayOnPointerInfo;
  35528. private _checkPrePointerObservable;
  35529. /**
  35530. * Use this method to simulate a pointer move on a mesh
  35531. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35532. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35533. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35534. */
  35535. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35536. /**
  35537. * Use this method to simulate a pointer down on a mesh
  35538. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35539. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35540. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35541. */
  35542. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35543. private _processPointerDown;
  35544. /** @hidden */
  35545. _isPointerSwiping(): boolean;
  35546. /**
  35547. * Use this method to simulate a pointer up on a mesh
  35548. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35549. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35550. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35551. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35552. */
  35553. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35554. private _processPointerUp;
  35555. /**
  35556. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35557. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35558. * @returns true if the pointer was captured
  35559. */
  35560. isPointerCaptured(pointerId?: number): boolean;
  35561. /**
  35562. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35563. * @param attachUp defines if you want to attach events to pointerup
  35564. * @param attachDown defines if you want to attach events to pointerdown
  35565. * @param attachMove defines if you want to attach events to pointermove
  35566. */
  35567. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35568. /**
  35569. * Detaches all event handlers
  35570. */
  35571. detachControl(): void;
  35572. /**
  35573. * Force the value of meshUnderPointer
  35574. * @param mesh defines the mesh to use
  35575. */
  35576. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35577. /**
  35578. * Gets the mesh under the pointer
  35579. * @returns a Mesh or null if no mesh is under the pointer
  35580. */
  35581. getPointerOverMesh(): Nullable<AbstractMesh>;
  35582. }
  35583. }
  35584. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35585. /**
  35586. * Helper class used to generate session unique ID
  35587. */
  35588. export class UniqueIdGenerator {
  35589. private static _UniqueIdCounter;
  35590. /**
  35591. * Gets an unique (relatively to the current scene) Id
  35592. */
  35593. static get UniqueId(): number;
  35594. }
  35595. }
  35596. declare module "babylonjs/Animations/animationGroup" {
  35597. import { Animatable } from "babylonjs/Animations/animatable";
  35598. import { Animation } from "babylonjs/Animations/animation";
  35599. import { Scene, IDisposable } from "babylonjs/scene";
  35600. import { Observable } from "babylonjs/Misc/observable";
  35601. import { Nullable } from "babylonjs/types";
  35602. import "babylonjs/Animations/animatable";
  35603. /**
  35604. * This class defines the direct association between an animation and a target
  35605. */
  35606. export class TargetedAnimation {
  35607. /**
  35608. * Animation to perform
  35609. */
  35610. animation: Animation;
  35611. /**
  35612. * Target to animate
  35613. */
  35614. target: any;
  35615. /**
  35616. * Serialize the object
  35617. * @returns the JSON object representing the current entity
  35618. */
  35619. serialize(): any;
  35620. }
  35621. /**
  35622. * Use this class to create coordinated animations on multiple targets
  35623. */
  35624. export class AnimationGroup implements IDisposable {
  35625. /** The name of the animation group */
  35626. name: string;
  35627. private _scene;
  35628. private _targetedAnimations;
  35629. private _animatables;
  35630. private _from;
  35631. private _to;
  35632. private _isStarted;
  35633. private _isPaused;
  35634. private _speedRatio;
  35635. private _loopAnimation;
  35636. /**
  35637. * Gets or sets the unique id of the node
  35638. */
  35639. uniqueId: number;
  35640. /**
  35641. * This observable will notify when one animation have ended
  35642. */
  35643. onAnimationEndObservable: Observable<TargetedAnimation>;
  35644. /**
  35645. * Observer raised when one animation loops
  35646. */
  35647. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35648. /**
  35649. * Observer raised when all animations have looped
  35650. */
  35651. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35652. /**
  35653. * This observable will notify when all animations have ended.
  35654. */
  35655. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35656. /**
  35657. * This observable will notify when all animations have paused.
  35658. */
  35659. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35660. /**
  35661. * This observable will notify when all animations are playing.
  35662. */
  35663. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35664. /**
  35665. * Gets the first frame
  35666. */
  35667. get from(): number;
  35668. /**
  35669. * Gets the last frame
  35670. */
  35671. get to(): number;
  35672. /**
  35673. * Define if the animations are started
  35674. */
  35675. get isStarted(): boolean;
  35676. /**
  35677. * Gets a value indicating that the current group is playing
  35678. */
  35679. get isPlaying(): boolean;
  35680. /**
  35681. * Gets or sets the speed ratio to use for all animations
  35682. */
  35683. get speedRatio(): number;
  35684. /**
  35685. * Gets or sets the speed ratio to use for all animations
  35686. */
  35687. set speedRatio(value: number);
  35688. /**
  35689. * Gets or sets if all animations should loop or not
  35690. */
  35691. get loopAnimation(): boolean;
  35692. set loopAnimation(value: boolean);
  35693. /**
  35694. * Gets the targeted animations for this animation group
  35695. */
  35696. get targetedAnimations(): Array<TargetedAnimation>;
  35697. /**
  35698. * returning the list of animatables controlled by this animation group.
  35699. */
  35700. get animatables(): Array<Animatable>;
  35701. /**
  35702. * Instantiates a new Animation Group.
  35703. * This helps managing several animations at once.
  35704. * @see http://doc.babylonjs.com/how_to/group
  35705. * @param name Defines the name of the group
  35706. * @param scene Defines the scene the group belongs to
  35707. */
  35708. constructor(
  35709. /** The name of the animation group */
  35710. name: string, scene?: Nullable<Scene>);
  35711. /**
  35712. * Add an animation (with its target) in the group
  35713. * @param animation defines the animation we want to add
  35714. * @param target defines the target of the animation
  35715. * @returns the TargetedAnimation object
  35716. */
  35717. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35718. /**
  35719. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35720. * It can add constant keys at begin or end
  35721. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35722. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35723. * @returns the animation group
  35724. */
  35725. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35726. private _animationLoopCount;
  35727. private _animationLoopFlags;
  35728. private _processLoop;
  35729. /**
  35730. * Start all animations on given targets
  35731. * @param loop defines if animations must loop
  35732. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35733. * @param from defines the from key (optional)
  35734. * @param to defines the to key (optional)
  35735. * @returns the current animation group
  35736. */
  35737. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35738. /**
  35739. * Pause all animations
  35740. * @returns the animation group
  35741. */
  35742. pause(): AnimationGroup;
  35743. /**
  35744. * Play all animations to initial state
  35745. * This function will start() the animations if they were not started or will restart() them if they were paused
  35746. * @param loop defines if animations must loop
  35747. * @returns the animation group
  35748. */
  35749. play(loop?: boolean): AnimationGroup;
  35750. /**
  35751. * Reset all animations to initial state
  35752. * @returns the animation group
  35753. */
  35754. reset(): AnimationGroup;
  35755. /**
  35756. * Restart animations from key 0
  35757. * @returns the animation group
  35758. */
  35759. restart(): AnimationGroup;
  35760. /**
  35761. * Stop all animations
  35762. * @returns the animation group
  35763. */
  35764. stop(): AnimationGroup;
  35765. /**
  35766. * Set animation weight for all animatables
  35767. * @param weight defines the weight to use
  35768. * @return the animationGroup
  35769. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35770. */
  35771. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35772. /**
  35773. * Synchronize and normalize all animatables with a source animatable
  35774. * @param root defines the root animatable to synchronize with
  35775. * @return the animationGroup
  35776. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35777. */
  35778. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35779. /**
  35780. * Goes to a specific frame in this animation group
  35781. * @param frame the frame number to go to
  35782. * @return the animationGroup
  35783. */
  35784. goToFrame(frame: number): AnimationGroup;
  35785. /**
  35786. * Dispose all associated resources
  35787. */
  35788. dispose(): void;
  35789. private _checkAnimationGroupEnded;
  35790. /**
  35791. * Clone the current animation group and returns a copy
  35792. * @param newName defines the name of the new group
  35793. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35794. * @returns the new aniamtion group
  35795. */
  35796. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35797. /**
  35798. * Serializes the animationGroup to an object
  35799. * @returns Serialized object
  35800. */
  35801. serialize(): any;
  35802. /**
  35803. * Returns a new AnimationGroup object parsed from the source provided.
  35804. * @param parsedAnimationGroup defines the source
  35805. * @param scene defines the scene that will receive the animationGroup
  35806. * @returns a new AnimationGroup
  35807. */
  35808. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35809. /**
  35810. * Returns the string "AnimationGroup"
  35811. * @returns "AnimationGroup"
  35812. */
  35813. getClassName(): string;
  35814. /**
  35815. * Creates a detailled string about the object
  35816. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35817. * @returns a string representing the object
  35818. */
  35819. toString(fullDetails?: boolean): string;
  35820. }
  35821. }
  35822. declare module "babylonjs/scene" {
  35823. import { Nullable } from "babylonjs/types";
  35824. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35825. import { Observable } from "babylonjs/Misc/observable";
  35826. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  35827. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  35828. import { Geometry } from "babylonjs/Meshes/geometry";
  35829. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35830. import { SubMesh } from "babylonjs/Meshes/subMesh";
  35831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35832. import { Mesh } from "babylonjs/Meshes/mesh";
  35833. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35834. import { Bone } from "babylonjs/Bones/bone";
  35835. import { Skeleton } from "babylonjs/Bones/skeleton";
  35836. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35837. import { Camera } from "babylonjs/Cameras/camera";
  35838. import { AbstractScene } from "babylonjs/abstractScene";
  35839. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35840. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35841. import { Material } from "babylonjs/Materials/material";
  35842. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35843. import { Effect } from "babylonjs/Materials/effect";
  35844. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35845. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35846. import { Light } from "babylonjs/Lights/light";
  35847. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35848. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  35849. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  35850. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  35851. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35852. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  35853. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35854. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  35855. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  35856. import { Engine } from "babylonjs/Engines/engine";
  35857. import { Node } from "babylonjs/node";
  35858. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  35859. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35860. import { WebRequest } from "babylonjs/Misc/webRequest";
  35861. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  35862. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  35863. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35864. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  35865. import { Plane } from "babylonjs/Maths/math.plane";
  35866. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  35867. import { Ray } from "babylonjs/Culling/ray";
  35868. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  35869. import { Animation } from "babylonjs/Animations/animation";
  35870. import { Animatable } from "babylonjs/Animations/animatable";
  35871. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35872. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  35873. import { Collider } from "babylonjs/Collisions/collider";
  35874. /**
  35875. * Define an interface for all classes that will hold resources
  35876. */
  35877. export interface IDisposable {
  35878. /**
  35879. * Releases all held resources
  35880. */
  35881. dispose(): void;
  35882. }
  35883. /** Interface defining initialization parameters for Scene class */
  35884. export interface SceneOptions {
  35885. /**
  35886. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35887. * It will improve performance when the number of geometries becomes important.
  35888. */
  35889. useGeometryUniqueIdsMap?: boolean;
  35890. /**
  35891. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35892. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35893. */
  35894. useMaterialMeshMap?: boolean;
  35895. /**
  35896. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35897. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35898. */
  35899. useClonedMeshMap?: boolean;
  35900. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35901. virtual?: boolean;
  35902. }
  35903. /**
  35904. * Represents a scene to be rendered by the engine.
  35905. * @see http://doc.babylonjs.com/features/scene
  35906. */
  35907. export class Scene extends AbstractScene implements IAnimatable {
  35908. /** The fog is deactivated */
  35909. static readonly FOGMODE_NONE: number;
  35910. /** The fog density is following an exponential function */
  35911. static readonly FOGMODE_EXP: number;
  35912. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35913. static readonly FOGMODE_EXP2: number;
  35914. /** The fog density is following a linear function. */
  35915. static readonly FOGMODE_LINEAR: number;
  35916. /**
  35917. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35918. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35919. */
  35920. static MinDeltaTime: number;
  35921. /**
  35922. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35923. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35924. */
  35925. static MaxDeltaTime: number;
  35926. /**
  35927. * Factory used to create the default material.
  35928. * @param name The name of the material to create
  35929. * @param scene The scene to create the material for
  35930. * @returns The default material
  35931. */
  35932. static DefaultMaterialFactory(scene: Scene): Material;
  35933. /**
  35934. * Factory used to create the a collision coordinator.
  35935. * @returns The collision coordinator
  35936. */
  35937. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35938. /** @hidden */
  35939. _inputManager: InputManager;
  35940. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35941. cameraToUseForPointers: Nullable<Camera>;
  35942. /** @hidden */
  35943. readonly _isScene: boolean;
  35944. /**
  35945. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35946. */
  35947. autoClear: boolean;
  35948. /**
  35949. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35950. */
  35951. autoClearDepthAndStencil: boolean;
  35952. /**
  35953. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35954. */
  35955. clearColor: Color4;
  35956. /**
  35957. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35958. */
  35959. ambientColor: Color3;
  35960. /**
  35961. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35962. * It should only be one of the following (if not the default embedded one):
  35963. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35964. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35965. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35966. * The material properties need to be setup according to the type of texture in use.
  35967. */
  35968. environmentBRDFTexture: BaseTexture;
  35969. /** @hidden */
  35970. protected _environmentTexture: Nullable<BaseTexture>;
  35971. /**
  35972. * Texture used in all pbr material as the reflection texture.
  35973. * As in the majority of the scene they are the same (exception for multi room and so on),
  35974. * this is easier to reference from here than from all the materials.
  35975. */
  35976. get environmentTexture(): Nullable<BaseTexture>;
  35977. /**
  35978. * Texture used in all pbr material as the reflection texture.
  35979. * As in the majority of the scene they are the same (exception for multi room and so on),
  35980. * this is easier to set here than in all the materials.
  35981. */
  35982. set environmentTexture(value: Nullable<BaseTexture>);
  35983. /** @hidden */
  35984. protected _environmentIntensity: number;
  35985. /**
  35986. * Intensity of the environment in all pbr material.
  35987. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35988. * As in the majority of the scene they are the same (exception for multi room and so on),
  35989. * this is easier to reference from here than from all the materials.
  35990. */
  35991. get environmentIntensity(): number;
  35992. /**
  35993. * Intensity of the environment in all pbr material.
  35994. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35995. * As in the majority of the scene they are the same (exception for multi room and so on),
  35996. * this is easier to set here than in all the materials.
  35997. */
  35998. set environmentIntensity(value: number);
  35999. /** @hidden */
  36000. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36001. /**
  36002. * Default image processing configuration used either in the rendering
  36003. * Forward main pass or through the imageProcessingPostProcess if present.
  36004. * As in the majority of the scene they are the same (exception for multi camera),
  36005. * this is easier to reference from here than from all the materials and post process.
  36006. *
  36007. * No setter as we it is a shared configuration, you can set the values instead.
  36008. */
  36009. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36010. private _forceWireframe;
  36011. /**
  36012. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36013. */
  36014. set forceWireframe(value: boolean);
  36015. get forceWireframe(): boolean;
  36016. private _skipFrustumClipping;
  36017. /**
  36018. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36019. */
  36020. set skipFrustumClipping(value: boolean);
  36021. get skipFrustumClipping(): boolean;
  36022. private _forcePointsCloud;
  36023. /**
  36024. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36025. */
  36026. set forcePointsCloud(value: boolean);
  36027. get forcePointsCloud(): boolean;
  36028. /**
  36029. * Gets or sets the active clipplane 1
  36030. */
  36031. clipPlane: Nullable<Plane>;
  36032. /**
  36033. * Gets or sets the active clipplane 2
  36034. */
  36035. clipPlane2: Nullable<Plane>;
  36036. /**
  36037. * Gets or sets the active clipplane 3
  36038. */
  36039. clipPlane3: Nullable<Plane>;
  36040. /**
  36041. * Gets or sets the active clipplane 4
  36042. */
  36043. clipPlane4: Nullable<Plane>;
  36044. /**
  36045. * Gets or sets the active clipplane 5
  36046. */
  36047. clipPlane5: Nullable<Plane>;
  36048. /**
  36049. * Gets or sets the active clipplane 6
  36050. */
  36051. clipPlane6: Nullable<Plane>;
  36052. /**
  36053. * Gets or sets a boolean indicating if animations are enabled
  36054. */
  36055. animationsEnabled: boolean;
  36056. private _animationPropertiesOverride;
  36057. /**
  36058. * Gets or sets the animation properties override
  36059. */
  36060. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36061. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36062. /**
  36063. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36064. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36065. */
  36066. useConstantAnimationDeltaTime: boolean;
  36067. /**
  36068. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36069. * Please note that it requires to run a ray cast through the scene on every frame
  36070. */
  36071. constantlyUpdateMeshUnderPointer: boolean;
  36072. /**
  36073. * Defines the HTML cursor to use when hovering over interactive elements
  36074. */
  36075. hoverCursor: string;
  36076. /**
  36077. * Defines the HTML default cursor to use (empty by default)
  36078. */
  36079. defaultCursor: string;
  36080. /**
  36081. * Defines wether cursors are handled by the scene.
  36082. */
  36083. doNotHandleCursors: boolean;
  36084. /**
  36085. * This is used to call preventDefault() on pointer down
  36086. * in order to block unwanted artifacts like system double clicks
  36087. */
  36088. preventDefaultOnPointerDown: boolean;
  36089. /**
  36090. * This is used to call preventDefault() on pointer up
  36091. * in order to block unwanted artifacts like system double clicks
  36092. */
  36093. preventDefaultOnPointerUp: boolean;
  36094. /**
  36095. * Gets or sets user defined metadata
  36096. */
  36097. metadata: any;
  36098. /**
  36099. * For internal use only. Please do not use.
  36100. */
  36101. reservedDataStore: any;
  36102. /**
  36103. * Gets the name of the plugin used to load this scene (null by default)
  36104. */
  36105. loadingPluginName: string;
  36106. /**
  36107. * Use this array to add regular expressions used to disable offline support for specific urls
  36108. */
  36109. disableOfflineSupportExceptionRules: RegExp[];
  36110. /**
  36111. * An event triggered when the scene is disposed.
  36112. */
  36113. onDisposeObservable: Observable<Scene>;
  36114. private _onDisposeObserver;
  36115. /** Sets a function to be executed when this scene is disposed. */
  36116. set onDispose(callback: () => void);
  36117. /**
  36118. * An event triggered before rendering the scene (right after animations and physics)
  36119. */
  36120. onBeforeRenderObservable: Observable<Scene>;
  36121. private _onBeforeRenderObserver;
  36122. /** Sets a function to be executed before rendering this scene */
  36123. set beforeRender(callback: Nullable<() => void>);
  36124. /**
  36125. * An event triggered after rendering the scene
  36126. */
  36127. onAfterRenderObservable: Observable<Scene>;
  36128. /**
  36129. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36130. */
  36131. onAfterRenderCameraObservable: Observable<Camera>;
  36132. private _onAfterRenderObserver;
  36133. /** Sets a function to be executed after rendering this scene */
  36134. set afterRender(callback: Nullable<() => void>);
  36135. /**
  36136. * An event triggered before animating the scene
  36137. */
  36138. onBeforeAnimationsObservable: Observable<Scene>;
  36139. /**
  36140. * An event triggered after animations processing
  36141. */
  36142. onAfterAnimationsObservable: Observable<Scene>;
  36143. /**
  36144. * An event triggered before draw calls are ready to be sent
  36145. */
  36146. onBeforeDrawPhaseObservable: Observable<Scene>;
  36147. /**
  36148. * An event triggered after draw calls have been sent
  36149. */
  36150. onAfterDrawPhaseObservable: Observable<Scene>;
  36151. /**
  36152. * An event triggered when the scene is ready
  36153. */
  36154. onReadyObservable: Observable<Scene>;
  36155. /**
  36156. * An event triggered before rendering a camera
  36157. */
  36158. onBeforeCameraRenderObservable: Observable<Camera>;
  36159. private _onBeforeCameraRenderObserver;
  36160. /** Sets a function to be executed before rendering a camera*/
  36161. set beforeCameraRender(callback: () => void);
  36162. /**
  36163. * An event triggered after rendering a camera
  36164. */
  36165. onAfterCameraRenderObservable: Observable<Camera>;
  36166. private _onAfterCameraRenderObserver;
  36167. /** Sets a function to be executed after rendering a camera*/
  36168. set afterCameraRender(callback: () => void);
  36169. /**
  36170. * An event triggered when active meshes evaluation is about to start
  36171. */
  36172. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36173. /**
  36174. * An event triggered when active meshes evaluation is done
  36175. */
  36176. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36177. /**
  36178. * An event triggered when particles rendering is about to start
  36179. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36180. */
  36181. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36182. /**
  36183. * An event triggered when particles rendering is done
  36184. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36185. */
  36186. onAfterParticlesRenderingObservable: Observable<Scene>;
  36187. /**
  36188. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36189. */
  36190. onDataLoadedObservable: Observable<Scene>;
  36191. /**
  36192. * An event triggered when a camera is created
  36193. */
  36194. onNewCameraAddedObservable: Observable<Camera>;
  36195. /**
  36196. * An event triggered when a camera is removed
  36197. */
  36198. onCameraRemovedObservable: Observable<Camera>;
  36199. /**
  36200. * An event triggered when a light is created
  36201. */
  36202. onNewLightAddedObservable: Observable<Light>;
  36203. /**
  36204. * An event triggered when a light is removed
  36205. */
  36206. onLightRemovedObservable: Observable<Light>;
  36207. /**
  36208. * An event triggered when a geometry is created
  36209. */
  36210. onNewGeometryAddedObservable: Observable<Geometry>;
  36211. /**
  36212. * An event triggered when a geometry is removed
  36213. */
  36214. onGeometryRemovedObservable: Observable<Geometry>;
  36215. /**
  36216. * An event triggered when a transform node is created
  36217. */
  36218. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36219. /**
  36220. * An event triggered when a transform node is removed
  36221. */
  36222. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36223. /**
  36224. * An event triggered when a mesh is created
  36225. */
  36226. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36227. /**
  36228. * An event triggered when a mesh is removed
  36229. */
  36230. onMeshRemovedObservable: Observable<AbstractMesh>;
  36231. /**
  36232. * An event triggered when a skeleton is created
  36233. */
  36234. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36235. /**
  36236. * An event triggered when a skeleton is removed
  36237. */
  36238. onSkeletonRemovedObservable: Observable<Skeleton>;
  36239. /**
  36240. * An event triggered when a material is created
  36241. */
  36242. onNewMaterialAddedObservable: Observable<Material>;
  36243. /**
  36244. * An event triggered when a material is removed
  36245. */
  36246. onMaterialRemovedObservable: Observable<Material>;
  36247. /**
  36248. * An event triggered when a texture is created
  36249. */
  36250. onNewTextureAddedObservable: Observable<BaseTexture>;
  36251. /**
  36252. * An event triggered when a texture is removed
  36253. */
  36254. onTextureRemovedObservable: Observable<BaseTexture>;
  36255. /**
  36256. * An event triggered when render targets are about to be rendered
  36257. * Can happen multiple times per frame.
  36258. */
  36259. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36260. /**
  36261. * An event triggered when render targets were rendered.
  36262. * Can happen multiple times per frame.
  36263. */
  36264. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36265. /**
  36266. * An event triggered before calculating deterministic simulation step
  36267. */
  36268. onBeforeStepObservable: Observable<Scene>;
  36269. /**
  36270. * An event triggered after calculating deterministic simulation step
  36271. */
  36272. onAfterStepObservable: Observable<Scene>;
  36273. /**
  36274. * An event triggered when the activeCamera property is updated
  36275. */
  36276. onActiveCameraChanged: Observable<Scene>;
  36277. /**
  36278. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36279. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36280. * 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)
  36281. */
  36282. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36283. /**
  36284. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36285. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36286. * 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)
  36287. */
  36288. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36289. /**
  36290. * This Observable will when a mesh has been imported into the scene.
  36291. */
  36292. onMeshImportedObservable: Observable<AbstractMesh>;
  36293. /**
  36294. * This Observable will when an animation file has been imported into the scene.
  36295. */
  36296. onAnimationFileImportedObservable: Observable<Scene>;
  36297. /**
  36298. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36299. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36300. */
  36301. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36302. /** @hidden */
  36303. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36304. /**
  36305. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36306. */
  36307. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36308. /**
  36309. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36310. */
  36311. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36312. /**
  36313. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36314. */
  36315. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36316. /** Callback called when a pointer move is detected */
  36317. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36318. /** Callback called when a pointer down is detected */
  36319. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36320. /** Callback called when a pointer up is detected */
  36321. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36322. /** Callback called when a pointer pick is detected */
  36323. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36324. /**
  36325. * 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).
  36326. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36327. */
  36328. onPrePointerObservable: Observable<PointerInfoPre>;
  36329. /**
  36330. * Observable event triggered each time an input event is received from the rendering canvas
  36331. */
  36332. onPointerObservable: Observable<PointerInfo>;
  36333. /**
  36334. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36335. */
  36336. get unTranslatedPointer(): Vector2;
  36337. /**
  36338. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36339. */
  36340. static get DragMovementThreshold(): number;
  36341. static set DragMovementThreshold(value: number);
  36342. /**
  36343. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36344. */
  36345. static get LongPressDelay(): number;
  36346. static set LongPressDelay(value: number);
  36347. /**
  36348. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36349. */
  36350. static get DoubleClickDelay(): number;
  36351. static set DoubleClickDelay(value: number);
  36352. /** If you need to check double click without raising a single click at first click, enable this flag */
  36353. static get ExclusiveDoubleClickMode(): boolean;
  36354. static set ExclusiveDoubleClickMode(value: boolean);
  36355. /** @hidden */
  36356. _mirroredCameraPosition: Nullable<Vector3>;
  36357. /**
  36358. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36359. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36360. */
  36361. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36362. /**
  36363. * Observable event triggered each time an keyboard event is received from the hosting window
  36364. */
  36365. onKeyboardObservable: Observable<KeyboardInfo>;
  36366. private _useRightHandedSystem;
  36367. /**
  36368. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36369. */
  36370. set useRightHandedSystem(value: boolean);
  36371. get useRightHandedSystem(): boolean;
  36372. private _timeAccumulator;
  36373. private _currentStepId;
  36374. private _currentInternalStep;
  36375. /**
  36376. * Sets the step Id used by deterministic lock step
  36377. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36378. * @param newStepId defines the step Id
  36379. */
  36380. setStepId(newStepId: number): void;
  36381. /**
  36382. * Gets the step Id used by deterministic lock step
  36383. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36384. * @returns the step Id
  36385. */
  36386. getStepId(): number;
  36387. /**
  36388. * Gets the internal step used by deterministic lock step
  36389. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36390. * @returns the internal step
  36391. */
  36392. getInternalStep(): number;
  36393. private _fogEnabled;
  36394. /**
  36395. * Gets or sets a boolean indicating if fog is enabled on this scene
  36396. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36397. * (Default is true)
  36398. */
  36399. set fogEnabled(value: boolean);
  36400. get fogEnabled(): boolean;
  36401. private _fogMode;
  36402. /**
  36403. * Gets or sets the fog mode to use
  36404. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36405. * | mode | value |
  36406. * | --- | --- |
  36407. * | FOGMODE_NONE | 0 |
  36408. * | FOGMODE_EXP | 1 |
  36409. * | FOGMODE_EXP2 | 2 |
  36410. * | FOGMODE_LINEAR | 3 |
  36411. */
  36412. set fogMode(value: number);
  36413. get fogMode(): number;
  36414. /**
  36415. * Gets or sets the fog color to use
  36416. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36417. * (Default is Color3(0.2, 0.2, 0.3))
  36418. */
  36419. fogColor: Color3;
  36420. /**
  36421. * Gets or sets the fog density to use
  36422. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36423. * (Default is 0.1)
  36424. */
  36425. fogDensity: number;
  36426. /**
  36427. * Gets or sets the fog start distance to use
  36428. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36429. * (Default is 0)
  36430. */
  36431. fogStart: number;
  36432. /**
  36433. * Gets or sets the fog end distance to use
  36434. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36435. * (Default is 1000)
  36436. */
  36437. fogEnd: number;
  36438. private _shadowsEnabled;
  36439. /**
  36440. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36441. */
  36442. set shadowsEnabled(value: boolean);
  36443. get shadowsEnabled(): boolean;
  36444. private _lightsEnabled;
  36445. /**
  36446. * Gets or sets a boolean indicating if lights are enabled on this scene
  36447. */
  36448. set lightsEnabled(value: boolean);
  36449. get lightsEnabled(): boolean;
  36450. /** All of the active cameras added to this scene. */
  36451. activeCameras: Camera[];
  36452. /** @hidden */
  36453. _activeCamera: Nullable<Camera>;
  36454. /** Gets or sets the current active camera */
  36455. get activeCamera(): Nullable<Camera>;
  36456. set activeCamera(value: Nullable<Camera>);
  36457. private _defaultMaterial;
  36458. /** The default material used on meshes when no material is affected */
  36459. get defaultMaterial(): Material;
  36460. /** The default material used on meshes when no material is affected */
  36461. set defaultMaterial(value: Material);
  36462. private _texturesEnabled;
  36463. /**
  36464. * Gets or sets a boolean indicating if textures are enabled on this scene
  36465. */
  36466. set texturesEnabled(value: boolean);
  36467. get texturesEnabled(): boolean;
  36468. /**
  36469. * Gets or sets a boolean indicating if particles are enabled on this scene
  36470. */
  36471. particlesEnabled: boolean;
  36472. /**
  36473. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36474. */
  36475. spritesEnabled: boolean;
  36476. private _skeletonsEnabled;
  36477. /**
  36478. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36479. */
  36480. set skeletonsEnabled(value: boolean);
  36481. get skeletonsEnabled(): boolean;
  36482. /**
  36483. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36484. */
  36485. lensFlaresEnabled: boolean;
  36486. /**
  36487. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36488. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36489. */
  36490. collisionsEnabled: boolean;
  36491. private _collisionCoordinator;
  36492. /** @hidden */
  36493. get collisionCoordinator(): ICollisionCoordinator;
  36494. /**
  36495. * Defines the gravity applied to this scene (used only for collisions)
  36496. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36497. */
  36498. gravity: Vector3;
  36499. /**
  36500. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36501. */
  36502. postProcessesEnabled: boolean;
  36503. /**
  36504. * The list of postprocesses added to the scene
  36505. */
  36506. postProcesses: PostProcess[];
  36507. /**
  36508. * Gets the current postprocess manager
  36509. */
  36510. postProcessManager: PostProcessManager;
  36511. /**
  36512. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36513. */
  36514. renderTargetsEnabled: boolean;
  36515. /**
  36516. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36517. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36518. */
  36519. dumpNextRenderTargets: boolean;
  36520. /**
  36521. * The list of user defined render targets added to the scene
  36522. */
  36523. customRenderTargets: RenderTargetTexture[];
  36524. /**
  36525. * Defines if texture loading must be delayed
  36526. * If true, textures will only be loaded when they need to be rendered
  36527. */
  36528. useDelayedTextureLoading: boolean;
  36529. /**
  36530. * Gets the list of meshes imported to the scene through SceneLoader
  36531. */
  36532. importedMeshesFiles: String[];
  36533. /**
  36534. * Gets or sets a boolean indicating if probes are enabled on this scene
  36535. */
  36536. probesEnabled: boolean;
  36537. /**
  36538. * Gets or sets the current offline provider to use to store scene data
  36539. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36540. */
  36541. offlineProvider: IOfflineProvider;
  36542. /**
  36543. * Gets or sets the action manager associated with the scene
  36544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36545. */
  36546. actionManager: AbstractActionManager;
  36547. private _meshesForIntersections;
  36548. /**
  36549. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36550. */
  36551. proceduralTexturesEnabled: boolean;
  36552. private _engine;
  36553. private _totalVertices;
  36554. /** @hidden */
  36555. _activeIndices: PerfCounter;
  36556. /** @hidden */
  36557. _activeParticles: PerfCounter;
  36558. /** @hidden */
  36559. _activeBones: PerfCounter;
  36560. private _animationRatio;
  36561. /** @hidden */
  36562. _animationTimeLast: number;
  36563. /** @hidden */
  36564. _animationTime: number;
  36565. /**
  36566. * Gets or sets a general scale for animation speed
  36567. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36568. */
  36569. animationTimeScale: number;
  36570. /** @hidden */
  36571. _cachedMaterial: Nullable<Material>;
  36572. /** @hidden */
  36573. _cachedEffect: Nullable<Effect>;
  36574. /** @hidden */
  36575. _cachedVisibility: Nullable<number>;
  36576. private _renderId;
  36577. private _frameId;
  36578. private _executeWhenReadyTimeoutId;
  36579. private _intermediateRendering;
  36580. private _viewUpdateFlag;
  36581. private _projectionUpdateFlag;
  36582. /** @hidden */
  36583. _toBeDisposed: Nullable<IDisposable>[];
  36584. private _activeRequests;
  36585. /** @hidden */
  36586. _pendingData: any[];
  36587. private _isDisposed;
  36588. /**
  36589. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36590. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36591. */
  36592. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36593. private _activeMeshes;
  36594. private _processedMaterials;
  36595. private _renderTargets;
  36596. /** @hidden */
  36597. _activeParticleSystems: SmartArray<IParticleSystem>;
  36598. private _activeSkeletons;
  36599. private _softwareSkinnedMeshes;
  36600. private _renderingManager;
  36601. /** @hidden */
  36602. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36603. private _transformMatrix;
  36604. private _sceneUbo;
  36605. /** @hidden */
  36606. _viewMatrix: Matrix;
  36607. private _projectionMatrix;
  36608. /** @hidden */
  36609. _forcedViewPosition: Nullable<Vector3>;
  36610. /** @hidden */
  36611. _frustumPlanes: Plane[];
  36612. /**
  36613. * Gets the list of frustum planes (built from the active camera)
  36614. */
  36615. get frustumPlanes(): Plane[];
  36616. /**
  36617. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36618. * This is useful if there are more lights that the maximum simulteanous authorized
  36619. */
  36620. requireLightSorting: boolean;
  36621. /** @hidden */
  36622. readonly useMaterialMeshMap: boolean;
  36623. /** @hidden */
  36624. readonly useClonedMeshMap: boolean;
  36625. private _externalData;
  36626. private _uid;
  36627. /**
  36628. * @hidden
  36629. * Backing store of defined scene components.
  36630. */
  36631. _components: ISceneComponent[];
  36632. /**
  36633. * @hidden
  36634. * Backing store of defined scene components.
  36635. */
  36636. _serializableComponents: ISceneSerializableComponent[];
  36637. /**
  36638. * List of components to register on the next registration step.
  36639. */
  36640. private _transientComponents;
  36641. /**
  36642. * Registers the transient components if needed.
  36643. */
  36644. private _registerTransientComponents;
  36645. /**
  36646. * @hidden
  36647. * Add a component to the scene.
  36648. * Note that the ccomponent could be registered on th next frame if this is called after
  36649. * the register component stage.
  36650. * @param component Defines the component to add to the scene
  36651. */
  36652. _addComponent(component: ISceneComponent): void;
  36653. /**
  36654. * @hidden
  36655. * Gets a component from the scene.
  36656. * @param name defines the name of the component to retrieve
  36657. * @returns the component or null if not present
  36658. */
  36659. _getComponent(name: string): Nullable<ISceneComponent>;
  36660. /**
  36661. * @hidden
  36662. * Defines the actions happening before camera updates.
  36663. */
  36664. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36665. /**
  36666. * @hidden
  36667. * Defines the actions happening before clear the canvas.
  36668. */
  36669. _beforeClearStage: Stage<SimpleStageAction>;
  36670. /**
  36671. * @hidden
  36672. * Defines the actions when collecting render targets for the frame.
  36673. */
  36674. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36675. /**
  36676. * @hidden
  36677. * Defines the actions happening for one camera in the frame.
  36678. */
  36679. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36680. /**
  36681. * @hidden
  36682. * Defines the actions happening during the per mesh ready checks.
  36683. */
  36684. _isReadyForMeshStage: Stage<MeshStageAction>;
  36685. /**
  36686. * @hidden
  36687. * Defines the actions happening before evaluate active mesh checks.
  36688. */
  36689. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36690. /**
  36691. * @hidden
  36692. * Defines the actions happening during the evaluate sub mesh checks.
  36693. */
  36694. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36695. /**
  36696. * @hidden
  36697. * Defines the actions happening during the active mesh stage.
  36698. */
  36699. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36700. /**
  36701. * @hidden
  36702. * Defines the actions happening during the per camera render target step.
  36703. */
  36704. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36705. /**
  36706. * @hidden
  36707. * Defines the actions happening just before the active camera is drawing.
  36708. */
  36709. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36710. /**
  36711. * @hidden
  36712. * Defines the actions happening just before a render target is drawing.
  36713. */
  36714. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36715. /**
  36716. * @hidden
  36717. * Defines the actions happening just before a rendering group is drawing.
  36718. */
  36719. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36720. /**
  36721. * @hidden
  36722. * Defines the actions happening just before a mesh is drawing.
  36723. */
  36724. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36725. /**
  36726. * @hidden
  36727. * Defines the actions happening just after a mesh has been drawn.
  36728. */
  36729. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36730. /**
  36731. * @hidden
  36732. * Defines the actions happening just after a rendering group has been drawn.
  36733. */
  36734. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36735. /**
  36736. * @hidden
  36737. * Defines the actions happening just after the active camera has been drawn.
  36738. */
  36739. _afterCameraDrawStage: Stage<CameraStageAction>;
  36740. /**
  36741. * @hidden
  36742. * Defines the actions happening just after a render target has been drawn.
  36743. */
  36744. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36745. /**
  36746. * @hidden
  36747. * Defines the actions happening just after rendering all cameras and computing intersections.
  36748. */
  36749. _afterRenderStage: Stage<SimpleStageAction>;
  36750. /**
  36751. * @hidden
  36752. * Defines the actions happening when a pointer move event happens.
  36753. */
  36754. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36755. /**
  36756. * @hidden
  36757. * Defines the actions happening when a pointer down event happens.
  36758. */
  36759. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36760. /**
  36761. * @hidden
  36762. * Defines the actions happening when a pointer up event happens.
  36763. */
  36764. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36765. /**
  36766. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36767. */
  36768. private geometriesByUniqueId;
  36769. /**
  36770. * Creates a new Scene
  36771. * @param engine defines the engine to use to render this scene
  36772. * @param options defines the scene options
  36773. */
  36774. constructor(engine: Engine, options?: SceneOptions);
  36775. /**
  36776. * Gets a string idenfifying the name of the class
  36777. * @returns "Scene" string
  36778. */
  36779. getClassName(): string;
  36780. private _defaultMeshCandidates;
  36781. /**
  36782. * @hidden
  36783. */
  36784. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36785. private _defaultSubMeshCandidates;
  36786. /**
  36787. * @hidden
  36788. */
  36789. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36790. /**
  36791. * Sets the default candidate providers for the scene.
  36792. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36793. * and getCollidingSubMeshCandidates to their default function
  36794. */
  36795. setDefaultCandidateProviders(): void;
  36796. /**
  36797. * Gets the mesh that is currently under the pointer
  36798. */
  36799. get meshUnderPointer(): Nullable<AbstractMesh>;
  36800. /**
  36801. * Gets or sets the current on-screen X position of the pointer
  36802. */
  36803. get pointerX(): number;
  36804. set pointerX(value: number);
  36805. /**
  36806. * Gets or sets the current on-screen Y position of the pointer
  36807. */
  36808. get pointerY(): number;
  36809. set pointerY(value: number);
  36810. /**
  36811. * Gets the cached material (ie. the latest rendered one)
  36812. * @returns the cached material
  36813. */
  36814. getCachedMaterial(): Nullable<Material>;
  36815. /**
  36816. * Gets the cached effect (ie. the latest rendered one)
  36817. * @returns the cached effect
  36818. */
  36819. getCachedEffect(): Nullable<Effect>;
  36820. /**
  36821. * Gets the cached visibility state (ie. the latest rendered one)
  36822. * @returns the cached visibility state
  36823. */
  36824. getCachedVisibility(): Nullable<number>;
  36825. /**
  36826. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  36827. * @param material defines the current material
  36828. * @param effect defines the current effect
  36829. * @param visibility defines the current visibility state
  36830. * @returns true if one parameter is not cached
  36831. */
  36832. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36833. /**
  36834. * Gets the engine associated with the scene
  36835. * @returns an Engine
  36836. */
  36837. getEngine(): Engine;
  36838. /**
  36839. * Gets the total number of vertices rendered per frame
  36840. * @returns the total number of vertices rendered per frame
  36841. */
  36842. getTotalVertices(): number;
  36843. /**
  36844. * Gets the performance counter for total vertices
  36845. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36846. */
  36847. get totalVerticesPerfCounter(): PerfCounter;
  36848. /**
  36849. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36850. * @returns the total number of active indices rendered per frame
  36851. */
  36852. getActiveIndices(): number;
  36853. /**
  36854. * Gets the performance counter for active indices
  36855. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36856. */
  36857. get totalActiveIndicesPerfCounter(): PerfCounter;
  36858. /**
  36859. * Gets the total number of active particles rendered per frame
  36860. * @returns the total number of active particles rendered per frame
  36861. */
  36862. getActiveParticles(): number;
  36863. /**
  36864. * Gets the performance counter for active particles
  36865. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36866. */
  36867. get activeParticlesPerfCounter(): PerfCounter;
  36868. /**
  36869. * Gets the total number of active bones rendered per frame
  36870. * @returns the total number of active bones rendered per frame
  36871. */
  36872. getActiveBones(): number;
  36873. /**
  36874. * Gets the performance counter for active bones
  36875. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36876. */
  36877. get activeBonesPerfCounter(): PerfCounter;
  36878. /**
  36879. * Gets the array of active meshes
  36880. * @returns an array of AbstractMesh
  36881. */
  36882. getActiveMeshes(): SmartArray<AbstractMesh>;
  36883. /**
  36884. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36885. * @returns a number
  36886. */
  36887. getAnimationRatio(): number;
  36888. /**
  36889. * Gets an unique Id for the current render phase
  36890. * @returns a number
  36891. */
  36892. getRenderId(): number;
  36893. /**
  36894. * Gets an unique Id for the current frame
  36895. * @returns a number
  36896. */
  36897. getFrameId(): number;
  36898. /** Call this function if you want to manually increment the render Id*/
  36899. incrementRenderId(): void;
  36900. private _createUbo;
  36901. /**
  36902. * Use this method to simulate a pointer move on a mesh
  36903. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36904. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36905. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36906. * @returns the current scene
  36907. */
  36908. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36909. /**
  36910. * Use this method to simulate a pointer down on a mesh
  36911. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36912. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36913. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36914. * @returns the current scene
  36915. */
  36916. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36917. /**
  36918. * Use this method to simulate a pointer up on a mesh
  36919. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36920. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36921. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36922. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36923. * @returns the current scene
  36924. */
  36925. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36926. /**
  36927. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36928. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36929. * @returns true if the pointer was captured
  36930. */
  36931. isPointerCaptured(pointerId?: number): boolean;
  36932. /**
  36933. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36934. * @param attachUp defines if you want to attach events to pointerup
  36935. * @param attachDown defines if you want to attach events to pointerdown
  36936. * @param attachMove defines if you want to attach events to pointermove
  36937. */
  36938. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36939. /** Detaches all event handlers*/
  36940. detachControl(): void;
  36941. /**
  36942. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36943. * Delay loaded resources are not taking in account
  36944. * @return true if all required resources are ready
  36945. */
  36946. isReady(): boolean;
  36947. /** Resets all cached information relative to material (including effect and visibility) */
  36948. resetCachedMaterial(): void;
  36949. /**
  36950. * Registers a function to be called before every frame render
  36951. * @param func defines the function to register
  36952. */
  36953. registerBeforeRender(func: () => void): void;
  36954. /**
  36955. * Unregisters a function called before every frame render
  36956. * @param func defines the function to unregister
  36957. */
  36958. unregisterBeforeRender(func: () => void): void;
  36959. /**
  36960. * Registers a function to be called after every frame render
  36961. * @param func defines the function to register
  36962. */
  36963. registerAfterRender(func: () => void): void;
  36964. /**
  36965. * Unregisters a function called after every frame render
  36966. * @param func defines the function to unregister
  36967. */
  36968. unregisterAfterRender(func: () => void): void;
  36969. private _executeOnceBeforeRender;
  36970. /**
  36971. * The provided function will run before render once and will be disposed afterwards.
  36972. * A timeout delay can be provided so that the function will be executed in N ms.
  36973. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36974. * @param func The function to be executed.
  36975. * @param timeout optional delay in ms
  36976. */
  36977. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36978. /** @hidden */
  36979. _addPendingData(data: any): void;
  36980. /** @hidden */
  36981. _removePendingData(data: any): void;
  36982. /**
  36983. * Returns the number of items waiting to be loaded
  36984. * @returns the number of items waiting to be loaded
  36985. */
  36986. getWaitingItemsCount(): number;
  36987. /**
  36988. * Returns a boolean indicating if the scene is still loading data
  36989. */
  36990. get isLoading(): boolean;
  36991. /**
  36992. * Registers a function to be executed when the scene is ready
  36993. * @param {Function} func - the function to be executed
  36994. */
  36995. executeWhenReady(func: () => void): void;
  36996. /**
  36997. * Returns a promise that resolves when the scene is ready
  36998. * @returns A promise that resolves when the scene is ready
  36999. */
  37000. whenReadyAsync(): Promise<void>;
  37001. /** @hidden */
  37002. _checkIsReady(): void;
  37003. /**
  37004. * Gets all animatable attached to the scene
  37005. */
  37006. get animatables(): Animatable[];
  37007. /**
  37008. * Resets the last animation time frame.
  37009. * Useful to override when animations start running when loading a scene for the first time.
  37010. */
  37011. resetLastAnimationTimeFrame(): void;
  37012. /**
  37013. * Gets the current view matrix
  37014. * @returns a Matrix
  37015. */
  37016. getViewMatrix(): Matrix;
  37017. /**
  37018. * Gets the current projection matrix
  37019. * @returns a Matrix
  37020. */
  37021. getProjectionMatrix(): Matrix;
  37022. /**
  37023. * Gets the current transform matrix
  37024. * @returns a Matrix made of View * Projection
  37025. */
  37026. getTransformMatrix(): Matrix;
  37027. /**
  37028. * Sets the current transform matrix
  37029. * @param viewL defines the View matrix to use
  37030. * @param projectionL defines the Projection matrix to use
  37031. * @param viewR defines the right View matrix to use (if provided)
  37032. * @param projectionR defines the right Projection matrix to use (if provided)
  37033. */
  37034. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37035. /**
  37036. * Gets the uniform buffer used to store scene data
  37037. * @returns a UniformBuffer
  37038. */
  37039. getSceneUniformBuffer(): UniformBuffer;
  37040. /**
  37041. * Gets an unique (relatively to the current scene) Id
  37042. * @returns an unique number for the scene
  37043. */
  37044. getUniqueId(): number;
  37045. /**
  37046. * Add a mesh to the list of scene's meshes
  37047. * @param newMesh defines the mesh to add
  37048. * @param recursive if all child meshes should also be added to the scene
  37049. */
  37050. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37051. /**
  37052. * Remove a mesh for the list of scene's meshes
  37053. * @param toRemove defines the mesh to remove
  37054. * @param recursive if all child meshes should also be removed from the scene
  37055. * @returns the index where the mesh was in the mesh list
  37056. */
  37057. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37058. /**
  37059. * Add a transform node to the list of scene's transform nodes
  37060. * @param newTransformNode defines the transform node to add
  37061. */
  37062. addTransformNode(newTransformNode: TransformNode): void;
  37063. /**
  37064. * Remove a transform node for the list of scene's transform nodes
  37065. * @param toRemove defines the transform node to remove
  37066. * @returns the index where the transform node was in the transform node list
  37067. */
  37068. removeTransformNode(toRemove: TransformNode): number;
  37069. /**
  37070. * Remove a skeleton for the list of scene's skeletons
  37071. * @param toRemove defines the skeleton to remove
  37072. * @returns the index where the skeleton was in the skeleton list
  37073. */
  37074. removeSkeleton(toRemove: Skeleton): number;
  37075. /**
  37076. * Remove a morph target for the list of scene's morph targets
  37077. * @param toRemove defines the morph target to remove
  37078. * @returns the index where the morph target was in the morph target list
  37079. */
  37080. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37081. /**
  37082. * Remove a light for the list of scene's lights
  37083. * @param toRemove defines the light to remove
  37084. * @returns the index where the light was in the light list
  37085. */
  37086. removeLight(toRemove: Light): number;
  37087. /**
  37088. * Remove a camera for the list of scene's cameras
  37089. * @param toRemove defines the camera to remove
  37090. * @returns the index where the camera was in the camera list
  37091. */
  37092. removeCamera(toRemove: Camera): number;
  37093. /**
  37094. * Remove a particle system for the list of scene's particle systems
  37095. * @param toRemove defines the particle system to remove
  37096. * @returns the index where the particle system was in the particle system list
  37097. */
  37098. removeParticleSystem(toRemove: IParticleSystem): number;
  37099. /**
  37100. * Remove a animation for the list of scene's animations
  37101. * @param toRemove defines the animation to remove
  37102. * @returns the index where the animation was in the animation list
  37103. */
  37104. removeAnimation(toRemove: Animation): number;
  37105. /**
  37106. * Will stop the animation of the given target
  37107. * @param target - the target
  37108. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37109. * @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)
  37110. */
  37111. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37112. /**
  37113. * Removes the given animation group from this scene.
  37114. * @param toRemove The animation group to remove
  37115. * @returns The index of the removed animation group
  37116. */
  37117. removeAnimationGroup(toRemove: AnimationGroup): number;
  37118. /**
  37119. * Removes the given multi-material from this scene.
  37120. * @param toRemove The multi-material to remove
  37121. * @returns The index of the removed multi-material
  37122. */
  37123. removeMultiMaterial(toRemove: MultiMaterial): number;
  37124. /**
  37125. * Removes the given material from this scene.
  37126. * @param toRemove The material to remove
  37127. * @returns The index of the removed material
  37128. */
  37129. removeMaterial(toRemove: Material): number;
  37130. /**
  37131. * Removes the given action manager from this scene.
  37132. * @param toRemove The action manager to remove
  37133. * @returns The index of the removed action manager
  37134. */
  37135. removeActionManager(toRemove: AbstractActionManager): number;
  37136. /**
  37137. * Removes the given texture from this scene.
  37138. * @param toRemove The texture to remove
  37139. * @returns The index of the removed texture
  37140. */
  37141. removeTexture(toRemove: BaseTexture): number;
  37142. /**
  37143. * Adds the given light to this scene
  37144. * @param newLight The light to add
  37145. */
  37146. addLight(newLight: Light): void;
  37147. /**
  37148. * Sorts the list list based on light priorities
  37149. */
  37150. sortLightsByPriority(): void;
  37151. /**
  37152. * Adds the given camera to this scene
  37153. * @param newCamera The camera to add
  37154. */
  37155. addCamera(newCamera: Camera): void;
  37156. /**
  37157. * Adds the given skeleton to this scene
  37158. * @param newSkeleton The skeleton to add
  37159. */
  37160. addSkeleton(newSkeleton: Skeleton): void;
  37161. /**
  37162. * Adds the given particle system to this scene
  37163. * @param newParticleSystem The particle system to add
  37164. */
  37165. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37166. /**
  37167. * Adds the given animation to this scene
  37168. * @param newAnimation The animation to add
  37169. */
  37170. addAnimation(newAnimation: Animation): void;
  37171. /**
  37172. * Adds the given animation group to this scene.
  37173. * @param newAnimationGroup The animation group to add
  37174. */
  37175. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37176. /**
  37177. * Adds the given multi-material to this scene
  37178. * @param newMultiMaterial The multi-material to add
  37179. */
  37180. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37181. /**
  37182. * Adds the given material to this scene
  37183. * @param newMaterial The material to add
  37184. */
  37185. addMaterial(newMaterial: Material): void;
  37186. /**
  37187. * Adds the given morph target to this scene
  37188. * @param newMorphTargetManager The morph target to add
  37189. */
  37190. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37191. /**
  37192. * Adds the given geometry to this scene
  37193. * @param newGeometry The geometry to add
  37194. */
  37195. addGeometry(newGeometry: Geometry): void;
  37196. /**
  37197. * Adds the given action manager to this scene
  37198. * @param newActionManager The action manager to add
  37199. */
  37200. addActionManager(newActionManager: AbstractActionManager): void;
  37201. /**
  37202. * Adds the given texture to this scene.
  37203. * @param newTexture The texture to add
  37204. */
  37205. addTexture(newTexture: BaseTexture): void;
  37206. /**
  37207. * Switch active camera
  37208. * @param newCamera defines the new active camera
  37209. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37210. */
  37211. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37212. /**
  37213. * sets the active camera of the scene using its ID
  37214. * @param id defines the camera's ID
  37215. * @return the new active camera or null if none found.
  37216. */
  37217. setActiveCameraByID(id: string): Nullable<Camera>;
  37218. /**
  37219. * sets the active camera of the scene using its name
  37220. * @param name defines the camera's name
  37221. * @returns the new active camera or null if none found.
  37222. */
  37223. setActiveCameraByName(name: string): Nullable<Camera>;
  37224. /**
  37225. * get an animation group using its name
  37226. * @param name defines the material's name
  37227. * @return the animation group or null if none found.
  37228. */
  37229. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37230. /**
  37231. * Get a material using its unique id
  37232. * @param uniqueId defines the material's unique id
  37233. * @return the material or null if none found.
  37234. */
  37235. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37236. /**
  37237. * get a material using its id
  37238. * @param id defines the material's ID
  37239. * @return the material or null if none found.
  37240. */
  37241. getMaterialByID(id: string): Nullable<Material>;
  37242. /**
  37243. * Gets a the last added material using a given id
  37244. * @param id defines the material's ID
  37245. * @return the last material with the given id or null if none found.
  37246. */
  37247. getLastMaterialByID(id: string): Nullable<Material>;
  37248. /**
  37249. * Gets a material using its name
  37250. * @param name defines the material's name
  37251. * @return the material or null if none found.
  37252. */
  37253. getMaterialByName(name: string): Nullable<Material>;
  37254. /**
  37255. * Get a texture using its unique id
  37256. * @param uniqueId defines the texture's unique id
  37257. * @return the texture or null if none found.
  37258. */
  37259. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37260. /**
  37261. * Gets a camera using its id
  37262. * @param id defines the id to look for
  37263. * @returns the camera or null if not found
  37264. */
  37265. getCameraByID(id: string): Nullable<Camera>;
  37266. /**
  37267. * Gets a camera using its unique id
  37268. * @param uniqueId defines the unique id to look for
  37269. * @returns the camera or null if not found
  37270. */
  37271. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37272. /**
  37273. * Gets a camera using its name
  37274. * @param name defines the camera's name
  37275. * @return the camera or null if none found.
  37276. */
  37277. getCameraByName(name: string): Nullable<Camera>;
  37278. /**
  37279. * Gets a bone using its id
  37280. * @param id defines the bone's id
  37281. * @return the bone or null if not found
  37282. */
  37283. getBoneByID(id: string): Nullable<Bone>;
  37284. /**
  37285. * Gets a bone using its id
  37286. * @param name defines the bone's name
  37287. * @return the bone or null if not found
  37288. */
  37289. getBoneByName(name: string): Nullable<Bone>;
  37290. /**
  37291. * Gets a light node using its name
  37292. * @param name defines the the light's name
  37293. * @return the light or null if none found.
  37294. */
  37295. getLightByName(name: string): Nullable<Light>;
  37296. /**
  37297. * Gets a light node using its id
  37298. * @param id defines the light's id
  37299. * @return the light or null if none found.
  37300. */
  37301. getLightByID(id: string): Nullable<Light>;
  37302. /**
  37303. * Gets a light node using its scene-generated unique ID
  37304. * @param uniqueId defines the light's unique id
  37305. * @return the light or null if none found.
  37306. */
  37307. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37308. /**
  37309. * Gets a particle system by id
  37310. * @param id defines the particle system id
  37311. * @return the corresponding system or null if none found
  37312. */
  37313. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37314. /**
  37315. * Gets a geometry using its ID
  37316. * @param id defines the geometry's id
  37317. * @return the geometry or null if none found.
  37318. */
  37319. getGeometryByID(id: string): Nullable<Geometry>;
  37320. private _getGeometryByUniqueID;
  37321. /**
  37322. * Add a new geometry to this scene
  37323. * @param geometry defines the geometry to be added to the scene.
  37324. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37325. * @return a boolean defining if the geometry was added or not
  37326. */
  37327. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37328. /**
  37329. * Removes an existing geometry
  37330. * @param geometry defines the geometry to be removed from the scene
  37331. * @return a boolean defining if the geometry was removed or not
  37332. */
  37333. removeGeometry(geometry: Geometry): boolean;
  37334. /**
  37335. * Gets the list of geometries attached to the scene
  37336. * @returns an array of Geometry
  37337. */
  37338. getGeometries(): Geometry[];
  37339. /**
  37340. * Gets the first added mesh found of a given ID
  37341. * @param id defines the id to search for
  37342. * @return the mesh found or null if not found at all
  37343. */
  37344. getMeshByID(id: string): Nullable<AbstractMesh>;
  37345. /**
  37346. * Gets a list of meshes using their id
  37347. * @param id defines the id to search for
  37348. * @returns a list of meshes
  37349. */
  37350. getMeshesByID(id: string): Array<AbstractMesh>;
  37351. /**
  37352. * Gets the first added transform node found of a given ID
  37353. * @param id defines the id to search for
  37354. * @return the found transform node or null if not found at all.
  37355. */
  37356. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37357. /**
  37358. * Gets a transform node with its auto-generated unique id
  37359. * @param uniqueId efines the unique id to search for
  37360. * @return the found transform node or null if not found at all.
  37361. */
  37362. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37363. /**
  37364. * Gets a list of transform nodes using their id
  37365. * @param id defines the id to search for
  37366. * @returns a list of transform nodes
  37367. */
  37368. getTransformNodesByID(id: string): Array<TransformNode>;
  37369. /**
  37370. * Gets a mesh with its auto-generated unique id
  37371. * @param uniqueId defines the unique id to search for
  37372. * @return the found mesh or null if not found at all.
  37373. */
  37374. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37375. /**
  37376. * Gets a the last added mesh using a given id
  37377. * @param id defines the id to search for
  37378. * @return the found mesh or null if not found at all.
  37379. */
  37380. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37381. /**
  37382. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37383. * @param id defines the id to search for
  37384. * @return the found node or null if not found at all
  37385. */
  37386. getLastEntryByID(id: string): Nullable<Node>;
  37387. /**
  37388. * Gets a node (Mesh, Camera, Light) using a given id
  37389. * @param id defines the id to search for
  37390. * @return the found node or null if not found at all
  37391. */
  37392. getNodeByID(id: string): Nullable<Node>;
  37393. /**
  37394. * Gets a node (Mesh, Camera, Light) using a given name
  37395. * @param name defines the name to search for
  37396. * @return the found node or null if not found at all.
  37397. */
  37398. getNodeByName(name: string): Nullable<Node>;
  37399. /**
  37400. * Gets a mesh using a given name
  37401. * @param name defines the name to search for
  37402. * @return the found mesh or null if not found at all.
  37403. */
  37404. getMeshByName(name: string): Nullable<AbstractMesh>;
  37405. /**
  37406. * Gets a transform node using a given name
  37407. * @param name defines the name to search for
  37408. * @return the found transform node or null if not found at all.
  37409. */
  37410. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37411. /**
  37412. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37413. * @param id defines the id to search for
  37414. * @return the found skeleton or null if not found at all.
  37415. */
  37416. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37417. /**
  37418. * Gets a skeleton using a given auto generated unique id
  37419. * @param uniqueId defines the unique id to search for
  37420. * @return the found skeleton or null if not found at all.
  37421. */
  37422. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37423. /**
  37424. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37425. * @param id defines the id to search for
  37426. * @return the found skeleton or null if not found at all.
  37427. */
  37428. getSkeletonById(id: string): Nullable<Skeleton>;
  37429. /**
  37430. * Gets a skeleton using a given name
  37431. * @param name defines the name to search for
  37432. * @return the found skeleton or null if not found at all.
  37433. */
  37434. getSkeletonByName(name: string): Nullable<Skeleton>;
  37435. /**
  37436. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37437. * @param id defines the id to search for
  37438. * @return the found morph target manager or null if not found at all.
  37439. */
  37440. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37441. /**
  37442. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37443. * @param id defines the id to search for
  37444. * @return the found morph target or null if not found at all.
  37445. */
  37446. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37447. /**
  37448. * Gets a boolean indicating if the given mesh is active
  37449. * @param mesh defines the mesh to look for
  37450. * @returns true if the mesh is in the active list
  37451. */
  37452. isActiveMesh(mesh: AbstractMesh): boolean;
  37453. /**
  37454. * Return a unique id as a string which can serve as an identifier for the scene
  37455. */
  37456. get uid(): string;
  37457. /**
  37458. * Add an externaly attached data from its key.
  37459. * This method call will fail and return false, if such key already exists.
  37460. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37461. * @param key the unique key that identifies the data
  37462. * @param data the data object to associate to the key for this Engine instance
  37463. * @return true if no such key were already present and the data was added successfully, false otherwise
  37464. */
  37465. addExternalData<T>(key: string, data: T): boolean;
  37466. /**
  37467. * Get an externaly attached data from its key
  37468. * @param key the unique key that identifies the data
  37469. * @return the associated data, if present (can be null), or undefined if not present
  37470. */
  37471. getExternalData<T>(key: string): Nullable<T>;
  37472. /**
  37473. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37474. * @param key the unique key that identifies the data
  37475. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37476. * @return the associated data, can be null if the factory returned null.
  37477. */
  37478. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37479. /**
  37480. * Remove an externaly attached data from the Engine instance
  37481. * @param key the unique key that identifies the data
  37482. * @return true if the data was successfully removed, false if it doesn't exist
  37483. */
  37484. removeExternalData(key: string): boolean;
  37485. private _evaluateSubMesh;
  37486. /**
  37487. * Clear the processed materials smart array preventing retention point in material dispose.
  37488. */
  37489. freeProcessedMaterials(): void;
  37490. private _preventFreeActiveMeshesAndRenderingGroups;
  37491. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37492. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37493. * when disposing several meshes in a row or a hierarchy of meshes.
  37494. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37495. */
  37496. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37497. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37498. /**
  37499. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37500. */
  37501. freeActiveMeshes(): void;
  37502. /**
  37503. * Clear the info related to rendering groups preventing retention points during dispose.
  37504. */
  37505. freeRenderingGroups(): void;
  37506. /** @hidden */
  37507. _isInIntermediateRendering(): boolean;
  37508. /**
  37509. * Lambda returning the list of potentially active meshes.
  37510. */
  37511. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37512. /**
  37513. * Lambda returning the list of potentially active sub meshes.
  37514. */
  37515. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37516. /**
  37517. * Lambda returning the list of potentially intersecting sub meshes.
  37518. */
  37519. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37520. /**
  37521. * Lambda returning the list of potentially colliding sub meshes.
  37522. */
  37523. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37524. private _activeMeshesFrozen;
  37525. private _skipEvaluateActiveMeshesCompletely;
  37526. /**
  37527. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37528. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37529. * @returns the current scene
  37530. */
  37531. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37532. /**
  37533. * Use this function to restart evaluating active meshes on every frame
  37534. * @returns the current scene
  37535. */
  37536. unfreezeActiveMeshes(): Scene;
  37537. private _evaluateActiveMeshes;
  37538. private _activeMesh;
  37539. /**
  37540. * Update the transform matrix to update from the current active camera
  37541. * @param force defines a boolean used to force the update even if cache is up to date
  37542. */
  37543. updateTransformMatrix(force?: boolean): void;
  37544. private _bindFrameBuffer;
  37545. /** @hidden */
  37546. _allowPostProcessClearColor: boolean;
  37547. /** @hidden */
  37548. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37549. private _processSubCameras;
  37550. private _checkIntersections;
  37551. /** @hidden */
  37552. _advancePhysicsEngineStep(step: number): void;
  37553. /**
  37554. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37555. */
  37556. getDeterministicFrameTime: () => number;
  37557. /** @hidden */
  37558. _animate(): void;
  37559. /** Execute all animations (for a frame) */
  37560. animate(): void;
  37561. /**
  37562. * Render the scene
  37563. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37564. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37565. */
  37566. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37567. /**
  37568. * Freeze all materials
  37569. * A frozen material will not be updatable but should be faster to render
  37570. */
  37571. freezeMaterials(): void;
  37572. /**
  37573. * Unfreeze all materials
  37574. * A frozen material will not be updatable but should be faster to render
  37575. */
  37576. unfreezeMaterials(): void;
  37577. /**
  37578. * Releases all held ressources
  37579. */
  37580. dispose(): void;
  37581. /**
  37582. * Gets if the scene is already disposed
  37583. */
  37584. get isDisposed(): boolean;
  37585. /**
  37586. * Call this function to reduce memory footprint of the scene.
  37587. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37588. */
  37589. clearCachedVertexData(): void;
  37590. /**
  37591. * This function will remove the local cached buffer data from texture.
  37592. * It will save memory but will prevent the texture from being rebuilt
  37593. */
  37594. cleanCachedTextureBuffer(): void;
  37595. /**
  37596. * Get the world extend vectors with an optional filter
  37597. *
  37598. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37599. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37600. */
  37601. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37602. min: Vector3;
  37603. max: Vector3;
  37604. };
  37605. /**
  37606. * Creates a ray that can be used to pick in the scene
  37607. * @param x defines the x coordinate of the origin (on-screen)
  37608. * @param y defines the y coordinate of the origin (on-screen)
  37609. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37610. * @param camera defines the camera to use for the picking
  37611. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37612. * @returns a Ray
  37613. */
  37614. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37615. /**
  37616. * Creates a ray that can be used to pick in the scene
  37617. * @param x defines the x coordinate of the origin (on-screen)
  37618. * @param y defines the y coordinate of the origin (on-screen)
  37619. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37620. * @param result defines the ray where to store the picking ray
  37621. * @param camera defines the camera to use for the picking
  37622. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37623. * @returns the current scene
  37624. */
  37625. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37626. /**
  37627. * Creates a ray that can be used to pick in the scene
  37628. * @param x defines the x coordinate of the origin (on-screen)
  37629. * @param y defines the y coordinate of the origin (on-screen)
  37630. * @param camera defines the camera to use for the picking
  37631. * @returns a Ray
  37632. */
  37633. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37634. /**
  37635. * Creates a ray that can be used to pick in the scene
  37636. * @param x defines the x coordinate of the origin (on-screen)
  37637. * @param y defines the y coordinate of the origin (on-screen)
  37638. * @param result defines the ray where to store the picking ray
  37639. * @param camera defines the camera to use for the picking
  37640. * @returns the current scene
  37641. */
  37642. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37643. /** Launch a ray to try to pick a mesh in the scene
  37644. * @param x position on screen
  37645. * @param y position on screen
  37646. * @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
  37647. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37648. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37649. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37650. * @returns a PickingInfo
  37651. */
  37652. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37653. /** Use the given ray to pick a mesh in the scene
  37654. * @param ray The ray to use to pick meshes
  37655. * @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
  37656. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37657. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37658. * @returns a PickingInfo
  37659. */
  37660. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37661. /**
  37662. * Launch a ray to try to pick a mesh in the scene
  37663. * @param x X position on screen
  37664. * @param y Y position on screen
  37665. * @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
  37666. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37667. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37668. * @returns an array of PickingInfo
  37669. */
  37670. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37671. /**
  37672. * Launch a ray to try to pick a mesh in the scene
  37673. * @param ray Ray to use
  37674. * @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
  37675. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37676. * @returns an array of PickingInfo
  37677. */
  37678. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37679. /**
  37680. * Force the value of meshUnderPointer
  37681. * @param mesh defines the mesh to use
  37682. */
  37683. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37684. /**
  37685. * Gets the mesh under the pointer
  37686. * @returns a Mesh or null if no mesh is under the pointer
  37687. */
  37688. getPointerOverMesh(): Nullable<AbstractMesh>;
  37689. /** @hidden */
  37690. _rebuildGeometries(): void;
  37691. /** @hidden */
  37692. _rebuildTextures(): void;
  37693. private _getByTags;
  37694. /**
  37695. * Get a list of meshes by tags
  37696. * @param tagsQuery defines the tags query to use
  37697. * @param forEach defines a predicate used to filter results
  37698. * @returns an array of Mesh
  37699. */
  37700. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37701. /**
  37702. * Get a list of cameras by tags
  37703. * @param tagsQuery defines the tags query to use
  37704. * @param forEach defines a predicate used to filter results
  37705. * @returns an array of Camera
  37706. */
  37707. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37708. /**
  37709. * Get a list of lights by tags
  37710. * @param tagsQuery defines the tags query to use
  37711. * @param forEach defines a predicate used to filter results
  37712. * @returns an array of Light
  37713. */
  37714. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37715. /**
  37716. * Get a list of materials by tags
  37717. * @param tagsQuery defines the tags query to use
  37718. * @param forEach defines a predicate used to filter results
  37719. * @returns an array of Material
  37720. */
  37721. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37722. /**
  37723. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37724. * This allowed control for front to back rendering or reversly depending of the special needs.
  37725. *
  37726. * @param renderingGroupId The rendering group id corresponding to its index
  37727. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37728. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37729. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37730. */
  37731. 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;
  37732. /**
  37733. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37734. *
  37735. * @param renderingGroupId The rendering group id corresponding to its index
  37736. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37737. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37738. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37739. */
  37740. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37741. /**
  37742. * Gets the current auto clear configuration for one rendering group of the rendering
  37743. * manager.
  37744. * @param index the rendering group index to get the information for
  37745. * @returns The auto clear setup for the requested rendering group
  37746. */
  37747. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37748. private _blockMaterialDirtyMechanism;
  37749. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37750. get blockMaterialDirtyMechanism(): boolean;
  37751. set blockMaterialDirtyMechanism(value: boolean);
  37752. /**
  37753. * Will flag all materials as dirty to trigger new shader compilation
  37754. * @param flag defines the flag used to specify which material part must be marked as dirty
  37755. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37756. */
  37757. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37758. /** @hidden */
  37759. _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;
  37760. /** @hidden */
  37761. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37762. /** @hidden */
  37763. _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;
  37764. /** @hidden */
  37765. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37766. /** @hidden */
  37767. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37768. /** @hidden */
  37769. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37770. }
  37771. }
  37772. declare module "babylonjs/assetContainer" {
  37773. import { AbstractScene } from "babylonjs/abstractScene";
  37774. import { Scene } from "babylonjs/scene";
  37775. import { Mesh } from "babylonjs/Meshes/mesh";
  37776. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37777. import { Skeleton } from "babylonjs/Bones/skeleton";
  37778. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37779. import { Animatable } from "babylonjs/Animations/animatable";
  37780. import { Nullable } from "babylonjs/types";
  37781. import { Node } from "babylonjs/node";
  37782. /**
  37783. * Set of assets to keep when moving a scene into an asset container.
  37784. */
  37785. export class KeepAssets extends AbstractScene {
  37786. }
  37787. /**
  37788. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37789. */
  37790. export class InstantiatedEntries {
  37791. /**
  37792. * List of new root nodes (eg. nodes with no parent)
  37793. */
  37794. rootNodes: TransformNode[];
  37795. /**
  37796. * List of new skeletons
  37797. */
  37798. skeletons: Skeleton[];
  37799. /**
  37800. * List of new animation groups
  37801. */
  37802. animationGroups: AnimationGroup[];
  37803. }
  37804. /**
  37805. * Container with a set of assets that can be added or removed from a scene.
  37806. */
  37807. export class AssetContainer extends AbstractScene {
  37808. /**
  37809. * The scene the AssetContainer belongs to.
  37810. */
  37811. scene: Scene;
  37812. /**
  37813. * Instantiates an AssetContainer.
  37814. * @param scene The scene the AssetContainer belongs to.
  37815. */
  37816. constructor(scene: Scene);
  37817. /**
  37818. * Instantiate or clone all meshes and add the new ones to the scene.
  37819. * Skeletons and animation groups will all be cloned
  37820. * @param nameFunction defines an optional function used to get new names for clones
  37821. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  37822. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  37823. */
  37824. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  37825. /**
  37826. * Adds all the assets from the container to the scene.
  37827. */
  37828. addAllToScene(): void;
  37829. /**
  37830. * Removes all the assets in the container from the scene
  37831. */
  37832. removeAllFromScene(): void;
  37833. /**
  37834. * Disposes all the assets in the container
  37835. */
  37836. dispose(): void;
  37837. private _moveAssets;
  37838. /**
  37839. * Removes all the assets contained in the scene and adds them to the container.
  37840. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37841. */
  37842. moveAllFromScene(keepAssets?: KeepAssets): void;
  37843. /**
  37844. * 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.
  37845. * @returns the root mesh
  37846. */
  37847. createRootMesh(): Mesh;
  37848. /**
  37849. * Merge animations from this asset container into a scene
  37850. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37851. * @param animatables set of animatables to retarget to a node from the scene
  37852. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37853. */
  37854. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37855. }
  37856. }
  37857. declare module "babylonjs/abstractScene" {
  37858. import { Scene } from "babylonjs/scene";
  37859. import { Nullable } from "babylonjs/types";
  37860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37861. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37862. import { Geometry } from "babylonjs/Meshes/geometry";
  37863. import { Skeleton } from "babylonjs/Bones/skeleton";
  37864. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  37865. import { AssetContainer } from "babylonjs/assetContainer";
  37866. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  37867. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37868. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37869. import { Material } from "babylonjs/Materials/material";
  37870. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  37871. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37872. import { Camera } from "babylonjs/Cameras/camera";
  37873. import { Light } from "babylonjs/Lights/light";
  37874. import { Node } from "babylonjs/node";
  37875. import { Animation } from "babylonjs/Animations/animation";
  37876. /**
  37877. * Defines how the parser contract is defined.
  37878. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37879. */
  37880. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37881. /**
  37882. * Defines how the individual parser contract is defined.
  37883. * These parser can parse an individual asset
  37884. */
  37885. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37886. /**
  37887. * Base class of the scene acting as a container for the different elements composing a scene.
  37888. * This class is dynamically extended by the different components of the scene increasing
  37889. * flexibility and reducing coupling
  37890. */
  37891. export abstract class AbstractScene {
  37892. /**
  37893. * Stores the list of available parsers in the application.
  37894. */
  37895. private static _BabylonFileParsers;
  37896. /**
  37897. * Stores the list of available individual parsers in the application.
  37898. */
  37899. private static _IndividualBabylonFileParsers;
  37900. /**
  37901. * Adds a parser in the list of available ones
  37902. * @param name Defines the name of the parser
  37903. * @param parser Defines the parser to add
  37904. */
  37905. static AddParser(name: string, parser: BabylonFileParser): void;
  37906. /**
  37907. * Gets a general parser from the list of avaialble ones
  37908. * @param name Defines the name of the parser
  37909. * @returns the requested parser or null
  37910. */
  37911. static GetParser(name: string): Nullable<BabylonFileParser>;
  37912. /**
  37913. * Adds n individual parser in the list of available ones
  37914. * @param name Defines the name of the parser
  37915. * @param parser Defines the parser to add
  37916. */
  37917. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37918. /**
  37919. * Gets an individual parser from the list of avaialble ones
  37920. * @param name Defines the name of the parser
  37921. * @returns the requested parser or null
  37922. */
  37923. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37924. /**
  37925. * Parser json data and populate both a scene and its associated container object
  37926. * @param jsonData Defines the data to parse
  37927. * @param scene Defines the scene to parse the data for
  37928. * @param container Defines the container attached to the parsing sequence
  37929. * @param rootUrl Defines the root url of the data
  37930. */
  37931. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37932. /**
  37933. * Gets the list of root nodes (ie. nodes with no parent)
  37934. */
  37935. rootNodes: Node[];
  37936. /** All of the cameras added to this scene
  37937. * @see http://doc.babylonjs.com/babylon101/cameras
  37938. */
  37939. cameras: Camera[];
  37940. /**
  37941. * All of the lights added to this scene
  37942. * @see http://doc.babylonjs.com/babylon101/lights
  37943. */
  37944. lights: Light[];
  37945. /**
  37946. * All of the (abstract) meshes added to this scene
  37947. */
  37948. meshes: AbstractMesh[];
  37949. /**
  37950. * The list of skeletons added to the scene
  37951. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37952. */
  37953. skeletons: Skeleton[];
  37954. /**
  37955. * All of the particle systems added to this scene
  37956. * @see http://doc.babylonjs.com/babylon101/particles
  37957. */
  37958. particleSystems: IParticleSystem[];
  37959. /**
  37960. * Gets a list of Animations associated with the scene
  37961. */
  37962. animations: Animation[];
  37963. /**
  37964. * All of the animation groups added to this scene
  37965. * @see http://doc.babylonjs.com/how_to/group
  37966. */
  37967. animationGroups: AnimationGroup[];
  37968. /**
  37969. * All of the multi-materials added to this scene
  37970. * @see http://doc.babylonjs.com/how_to/multi_materials
  37971. */
  37972. multiMaterials: MultiMaterial[];
  37973. /**
  37974. * All of the materials added to this scene
  37975. * In the context of a Scene, it is not supposed to be modified manually.
  37976. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37977. * Note also that the order of the Material within the array is not significant and might change.
  37978. * @see http://doc.babylonjs.com/babylon101/materials
  37979. */
  37980. materials: Material[];
  37981. /**
  37982. * The list of morph target managers added to the scene
  37983. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37984. */
  37985. morphTargetManagers: MorphTargetManager[];
  37986. /**
  37987. * The list of geometries used in the scene.
  37988. */
  37989. geometries: Geometry[];
  37990. /**
  37991. * All of the tranform nodes added to this scene
  37992. * In the context of a Scene, it is not supposed to be modified manually.
  37993. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37994. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37995. * @see http://doc.babylonjs.com/how_to/transformnode
  37996. */
  37997. transformNodes: TransformNode[];
  37998. /**
  37999. * ActionManagers available on the scene.
  38000. */
  38001. actionManagers: AbstractActionManager[];
  38002. /**
  38003. * Textures to keep.
  38004. */
  38005. textures: BaseTexture[];
  38006. /**
  38007. * Environment texture for the scene
  38008. */
  38009. environmentTexture: Nullable<BaseTexture>;
  38010. /**
  38011. * @returns all meshes, lights, cameras, transformNodes and bones
  38012. */
  38013. getNodes(): Array<Node>;
  38014. }
  38015. }
  38016. declare module "babylonjs/Audio/sound" {
  38017. import { Observable } from "babylonjs/Misc/observable";
  38018. import { Vector3 } from "babylonjs/Maths/math.vector";
  38019. import { Nullable } from "babylonjs/types";
  38020. import { Scene } from "babylonjs/scene";
  38021. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38022. /**
  38023. * Interface used to define options for Sound class
  38024. */
  38025. export interface ISoundOptions {
  38026. /**
  38027. * Does the sound autoplay once loaded.
  38028. */
  38029. autoplay?: boolean;
  38030. /**
  38031. * Does the sound loop after it finishes playing once.
  38032. */
  38033. loop?: boolean;
  38034. /**
  38035. * Sound's volume
  38036. */
  38037. volume?: number;
  38038. /**
  38039. * Is it a spatial sound?
  38040. */
  38041. spatialSound?: boolean;
  38042. /**
  38043. * Maximum distance to hear that sound
  38044. */
  38045. maxDistance?: number;
  38046. /**
  38047. * Uses user defined attenuation function
  38048. */
  38049. useCustomAttenuation?: boolean;
  38050. /**
  38051. * Define the roll off factor of spatial sounds.
  38052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38053. */
  38054. rolloffFactor?: number;
  38055. /**
  38056. * Define the reference distance the sound should be heard perfectly.
  38057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38058. */
  38059. refDistance?: number;
  38060. /**
  38061. * Define the distance attenuation model the sound will follow.
  38062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38063. */
  38064. distanceModel?: string;
  38065. /**
  38066. * Defines the playback speed (1 by default)
  38067. */
  38068. playbackRate?: number;
  38069. /**
  38070. * Defines if the sound is from a streaming source
  38071. */
  38072. streaming?: boolean;
  38073. /**
  38074. * Defines an optional length (in seconds) inside the sound file
  38075. */
  38076. length?: number;
  38077. /**
  38078. * Defines an optional offset (in seconds) inside the sound file
  38079. */
  38080. offset?: number;
  38081. /**
  38082. * If true, URLs will not be required to state the audio file codec to use.
  38083. */
  38084. skipCodecCheck?: boolean;
  38085. }
  38086. /**
  38087. * Defines a sound that can be played in the application.
  38088. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38090. */
  38091. export class Sound {
  38092. /**
  38093. * The name of the sound in the scene.
  38094. */
  38095. name: string;
  38096. /**
  38097. * Does the sound autoplay once loaded.
  38098. */
  38099. autoplay: boolean;
  38100. /**
  38101. * Does the sound loop after it finishes playing once.
  38102. */
  38103. loop: boolean;
  38104. /**
  38105. * Does the sound use a custom attenuation curve to simulate the falloff
  38106. * happening when the source gets further away from the camera.
  38107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38108. */
  38109. useCustomAttenuation: boolean;
  38110. /**
  38111. * The sound track id this sound belongs to.
  38112. */
  38113. soundTrackId: number;
  38114. /**
  38115. * Is this sound currently played.
  38116. */
  38117. isPlaying: boolean;
  38118. /**
  38119. * Is this sound currently paused.
  38120. */
  38121. isPaused: boolean;
  38122. /**
  38123. * Does this sound enables spatial sound.
  38124. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38125. */
  38126. spatialSound: boolean;
  38127. /**
  38128. * Define the reference distance the sound should be heard perfectly.
  38129. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38130. */
  38131. refDistance: number;
  38132. /**
  38133. * Define the roll off factor of spatial sounds.
  38134. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38135. */
  38136. rolloffFactor: number;
  38137. /**
  38138. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38139. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38140. */
  38141. maxDistance: number;
  38142. /**
  38143. * Define the distance attenuation model the sound will follow.
  38144. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38145. */
  38146. distanceModel: string;
  38147. /**
  38148. * @hidden
  38149. * Back Compat
  38150. **/
  38151. onended: () => any;
  38152. /**
  38153. * Observable event when the current playing sound finishes.
  38154. */
  38155. onEndedObservable: Observable<Sound>;
  38156. private _panningModel;
  38157. private _playbackRate;
  38158. private _streaming;
  38159. private _startTime;
  38160. private _startOffset;
  38161. private _position;
  38162. /** @hidden */
  38163. _positionInEmitterSpace: boolean;
  38164. private _localDirection;
  38165. private _volume;
  38166. private _isReadyToPlay;
  38167. private _isDirectional;
  38168. private _readyToPlayCallback;
  38169. private _audioBuffer;
  38170. private _soundSource;
  38171. private _streamingSource;
  38172. private _soundPanner;
  38173. private _soundGain;
  38174. private _inputAudioNode;
  38175. private _outputAudioNode;
  38176. private _coneInnerAngle;
  38177. private _coneOuterAngle;
  38178. private _coneOuterGain;
  38179. private _scene;
  38180. private _connectedTransformNode;
  38181. private _customAttenuationFunction;
  38182. private _registerFunc;
  38183. private _isOutputConnected;
  38184. private _htmlAudioElement;
  38185. private _urlType;
  38186. private _length?;
  38187. private _offset?;
  38188. /** @hidden */
  38189. static _SceneComponentInitialization: (scene: Scene) => void;
  38190. /**
  38191. * Create a sound and attach it to a scene
  38192. * @param name Name of your sound
  38193. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38194. * @param scene defines the scene the sound belongs to
  38195. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38196. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38197. */
  38198. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38199. /**
  38200. * Release the sound and its associated resources
  38201. */
  38202. dispose(): void;
  38203. /**
  38204. * Gets if the sounds is ready to be played or not.
  38205. * @returns true if ready, otherwise false
  38206. */
  38207. isReady(): boolean;
  38208. private _soundLoaded;
  38209. /**
  38210. * Sets the data of the sound from an audiobuffer
  38211. * @param audioBuffer The audioBuffer containing the data
  38212. */
  38213. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38214. /**
  38215. * Updates the current sounds options such as maxdistance, loop...
  38216. * @param options A JSON object containing values named as the object properties
  38217. */
  38218. updateOptions(options: ISoundOptions): void;
  38219. private _createSpatialParameters;
  38220. private _updateSpatialParameters;
  38221. /**
  38222. * Switch the panning model to HRTF:
  38223. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38224. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38225. */
  38226. switchPanningModelToHRTF(): void;
  38227. /**
  38228. * Switch the panning model to Equal Power:
  38229. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38231. */
  38232. switchPanningModelToEqualPower(): void;
  38233. private _switchPanningModel;
  38234. /**
  38235. * Connect this sound to a sound track audio node like gain...
  38236. * @param soundTrackAudioNode the sound track audio node to connect to
  38237. */
  38238. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38239. /**
  38240. * Transform this sound into a directional source
  38241. * @param coneInnerAngle Size of the inner cone in degree
  38242. * @param coneOuterAngle Size of the outer cone in degree
  38243. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38244. */
  38245. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38246. /**
  38247. * Gets or sets the inner angle for the directional cone.
  38248. */
  38249. get directionalConeInnerAngle(): number;
  38250. /**
  38251. * Gets or sets the inner angle for the directional cone.
  38252. */
  38253. set directionalConeInnerAngle(value: number);
  38254. /**
  38255. * Gets or sets the outer angle for the directional cone.
  38256. */
  38257. get directionalConeOuterAngle(): number;
  38258. /**
  38259. * Gets or sets the outer angle for the directional cone.
  38260. */
  38261. set directionalConeOuterAngle(value: number);
  38262. /**
  38263. * Sets the position of the emitter if spatial sound is enabled
  38264. * @param newPosition Defines the new posisiton
  38265. */
  38266. setPosition(newPosition: Vector3): void;
  38267. /**
  38268. * Sets the local direction of the emitter if spatial sound is enabled
  38269. * @param newLocalDirection Defines the new local direction
  38270. */
  38271. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38272. private _updateDirection;
  38273. /** @hidden */
  38274. updateDistanceFromListener(): void;
  38275. /**
  38276. * Sets a new custom attenuation function for the sound.
  38277. * @param callback Defines the function used for the attenuation
  38278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38279. */
  38280. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38281. /**
  38282. * Play the sound
  38283. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38284. * @param offset (optional) Start the sound at a specific time in seconds
  38285. * @param length (optional) Sound duration (in seconds)
  38286. */
  38287. play(time?: number, offset?: number, length?: number): void;
  38288. private _onended;
  38289. /**
  38290. * Stop the sound
  38291. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38292. */
  38293. stop(time?: number): void;
  38294. /**
  38295. * Put the sound in pause
  38296. */
  38297. pause(): void;
  38298. /**
  38299. * Sets a dedicated volume for this sounds
  38300. * @param newVolume Define the new volume of the sound
  38301. * @param time Define time for gradual change to new volume
  38302. */
  38303. setVolume(newVolume: number, time?: number): void;
  38304. /**
  38305. * Set the sound play back rate
  38306. * @param newPlaybackRate Define the playback rate the sound should be played at
  38307. */
  38308. setPlaybackRate(newPlaybackRate: number): void;
  38309. /**
  38310. * Gets the volume of the sound.
  38311. * @returns the volume of the sound
  38312. */
  38313. getVolume(): number;
  38314. /**
  38315. * Attach the sound to a dedicated mesh
  38316. * @param transformNode The transform node to connect the sound with
  38317. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38318. */
  38319. attachToMesh(transformNode: TransformNode): void;
  38320. /**
  38321. * Detach the sound from the previously attached mesh
  38322. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38323. */
  38324. detachFromMesh(): void;
  38325. private _onRegisterAfterWorldMatrixUpdate;
  38326. /**
  38327. * Clone the current sound in the scene.
  38328. * @returns the new sound clone
  38329. */
  38330. clone(): Nullable<Sound>;
  38331. /**
  38332. * Gets the current underlying audio buffer containing the data
  38333. * @returns the audio buffer
  38334. */
  38335. getAudioBuffer(): Nullable<AudioBuffer>;
  38336. /**
  38337. * Serializes the Sound in a JSON representation
  38338. * @returns the JSON representation of the sound
  38339. */
  38340. serialize(): any;
  38341. /**
  38342. * Parse a JSON representation of a sound to innstantiate in a given scene
  38343. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38344. * @param scene Define the scene the new parsed sound should be created in
  38345. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38346. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38347. * @returns the newly parsed sound
  38348. */
  38349. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38350. }
  38351. }
  38352. declare module "babylonjs/Actions/directAudioActions" {
  38353. import { Action } from "babylonjs/Actions/action";
  38354. import { Condition } from "babylonjs/Actions/condition";
  38355. import { Sound } from "babylonjs/Audio/sound";
  38356. /**
  38357. * This defines an action helpful to play a defined sound on a triggered action.
  38358. */
  38359. export class PlaySoundAction extends Action {
  38360. private _sound;
  38361. /**
  38362. * Instantiate the action
  38363. * @param triggerOptions defines the trigger options
  38364. * @param sound defines the sound to play
  38365. * @param condition defines the trigger related conditions
  38366. */
  38367. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38368. /** @hidden */
  38369. _prepare(): void;
  38370. /**
  38371. * Execute the action and play the sound.
  38372. */
  38373. execute(): void;
  38374. /**
  38375. * Serializes the actions and its related information.
  38376. * @param parent defines the object to serialize in
  38377. * @returns the serialized object
  38378. */
  38379. serialize(parent: any): any;
  38380. }
  38381. /**
  38382. * This defines an action helpful to stop a defined sound on a triggered action.
  38383. */
  38384. export class StopSoundAction extends Action {
  38385. private _sound;
  38386. /**
  38387. * Instantiate the action
  38388. * @param triggerOptions defines the trigger options
  38389. * @param sound defines the sound to stop
  38390. * @param condition defines the trigger related conditions
  38391. */
  38392. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38393. /** @hidden */
  38394. _prepare(): void;
  38395. /**
  38396. * Execute the action and stop the sound.
  38397. */
  38398. execute(): void;
  38399. /**
  38400. * Serializes the actions and its related information.
  38401. * @param parent defines the object to serialize in
  38402. * @returns the serialized object
  38403. */
  38404. serialize(parent: any): any;
  38405. }
  38406. }
  38407. declare module "babylonjs/Actions/interpolateValueAction" {
  38408. import { Action } from "babylonjs/Actions/action";
  38409. import { Condition } from "babylonjs/Actions/condition";
  38410. import { Observable } from "babylonjs/Misc/observable";
  38411. /**
  38412. * This defines an action responsible to change the value of a property
  38413. * by interpolating between its current value and the newly set one once triggered.
  38414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38415. */
  38416. export class InterpolateValueAction extends Action {
  38417. /**
  38418. * Defines the path of the property where the value should be interpolated
  38419. */
  38420. propertyPath: string;
  38421. /**
  38422. * Defines the target value at the end of the interpolation.
  38423. */
  38424. value: any;
  38425. /**
  38426. * Defines the time it will take for the property to interpolate to the value.
  38427. */
  38428. duration: number;
  38429. /**
  38430. * Defines if the other scene animations should be stopped when the action has been triggered
  38431. */
  38432. stopOtherAnimations?: boolean;
  38433. /**
  38434. * Defines a callback raised once the interpolation animation has been done.
  38435. */
  38436. onInterpolationDone?: () => void;
  38437. /**
  38438. * Observable triggered once the interpolation animation has been done.
  38439. */
  38440. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38441. private _target;
  38442. private _effectiveTarget;
  38443. private _property;
  38444. /**
  38445. * Instantiate the action
  38446. * @param triggerOptions defines the trigger options
  38447. * @param target defines the object containing the value to interpolate
  38448. * @param propertyPath defines the path to the property in the target object
  38449. * @param value defines the target value at the end of the interpolation
  38450. * @param duration deines the time it will take for the property to interpolate to the value.
  38451. * @param condition defines the trigger related conditions
  38452. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38453. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38454. */
  38455. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38456. /** @hidden */
  38457. _prepare(): void;
  38458. /**
  38459. * Execute the action starts the value interpolation.
  38460. */
  38461. execute(): void;
  38462. /**
  38463. * Serializes the actions and its related information.
  38464. * @param parent defines the object to serialize in
  38465. * @returns the serialized object
  38466. */
  38467. serialize(parent: any): any;
  38468. }
  38469. }
  38470. declare module "babylonjs/Actions/index" {
  38471. export * from "babylonjs/Actions/abstractActionManager";
  38472. export * from "babylonjs/Actions/action";
  38473. export * from "babylonjs/Actions/actionEvent";
  38474. export * from "babylonjs/Actions/actionManager";
  38475. export * from "babylonjs/Actions/condition";
  38476. export * from "babylonjs/Actions/directActions";
  38477. export * from "babylonjs/Actions/directAudioActions";
  38478. export * from "babylonjs/Actions/interpolateValueAction";
  38479. }
  38480. declare module "babylonjs/Animations/index" {
  38481. export * from "babylonjs/Animations/animatable";
  38482. export * from "babylonjs/Animations/animation";
  38483. export * from "babylonjs/Animations/animationGroup";
  38484. export * from "babylonjs/Animations/animationPropertiesOverride";
  38485. export * from "babylonjs/Animations/easing";
  38486. export * from "babylonjs/Animations/runtimeAnimation";
  38487. export * from "babylonjs/Animations/animationEvent";
  38488. export * from "babylonjs/Animations/animationGroup";
  38489. export * from "babylonjs/Animations/animationKey";
  38490. export * from "babylonjs/Animations/animationRange";
  38491. export * from "babylonjs/Animations/animatable.interface";
  38492. }
  38493. declare module "babylonjs/Audio/soundTrack" {
  38494. import { Sound } from "babylonjs/Audio/sound";
  38495. import { Analyser } from "babylonjs/Audio/analyser";
  38496. import { Scene } from "babylonjs/scene";
  38497. /**
  38498. * Options allowed during the creation of a sound track.
  38499. */
  38500. export interface ISoundTrackOptions {
  38501. /**
  38502. * The volume the sound track should take during creation
  38503. */
  38504. volume?: number;
  38505. /**
  38506. * Define if the sound track is the main sound track of the scene
  38507. */
  38508. mainTrack?: boolean;
  38509. }
  38510. /**
  38511. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38512. * It will be also used in a future release to apply effects on a specific track.
  38513. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38514. */
  38515. export class SoundTrack {
  38516. /**
  38517. * The unique identifier of the sound track in the scene.
  38518. */
  38519. id: number;
  38520. /**
  38521. * The list of sounds included in the sound track.
  38522. */
  38523. soundCollection: Array<Sound>;
  38524. private _outputAudioNode;
  38525. private _scene;
  38526. private _connectedAnalyser;
  38527. private _options;
  38528. private _isInitialized;
  38529. /**
  38530. * Creates a new sound track.
  38531. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38532. * @param scene Define the scene the sound track belongs to
  38533. * @param options
  38534. */
  38535. constructor(scene: Scene, options?: ISoundTrackOptions);
  38536. private _initializeSoundTrackAudioGraph;
  38537. /**
  38538. * Release the sound track and its associated resources
  38539. */
  38540. dispose(): void;
  38541. /**
  38542. * Adds a sound to this sound track
  38543. * @param sound define the cound to add
  38544. * @ignoreNaming
  38545. */
  38546. AddSound(sound: Sound): void;
  38547. /**
  38548. * Removes a sound to this sound track
  38549. * @param sound define the cound to remove
  38550. * @ignoreNaming
  38551. */
  38552. RemoveSound(sound: Sound): void;
  38553. /**
  38554. * Set a global volume for the full sound track.
  38555. * @param newVolume Define the new volume of the sound track
  38556. */
  38557. setVolume(newVolume: number): void;
  38558. /**
  38559. * Switch the panning model to HRTF:
  38560. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38561. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38562. */
  38563. switchPanningModelToHRTF(): void;
  38564. /**
  38565. * Switch the panning model to Equal Power:
  38566. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38567. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38568. */
  38569. switchPanningModelToEqualPower(): void;
  38570. /**
  38571. * Connect the sound track to an audio analyser allowing some amazing
  38572. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38573. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38574. * @param analyser The analyser to connect to the engine
  38575. */
  38576. connectToAnalyser(analyser: Analyser): void;
  38577. }
  38578. }
  38579. declare module "babylonjs/Audio/audioSceneComponent" {
  38580. import { Sound } from "babylonjs/Audio/sound";
  38581. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38582. import { Nullable } from "babylonjs/types";
  38583. import { Vector3 } from "babylonjs/Maths/math.vector";
  38584. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38585. import { Scene } from "babylonjs/scene";
  38586. import { AbstractScene } from "babylonjs/abstractScene";
  38587. import "babylonjs/Audio/audioEngine";
  38588. module "babylonjs/abstractScene" {
  38589. interface AbstractScene {
  38590. /**
  38591. * The list of sounds used in the scene.
  38592. */
  38593. sounds: Nullable<Array<Sound>>;
  38594. }
  38595. }
  38596. module "babylonjs/scene" {
  38597. interface Scene {
  38598. /**
  38599. * @hidden
  38600. * Backing field
  38601. */
  38602. _mainSoundTrack: SoundTrack;
  38603. /**
  38604. * The main sound track played by the scene.
  38605. * It cotains your primary collection of sounds.
  38606. */
  38607. mainSoundTrack: SoundTrack;
  38608. /**
  38609. * The list of sound tracks added to the scene
  38610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38611. */
  38612. soundTracks: Nullable<Array<SoundTrack>>;
  38613. /**
  38614. * Gets a sound using a given name
  38615. * @param name defines the name to search for
  38616. * @return the found sound or null if not found at all.
  38617. */
  38618. getSoundByName(name: string): Nullable<Sound>;
  38619. /**
  38620. * Gets or sets if audio support is enabled
  38621. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38622. */
  38623. audioEnabled: boolean;
  38624. /**
  38625. * Gets or sets if audio will be output to headphones
  38626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38627. */
  38628. headphone: boolean;
  38629. /**
  38630. * Gets or sets custom audio listener position provider
  38631. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38632. */
  38633. audioListenerPositionProvider: Nullable<() => Vector3>;
  38634. /**
  38635. * Gets or sets a refresh rate when using 3D audio positioning
  38636. */
  38637. audioPositioningRefreshRate: number;
  38638. }
  38639. }
  38640. /**
  38641. * Defines the sound scene component responsible to manage any sounds
  38642. * in a given scene.
  38643. */
  38644. export class AudioSceneComponent implements ISceneSerializableComponent {
  38645. /**
  38646. * The component name helpfull to identify the component in the list of scene components.
  38647. */
  38648. readonly name: string;
  38649. /**
  38650. * The scene the component belongs to.
  38651. */
  38652. scene: Scene;
  38653. private _audioEnabled;
  38654. /**
  38655. * Gets whether audio is enabled or not.
  38656. * Please use related enable/disable method to switch state.
  38657. */
  38658. get audioEnabled(): boolean;
  38659. private _headphone;
  38660. /**
  38661. * Gets whether audio is outputing to headphone or not.
  38662. * Please use the according Switch methods to change output.
  38663. */
  38664. get headphone(): boolean;
  38665. /**
  38666. * Gets or sets a refresh rate when using 3D audio positioning
  38667. */
  38668. audioPositioningRefreshRate: number;
  38669. private _audioListenerPositionProvider;
  38670. /**
  38671. * Gets the current audio listener position provider
  38672. */
  38673. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38674. /**
  38675. * Sets a custom listener position for all sounds in the scene
  38676. * By default, this is the position of the first active camera
  38677. */
  38678. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38679. /**
  38680. * Creates a new instance of the component for the given scene
  38681. * @param scene Defines the scene to register the component in
  38682. */
  38683. constructor(scene: Scene);
  38684. /**
  38685. * Registers the component in a given scene
  38686. */
  38687. register(): void;
  38688. /**
  38689. * Rebuilds the elements related to this component in case of
  38690. * context lost for instance.
  38691. */
  38692. rebuild(): void;
  38693. /**
  38694. * Serializes the component data to the specified json object
  38695. * @param serializationObject The object to serialize to
  38696. */
  38697. serialize(serializationObject: any): void;
  38698. /**
  38699. * Adds all the elements from the container to the scene
  38700. * @param container the container holding the elements
  38701. */
  38702. addFromContainer(container: AbstractScene): void;
  38703. /**
  38704. * Removes all the elements in the container from the scene
  38705. * @param container contains the elements to remove
  38706. * @param dispose if the removed element should be disposed (default: false)
  38707. */
  38708. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38709. /**
  38710. * Disposes the component and the associated ressources.
  38711. */
  38712. dispose(): void;
  38713. /**
  38714. * Disables audio in the associated scene.
  38715. */
  38716. disableAudio(): void;
  38717. /**
  38718. * Enables audio in the associated scene.
  38719. */
  38720. enableAudio(): void;
  38721. /**
  38722. * Switch audio to headphone output.
  38723. */
  38724. switchAudioModeForHeadphones(): void;
  38725. /**
  38726. * Switch audio to normal speakers.
  38727. */
  38728. switchAudioModeForNormalSpeakers(): void;
  38729. private _cachedCameraDirection;
  38730. private _cachedCameraPosition;
  38731. private _lastCheck;
  38732. private _afterRender;
  38733. }
  38734. }
  38735. declare module "babylonjs/Audio/weightedsound" {
  38736. import { Sound } from "babylonjs/Audio/sound";
  38737. /**
  38738. * Wraps one or more Sound objects and selects one with random weight for playback.
  38739. */
  38740. export class WeightedSound {
  38741. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38742. loop: boolean;
  38743. private _coneInnerAngle;
  38744. private _coneOuterAngle;
  38745. private _volume;
  38746. /** A Sound is currently playing. */
  38747. isPlaying: boolean;
  38748. /** A Sound is currently paused. */
  38749. isPaused: boolean;
  38750. private _sounds;
  38751. private _weights;
  38752. private _currentIndex?;
  38753. /**
  38754. * Creates a new WeightedSound from the list of sounds given.
  38755. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38756. * @param sounds Array of Sounds that will be selected from.
  38757. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38758. */
  38759. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38760. /**
  38761. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38762. */
  38763. get directionalConeInnerAngle(): number;
  38764. /**
  38765. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38766. */
  38767. set directionalConeInnerAngle(value: number);
  38768. /**
  38769. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38770. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38771. */
  38772. get directionalConeOuterAngle(): number;
  38773. /**
  38774. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38775. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38776. */
  38777. set directionalConeOuterAngle(value: number);
  38778. /**
  38779. * Playback volume.
  38780. */
  38781. get volume(): number;
  38782. /**
  38783. * Playback volume.
  38784. */
  38785. set volume(value: number);
  38786. private _onended;
  38787. /**
  38788. * Suspend playback
  38789. */
  38790. pause(): void;
  38791. /**
  38792. * Stop playback
  38793. */
  38794. stop(): void;
  38795. /**
  38796. * Start playback.
  38797. * @param startOffset Position the clip head at a specific time in seconds.
  38798. */
  38799. play(startOffset?: number): void;
  38800. }
  38801. }
  38802. declare module "babylonjs/Audio/index" {
  38803. export * from "babylonjs/Audio/analyser";
  38804. export * from "babylonjs/Audio/audioEngine";
  38805. export * from "babylonjs/Audio/audioSceneComponent";
  38806. export * from "babylonjs/Audio/sound";
  38807. export * from "babylonjs/Audio/soundTrack";
  38808. export * from "babylonjs/Audio/weightedsound";
  38809. }
  38810. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  38811. import { Behavior } from "babylonjs/Behaviors/behavior";
  38812. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38813. import { BackEase } from "babylonjs/Animations/easing";
  38814. /**
  38815. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  38816. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38817. */
  38818. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  38819. /**
  38820. * Gets the name of the behavior.
  38821. */
  38822. get name(): string;
  38823. /**
  38824. * The easing function used by animations
  38825. */
  38826. static EasingFunction: BackEase;
  38827. /**
  38828. * The easing mode used by animations
  38829. */
  38830. static EasingMode: number;
  38831. /**
  38832. * The duration of the animation, in milliseconds
  38833. */
  38834. transitionDuration: number;
  38835. /**
  38836. * Length of the distance animated by the transition when lower radius is reached
  38837. */
  38838. lowerRadiusTransitionRange: number;
  38839. /**
  38840. * Length of the distance animated by the transition when upper radius is reached
  38841. */
  38842. upperRadiusTransitionRange: number;
  38843. private _autoTransitionRange;
  38844. /**
  38845. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38846. */
  38847. get autoTransitionRange(): boolean;
  38848. /**
  38849. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  38850. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  38851. */
  38852. set autoTransitionRange(value: boolean);
  38853. private _attachedCamera;
  38854. private _onAfterCheckInputsObserver;
  38855. private _onMeshTargetChangedObserver;
  38856. /**
  38857. * Initializes the behavior.
  38858. */
  38859. init(): void;
  38860. /**
  38861. * Attaches the behavior to its arc rotate camera.
  38862. * @param camera Defines the camera to attach the behavior to
  38863. */
  38864. attach(camera: ArcRotateCamera): void;
  38865. /**
  38866. * Detaches the behavior from its current arc rotate camera.
  38867. */
  38868. detach(): void;
  38869. private _radiusIsAnimating;
  38870. private _radiusBounceTransition;
  38871. private _animatables;
  38872. private _cachedWheelPrecision;
  38873. /**
  38874. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  38875. * @param radiusLimit The limit to check against.
  38876. * @return Bool to indicate if at limit.
  38877. */
  38878. private _isRadiusAtLimit;
  38879. /**
  38880. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  38881. * @param radiusDelta The delta by which to animate to. Can be negative.
  38882. */
  38883. private _applyBoundRadiusAnimation;
  38884. /**
  38885. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  38886. */
  38887. protected _clearAnimationLocks(): void;
  38888. /**
  38889. * Stops and removes all animations that have been applied to the camera
  38890. */
  38891. stopAllAnimations(): void;
  38892. }
  38893. }
  38894. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  38895. import { Behavior } from "babylonjs/Behaviors/behavior";
  38896. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38897. import { ExponentialEase } from "babylonjs/Animations/easing";
  38898. import { Nullable } from "babylonjs/types";
  38899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38900. import { Vector3 } from "babylonjs/Maths/math.vector";
  38901. /**
  38902. * 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.
  38903. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38904. */
  38905. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  38906. /**
  38907. * Gets the name of the behavior.
  38908. */
  38909. get name(): string;
  38910. private _mode;
  38911. private _radiusScale;
  38912. private _positionScale;
  38913. private _defaultElevation;
  38914. private _elevationReturnTime;
  38915. private _elevationReturnWaitTime;
  38916. private _zoomStopsAnimation;
  38917. private _framingTime;
  38918. /**
  38919. * The easing function used by animations
  38920. */
  38921. static EasingFunction: ExponentialEase;
  38922. /**
  38923. * The easing mode used by animations
  38924. */
  38925. static EasingMode: number;
  38926. /**
  38927. * Sets the current mode used by the behavior
  38928. */
  38929. set mode(mode: number);
  38930. /**
  38931. * Gets current mode used by the behavior.
  38932. */
  38933. get mode(): number;
  38934. /**
  38935. * Sets the scale applied to the radius (1 by default)
  38936. */
  38937. set radiusScale(radius: number);
  38938. /**
  38939. * Gets the scale applied to the radius
  38940. */
  38941. get radiusScale(): number;
  38942. /**
  38943. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38944. */
  38945. set positionScale(scale: number);
  38946. /**
  38947. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38948. */
  38949. get positionScale(): number;
  38950. /**
  38951. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38952. * behaviour is triggered, in radians.
  38953. */
  38954. set defaultElevation(elevation: number);
  38955. /**
  38956. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38957. * behaviour is triggered, in radians.
  38958. */
  38959. get defaultElevation(): number;
  38960. /**
  38961. * Sets the time (in milliseconds) taken to return to the default beta position.
  38962. * Negative value indicates camera should not return to default.
  38963. */
  38964. set elevationReturnTime(speed: number);
  38965. /**
  38966. * Gets the time (in milliseconds) taken to return to the default beta position.
  38967. * Negative value indicates camera should not return to default.
  38968. */
  38969. get elevationReturnTime(): number;
  38970. /**
  38971. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38972. */
  38973. set elevationReturnWaitTime(time: number);
  38974. /**
  38975. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38976. */
  38977. get elevationReturnWaitTime(): number;
  38978. /**
  38979. * Sets the flag that indicates if user zooming should stop animation.
  38980. */
  38981. set zoomStopsAnimation(flag: boolean);
  38982. /**
  38983. * Gets the flag that indicates if user zooming should stop animation.
  38984. */
  38985. get zoomStopsAnimation(): boolean;
  38986. /**
  38987. * Sets the transition time when framing the mesh, in milliseconds
  38988. */
  38989. set framingTime(time: number);
  38990. /**
  38991. * Gets the transition time when framing the mesh, in milliseconds
  38992. */
  38993. get framingTime(): number;
  38994. /**
  38995. * Define if the behavior should automatically change the configured
  38996. * camera limits and sensibilities.
  38997. */
  38998. autoCorrectCameraLimitsAndSensibility: boolean;
  38999. private _onPrePointerObservableObserver;
  39000. private _onAfterCheckInputsObserver;
  39001. private _onMeshTargetChangedObserver;
  39002. private _attachedCamera;
  39003. private _isPointerDown;
  39004. private _lastInteractionTime;
  39005. /**
  39006. * Initializes the behavior.
  39007. */
  39008. init(): void;
  39009. /**
  39010. * Attaches the behavior to its arc rotate camera.
  39011. * @param camera Defines the camera to attach the behavior to
  39012. */
  39013. attach(camera: ArcRotateCamera): void;
  39014. /**
  39015. * Detaches the behavior from its current arc rotate camera.
  39016. */
  39017. detach(): void;
  39018. private _animatables;
  39019. private _betaIsAnimating;
  39020. private _betaTransition;
  39021. private _radiusTransition;
  39022. private _vectorTransition;
  39023. /**
  39024. * Targets the given mesh and updates zoom level accordingly.
  39025. * @param mesh The mesh to target.
  39026. * @param radius Optional. If a cached radius position already exists, overrides default.
  39027. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39028. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39029. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39030. */
  39031. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39032. /**
  39033. * Targets the given mesh with its children and updates zoom level accordingly.
  39034. * @param mesh The mesh to target.
  39035. * @param radius Optional. If a cached radius position already exists, overrides default.
  39036. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39037. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39038. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39039. */
  39040. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39041. /**
  39042. * Targets the given meshes with their children and updates zoom level accordingly.
  39043. * @param meshes The mesh to target.
  39044. * @param radius Optional. If a cached radius position already exists, overrides default.
  39045. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  39046. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39047. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39048. */
  39049. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39050. /**
  39051. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39052. * @param minimumWorld Determines the smaller position of the bounding box extend
  39053. * @param maximumWorld Determines the bigger position of the bounding box extend
  39054. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39055. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39056. */
  39057. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39058. /**
  39059. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39060. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39061. * frustum width.
  39062. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39063. * to fully enclose the mesh in the viewing frustum.
  39064. */
  39065. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39066. /**
  39067. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39068. * is automatically returned to its default position (expected to be above ground plane).
  39069. */
  39070. private _maintainCameraAboveGround;
  39071. /**
  39072. * Returns the frustum slope based on the canvas ratio and camera FOV
  39073. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39074. */
  39075. private _getFrustumSlope;
  39076. /**
  39077. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39078. */
  39079. private _clearAnimationLocks;
  39080. /**
  39081. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39082. */
  39083. private _applyUserInteraction;
  39084. /**
  39085. * Stops and removes all animations that have been applied to the camera
  39086. */
  39087. stopAllAnimations(): void;
  39088. /**
  39089. * Gets a value indicating if the user is moving the camera
  39090. */
  39091. get isUserIsMoving(): boolean;
  39092. /**
  39093. * The camera can move all the way towards the mesh.
  39094. */
  39095. static IgnoreBoundsSizeMode: number;
  39096. /**
  39097. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39098. */
  39099. static FitFrustumSidesMode: number;
  39100. }
  39101. }
  39102. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39103. import { Nullable } from "babylonjs/types";
  39104. import { Camera } from "babylonjs/Cameras/camera";
  39105. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39106. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39107. /**
  39108. * Base class for Camera Pointer Inputs.
  39109. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39110. * for example usage.
  39111. */
  39112. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39113. /**
  39114. * Defines the camera the input is attached to.
  39115. */
  39116. abstract camera: Camera;
  39117. /**
  39118. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39119. */
  39120. protected _altKey: boolean;
  39121. protected _ctrlKey: boolean;
  39122. protected _metaKey: boolean;
  39123. protected _shiftKey: boolean;
  39124. /**
  39125. * Which mouse buttons were pressed at time of last mouse event.
  39126. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39127. */
  39128. protected _buttonsPressed: number;
  39129. /**
  39130. * Defines the buttons associated with the input to handle camera move.
  39131. */
  39132. buttons: number[];
  39133. /**
  39134. * Attach the input controls to a specific dom element to get the input from.
  39135. * @param element Defines the element the controls should be listened from
  39136. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39137. */
  39138. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39139. /**
  39140. * Detach the current controls from the specified dom element.
  39141. * @param element Defines the element to stop listening the inputs from
  39142. */
  39143. detachControl(element: Nullable<HTMLElement>): void;
  39144. /**
  39145. * Gets the class name of the current input.
  39146. * @returns the class name
  39147. */
  39148. getClassName(): string;
  39149. /**
  39150. * Get the friendly name associated with the input class.
  39151. * @returns the input friendly name
  39152. */
  39153. getSimpleName(): string;
  39154. /**
  39155. * Called on pointer POINTERDOUBLETAP event.
  39156. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39157. */
  39158. protected onDoubleTap(type: string): void;
  39159. /**
  39160. * Called on pointer POINTERMOVE event if only a single touch is active.
  39161. * Override this method to provide functionality.
  39162. */
  39163. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39164. /**
  39165. * Called on pointer POINTERMOVE event if multiple touches are active.
  39166. * Override this method to provide functionality.
  39167. */
  39168. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39169. /**
  39170. * Called on JS contextmenu event.
  39171. * Override this method to provide functionality.
  39172. */
  39173. protected onContextMenu(evt: PointerEvent): void;
  39174. /**
  39175. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39176. * press.
  39177. * Override this method to provide functionality.
  39178. */
  39179. protected onButtonDown(evt: PointerEvent): void;
  39180. /**
  39181. * Called each time a new POINTERUP event occurs. Ie, for each button
  39182. * release.
  39183. * Override this method to provide functionality.
  39184. */
  39185. protected onButtonUp(evt: PointerEvent): void;
  39186. /**
  39187. * Called when window becomes inactive.
  39188. * Override this method to provide functionality.
  39189. */
  39190. protected onLostFocus(): void;
  39191. private _pointerInput;
  39192. private _observer;
  39193. private _onLostFocus;
  39194. private pointA;
  39195. private pointB;
  39196. }
  39197. }
  39198. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39199. import { Nullable } from "babylonjs/types";
  39200. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39201. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39202. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39203. /**
  39204. * Manage the pointers inputs to control an arc rotate camera.
  39205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39206. */
  39207. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39208. /**
  39209. * Defines the camera the input is attached to.
  39210. */
  39211. camera: ArcRotateCamera;
  39212. /**
  39213. * Gets the class name of the current input.
  39214. * @returns the class name
  39215. */
  39216. getClassName(): string;
  39217. /**
  39218. * Defines the buttons associated with the input to handle camera move.
  39219. */
  39220. buttons: number[];
  39221. /**
  39222. * Defines the pointer angular sensibility along the X axis or how fast is
  39223. * the camera rotating.
  39224. */
  39225. angularSensibilityX: number;
  39226. /**
  39227. * Defines the pointer angular sensibility along the Y axis or how fast is
  39228. * the camera rotating.
  39229. */
  39230. angularSensibilityY: number;
  39231. /**
  39232. * Defines the pointer pinch precision or how fast is the camera zooming.
  39233. */
  39234. pinchPrecision: number;
  39235. /**
  39236. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39237. * from 0.
  39238. * It defines the percentage of current camera.radius to use as delta when
  39239. * pinch zoom is used.
  39240. */
  39241. pinchDeltaPercentage: number;
  39242. /**
  39243. * Defines the pointer panning sensibility or how fast is the camera moving.
  39244. */
  39245. panningSensibility: number;
  39246. /**
  39247. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39248. */
  39249. multiTouchPanning: boolean;
  39250. /**
  39251. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39252. * zoom (pinch) through multitouch.
  39253. */
  39254. multiTouchPanAndZoom: boolean;
  39255. /**
  39256. * Revers pinch action direction.
  39257. */
  39258. pinchInwards: boolean;
  39259. private _isPanClick;
  39260. private _twoFingerActivityCount;
  39261. private _isPinching;
  39262. /**
  39263. * Called on pointer POINTERMOVE event if only a single touch is active.
  39264. */
  39265. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39266. /**
  39267. * Called on pointer POINTERDOUBLETAP event.
  39268. */
  39269. protected onDoubleTap(type: string): void;
  39270. /**
  39271. * Called on pointer POINTERMOVE event if multiple touches are active.
  39272. */
  39273. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39274. /**
  39275. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39276. * press.
  39277. */
  39278. protected onButtonDown(evt: PointerEvent): void;
  39279. /**
  39280. * Called each time a new POINTERUP event occurs. Ie, for each button
  39281. * release.
  39282. */
  39283. protected onButtonUp(evt: PointerEvent): void;
  39284. /**
  39285. * Called when window becomes inactive.
  39286. */
  39287. protected onLostFocus(): void;
  39288. }
  39289. }
  39290. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39291. import { Nullable } from "babylonjs/types";
  39292. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39293. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39294. /**
  39295. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39297. */
  39298. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39299. /**
  39300. * Defines the camera the input is attached to.
  39301. */
  39302. camera: ArcRotateCamera;
  39303. /**
  39304. * Defines the list of key codes associated with the up action (increase alpha)
  39305. */
  39306. keysUp: number[];
  39307. /**
  39308. * Defines the list of key codes associated with the down action (decrease alpha)
  39309. */
  39310. keysDown: number[];
  39311. /**
  39312. * Defines the list of key codes associated with the left action (increase beta)
  39313. */
  39314. keysLeft: number[];
  39315. /**
  39316. * Defines the list of key codes associated with the right action (decrease beta)
  39317. */
  39318. keysRight: number[];
  39319. /**
  39320. * Defines the list of key codes associated with the reset action.
  39321. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39322. */
  39323. keysReset: number[];
  39324. /**
  39325. * Defines the panning sensibility of the inputs.
  39326. * (How fast is the camera paning)
  39327. */
  39328. panningSensibility: number;
  39329. /**
  39330. * Defines the zooming sensibility of the inputs.
  39331. * (How fast is the camera zooming)
  39332. */
  39333. zoomingSensibility: number;
  39334. /**
  39335. * Defines wether maintaining the alt key down switch the movement mode from
  39336. * orientation to zoom.
  39337. */
  39338. useAltToZoom: boolean;
  39339. /**
  39340. * Rotation speed of the camera
  39341. */
  39342. angularSpeed: number;
  39343. private _keys;
  39344. private _ctrlPressed;
  39345. private _altPressed;
  39346. private _onCanvasBlurObserver;
  39347. private _onKeyboardObserver;
  39348. private _engine;
  39349. private _scene;
  39350. /**
  39351. * Attach the input controls to a specific dom element to get the input from.
  39352. * @param element Defines the element the controls should be listened from
  39353. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39354. */
  39355. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39356. /**
  39357. * Detach the current controls from the specified dom element.
  39358. * @param element Defines the element to stop listening the inputs from
  39359. */
  39360. detachControl(element: Nullable<HTMLElement>): void;
  39361. /**
  39362. * Update the current camera state depending on the inputs that have been used this frame.
  39363. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39364. */
  39365. checkInputs(): void;
  39366. /**
  39367. * Gets the class name of the current intput.
  39368. * @returns the class name
  39369. */
  39370. getClassName(): string;
  39371. /**
  39372. * Get the friendly name associated with the input class.
  39373. * @returns the input friendly name
  39374. */
  39375. getSimpleName(): string;
  39376. }
  39377. }
  39378. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39379. import { Nullable } from "babylonjs/types";
  39380. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39381. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39382. /**
  39383. * Manage the mouse wheel inputs to control an arc rotate camera.
  39384. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39385. */
  39386. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39387. /**
  39388. * Defines the camera the input is attached to.
  39389. */
  39390. camera: ArcRotateCamera;
  39391. /**
  39392. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39393. */
  39394. wheelPrecision: number;
  39395. /**
  39396. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39397. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39398. */
  39399. wheelDeltaPercentage: number;
  39400. private _wheel;
  39401. private _observer;
  39402. private computeDeltaFromMouseWheelLegacyEvent;
  39403. /**
  39404. * Attach the input controls to a specific dom element to get the input from.
  39405. * @param element Defines the element the controls should be listened from
  39406. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39407. */
  39408. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39409. /**
  39410. * Detach the current controls from the specified dom element.
  39411. * @param element Defines the element to stop listening the inputs from
  39412. */
  39413. detachControl(element: Nullable<HTMLElement>): void;
  39414. /**
  39415. * Gets the class name of the current intput.
  39416. * @returns the class name
  39417. */
  39418. getClassName(): string;
  39419. /**
  39420. * Get the friendly name associated with the input class.
  39421. * @returns the input friendly name
  39422. */
  39423. getSimpleName(): string;
  39424. }
  39425. }
  39426. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39427. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39428. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39429. /**
  39430. * Default Inputs manager for the ArcRotateCamera.
  39431. * It groups all the default supported inputs for ease of use.
  39432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39433. */
  39434. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39435. /**
  39436. * Instantiates a new ArcRotateCameraInputsManager.
  39437. * @param camera Defines the camera the inputs belong to
  39438. */
  39439. constructor(camera: ArcRotateCamera);
  39440. /**
  39441. * Add mouse wheel input support to the input manager.
  39442. * @returns the current input manager
  39443. */
  39444. addMouseWheel(): ArcRotateCameraInputsManager;
  39445. /**
  39446. * Add pointers input support to the input manager.
  39447. * @returns the current input manager
  39448. */
  39449. addPointers(): ArcRotateCameraInputsManager;
  39450. /**
  39451. * Add keyboard input support to the input manager.
  39452. * @returns the current input manager
  39453. */
  39454. addKeyboard(): ArcRotateCameraInputsManager;
  39455. }
  39456. }
  39457. declare module "babylonjs/Cameras/arcRotateCamera" {
  39458. import { Observable } from "babylonjs/Misc/observable";
  39459. import { Nullable } from "babylonjs/types";
  39460. import { Scene } from "babylonjs/scene";
  39461. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39463. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39464. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39465. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39466. import { Camera } from "babylonjs/Cameras/camera";
  39467. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39468. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39469. import { Collider } from "babylonjs/Collisions/collider";
  39470. /**
  39471. * This represents an orbital type of camera.
  39472. *
  39473. * 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.
  39474. * 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.
  39475. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39476. */
  39477. export class ArcRotateCamera extends TargetCamera {
  39478. /**
  39479. * Defines the rotation angle of the camera along the longitudinal axis.
  39480. */
  39481. alpha: number;
  39482. /**
  39483. * Defines the rotation angle of the camera along the latitudinal axis.
  39484. */
  39485. beta: number;
  39486. /**
  39487. * Defines the radius of the camera from it s target point.
  39488. */
  39489. radius: number;
  39490. protected _target: Vector3;
  39491. protected _targetHost: Nullable<AbstractMesh>;
  39492. /**
  39493. * Defines the target point of the camera.
  39494. * The camera looks towards it form the radius distance.
  39495. */
  39496. get target(): Vector3;
  39497. set target(value: Vector3);
  39498. /**
  39499. * Define the current local position of the camera in the scene
  39500. */
  39501. get position(): Vector3;
  39502. set position(newPosition: Vector3);
  39503. protected _upVector: Vector3;
  39504. protected _upToYMatrix: Matrix;
  39505. protected _YToUpMatrix: Matrix;
  39506. /**
  39507. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39508. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39509. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39510. */
  39511. set upVector(vec: Vector3);
  39512. get upVector(): Vector3;
  39513. /**
  39514. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39515. */
  39516. setMatUp(): void;
  39517. /**
  39518. * Current inertia value on the longitudinal axis.
  39519. * The bigger this number the longer it will take for the camera to stop.
  39520. */
  39521. inertialAlphaOffset: number;
  39522. /**
  39523. * Current inertia value on the latitudinal axis.
  39524. * The bigger this number the longer it will take for the camera to stop.
  39525. */
  39526. inertialBetaOffset: number;
  39527. /**
  39528. * Current inertia value on the radius axis.
  39529. * The bigger this number the longer it will take for the camera to stop.
  39530. */
  39531. inertialRadiusOffset: number;
  39532. /**
  39533. * Minimum allowed angle on the longitudinal axis.
  39534. * This can help limiting how the Camera is able to move in the scene.
  39535. */
  39536. lowerAlphaLimit: Nullable<number>;
  39537. /**
  39538. * Maximum allowed angle on the longitudinal axis.
  39539. * This can help limiting how the Camera is able to move in the scene.
  39540. */
  39541. upperAlphaLimit: Nullable<number>;
  39542. /**
  39543. * Minimum allowed angle on the latitudinal axis.
  39544. * This can help limiting how the Camera is able to move in the scene.
  39545. */
  39546. lowerBetaLimit: number;
  39547. /**
  39548. * Maximum allowed angle on the latitudinal axis.
  39549. * This can help limiting how the Camera is able to move in the scene.
  39550. */
  39551. upperBetaLimit: number;
  39552. /**
  39553. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39554. * This can help limiting how the Camera is able to move in the scene.
  39555. */
  39556. lowerRadiusLimit: Nullable<number>;
  39557. /**
  39558. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39559. * This can help limiting how the Camera is able to move in the scene.
  39560. */
  39561. upperRadiusLimit: Nullable<number>;
  39562. /**
  39563. * Defines the current inertia value used during panning of the camera along the X axis.
  39564. */
  39565. inertialPanningX: number;
  39566. /**
  39567. * Defines the current inertia value used during panning of the camera along the Y axis.
  39568. */
  39569. inertialPanningY: number;
  39570. /**
  39571. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39572. * Basically if your fingers moves away from more than this distance you will be considered
  39573. * in pinch mode.
  39574. */
  39575. pinchToPanMaxDistance: number;
  39576. /**
  39577. * Defines the maximum distance the camera can pan.
  39578. * This could help keeping the cammera always in your scene.
  39579. */
  39580. panningDistanceLimit: Nullable<number>;
  39581. /**
  39582. * Defines the target of the camera before paning.
  39583. */
  39584. panningOriginTarget: Vector3;
  39585. /**
  39586. * Defines the value of the inertia used during panning.
  39587. * 0 would mean stop inertia and one would mean no decelleration at all.
  39588. */
  39589. panningInertia: number;
  39590. /**
  39591. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39592. */
  39593. get angularSensibilityX(): number;
  39594. set angularSensibilityX(value: number);
  39595. /**
  39596. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39597. */
  39598. get angularSensibilityY(): number;
  39599. set angularSensibilityY(value: number);
  39600. /**
  39601. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39602. */
  39603. get pinchPrecision(): number;
  39604. set pinchPrecision(value: number);
  39605. /**
  39606. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39607. * It will be used instead of pinchDeltaPrecision if different from 0.
  39608. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39609. */
  39610. get pinchDeltaPercentage(): number;
  39611. set pinchDeltaPercentage(value: number);
  39612. /**
  39613. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39614. */
  39615. get panningSensibility(): number;
  39616. set panningSensibility(value: number);
  39617. /**
  39618. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39619. */
  39620. get keysUp(): number[];
  39621. set keysUp(value: number[]);
  39622. /**
  39623. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39624. */
  39625. get keysDown(): number[];
  39626. set keysDown(value: number[]);
  39627. /**
  39628. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39629. */
  39630. get keysLeft(): number[];
  39631. set keysLeft(value: number[]);
  39632. /**
  39633. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39634. */
  39635. get keysRight(): number[];
  39636. set keysRight(value: number[]);
  39637. /**
  39638. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39639. */
  39640. get wheelPrecision(): number;
  39641. set wheelPrecision(value: number);
  39642. /**
  39643. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39644. * It will be used instead of pinchDeltaPrecision if different from 0.
  39645. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39646. */
  39647. get wheelDeltaPercentage(): number;
  39648. set wheelDeltaPercentage(value: number);
  39649. /**
  39650. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39651. */
  39652. zoomOnFactor: number;
  39653. /**
  39654. * Defines a screen offset for the camera position.
  39655. */
  39656. targetScreenOffset: Vector2;
  39657. /**
  39658. * Allows the camera to be completely reversed.
  39659. * If false the camera can not arrive upside down.
  39660. */
  39661. allowUpsideDown: boolean;
  39662. /**
  39663. * Define if double tap/click is used to restore the previously saved state of the camera.
  39664. */
  39665. useInputToRestoreState: boolean;
  39666. /** @hidden */
  39667. _viewMatrix: Matrix;
  39668. /** @hidden */
  39669. _useCtrlForPanning: boolean;
  39670. /** @hidden */
  39671. _panningMouseButton: number;
  39672. /**
  39673. * Defines the input associated to the camera.
  39674. */
  39675. inputs: ArcRotateCameraInputsManager;
  39676. /** @hidden */
  39677. _reset: () => void;
  39678. /**
  39679. * Defines the allowed panning axis.
  39680. */
  39681. panningAxis: Vector3;
  39682. protected _localDirection: Vector3;
  39683. protected _transformedDirection: Vector3;
  39684. private _bouncingBehavior;
  39685. /**
  39686. * Gets the bouncing behavior of the camera if it has been enabled.
  39687. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39688. */
  39689. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39690. /**
  39691. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39692. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39693. */
  39694. get useBouncingBehavior(): boolean;
  39695. set useBouncingBehavior(value: boolean);
  39696. private _framingBehavior;
  39697. /**
  39698. * Gets the framing behavior of the camera if it has been enabled.
  39699. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39700. */
  39701. get framingBehavior(): Nullable<FramingBehavior>;
  39702. /**
  39703. * Defines if the framing behavior of the camera is enabled on the camera.
  39704. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39705. */
  39706. get useFramingBehavior(): boolean;
  39707. set useFramingBehavior(value: boolean);
  39708. private _autoRotationBehavior;
  39709. /**
  39710. * Gets the auto rotation behavior of the camera if it has been enabled.
  39711. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39712. */
  39713. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39714. /**
  39715. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39716. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39717. */
  39718. get useAutoRotationBehavior(): boolean;
  39719. set useAutoRotationBehavior(value: boolean);
  39720. /**
  39721. * Observable triggered when the mesh target has been changed on the camera.
  39722. */
  39723. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39724. /**
  39725. * Event raised when the camera is colliding with a mesh.
  39726. */
  39727. onCollide: (collidedMesh: AbstractMesh) => void;
  39728. /**
  39729. * Defines whether the camera should check collision with the objects oh the scene.
  39730. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39731. */
  39732. checkCollisions: boolean;
  39733. /**
  39734. * Defines the collision radius of the camera.
  39735. * This simulates a sphere around the camera.
  39736. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39737. */
  39738. collisionRadius: Vector3;
  39739. protected _collider: Collider;
  39740. protected _previousPosition: Vector3;
  39741. protected _collisionVelocity: Vector3;
  39742. protected _newPosition: Vector3;
  39743. protected _previousAlpha: number;
  39744. protected _previousBeta: number;
  39745. protected _previousRadius: number;
  39746. protected _collisionTriggered: boolean;
  39747. protected _targetBoundingCenter: Nullable<Vector3>;
  39748. private _computationVector;
  39749. /**
  39750. * Instantiates a new ArcRotateCamera in a given scene
  39751. * @param name Defines the name of the camera
  39752. * @param alpha Defines the camera rotation along the logitudinal axis
  39753. * @param beta Defines the camera rotation along the latitudinal axis
  39754. * @param radius Defines the camera distance from its target
  39755. * @param target Defines the camera target
  39756. * @param scene Defines the scene the camera belongs to
  39757. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39758. */
  39759. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39760. /** @hidden */
  39761. _initCache(): void;
  39762. /** @hidden */
  39763. _updateCache(ignoreParentClass?: boolean): void;
  39764. protected _getTargetPosition(): Vector3;
  39765. private _storedAlpha;
  39766. private _storedBeta;
  39767. private _storedRadius;
  39768. private _storedTarget;
  39769. private _storedTargetScreenOffset;
  39770. /**
  39771. * Stores the current state of the camera (alpha, beta, radius and target)
  39772. * @returns the camera itself
  39773. */
  39774. storeState(): Camera;
  39775. /**
  39776. * @hidden
  39777. * Restored camera state. You must call storeState() first
  39778. */
  39779. _restoreStateValues(): boolean;
  39780. /** @hidden */
  39781. _isSynchronizedViewMatrix(): boolean;
  39782. /**
  39783. * Attached controls to the current camera.
  39784. * @param element Defines the element the controls should be listened from
  39785. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39786. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  39787. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  39788. */
  39789. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  39790. /**
  39791. * Detach the current controls from the camera.
  39792. * The camera will stop reacting to inputs.
  39793. * @param element Defines the element to stop listening the inputs from
  39794. */
  39795. detachControl(element: HTMLElement): void;
  39796. /** @hidden */
  39797. _checkInputs(): void;
  39798. protected _checkLimits(): void;
  39799. /**
  39800. * Rebuilds angles (alpha, beta) and radius from the give position and target
  39801. */
  39802. rebuildAnglesAndRadius(): void;
  39803. /**
  39804. * Use a position to define the current camera related information like alpha, beta and radius
  39805. * @param position Defines the position to set the camera at
  39806. */
  39807. setPosition(position: Vector3): void;
  39808. /**
  39809. * Defines the target the camera should look at.
  39810. * This will automatically adapt alpha beta and radius to fit within the new target.
  39811. * @param target Defines the new target as a Vector or a mesh
  39812. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  39813. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  39814. */
  39815. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  39816. /** @hidden */
  39817. _getViewMatrix(): Matrix;
  39818. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  39819. /**
  39820. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  39821. * @param meshes Defines the mesh to zoom on
  39822. * @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)
  39823. */
  39824. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  39825. /**
  39826. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  39827. * The target will be changed but the radius
  39828. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  39829. * @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)
  39830. */
  39831. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  39832. min: Vector3;
  39833. max: Vector3;
  39834. distance: number;
  39835. }, doNotUpdateMaxZ?: boolean): void;
  39836. /**
  39837. * @override
  39838. * Override Camera.createRigCamera
  39839. */
  39840. createRigCamera(name: string, cameraIndex: number): Camera;
  39841. /**
  39842. * @hidden
  39843. * @override
  39844. * Override Camera._updateRigCameras
  39845. */
  39846. _updateRigCameras(): void;
  39847. /**
  39848. * Destroy the camera and release the current resources hold by it.
  39849. */
  39850. dispose(): void;
  39851. /**
  39852. * Gets the current object class name.
  39853. * @return the class name
  39854. */
  39855. getClassName(): string;
  39856. }
  39857. }
  39858. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  39859. import { Behavior } from "babylonjs/Behaviors/behavior";
  39860. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39861. /**
  39862. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  39863. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39864. */
  39865. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  39866. /**
  39867. * Gets the name of the behavior.
  39868. */
  39869. get name(): string;
  39870. private _zoomStopsAnimation;
  39871. private _idleRotationSpeed;
  39872. private _idleRotationWaitTime;
  39873. private _idleRotationSpinupTime;
  39874. /**
  39875. * Sets the flag that indicates if user zooming should stop animation.
  39876. */
  39877. set zoomStopsAnimation(flag: boolean);
  39878. /**
  39879. * Gets the flag that indicates if user zooming should stop animation.
  39880. */
  39881. get zoomStopsAnimation(): boolean;
  39882. /**
  39883. * Sets the default speed at which the camera rotates around the model.
  39884. */
  39885. set idleRotationSpeed(speed: number);
  39886. /**
  39887. * Gets the default speed at which the camera rotates around the model.
  39888. */
  39889. get idleRotationSpeed(): number;
  39890. /**
  39891. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  39892. */
  39893. set idleRotationWaitTime(time: number);
  39894. /**
  39895. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  39896. */
  39897. get idleRotationWaitTime(): number;
  39898. /**
  39899. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39900. */
  39901. set idleRotationSpinupTime(time: number);
  39902. /**
  39903. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  39904. */
  39905. get idleRotationSpinupTime(): number;
  39906. /**
  39907. * Gets a value indicating if the camera is currently rotating because of this behavior
  39908. */
  39909. get rotationInProgress(): boolean;
  39910. private _onPrePointerObservableObserver;
  39911. private _onAfterCheckInputsObserver;
  39912. private _attachedCamera;
  39913. private _isPointerDown;
  39914. private _lastFrameTime;
  39915. private _lastInteractionTime;
  39916. private _cameraRotationSpeed;
  39917. /**
  39918. * Initializes the behavior.
  39919. */
  39920. init(): void;
  39921. /**
  39922. * Attaches the behavior to its arc rotate camera.
  39923. * @param camera Defines the camera to attach the behavior to
  39924. */
  39925. attach(camera: ArcRotateCamera): void;
  39926. /**
  39927. * Detaches the behavior from its current arc rotate camera.
  39928. */
  39929. detach(): void;
  39930. /**
  39931. * Returns true if user is scrolling.
  39932. * @return true if user is scrolling.
  39933. */
  39934. private _userIsZooming;
  39935. private _lastFrameRadius;
  39936. private _shouldAnimationStopForInteraction;
  39937. /**
  39938. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39939. */
  39940. private _applyUserInteraction;
  39941. private _userIsMoving;
  39942. }
  39943. }
  39944. declare module "babylonjs/Behaviors/Cameras/index" {
  39945. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39946. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39947. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  39948. }
  39949. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  39950. import { Mesh } from "babylonjs/Meshes/mesh";
  39951. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39952. import { Behavior } from "babylonjs/Behaviors/behavior";
  39953. /**
  39954. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39955. */
  39956. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39957. private ui;
  39958. /**
  39959. * The name of the behavior
  39960. */
  39961. name: string;
  39962. /**
  39963. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39964. */
  39965. distanceAwayFromFace: number;
  39966. /**
  39967. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39968. */
  39969. distanceAwayFromBottomOfFace: number;
  39970. private _faceVectors;
  39971. private _target;
  39972. private _scene;
  39973. private _onRenderObserver;
  39974. private _tmpMatrix;
  39975. private _tmpVector;
  39976. /**
  39977. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39978. * @param ui The transform node that should be attched to the mesh
  39979. */
  39980. constructor(ui: TransformNode);
  39981. /**
  39982. * Initializes the behavior
  39983. */
  39984. init(): void;
  39985. private _closestFace;
  39986. private _zeroVector;
  39987. private _lookAtTmpMatrix;
  39988. private _lookAtToRef;
  39989. /**
  39990. * Attaches the AttachToBoxBehavior to the passed in mesh
  39991. * @param target The mesh that the specified node will be attached to
  39992. */
  39993. attach(target: Mesh): void;
  39994. /**
  39995. * Detaches the behavior from the mesh
  39996. */
  39997. detach(): void;
  39998. }
  39999. }
  40000. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40001. import { Behavior } from "babylonjs/Behaviors/behavior";
  40002. import { Mesh } from "babylonjs/Meshes/mesh";
  40003. /**
  40004. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40005. */
  40006. export class FadeInOutBehavior implements Behavior<Mesh> {
  40007. /**
  40008. * Time in milliseconds to delay before fading in (Default: 0)
  40009. */
  40010. delay: number;
  40011. /**
  40012. * Time in milliseconds for the mesh to fade in (Default: 300)
  40013. */
  40014. fadeInTime: number;
  40015. private _millisecondsPerFrame;
  40016. private _hovered;
  40017. private _hoverValue;
  40018. private _ownerNode;
  40019. /**
  40020. * Instatiates the FadeInOutBehavior
  40021. */
  40022. constructor();
  40023. /**
  40024. * The name of the behavior
  40025. */
  40026. get name(): string;
  40027. /**
  40028. * Initializes the behavior
  40029. */
  40030. init(): void;
  40031. /**
  40032. * Attaches the fade behavior on the passed in mesh
  40033. * @param ownerNode The mesh that will be faded in/out once attached
  40034. */
  40035. attach(ownerNode: Mesh): void;
  40036. /**
  40037. * Detaches the behavior from the mesh
  40038. */
  40039. detach(): void;
  40040. /**
  40041. * Triggers the mesh to begin fading in or out
  40042. * @param value if the object should fade in or out (true to fade in)
  40043. */
  40044. fadeIn(value: boolean): void;
  40045. private _update;
  40046. private _setAllVisibility;
  40047. }
  40048. }
  40049. declare module "babylonjs/Misc/pivotTools" {
  40050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40051. /**
  40052. * Class containing a set of static utilities functions for managing Pivots
  40053. * @hidden
  40054. */
  40055. export class PivotTools {
  40056. private static _PivotCached;
  40057. private static _OldPivotPoint;
  40058. private static _PivotTranslation;
  40059. private static _PivotTmpVector;
  40060. /** @hidden */
  40061. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40062. /** @hidden */
  40063. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40064. }
  40065. }
  40066. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40067. import { Scene } from "babylonjs/scene";
  40068. import { Vector4 } from "babylonjs/Maths/math.vector";
  40069. import { Mesh } from "babylonjs/Meshes/mesh";
  40070. import { Nullable } from "babylonjs/types";
  40071. import { Plane } from "babylonjs/Maths/math.plane";
  40072. /**
  40073. * Class containing static functions to help procedurally build meshes
  40074. */
  40075. export class PlaneBuilder {
  40076. /**
  40077. * Creates a plane mesh
  40078. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40079. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40080. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40084. * @param name defines the name of the mesh
  40085. * @param options defines the options used to create the mesh
  40086. * @param scene defines the hosting scene
  40087. * @returns the plane mesh
  40088. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40089. */
  40090. static CreatePlane(name: string, options: {
  40091. size?: number;
  40092. width?: number;
  40093. height?: number;
  40094. sideOrientation?: number;
  40095. frontUVs?: Vector4;
  40096. backUVs?: Vector4;
  40097. updatable?: boolean;
  40098. sourcePlane?: Plane;
  40099. }, scene?: Nullable<Scene>): Mesh;
  40100. }
  40101. }
  40102. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40103. import { Behavior } from "babylonjs/Behaviors/behavior";
  40104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40105. import { Observable } from "babylonjs/Misc/observable";
  40106. import { Vector3 } from "babylonjs/Maths/math.vector";
  40107. import { Ray } from "babylonjs/Culling/ray";
  40108. import "babylonjs/Meshes/Builders/planeBuilder";
  40109. /**
  40110. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40111. */
  40112. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40113. private static _AnyMouseID;
  40114. /**
  40115. * Abstract mesh the behavior is set on
  40116. */
  40117. attachedNode: AbstractMesh;
  40118. private _dragPlane;
  40119. private _scene;
  40120. private _pointerObserver;
  40121. private _beforeRenderObserver;
  40122. private static _planeScene;
  40123. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40124. /**
  40125. * 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)
  40126. */
  40127. maxDragAngle: number;
  40128. /**
  40129. * @hidden
  40130. */
  40131. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40132. /**
  40133. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40134. */
  40135. currentDraggingPointerID: number;
  40136. /**
  40137. * The last position where the pointer hit the drag plane in world space
  40138. */
  40139. lastDragPosition: Vector3;
  40140. /**
  40141. * If the behavior is currently in a dragging state
  40142. */
  40143. dragging: boolean;
  40144. /**
  40145. * 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)
  40146. */
  40147. dragDeltaRatio: number;
  40148. /**
  40149. * If the drag plane orientation should be updated during the dragging (Default: true)
  40150. */
  40151. updateDragPlane: boolean;
  40152. private _debugMode;
  40153. private _moving;
  40154. /**
  40155. * Fires each time the attached mesh is dragged with the pointer
  40156. * * delta between last drag position and current drag position in world space
  40157. * * dragDistance along the drag axis
  40158. * * dragPlaneNormal normal of the current drag plane used during the drag
  40159. * * dragPlanePoint in world space where the drag intersects the drag plane
  40160. */
  40161. onDragObservable: Observable<{
  40162. delta: Vector3;
  40163. dragPlanePoint: Vector3;
  40164. dragPlaneNormal: Vector3;
  40165. dragDistance: number;
  40166. pointerId: number;
  40167. }>;
  40168. /**
  40169. * Fires each time a drag begins (eg. mouse down on mesh)
  40170. */
  40171. onDragStartObservable: Observable<{
  40172. dragPlanePoint: Vector3;
  40173. pointerId: number;
  40174. }>;
  40175. /**
  40176. * Fires each time a drag ends (eg. mouse release after drag)
  40177. */
  40178. onDragEndObservable: Observable<{
  40179. dragPlanePoint: Vector3;
  40180. pointerId: number;
  40181. }>;
  40182. /**
  40183. * If the attached mesh should be moved when dragged
  40184. */
  40185. moveAttached: boolean;
  40186. /**
  40187. * If the drag behavior will react to drag events (Default: true)
  40188. */
  40189. enabled: boolean;
  40190. /**
  40191. * If pointer events should start and release the drag (Default: true)
  40192. */
  40193. startAndReleaseDragOnPointerEvents: boolean;
  40194. /**
  40195. * If camera controls should be detached during the drag
  40196. */
  40197. detachCameraControls: boolean;
  40198. /**
  40199. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40200. */
  40201. useObjectOrientationForDragging: boolean;
  40202. private _options;
  40203. /**
  40204. * Gets the options used by the behavior
  40205. */
  40206. get options(): {
  40207. dragAxis?: Vector3;
  40208. dragPlaneNormal?: Vector3;
  40209. };
  40210. /**
  40211. * Sets the options used by the behavior
  40212. */
  40213. set options(options: {
  40214. dragAxis?: Vector3;
  40215. dragPlaneNormal?: Vector3;
  40216. });
  40217. /**
  40218. * Creates a pointer drag behavior that can be attached to a mesh
  40219. * @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)
  40220. */
  40221. constructor(options?: {
  40222. dragAxis?: Vector3;
  40223. dragPlaneNormal?: Vector3;
  40224. });
  40225. /**
  40226. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40227. */
  40228. validateDrag: (targetPosition: Vector3) => boolean;
  40229. /**
  40230. * The name of the behavior
  40231. */
  40232. get name(): string;
  40233. /**
  40234. * Initializes the behavior
  40235. */
  40236. init(): void;
  40237. private _tmpVector;
  40238. private _alternatePickedPoint;
  40239. private _worldDragAxis;
  40240. private _targetPosition;
  40241. private _attachedElement;
  40242. /**
  40243. * Attaches the drag behavior the passed in mesh
  40244. * @param ownerNode The mesh that will be dragged around once attached
  40245. * @param predicate Predicate to use for pick filtering
  40246. */
  40247. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40248. /**
  40249. * Force relase the drag action by code.
  40250. */
  40251. releaseDrag(): void;
  40252. private _startDragRay;
  40253. private _lastPointerRay;
  40254. /**
  40255. * Simulates the start of a pointer drag event on the behavior
  40256. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40257. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40258. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40259. */
  40260. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40261. private _startDrag;
  40262. private _dragDelta;
  40263. private _moveDrag;
  40264. private _pickWithRayOnDragPlane;
  40265. private _pointA;
  40266. private _pointB;
  40267. private _pointC;
  40268. private _lineA;
  40269. private _lineB;
  40270. private _localAxis;
  40271. private _lookAt;
  40272. private _updateDragPlanePosition;
  40273. /**
  40274. * Detaches the behavior from the mesh
  40275. */
  40276. detach(): void;
  40277. }
  40278. }
  40279. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40280. import { Mesh } from "babylonjs/Meshes/mesh";
  40281. import { Behavior } from "babylonjs/Behaviors/behavior";
  40282. /**
  40283. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40284. */
  40285. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40286. private _dragBehaviorA;
  40287. private _dragBehaviorB;
  40288. private _startDistance;
  40289. private _initialScale;
  40290. private _targetScale;
  40291. private _ownerNode;
  40292. private _sceneRenderObserver;
  40293. /**
  40294. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40295. */
  40296. constructor();
  40297. /**
  40298. * The name of the behavior
  40299. */
  40300. get name(): string;
  40301. /**
  40302. * Initializes the behavior
  40303. */
  40304. init(): void;
  40305. private _getCurrentDistance;
  40306. /**
  40307. * Attaches the scale behavior the passed in mesh
  40308. * @param ownerNode The mesh that will be scaled around once attached
  40309. */
  40310. attach(ownerNode: Mesh): void;
  40311. /**
  40312. * Detaches the behavior from the mesh
  40313. */
  40314. detach(): void;
  40315. }
  40316. }
  40317. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40318. import { Behavior } from "babylonjs/Behaviors/behavior";
  40319. import { Mesh } from "babylonjs/Meshes/mesh";
  40320. import { Observable } from "babylonjs/Misc/observable";
  40321. /**
  40322. * 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
  40323. */
  40324. export class SixDofDragBehavior implements Behavior<Mesh> {
  40325. private static _virtualScene;
  40326. private _ownerNode;
  40327. private _sceneRenderObserver;
  40328. private _scene;
  40329. private _targetPosition;
  40330. private _virtualOriginMesh;
  40331. private _virtualDragMesh;
  40332. private _pointerObserver;
  40333. private _moving;
  40334. private _startingOrientation;
  40335. /**
  40336. * 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)
  40337. */
  40338. private zDragFactor;
  40339. /**
  40340. * If the object should rotate to face the drag origin
  40341. */
  40342. rotateDraggedObject: boolean;
  40343. /**
  40344. * If the behavior is currently in a dragging state
  40345. */
  40346. dragging: boolean;
  40347. /**
  40348. * 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)
  40349. */
  40350. dragDeltaRatio: number;
  40351. /**
  40352. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40353. */
  40354. currentDraggingPointerID: number;
  40355. /**
  40356. * If camera controls should be detached during the drag
  40357. */
  40358. detachCameraControls: boolean;
  40359. /**
  40360. * Fires each time a drag starts
  40361. */
  40362. onDragStartObservable: Observable<{}>;
  40363. /**
  40364. * Fires each time a drag ends (eg. mouse release after drag)
  40365. */
  40366. onDragEndObservable: Observable<{}>;
  40367. /**
  40368. * 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
  40369. */
  40370. constructor();
  40371. /**
  40372. * The name of the behavior
  40373. */
  40374. get name(): string;
  40375. /**
  40376. * Initializes the behavior
  40377. */
  40378. init(): void;
  40379. /**
  40380. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40381. */
  40382. private get _pointerCamera();
  40383. /**
  40384. * Attaches the scale behavior the passed in mesh
  40385. * @param ownerNode The mesh that will be scaled around once attached
  40386. */
  40387. attach(ownerNode: Mesh): void;
  40388. /**
  40389. * Detaches the behavior from the mesh
  40390. */
  40391. detach(): void;
  40392. }
  40393. }
  40394. declare module "babylonjs/Behaviors/Meshes/index" {
  40395. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40396. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40397. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40398. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40399. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40400. }
  40401. declare module "babylonjs/Behaviors/index" {
  40402. export * from "babylonjs/Behaviors/behavior";
  40403. export * from "babylonjs/Behaviors/Cameras/index";
  40404. export * from "babylonjs/Behaviors/Meshes/index";
  40405. }
  40406. declare module "babylonjs/Bones/boneIKController" {
  40407. import { Bone } from "babylonjs/Bones/bone";
  40408. import { Vector3 } from "babylonjs/Maths/math.vector";
  40409. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40410. import { Nullable } from "babylonjs/types";
  40411. /**
  40412. * Class used to apply inverse kinematics to bones
  40413. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40414. */
  40415. export class BoneIKController {
  40416. private static _tmpVecs;
  40417. private static _tmpQuat;
  40418. private static _tmpMats;
  40419. /**
  40420. * Gets or sets the target mesh
  40421. */
  40422. targetMesh: AbstractMesh;
  40423. /** Gets or sets the mesh used as pole */
  40424. poleTargetMesh: AbstractMesh;
  40425. /**
  40426. * Gets or sets the bone used as pole
  40427. */
  40428. poleTargetBone: Nullable<Bone>;
  40429. /**
  40430. * Gets or sets the target position
  40431. */
  40432. targetPosition: Vector3;
  40433. /**
  40434. * Gets or sets the pole target position
  40435. */
  40436. poleTargetPosition: Vector3;
  40437. /**
  40438. * Gets or sets the pole target local offset
  40439. */
  40440. poleTargetLocalOffset: Vector3;
  40441. /**
  40442. * Gets or sets the pole angle
  40443. */
  40444. poleAngle: number;
  40445. /**
  40446. * Gets or sets the mesh associated with the controller
  40447. */
  40448. mesh: AbstractMesh;
  40449. /**
  40450. * 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)
  40451. */
  40452. slerpAmount: number;
  40453. private _bone1Quat;
  40454. private _bone1Mat;
  40455. private _bone2Ang;
  40456. private _bone1;
  40457. private _bone2;
  40458. private _bone1Length;
  40459. private _bone2Length;
  40460. private _maxAngle;
  40461. private _maxReach;
  40462. private _rightHandedSystem;
  40463. private _bendAxis;
  40464. private _slerping;
  40465. private _adjustRoll;
  40466. /**
  40467. * Gets or sets maximum allowed angle
  40468. */
  40469. get maxAngle(): number;
  40470. set maxAngle(value: number);
  40471. /**
  40472. * Creates a new BoneIKController
  40473. * @param mesh defines the mesh to control
  40474. * @param bone defines the bone to control
  40475. * @param options defines options to set up the controller
  40476. */
  40477. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40478. targetMesh?: AbstractMesh;
  40479. poleTargetMesh?: AbstractMesh;
  40480. poleTargetBone?: Bone;
  40481. poleTargetLocalOffset?: Vector3;
  40482. poleAngle?: number;
  40483. bendAxis?: Vector3;
  40484. maxAngle?: number;
  40485. slerpAmount?: number;
  40486. });
  40487. private _setMaxAngle;
  40488. /**
  40489. * Force the controller to update the bones
  40490. */
  40491. update(): void;
  40492. }
  40493. }
  40494. declare module "babylonjs/Bones/boneLookController" {
  40495. import { Vector3 } from "babylonjs/Maths/math.vector";
  40496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40497. import { Bone } from "babylonjs/Bones/bone";
  40498. import { Space } from "babylonjs/Maths/math.axis";
  40499. /**
  40500. * Class used to make a bone look toward a point in space
  40501. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40502. */
  40503. export class BoneLookController {
  40504. private static _tmpVecs;
  40505. private static _tmpQuat;
  40506. private static _tmpMats;
  40507. /**
  40508. * The target Vector3 that the bone will look at
  40509. */
  40510. target: Vector3;
  40511. /**
  40512. * The mesh that the bone is attached to
  40513. */
  40514. mesh: AbstractMesh;
  40515. /**
  40516. * The bone that will be looking to the target
  40517. */
  40518. bone: Bone;
  40519. /**
  40520. * The up axis of the coordinate system that is used when the bone is rotated
  40521. */
  40522. upAxis: Vector3;
  40523. /**
  40524. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40525. */
  40526. upAxisSpace: Space;
  40527. /**
  40528. * Used to make an adjustment to the yaw of the bone
  40529. */
  40530. adjustYaw: number;
  40531. /**
  40532. * Used to make an adjustment to the pitch of the bone
  40533. */
  40534. adjustPitch: number;
  40535. /**
  40536. * Used to make an adjustment to the roll of the bone
  40537. */
  40538. adjustRoll: number;
  40539. /**
  40540. * 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)
  40541. */
  40542. slerpAmount: number;
  40543. private _minYaw;
  40544. private _maxYaw;
  40545. private _minPitch;
  40546. private _maxPitch;
  40547. private _minYawSin;
  40548. private _minYawCos;
  40549. private _maxYawSin;
  40550. private _maxYawCos;
  40551. private _midYawConstraint;
  40552. private _minPitchTan;
  40553. private _maxPitchTan;
  40554. private _boneQuat;
  40555. private _slerping;
  40556. private _transformYawPitch;
  40557. private _transformYawPitchInv;
  40558. private _firstFrameSkipped;
  40559. private _yawRange;
  40560. private _fowardAxis;
  40561. /**
  40562. * Gets or sets the minimum yaw angle that the bone can look to
  40563. */
  40564. get minYaw(): number;
  40565. set minYaw(value: number);
  40566. /**
  40567. * Gets or sets the maximum yaw angle that the bone can look to
  40568. */
  40569. get maxYaw(): number;
  40570. set maxYaw(value: number);
  40571. /**
  40572. * Gets or sets the minimum pitch angle that the bone can look to
  40573. */
  40574. get minPitch(): number;
  40575. set minPitch(value: number);
  40576. /**
  40577. * Gets or sets the maximum pitch angle that the bone can look to
  40578. */
  40579. get maxPitch(): number;
  40580. set maxPitch(value: number);
  40581. /**
  40582. * Create a BoneLookController
  40583. * @param mesh the mesh that the bone belongs to
  40584. * @param bone the bone that will be looking to the target
  40585. * @param target the target Vector3 to look at
  40586. * @param options optional settings:
  40587. * * maxYaw: the maximum angle the bone will yaw to
  40588. * * minYaw: the minimum angle the bone will yaw to
  40589. * * maxPitch: the maximum angle the bone will pitch to
  40590. * * minPitch: the minimum angle the bone will yaw to
  40591. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40592. * * upAxis: the up axis of the coordinate system
  40593. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40594. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40595. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40596. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40597. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40598. * * adjustRoll: used to make an adjustment to the roll of the bone
  40599. **/
  40600. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40601. maxYaw?: number;
  40602. minYaw?: number;
  40603. maxPitch?: number;
  40604. minPitch?: number;
  40605. slerpAmount?: number;
  40606. upAxis?: Vector3;
  40607. upAxisSpace?: Space;
  40608. yawAxis?: Vector3;
  40609. pitchAxis?: Vector3;
  40610. adjustYaw?: number;
  40611. adjustPitch?: number;
  40612. adjustRoll?: number;
  40613. });
  40614. /**
  40615. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40616. */
  40617. update(): void;
  40618. private _getAngleDiff;
  40619. private _getAngleBetween;
  40620. private _isAngleBetween;
  40621. }
  40622. }
  40623. declare module "babylonjs/Bones/index" {
  40624. export * from "babylonjs/Bones/bone";
  40625. export * from "babylonjs/Bones/boneIKController";
  40626. export * from "babylonjs/Bones/boneLookController";
  40627. export * from "babylonjs/Bones/skeleton";
  40628. }
  40629. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40630. import { Nullable } from "babylonjs/types";
  40631. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40632. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40633. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40634. /**
  40635. * Manage the gamepad inputs to control an arc rotate camera.
  40636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40637. */
  40638. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40639. /**
  40640. * Defines the camera the input is attached to.
  40641. */
  40642. camera: ArcRotateCamera;
  40643. /**
  40644. * Defines the gamepad the input is gathering event from.
  40645. */
  40646. gamepad: Nullable<Gamepad>;
  40647. /**
  40648. * Defines the gamepad rotation sensiblity.
  40649. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40650. */
  40651. gamepadRotationSensibility: number;
  40652. /**
  40653. * Defines the gamepad move sensiblity.
  40654. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40655. */
  40656. gamepadMoveSensibility: number;
  40657. private _yAxisScale;
  40658. /**
  40659. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40660. */
  40661. get invertYAxis(): boolean;
  40662. set invertYAxis(value: boolean);
  40663. private _onGamepadConnectedObserver;
  40664. private _onGamepadDisconnectedObserver;
  40665. /**
  40666. * Attach the input controls to a specific dom element to get the input from.
  40667. * @param element Defines the element the controls should be listened from
  40668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40669. */
  40670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40671. /**
  40672. * Detach the current controls from the specified dom element.
  40673. * @param element Defines the element to stop listening the inputs from
  40674. */
  40675. detachControl(element: Nullable<HTMLElement>): void;
  40676. /**
  40677. * Update the current camera state depending on the inputs that have been used this frame.
  40678. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40679. */
  40680. checkInputs(): void;
  40681. /**
  40682. * Gets the class name of the current intput.
  40683. * @returns the class name
  40684. */
  40685. getClassName(): string;
  40686. /**
  40687. * Get the friendly name associated with the input class.
  40688. * @returns the input friendly name
  40689. */
  40690. getSimpleName(): string;
  40691. }
  40692. }
  40693. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40694. import { Nullable } from "babylonjs/types";
  40695. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40696. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40697. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40698. interface ArcRotateCameraInputsManager {
  40699. /**
  40700. * Add orientation input support to the input manager.
  40701. * @returns the current input manager
  40702. */
  40703. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40704. }
  40705. }
  40706. /**
  40707. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40708. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40709. */
  40710. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40711. /**
  40712. * Defines the camera the input is attached to.
  40713. */
  40714. camera: ArcRotateCamera;
  40715. /**
  40716. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40717. */
  40718. alphaCorrection: number;
  40719. /**
  40720. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40721. */
  40722. gammaCorrection: number;
  40723. private _alpha;
  40724. private _gamma;
  40725. private _dirty;
  40726. private _deviceOrientationHandler;
  40727. /**
  40728. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40729. */
  40730. constructor();
  40731. /**
  40732. * Attach the input controls to a specific dom element to get the input from.
  40733. * @param element Defines the element the controls should be listened from
  40734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40735. */
  40736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40737. /** @hidden */
  40738. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40739. /**
  40740. * Update the current camera state depending on the inputs that have been used this frame.
  40741. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40742. */
  40743. checkInputs(): void;
  40744. /**
  40745. * Detach the current controls from the specified dom element.
  40746. * @param element Defines the element to stop listening the inputs from
  40747. */
  40748. detachControl(element: Nullable<HTMLElement>): void;
  40749. /**
  40750. * Gets the class name of the current intput.
  40751. * @returns the class name
  40752. */
  40753. getClassName(): string;
  40754. /**
  40755. * Get the friendly name associated with the input class.
  40756. * @returns the input friendly name
  40757. */
  40758. getSimpleName(): string;
  40759. }
  40760. }
  40761. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40762. import { Nullable } from "babylonjs/types";
  40763. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40764. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40765. /**
  40766. * Listen to mouse events to control the camera.
  40767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40768. */
  40769. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40770. /**
  40771. * Defines the camera the input is attached to.
  40772. */
  40773. camera: FlyCamera;
  40774. /**
  40775. * Defines if touch is enabled. (Default is true.)
  40776. */
  40777. touchEnabled: boolean;
  40778. /**
  40779. * Defines the buttons associated with the input to handle camera rotation.
  40780. */
  40781. buttons: number[];
  40782. /**
  40783. * Assign buttons for Yaw control.
  40784. */
  40785. buttonsYaw: number[];
  40786. /**
  40787. * Assign buttons for Pitch control.
  40788. */
  40789. buttonsPitch: number[];
  40790. /**
  40791. * Assign buttons for Roll control.
  40792. */
  40793. buttonsRoll: number[];
  40794. /**
  40795. * Detect if any button is being pressed while mouse is moved.
  40796. * -1 = Mouse locked.
  40797. * 0 = Left button.
  40798. * 1 = Middle Button.
  40799. * 2 = Right Button.
  40800. */
  40801. activeButton: number;
  40802. /**
  40803. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  40804. * Higher values reduce its sensitivity.
  40805. */
  40806. angularSensibility: number;
  40807. private _mousemoveCallback;
  40808. private _observer;
  40809. private _rollObserver;
  40810. private previousPosition;
  40811. private noPreventDefault;
  40812. private element;
  40813. /**
  40814. * Listen to mouse events to control the camera.
  40815. * @param touchEnabled Define if touch is enabled. (Default is true.)
  40816. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40817. */
  40818. constructor(touchEnabled?: boolean);
  40819. /**
  40820. * Attach the mouse control to the HTML DOM element.
  40821. * @param element Defines the element that listens to the input events.
  40822. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  40823. */
  40824. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40825. /**
  40826. * Detach the current controls from the specified dom element.
  40827. * @param element Defines the element to stop listening the inputs from
  40828. */
  40829. detachControl(element: Nullable<HTMLElement>): void;
  40830. /**
  40831. * Gets the class name of the current input.
  40832. * @returns the class name.
  40833. */
  40834. getClassName(): string;
  40835. /**
  40836. * Get the friendly name associated with the input class.
  40837. * @returns the input's friendly name.
  40838. */
  40839. getSimpleName(): string;
  40840. private _pointerInput;
  40841. private _onMouseMove;
  40842. /**
  40843. * Rotate camera by mouse offset.
  40844. */
  40845. private rotateCamera;
  40846. }
  40847. }
  40848. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  40849. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40850. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40851. /**
  40852. * Default Inputs manager for the FlyCamera.
  40853. * It groups all the default supported inputs for ease of use.
  40854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40855. */
  40856. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  40857. /**
  40858. * Instantiates a new FlyCameraInputsManager.
  40859. * @param camera Defines the camera the inputs belong to.
  40860. */
  40861. constructor(camera: FlyCamera);
  40862. /**
  40863. * Add keyboard input support to the input manager.
  40864. * @returns the new FlyCameraKeyboardMoveInput().
  40865. */
  40866. addKeyboard(): FlyCameraInputsManager;
  40867. /**
  40868. * Add mouse input support to the input manager.
  40869. * @param touchEnabled Enable touch screen support.
  40870. * @returns the new FlyCameraMouseInput().
  40871. */
  40872. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  40873. }
  40874. }
  40875. declare module "babylonjs/Cameras/flyCamera" {
  40876. import { Scene } from "babylonjs/scene";
  40877. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  40878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40879. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40880. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  40881. /**
  40882. * This is a flying camera, designed for 3D movement and rotation in all directions,
  40883. * such as in a 3D Space Shooter or a Flight Simulator.
  40884. */
  40885. export class FlyCamera extends TargetCamera {
  40886. /**
  40887. * Define the collision ellipsoid of the camera.
  40888. * This is helpful for simulating a camera body, like a player's body.
  40889. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40890. */
  40891. ellipsoid: Vector3;
  40892. /**
  40893. * Define an offset for the position of the ellipsoid around the camera.
  40894. * This can be helpful if the camera is attached away from the player's body center,
  40895. * such as at its head.
  40896. */
  40897. ellipsoidOffset: Vector3;
  40898. /**
  40899. * Enable or disable collisions of the camera with the rest of the scene objects.
  40900. */
  40901. checkCollisions: boolean;
  40902. /**
  40903. * Enable or disable gravity on the camera.
  40904. */
  40905. applyGravity: boolean;
  40906. /**
  40907. * Define the current direction the camera is moving to.
  40908. */
  40909. cameraDirection: Vector3;
  40910. /**
  40911. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  40912. * This overrides and empties cameraRotation.
  40913. */
  40914. rotationQuaternion: Quaternion;
  40915. /**
  40916. * Track Roll to maintain the wanted Rolling when looking around.
  40917. */
  40918. _trackRoll: number;
  40919. /**
  40920. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  40921. */
  40922. rollCorrect: number;
  40923. /**
  40924. * Mimic a banked turn, Rolling the camera when Yawing.
  40925. * It's recommended to use rollCorrect = 10 for faster banking correction.
  40926. */
  40927. bankedTurn: boolean;
  40928. /**
  40929. * Limit in radians for how much Roll banking will add. (Default: 90°)
  40930. */
  40931. bankedTurnLimit: number;
  40932. /**
  40933. * Value of 0 disables the banked Roll.
  40934. * Value of 1 is equal to the Yaw angle in radians.
  40935. */
  40936. bankedTurnMultiplier: number;
  40937. /**
  40938. * The inputs manager loads all the input sources, such as keyboard and mouse.
  40939. */
  40940. inputs: FlyCameraInputsManager;
  40941. /**
  40942. * Gets the input sensibility for mouse input.
  40943. * Higher values reduce sensitivity.
  40944. */
  40945. get angularSensibility(): number;
  40946. /**
  40947. * Sets the input sensibility for a mouse input.
  40948. * Higher values reduce sensitivity.
  40949. */
  40950. set angularSensibility(value: number);
  40951. /**
  40952. * Get the keys for camera movement forward.
  40953. */
  40954. get keysForward(): number[];
  40955. /**
  40956. * Set the keys for camera movement forward.
  40957. */
  40958. set keysForward(value: number[]);
  40959. /**
  40960. * Get the keys for camera movement backward.
  40961. */
  40962. get keysBackward(): number[];
  40963. set keysBackward(value: number[]);
  40964. /**
  40965. * Get the keys for camera movement up.
  40966. */
  40967. get keysUp(): number[];
  40968. /**
  40969. * Set the keys for camera movement up.
  40970. */
  40971. set keysUp(value: number[]);
  40972. /**
  40973. * Get the keys for camera movement down.
  40974. */
  40975. get keysDown(): number[];
  40976. /**
  40977. * Set the keys for camera movement down.
  40978. */
  40979. set keysDown(value: number[]);
  40980. /**
  40981. * Get the keys for camera movement left.
  40982. */
  40983. get keysLeft(): number[];
  40984. /**
  40985. * Set the keys for camera movement left.
  40986. */
  40987. set keysLeft(value: number[]);
  40988. /**
  40989. * Set the keys for camera movement right.
  40990. */
  40991. get keysRight(): number[];
  40992. /**
  40993. * Set the keys for camera movement right.
  40994. */
  40995. set keysRight(value: number[]);
  40996. /**
  40997. * Event raised when the camera collides with a mesh in the scene.
  40998. */
  40999. onCollide: (collidedMesh: AbstractMesh) => void;
  41000. private _collider;
  41001. private _needMoveForGravity;
  41002. private _oldPosition;
  41003. private _diffPosition;
  41004. private _newPosition;
  41005. /** @hidden */
  41006. _localDirection: Vector3;
  41007. /** @hidden */
  41008. _transformedDirection: Vector3;
  41009. /**
  41010. * Instantiates a FlyCamera.
  41011. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41012. * such as in a 3D Space Shooter or a Flight Simulator.
  41013. * @param name Define the name of the camera in the scene.
  41014. * @param position Define the starting position of the camera in the scene.
  41015. * @param scene Define the scene the camera belongs to.
  41016. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41017. */
  41018. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41019. /**
  41020. * Attach a control to the HTML DOM element.
  41021. * @param element Defines the element that listens to the input events.
  41022. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41023. */
  41024. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41025. /**
  41026. * Detach a control from the HTML DOM element.
  41027. * The camera will stop reacting to that input.
  41028. * @param element Defines the element that listens to the input events.
  41029. */
  41030. detachControl(element: HTMLElement): void;
  41031. private _collisionMask;
  41032. /**
  41033. * Get the mask that the camera ignores in collision events.
  41034. */
  41035. get collisionMask(): number;
  41036. /**
  41037. * Set the mask that the camera ignores in collision events.
  41038. */
  41039. set collisionMask(mask: number);
  41040. /** @hidden */
  41041. _collideWithWorld(displacement: Vector3): void;
  41042. /** @hidden */
  41043. private _onCollisionPositionChange;
  41044. /** @hidden */
  41045. _checkInputs(): void;
  41046. /** @hidden */
  41047. _decideIfNeedsToMove(): boolean;
  41048. /** @hidden */
  41049. _updatePosition(): void;
  41050. /**
  41051. * Restore the Roll to its target value at the rate specified.
  41052. * @param rate - Higher means slower restoring.
  41053. * @hidden
  41054. */
  41055. restoreRoll(rate: number): void;
  41056. /**
  41057. * Destroy the camera and release the current resources held by it.
  41058. */
  41059. dispose(): void;
  41060. /**
  41061. * Get the current object class name.
  41062. * @returns the class name.
  41063. */
  41064. getClassName(): string;
  41065. }
  41066. }
  41067. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41068. import { Nullable } from "babylonjs/types";
  41069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41070. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41071. /**
  41072. * Listen to keyboard events to control the camera.
  41073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41074. */
  41075. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41076. /**
  41077. * Defines the camera the input is attached to.
  41078. */
  41079. camera: FlyCamera;
  41080. /**
  41081. * The list of keyboard keys used to control the forward move of the camera.
  41082. */
  41083. keysForward: number[];
  41084. /**
  41085. * The list of keyboard keys used to control the backward move of the camera.
  41086. */
  41087. keysBackward: number[];
  41088. /**
  41089. * The list of keyboard keys used to control the forward move of the camera.
  41090. */
  41091. keysUp: number[];
  41092. /**
  41093. * The list of keyboard keys used to control the backward move of the camera.
  41094. */
  41095. keysDown: number[];
  41096. /**
  41097. * The list of keyboard keys used to control the right strafe move of the camera.
  41098. */
  41099. keysRight: number[];
  41100. /**
  41101. * The list of keyboard keys used to control the left strafe move of the camera.
  41102. */
  41103. keysLeft: number[];
  41104. private _keys;
  41105. private _onCanvasBlurObserver;
  41106. private _onKeyboardObserver;
  41107. private _engine;
  41108. private _scene;
  41109. /**
  41110. * Attach the input controls to a specific dom element to get the input from.
  41111. * @param element Defines the element the controls should be listened from
  41112. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41113. */
  41114. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41115. /**
  41116. * Detach the current controls from the specified dom element.
  41117. * @param element Defines the element to stop listening the inputs from
  41118. */
  41119. detachControl(element: Nullable<HTMLElement>): void;
  41120. /**
  41121. * Gets the class name of the current intput.
  41122. * @returns the class name
  41123. */
  41124. getClassName(): string;
  41125. /** @hidden */
  41126. _onLostFocus(e: FocusEvent): void;
  41127. /**
  41128. * Get the friendly name associated with the input class.
  41129. * @returns the input friendly name
  41130. */
  41131. getSimpleName(): string;
  41132. /**
  41133. * Update the current camera state depending on the inputs that have been used this frame.
  41134. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41135. */
  41136. checkInputs(): void;
  41137. }
  41138. }
  41139. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41140. import { Nullable } from "babylonjs/types";
  41141. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41142. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41143. /**
  41144. * Manage the mouse wheel inputs to control a follow camera.
  41145. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41146. */
  41147. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41148. /**
  41149. * Defines the camera the input is attached to.
  41150. */
  41151. camera: FollowCamera;
  41152. /**
  41153. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41154. */
  41155. axisControlRadius: boolean;
  41156. /**
  41157. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41158. */
  41159. axisControlHeight: boolean;
  41160. /**
  41161. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41162. */
  41163. axisControlRotation: boolean;
  41164. /**
  41165. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41166. * relation to mouseWheel events.
  41167. */
  41168. wheelPrecision: number;
  41169. /**
  41170. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41171. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41172. */
  41173. wheelDeltaPercentage: number;
  41174. private _wheel;
  41175. private _observer;
  41176. /**
  41177. * Attach the input controls to a specific dom element to get the input from.
  41178. * @param element Defines the element the controls should be listened from
  41179. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41180. */
  41181. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41182. /**
  41183. * Detach the current controls from the specified dom element.
  41184. * @param element Defines the element to stop listening the inputs from
  41185. */
  41186. detachControl(element: Nullable<HTMLElement>): void;
  41187. /**
  41188. * Gets the class name of the current intput.
  41189. * @returns the class name
  41190. */
  41191. getClassName(): string;
  41192. /**
  41193. * Get the friendly name associated with the input class.
  41194. * @returns the input friendly name
  41195. */
  41196. getSimpleName(): string;
  41197. }
  41198. }
  41199. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41200. import { Nullable } from "babylonjs/types";
  41201. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41202. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41203. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41204. /**
  41205. * Manage the pointers inputs to control an follow camera.
  41206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41207. */
  41208. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41209. /**
  41210. * Defines the camera the input is attached to.
  41211. */
  41212. camera: FollowCamera;
  41213. /**
  41214. * Gets the class name of the current input.
  41215. * @returns the class name
  41216. */
  41217. getClassName(): string;
  41218. /**
  41219. * Defines the pointer angular sensibility along the X axis or how fast is
  41220. * the camera rotating.
  41221. * A negative number will reverse the axis direction.
  41222. */
  41223. angularSensibilityX: number;
  41224. /**
  41225. * Defines the pointer angular sensibility along the Y axis or how fast is
  41226. * the camera rotating.
  41227. * A negative number will reverse the axis direction.
  41228. */
  41229. angularSensibilityY: number;
  41230. /**
  41231. * Defines the pointer pinch precision or how fast is the camera zooming.
  41232. * A negative number will reverse the axis direction.
  41233. */
  41234. pinchPrecision: number;
  41235. /**
  41236. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41237. * from 0.
  41238. * It defines the percentage of current camera.radius to use as delta when
  41239. * pinch zoom is used.
  41240. */
  41241. pinchDeltaPercentage: number;
  41242. /**
  41243. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41244. */
  41245. axisXControlRadius: boolean;
  41246. /**
  41247. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41248. */
  41249. axisXControlHeight: boolean;
  41250. /**
  41251. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41252. */
  41253. axisXControlRotation: boolean;
  41254. /**
  41255. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41256. */
  41257. axisYControlRadius: boolean;
  41258. /**
  41259. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41260. */
  41261. axisYControlHeight: boolean;
  41262. /**
  41263. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41264. */
  41265. axisYControlRotation: boolean;
  41266. /**
  41267. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41268. */
  41269. axisPinchControlRadius: boolean;
  41270. /**
  41271. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41272. */
  41273. axisPinchControlHeight: boolean;
  41274. /**
  41275. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41276. */
  41277. axisPinchControlRotation: boolean;
  41278. /**
  41279. * Log error messages if basic misconfiguration has occurred.
  41280. */
  41281. warningEnable: boolean;
  41282. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41283. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41284. private _warningCounter;
  41285. private _warning;
  41286. }
  41287. }
  41288. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41289. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41290. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41291. /**
  41292. * Default Inputs manager for the FollowCamera.
  41293. * It groups all the default supported inputs for ease of use.
  41294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41295. */
  41296. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41297. /**
  41298. * Instantiates a new FollowCameraInputsManager.
  41299. * @param camera Defines the camera the inputs belong to
  41300. */
  41301. constructor(camera: FollowCamera);
  41302. /**
  41303. * Add keyboard input support to the input manager.
  41304. * @returns the current input manager
  41305. */
  41306. addKeyboard(): FollowCameraInputsManager;
  41307. /**
  41308. * Add mouse wheel input support to the input manager.
  41309. * @returns the current input manager
  41310. */
  41311. addMouseWheel(): FollowCameraInputsManager;
  41312. /**
  41313. * Add pointers input support to the input manager.
  41314. * @returns the current input manager
  41315. */
  41316. addPointers(): FollowCameraInputsManager;
  41317. /**
  41318. * Add orientation input support to the input manager.
  41319. * @returns the current input manager
  41320. */
  41321. addVRDeviceOrientation(): FollowCameraInputsManager;
  41322. }
  41323. }
  41324. declare module "babylonjs/Cameras/followCamera" {
  41325. import { Nullable } from "babylonjs/types";
  41326. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41327. import { Scene } from "babylonjs/scene";
  41328. import { Vector3 } from "babylonjs/Maths/math.vector";
  41329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41330. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41331. /**
  41332. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41333. * an arc rotate version arcFollowCamera are available.
  41334. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41335. */
  41336. export class FollowCamera extends TargetCamera {
  41337. /**
  41338. * Distance the follow camera should follow an object at
  41339. */
  41340. radius: number;
  41341. /**
  41342. * Minimum allowed distance of the camera to the axis of rotation
  41343. * (The camera can not get closer).
  41344. * This can help limiting how the Camera is able to move in the scene.
  41345. */
  41346. lowerRadiusLimit: Nullable<number>;
  41347. /**
  41348. * Maximum allowed distance of the camera to the axis of rotation
  41349. * (The camera can not get further).
  41350. * This can help limiting how the Camera is able to move in the scene.
  41351. */
  41352. upperRadiusLimit: Nullable<number>;
  41353. /**
  41354. * Define a rotation offset between the camera and the object it follows
  41355. */
  41356. rotationOffset: number;
  41357. /**
  41358. * Minimum allowed angle to camera position relative to target object.
  41359. * This can help limiting how the Camera is able to move in the scene.
  41360. */
  41361. lowerRotationOffsetLimit: Nullable<number>;
  41362. /**
  41363. * Maximum allowed angle to camera position relative to target object.
  41364. * This can help limiting how the Camera is able to move in the scene.
  41365. */
  41366. upperRotationOffsetLimit: Nullable<number>;
  41367. /**
  41368. * Define a height offset between the camera and the object it follows.
  41369. * It can help following an object from the top (like a car chaing a plane)
  41370. */
  41371. heightOffset: number;
  41372. /**
  41373. * Minimum allowed height of camera position relative to target object.
  41374. * This can help limiting how the Camera is able to move in the scene.
  41375. */
  41376. lowerHeightOffsetLimit: Nullable<number>;
  41377. /**
  41378. * Maximum allowed height of camera position relative to target object.
  41379. * This can help limiting how the Camera is able to move in the scene.
  41380. */
  41381. upperHeightOffsetLimit: Nullable<number>;
  41382. /**
  41383. * Define how fast the camera can accelerate to follow it s target.
  41384. */
  41385. cameraAcceleration: number;
  41386. /**
  41387. * Define the speed limit of the camera following an object.
  41388. */
  41389. maxCameraSpeed: number;
  41390. /**
  41391. * Define the target of the camera.
  41392. */
  41393. lockedTarget: Nullable<AbstractMesh>;
  41394. /**
  41395. * Defines the input associated with the camera.
  41396. */
  41397. inputs: FollowCameraInputsManager;
  41398. /**
  41399. * Instantiates the follow camera.
  41400. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41401. * @param name Define the name of the camera in the scene
  41402. * @param position Define the position of the camera
  41403. * @param scene Define the scene the camera belong to
  41404. * @param lockedTarget Define the target of the camera
  41405. */
  41406. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41407. private _follow;
  41408. /**
  41409. * Attached controls to the current camera.
  41410. * @param element Defines the element the controls should be listened from
  41411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41412. */
  41413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41414. /**
  41415. * Detach the current controls from the camera.
  41416. * The camera will stop reacting to inputs.
  41417. * @param element Defines the element to stop listening the inputs from
  41418. */
  41419. detachControl(element: HTMLElement): void;
  41420. /** @hidden */
  41421. _checkInputs(): void;
  41422. private _checkLimits;
  41423. /**
  41424. * Gets the camera class name.
  41425. * @returns the class name
  41426. */
  41427. getClassName(): string;
  41428. }
  41429. /**
  41430. * Arc Rotate version of the follow camera.
  41431. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41432. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41433. */
  41434. export class ArcFollowCamera extends TargetCamera {
  41435. /** The longitudinal angle of the camera */
  41436. alpha: number;
  41437. /** The latitudinal angle of the camera */
  41438. beta: number;
  41439. /** The radius of the camera from its target */
  41440. radius: number;
  41441. /** Define the camera target (the messh it should follow) */
  41442. target: Nullable<AbstractMesh>;
  41443. private _cartesianCoordinates;
  41444. /**
  41445. * Instantiates a new ArcFollowCamera
  41446. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41447. * @param name Define the name of the camera
  41448. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41449. * @param beta Define the rotation angle of the camera around the elevation axis
  41450. * @param radius Define the radius of the camera from its target point
  41451. * @param target Define the target of the camera
  41452. * @param scene Define the scene the camera belongs to
  41453. */
  41454. constructor(name: string,
  41455. /** The longitudinal angle of the camera */
  41456. alpha: number,
  41457. /** The latitudinal angle of the camera */
  41458. beta: number,
  41459. /** The radius of the camera from its target */
  41460. radius: number,
  41461. /** Define the camera target (the messh it should follow) */
  41462. target: Nullable<AbstractMesh>, scene: Scene);
  41463. private _follow;
  41464. /** @hidden */
  41465. _checkInputs(): void;
  41466. /**
  41467. * Returns the class name of the object.
  41468. * It is mostly used internally for serialization purposes.
  41469. */
  41470. getClassName(): string;
  41471. }
  41472. }
  41473. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41474. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41475. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41476. import { Nullable } from "babylonjs/types";
  41477. /**
  41478. * Manage the keyboard inputs to control the movement of a follow camera.
  41479. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41480. */
  41481. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41482. /**
  41483. * Defines the camera the input is attached to.
  41484. */
  41485. camera: FollowCamera;
  41486. /**
  41487. * Defines the list of key codes associated with the up action (increase heightOffset)
  41488. */
  41489. keysHeightOffsetIncr: number[];
  41490. /**
  41491. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41492. */
  41493. keysHeightOffsetDecr: number[];
  41494. /**
  41495. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41496. */
  41497. keysHeightOffsetModifierAlt: boolean;
  41498. /**
  41499. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41500. */
  41501. keysHeightOffsetModifierCtrl: boolean;
  41502. /**
  41503. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41504. */
  41505. keysHeightOffsetModifierShift: boolean;
  41506. /**
  41507. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41508. */
  41509. keysRotationOffsetIncr: number[];
  41510. /**
  41511. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41512. */
  41513. keysRotationOffsetDecr: number[];
  41514. /**
  41515. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41516. */
  41517. keysRotationOffsetModifierAlt: boolean;
  41518. /**
  41519. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41520. */
  41521. keysRotationOffsetModifierCtrl: boolean;
  41522. /**
  41523. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41524. */
  41525. keysRotationOffsetModifierShift: boolean;
  41526. /**
  41527. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41528. */
  41529. keysRadiusIncr: number[];
  41530. /**
  41531. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41532. */
  41533. keysRadiusDecr: number[];
  41534. /**
  41535. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41536. */
  41537. keysRadiusModifierAlt: boolean;
  41538. /**
  41539. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41540. */
  41541. keysRadiusModifierCtrl: boolean;
  41542. /**
  41543. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41544. */
  41545. keysRadiusModifierShift: boolean;
  41546. /**
  41547. * Defines the rate of change of heightOffset.
  41548. */
  41549. heightSensibility: number;
  41550. /**
  41551. * Defines the rate of change of rotationOffset.
  41552. */
  41553. rotationSensibility: number;
  41554. /**
  41555. * Defines the rate of change of radius.
  41556. */
  41557. radiusSensibility: number;
  41558. private _keys;
  41559. private _ctrlPressed;
  41560. private _altPressed;
  41561. private _shiftPressed;
  41562. private _onCanvasBlurObserver;
  41563. private _onKeyboardObserver;
  41564. private _engine;
  41565. private _scene;
  41566. /**
  41567. * Attach the input controls to a specific dom element to get the input from.
  41568. * @param element Defines the element the controls should be listened from
  41569. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41570. */
  41571. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41572. /**
  41573. * Detach the current controls from the specified dom element.
  41574. * @param element Defines the element to stop listening the inputs from
  41575. */
  41576. detachControl(element: Nullable<HTMLElement>): void;
  41577. /**
  41578. * Update the current camera state depending on the inputs that have been used this frame.
  41579. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41580. */
  41581. checkInputs(): void;
  41582. /**
  41583. * Gets the class name of the current input.
  41584. * @returns the class name
  41585. */
  41586. getClassName(): string;
  41587. /**
  41588. * Get the friendly name associated with the input class.
  41589. * @returns the input friendly name
  41590. */
  41591. getSimpleName(): string;
  41592. /**
  41593. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41594. * allow modification of the heightOffset value.
  41595. */
  41596. private _modifierHeightOffset;
  41597. /**
  41598. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41599. * allow modification of the rotationOffset value.
  41600. */
  41601. private _modifierRotationOffset;
  41602. /**
  41603. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41604. * allow modification of the radius value.
  41605. */
  41606. private _modifierRadius;
  41607. }
  41608. }
  41609. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41610. import { Nullable } from "babylonjs/types";
  41611. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41612. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41613. import { Observable } from "babylonjs/Misc/observable";
  41614. module "babylonjs/Cameras/freeCameraInputsManager" {
  41615. interface FreeCameraInputsManager {
  41616. /**
  41617. * @hidden
  41618. */
  41619. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41620. /**
  41621. * Add orientation input support to the input manager.
  41622. * @returns the current input manager
  41623. */
  41624. addDeviceOrientation(): FreeCameraInputsManager;
  41625. }
  41626. }
  41627. /**
  41628. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41629. * Screen rotation is taken into account.
  41630. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41631. */
  41632. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41633. private _camera;
  41634. private _screenOrientationAngle;
  41635. private _constantTranform;
  41636. private _screenQuaternion;
  41637. private _alpha;
  41638. private _beta;
  41639. private _gamma;
  41640. /**
  41641. * Can be used to detect if a device orientation sensor is available on a device
  41642. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41643. * @returns a promise that will resolve on orientation change
  41644. */
  41645. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41646. /**
  41647. * @hidden
  41648. */
  41649. _onDeviceOrientationChangedObservable: Observable<void>;
  41650. /**
  41651. * Instantiates a new input
  41652. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41653. */
  41654. constructor();
  41655. /**
  41656. * Define the camera controlled by the input.
  41657. */
  41658. get camera(): FreeCamera;
  41659. set camera(camera: FreeCamera);
  41660. /**
  41661. * Attach the input controls to a specific dom element to get the input from.
  41662. * @param element Defines the element the controls should be listened from
  41663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41664. */
  41665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41666. private _orientationChanged;
  41667. private _deviceOrientation;
  41668. /**
  41669. * Detach the current controls from the specified dom element.
  41670. * @param element Defines the element to stop listening the inputs from
  41671. */
  41672. detachControl(element: Nullable<HTMLElement>): void;
  41673. /**
  41674. * Update the current camera state depending on the inputs that have been used this frame.
  41675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41676. */
  41677. checkInputs(): void;
  41678. /**
  41679. * Gets the class name of the current intput.
  41680. * @returns the class name
  41681. */
  41682. getClassName(): string;
  41683. /**
  41684. * Get the friendly name associated with the input class.
  41685. * @returns the input friendly name
  41686. */
  41687. getSimpleName(): string;
  41688. }
  41689. }
  41690. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41691. import { Nullable } from "babylonjs/types";
  41692. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41693. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41694. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41695. /**
  41696. * Manage the gamepad inputs to control a free camera.
  41697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41698. */
  41699. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41700. /**
  41701. * Define the camera the input is attached to.
  41702. */
  41703. camera: FreeCamera;
  41704. /**
  41705. * Define the Gamepad controlling the input
  41706. */
  41707. gamepad: Nullable<Gamepad>;
  41708. /**
  41709. * Defines the gamepad rotation sensiblity.
  41710. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41711. */
  41712. gamepadAngularSensibility: number;
  41713. /**
  41714. * Defines the gamepad move sensiblity.
  41715. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41716. */
  41717. gamepadMoveSensibility: number;
  41718. private _yAxisScale;
  41719. /**
  41720. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41721. */
  41722. get invertYAxis(): boolean;
  41723. set invertYAxis(value: boolean);
  41724. private _onGamepadConnectedObserver;
  41725. private _onGamepadDisconnectedObserver;
  41726. private _cameraTransform;
  41727. private _deltaTransform;
  41728. private _vector3;
  41729. private _vector2;
  41730. /**
  41731. * Attach the input controls to a specific dom element to get the input from.
  41732. * @param element Defines the element the controls should be listened from
  41733. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41734. */
  41735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41736. /**
  41737. * Detach the current controls from the specified dom element.
  41738. * @param element Defines the element to stop listening the inputs from
  41739. */
  41740. detachControl(element: Nullable<HTMLElement>): void;
  41741. /**
  41742. * Update the current camera state depending on the inputs that have been used this frame.
  41743. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41744. */
  41745. checkInputs(): void;
  41746. /**
  41747. * Gets the class name of the current intput.
  41748. * @returns the class name
  41749. */
  41750. getClassName(): string;
  41751. /**
  41752. * Get the friendly name associated with the input class.
  41753. * @returns the input friendly name
  41754. */
  41755. getSimpleName(): string;
  41756. }
  41757. }
  41758. declare module "babylonjs/Misc/virtualJoystick" {
  41759. import { Nullable } from "babylonjs/types";
  41760. import { Vector3 } from "babylonjs/Maths/math.vector";
  41761. /**
  41762. * Defines the potential axis of a Joystick
  41763. */
  41764. export enum JoystickAxis {
  41765. /** X axis */
  41766. X = 0,
  41767. /** Y axis */
  41768. Y = 1,
  41769. /** Z axis */
  41770. Z = 2
  41771. }
  41772. /**
  41773. * Class used to define virtual joystick (used in touch mode)
  41774. */
  41775. export class VirtualJoystick {
  41776. /**
  41777. * Gets or sets a boolean indicating that left and right values must be inverted
  41778. */
  41779. reverseLeftRight: boolean;
  41780. /**
  41781. * Gets or sets a boolean indicating that up and down values must be inverted
  41782. */
  41783. reverseUpDown: boolean;
  41784. /**
  41785. * Gets the offset value for the position (ie. the change of the position value)
  41786. */
  41787. deltaPosition: Vector3;
  41788. /**
  41789. * Gets a boolean indicating if the virtual joystick was pressed
  41790. */
  41791. pressed: boolean;
  41792. /**
  41793. * Canvas the virtual joystick will render onto, default z-index of this is 5
  41794. */
  41795. static Canvas: Nullable<HTMLCanvasElement>;
  41796. private static _globalJoystickIndex;
  41797. private static vjCanvasContext;
  41798. private static vjCanvasWidth;
  41799. private static vjCanvasHeight;
  41800. private static halfWidth;
  41801. private _action;
  41802. private _axisTargetedByLeftAndRight;
  41803. private _axisTargetedByUpAndDown;
  41804. private _joystickSensibility;
  41805. private _inversedSensibility;
  41806. private _joystickPointerID;
  41807. private _joystickColor;
  41808. private _joystickPointerPos;
  41809. private _joystickPreviousPointerPos;
  41810. private _joystickPointerStartPos;
  41811. private _deltaJoystickVector;
  41812. private _leftJoystick;
  41813. private _touches;
  41814. private _onPointerDownHandlerRef;
  41815. private _onPointerMoveHandlerRef;
  41816. private _onPointerUpHandlerRef;
  41817. private _onResize;
  41818. /**
  41819. * Creates a new virtual joystick
  41820. * @param leftJoystick defines that the joystick is for left hand (false by default)
  41821. */
  41822. constructor(leftJoystick?: boolean);
  41823. /**
  41824. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  41825. * @param newJoystickSensibility defines the new sensibility
  41826. */
  41827. setJoystickSensibility(newJoystickSensibility: number): void;
  41828. private _onPointerDown;
  41829. private _onPointerMove;
  41830. private _onPointerUp;
  41831. /**
  41832. * Change the color of the virtual joystick
  41833. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  41834. */
  41835. setJoystickColor(newColor: string): void;
  41836. /**
  41837. * Defines a callback to call when the joystick is touched
  41838. * @param action defines the callback
  41839. */
  41840. setActionOnTouch(action: () => any): void;
  41841. /**
  41842. * Defines which axis you'd like to control for left & right
  41843. * @param axis defines the axis to use
  41844. */
  41845. setAxisForLeftRight(axis: JoystickAxis): void;
  41846. /**
  41847. * Defines which axis you'd like to control for up & down
  41848. * @param axis defines the axis to use
  41849. */
  41850. setAxisForUpDown(axis: JoystickAxis): void;
  41851. private _drawVirtualJoystick;
  41852. /**
  41853. * Release internal HTML canvas
  41854. */
  41855. releaseCanvas(): void;
  41856. }
  41857. }
  41858. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  41859. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  41860. import { Nullable } from "babylonjs/types";
  41861. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41862. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41863. module "babylonjs/Cameras/freeCameraInputsManager" {
  41864. interface FreeCameraInputsManager {
  41865. /**
  41866. * Add virtual joystick input support to the input manager.
  41867. * @returns the current input manager
  41868. */
  41869. addVirtualJoystick(): FreeCameraInputsManager;
  41870. }
  41871. }
  41872. /**
  41873. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  41874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41875. */
  41876. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  41877. /**
  41878. * Defines the camera the input is attached to.
  41879. */
  41880. camera: FreeCamera;
  41881. private _leftjoystick;
  41882. private _rightjoystick;
  41883. /**
  41884. * Gets the left stick of the virtual joystick.
  41885. * @returns The virtual Joystick
  41886. */
  41887. getLeftJoystick(): VirtualJoystick;
  41888. /**
  41889. * Gets the right stick of the virtual joystick.
  41890. * @returns The virtual Joystick
  41891. */
  41892. getRightJoystick(): VirtualJoystick;
  41893. /**
  41894. * Update the current camera state depending on the inputs that have been used this frame.
  41895. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41896. */
  41897. checkInputs(): void;
  41898. /**
  41899. * Attach the input controls to a specific dom element to get the input from.
  41900. * @param element Defines the element the controls should be listened from
  41901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41902. */
  41903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41904. /**
  41905. * Detach the current controls from the specified dom element.
  41906. * @param element Defines the element to stop listening the inputs from
  41907. */
  41908. detachControl(element: Nullable<HTMLElement>): void;
  41909. /**
  41910. * Gets the class name of the current intput.
  41911. * @returns the class name
  41912. */
  41913. getClassName(): string;
  41914. /**
  41915. * Get the friendly name associated with the input class.
  41916. * @returns the input friendly name
  41917. */
  41918. getSimpleName(): string;
  41919. }
  41920. }
  41921. declare module "babylonjs/Cameras/Inputs/index" {
  41922. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  41923. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  41924. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  41925. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  41926. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41927. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  41928. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  41929. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  41930. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  41931. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  41932. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41933. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  41934. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  41935. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  41936. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  41937. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  41938. }
  41939. declare module "babylonjs/Cameras/touchCamera" {
  41940. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41941. import { Scene } from "babylonjs/scene";
  41942. import { Vector3 } from "babylonjs/Maths/math.vector";
  41943. /**
  41944. * This represents a FPS type of camera controlled by touch.
  41945. * This is like a universal camera minus the Gamepad controls.
  41946. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41947. */
  41948. export class TouchCamera extends FreeCamera {
  41949. /**
  41950. * Defines the touch sensibility for rotation.
  41951. * The higher the faster.
  41952. */
  41953. get touchAngularSensibility(): number;
  41954. set touchAngularSensibility(value: number);
  41955. /**
  41956. * Defines the touch sensibility for move.
  41957. * The higher the faster.
  41958. */
  41959. get touchMoveSensibility(): number;
  41960. set touchMoveSensibility(value: number);
  41961. /**
  41962. * Instantiates a new touch camera.
  41963. * This represents a FPS type of camera controlled by touch.
  41964. * This is like a universal camera minus the Gamepad controls.
  41965. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41966. * @param name Define the name of the camera in the scene
  41967. * @param position Define the start position of the camera in the scene
  41968. * @param scene Define the scene the camera belongs to
  41969. */
  41970. constructor(name: string, position: Vector3, scene: Scene);
  41971. /**
  41972. * Gets the current object class name.
  41973. * @return the class name
  41974. */
  41975. getClassName(): string;
  41976. /** @hidden */
  41977. _setupInputs(): void;
  41978. }
  41979. }
  41980. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  41981. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41982. import { Scene } from "babylonjs/scene";
  41983. import { Vector3 } from "babylonjs/Maths/math.vector";
  41984. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  41985. import { Axis } from "babylonjs/Maths/math.axis";
  41986. /**
  41987. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  41988. * being tilted forward or back and left or right.
  41989. */
  41990. export class DeviceOrientationCamera extends FreeCamera {
  41991. private _initialQuaternion;
  41992. private _quaternionCache;
  41993. private _tmpDragQuaternion;
  41994. private _disablePointerInputWhenUsingDeviceOrientation;
  41995. /**
  41996. * Creates a new device orientation camera
  41997. * @param name The name of the camera
  41998. * @param position The start position camera
  41999. * @param scene The scene the camera belongs to
  42000. */
  42001. constructor(name: string, position: Vector3, scene: Scene);
  42002. /**
  42003. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42004. */
  42005. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42006. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42007. private _dragFactor;
  42008. /**
  42009. * Enabled turning on the y axis when the orientation sensor is active
  42010. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42011. */
  42012. enableHorizontalDragging(dragFactor?: number): void;
  42013. /**
  42014. * Gets the current instance class name ("DeviceOrientationCamera").
  42015. * This helps avoiding instanceof at run time.
  42016. * @returns the class name
  42017. */
  42018. getClassName(): string;
  42019. /**
  42020. * @hidden
  42021. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42022. */
  42023. _checkInputs(): void;
  42024. /**
  42025. * Reset the camera to its default orientation on the specified axis only.
  42026. * @param axis The axis to reset
  42027. */
  42028. resetToCurrentRotation(axis?: Axis): void;
  42029. }
  42030. }
  42031. declare module "babylonjs/Gamepads/xboxGamepad" {
  42032. import { Observable } from "babylonjs/Misc/observable";
  42033. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42034. /**
  42035. * Defines supported buttons for XBox360 compatible gamepads
  42036. */
  42037. export enum Xbox360Button {
  42038. /** A */
  42039. A = 0,
  42040. /** B */
  42041. B = 1,
  42042. /** X */
  42043. X = 2,
  42044. /** Y */
  42045. Y = 3,
  42046. /** Start */
  42047. Start = 4,
  42048. /** Back */
  42049. Back = 5,
  42050. /** Left button */
  42051. LB = 6,
  42052. /** Right button */
  42053. RB = 7,
  42054. /** Left stick */
  42055. LeftStick = 8,
  42056. /** Right stick */
  42057. RightStick = 9
  42058. }
  42059. /** Defines values for XBox360 DPad */
  42060. export enum Xbox360Dpad {
  42061. /** Up */
  42062. Up = 0,
  42063. /** Down */
  42064. Down = 1,
  42065. /** Left */
  42066. Left = 2,
  42067. /** Right */
  42068. Right = 3
  42069. }
  42070. /**
  42071. * Defines a XBox360 gamepad
  42072. */
  42073. export class Xbox360Pad extends Gamepad {
  42074. private _leftTrigger;
  42075. private _rightTrigger;
  42076. private _onlefttriggerchanged;
  42077. private _onrighttriggerchanged;
  42078. private _onbuttondown;
  42079. private _onbuttonup;
  42080. private _ondpaddown;
  42081. private _ondpadup;
  42082. /** Observable raised when a button is pressed */
  42083. onButtonDownObservable: Observable<Xbox360Button>;
  42084. /** Observable raised when a button is released */
  42085. onButtonUpObservable: Observable<Xbox360Button>;
  42086. /** Observable raised when a pad is pressed */
  42087. onPadDownObservable: Observable<Xbox360Dpad>;
  42088. /** Observable raised when a pad is released */
  42089. onPadUpObservable: Observable<Xbox360Dpad>;
  42090. private _buttonA;
  42091. private _buttonB;
  42092. private _buttonX;
  42093. private _buttonY;
  42094. private _buttonBack;
  42095. private _buttonStart;
  42096. private _buttonLB;
  42097. private _buttonRB;
  42098. private _buttonLeftStick;
  42099. private _buttonRightStick;
  42100. private _dPadUp;
  42101. private _dPadDown;
  42102. private _dPadLeft;
  42103. private _dPadRight;
  42104. private _isXboxOnePad;
  42105. /**
  42106. * Creates a new XBox360 gamepad object
  42107. * @param id defines the id of this gamepad
  42108. * @param index defines its index
  42109. * @param gamepad defines the internal HTML gamepad object
  42110. * @param xboxOne defines if it is a XBox One gamepad
  42111. */
  42112. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42113. /**
  42114. * Defines the callback to call when left trigger is pressed
  42115. * @param callback defines the callback to use
  42116. */
  42117. onlefttriggerchanged(callback: (value: number) => void): void;
  42118. /**
  42119. * Defines the callback to call when right trigger is pressed
  42120. * @param callback defines the callback to use
  42121. */
  42122. onrighttriggerchanged(callback: (value: number) => void): void;
  42123. /**
  42124. * Gets the left trigger value
  42125. */
  42126. get leftTrigger(): number;
  42127. /**
  42128. * Sets the left trigger value
  42129. */
  42130. set leftTrigger(newValue: number);
  42131. /**
  42132. * Gets the right trigger value
  42133. */
  42134. get rightTrigger(): number;
  42135. /**
  42136. * Sets the right trigger value
  42137. */
  42138. set rightTrigger(newValue: number);
  42139. /**
  42140. * Defines the callback to call when a button is pressed
  42141. * @param callback defines the callback to use
  42142. */
  42143. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42144. /**
  42145. * Defines the callback to call when a button is released
  42146. * @param callback defines the callback to use
  42147. */
  42148. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42149. /**
  42150. * Defines the callback to call when a pad is pressed
  42151. * @param callback defines the callback to use
  42152. */
  42153. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42154. /**
  42155. * Defines the callback to call when a pad is released
  42156. * @param callback defines the callback to use
  42157. */
  42158. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42159. private _setButtonValue;
  42160. private _setDPadValue;
  42161. /**
  42162. * Gets the value of the `A` button
  42163. */
  42164. get buttonA(): number;
  42165. /**
  42166. * Sets the value of the `A` button
  42167. */
  42168. set buttonA(value: number);
  42169. /**
  42170. * Gets the value of the `B` button
  42171. */
  42172. get buttonB(): number;
  42173. /**
  42174. * Sets the value of the `B` button
  42175. */
  42176. set buttonB(value: number);
  42177. /**
  42178. * Gets the value of the `X` button
  42179. */
  42180. get buttonX(): number;
  42181. /**
  42182. * Sets the value of the `X` button
  42183. */
  42184. set buttonX(value: number);
  42185. /**
  42186. * Gets the value of the `Y` button
  42187. */
  42188. get buttonY(): number;
  42189. /**
  42190. * Sets the value of the `Y` button
  42191. */
  42192. set buttonY(value: number);
  42193. /**
  42194. * Gets the value of the `Start` button
  42195. */
  42196. get buttonStart(): number;
  42197. /**
  42198. * Sets the value of the `Start` button
  42199. */
  42200. set buttonStart(value: number);
  42201. /**
  42202. * Gets the value of the `Back` button
  42203. */
  42204. get buttonBack(): number;
  42205. /**
  42206. * Sets the value of the `Back` button
  42207. */
  42208. set buttonBack(value: number);
  42209. /**
  42210. * Gets the value of the `Left` button
  42211. */
  42212. get buttonLB(): number;
  42213. /**
  42214. * Sets the value of the `Left` button
  42215. */
  42216. set buttonLB(value: number);
  42217. /**
  42218. * Gets the value of the `Right` button
  42219. */
  42220. get buttonRB(): number;
  42221. /**
  42222. * Sets the value of the `Right` button
  42223. */
  42224. set buttonRB(value: number);
  42225. /**
  42226. * Gets the value of the Left joystick
  42227. */
  42228. get buttonLeftStick(): number;
  42229. /**
  42230. * Sets the value of the Left joystick
  42231. */
  42232. set buttonLeftStick(value: number);
  42233. /**
  42234. * Gets the value of the Right joystick
  42235. */
  42236. get buttonRightStick(): number;
  42237. /**
  42238. * Sets the value of the Right joystick
  42239. */
  42240. set buttonRightStick(value: number);
  42241. /**
  42242. * Gets the value of D-pad up
  42243. */
  42244. get dPadUp(): number;
  42245. /**
  42246. * Sets the value of D-pad up
  42247. */
  42248. set dPadUp(value: number);
  42249. /**
  42250. * Gets the value of D-pad down
  42251. */
  42252. get dPadDown(): number;
  42253. /**
  42254. * Sets the value of D-pad down
  42255. */
  42256. set dPadDown(value: number);
  42257. /**
  42258. * Gets the value of D-pad left
  42259. */
  42260. get dPadLeft(): number;
  42261. /**
  42262. * Sets the value of D-pad left
  42263. */
  42264. set dPadLeft(value: number);
  42265. /**
  42266. * Gets the value of D-pad right
  42267. */
  42268. get dPadRight(): number;
  42269. /**
  42270. * Sets the value of D-pad right
  42271. */
  42272. set dPadRight(value: number);
  42273. /**
  42274. * Force the gamepad to synchronize with device values
  42275. */
  42276. update(): void;
  42277. /**
  42278. * Disposes the gamepad
  42279. */
  42280. dispose(): void;
  42281. }
  42282. }
  42283. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42284. import { Observable } from "babylonjs/Misc/observable";
  42285. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42286. /**
  42287. * Defines supported buttons for DualShock compatible gamepads
  42288. */
  42289. export enum DualShockButton {
  42290. /** Cross */
  42291. Cross = 0,
  42292. /** Circle */
  42293. Circle = 1,
  42294. /** Square */
  42295. Square = 2,
  42296. /** Triangle */
  42297. Triangle = 3,
  42298. /** Options */
  42299. Options = 4,
  42300. /** Share */
  42301. Share = 5,
  42302. /** L1 */
  42303. L1 = 6,
  42304. /** R1 */
  42305. R1 = 7,
  42306. /** Left stick */
  42307. LeftStick = 8,
  42308. /** Right stick */
  42309. RightStick = 9
  42310. }
  42311. /** Defines values for DualShock DPad */
  42312. export enum DualShockDpad {
  42313. /** Up */
  42314. Up = 0,
  42315. /** Down */
  42316. Down = 1,
  42317. /** Left */
  42318. Left = 2,
  42319. /** Right */
  42320. Right = 3
  42321. }
  42322. /**
  42323. * Defines a DualShock gamepad
  42324. */
  42325. export class DualShockPad extends Gamepad {
  42326. private _leftTrigger;
  42327. private _rightTrigger;
  42328. private _onlefttriggerchanged;
  42329. private _onrighttriggerchanged;
  42330. private _onbuttondown;
  42331. private _onbuttonup;
  42332. private _ondpaddown;
  42333. private _ondpadup;
  42334. /** Observable raised when a button is pressed */
  42335. onButtonDownObservable: Observable<DualShockButton>;
  42336. /** Observable raised when a button is released */
  42337. onButtonUpObservable: Observable<DualShockButton>;
  42338. /** Observable raised when a pad is pressed */
  42339. onPadDownObservable: Observable<DualShockDpad>;
  42340. /** Observable raised when a pad is released */
  42341. onPadUpObservable: Observable<DualShockDpad>;
  42342. private _buttonCross;
  42343. private _buttonCircle;
  42344. private _buttonSquare;
  42345. private _buttonTriangle;
  42346. private _buttonShare;
  42347. private _buttonOptions;
  42348. private _buttonL1;
  42349. private _buttonR1;
  42350. private _buttonLeftStick;
  42351. private _buttonRightStick;
  42352. private _dPadUp;
  42353. private _dPadDown;
  42354. private _dPadLeft;
  42355. private _dPadRight;
  42356. /**
  42357. * Creates a new DualShock gamepad object
  42358. * @param id defines the id of this gamepad
  42359. * @param index defines its index
  42360. * @param gamepad defines the internal HTML gamepad object
  42361. */
  42362. constructor(id: string, index: number, gamepad: any);
  42363. /**
  42364. * Defines the callback to call when left trigger is pressed
  42365. * @param callback defines the callback to use
  42366. */
  42367. onlefttriggerchanged(callback: (value: number) => void): void;
  42368. /**
  42369. * Defines the callback to call when right trigger is pressed
  42370. * @param callback defines the callback to use
  42371. */
  42372. onrighttriggerchanged(callback: (value: number) => void): void;
  42373. /**
  42374. * Gets the left trigger value
  42375. */
  42376. get leftTrigger(): number;
  42377. /**
  42378. * Sets the left trigger value
  42379. */
  42380. set leftTrigger(newValue: number);
  42381. /**
  42382. * Gets the right trigger value
  42383. */
  42384. get rightTrigger(): number;
  42385. /**
  42386. * Sets the right trigger value
  42387. */
  42388. set rightTrigger(newValue: number);
  42389. /**
  42390. * Defines the callback to call when a button is pressed
  42391. * @param callback defines the callback to use
  42392. */
  42393. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42394. /**
  42395. * Defines the callback to call when a button is released
  42396. * @param callback defines the callback to use
  42397. */
  42398. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42399. /**
  42400. * Defines the callback to call when a pad is pressed
  42401. * @param callback defines the callback to use
  42402. */
  42403. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42404. /**
  42405. * Defines the callback to call when a pad is released
  42406. * @param callback defines the callback to use
  42407. */
  42408. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42409. private _setButtonValue;
  42410. private _setDPadValue;
  42411. /**
  42412. * Gets the value of the `Cross` button
  42413. */
  42414. get buttonCross(): number;
  42415. /**
  42416. * Sets the value of the `Cross` button
  42417. */
  42418. set buttonCross(value: number);
  42419. /**
  42420. * Gets the value of the `Circle` button
  42421. */
  42422. get buttonCircle(): number;
  42423. /**
  42424. * Sets the value of the `Circle` button
  42425. */
  42426. set buttonCircle(value: number);
  42427. /**
  42428. * Gets the value of the `Square` button
  42429. */
  42430. get buttonSquare(): number;
  42431. /**
  42432. * Sets the value of the `Square` button
  42433. */
  42434. set buttonSquare(value: number);
  42435. /**
  42436. * Gets the value of the `Triangle` button
  42437. */
  42438. get buttonTriangle(): number;
  42439. /**
  42440. * Sets the value of the `Triangle` button
  42441. */
  42442. set buttonTriangle(value: number);
  42443. /**
  42444. * Gets the value of the `Options` button
  42445. */
  42446. get buttonOptions(): number;
  42447. /**
  42448. * Sets the value of the `Options` button
  42449. */
  42450. set buttonOptions(value: number);
  42451. /**
  42452. * Gets the value of the `Share` button
  42453. */
  42454. get buttonShare(): number;
  42455. /**
  42456. * Sets the value of the `Share` button
  42457. */
  42458. set buttonShare(value: number);
  42459. /**
  42460. * Gets the value of the `L1` button
  42461. */
  42462. get buttonL1(): number;
  42463. /**
  42464. * Sets the value of the `L1` button
  42465. */
  42466. set buttonL1(value: number);
  42467. /**
  42468. * Gets the value of the `R1` button
  42469. */
  42470. get buttonR1(): number;
  42471. /**
  42472. * Sets the value of the `R1` button
  42473. */
  42474. set buttonR1(value: number);
  42475. /**
  42476. * Gets the value of the Left joystick
  42477. */
  42478. get buttonLeftStick(): number;
  42479. /**
  42480. * Sets the value of the Left joystick
  42481. */
  42482. set buttonLeftStick(value: number);
  42483. /**
  42484. * Gets the value of the Right joystick
  42485. */
  42486. get buttonRightStick(): number;
  42487. /**
  42488. * Sets the value of the Right joystick
  42489. */
  42490. set buttonRightStick(value: number);
  42491. /**
  42492. * Gets the value of D-pad up
  42493. */
  42494. get dPadUp(): number;
  42495. /**
  42496. * Sets the value of D-pad up
  42497. */
  42498. set dPadUp(value: number);
  42499. /**
  42500. * Gets the value of D-pad down
  42501. */
  42502. get dPadDown(): number;
  42503. /**
  42504. * Sets the value of D-pad down
  42505. */
  42506. set dPadDown(value: number);
  42507. /**
  42508. * Gets the value of D-pad left
  42509. */
  42510. get dPadLeft(): number;
  42511. /**
  42512. * Sets the value of D-pad left
  42513. */
  42514. set dPadLeft(value: number);
  42515. /**
  42516. * Gets the value of D-pad right
  42517. */
  42518. get dPadRight(): number;
  42519. /**
  42520. * Sets the value of D-pad right
  42521. */
  42522. set dPadRight(value: number);
  42523. /**
  42524. * Force the gamepad to synchronize with device values
  42525. */
  42526. update(): void;
  42527. /**
  42528. * Disposes the gamepad
  42529. */
  42530. dispose(): void;
  42531. }
  42532. }
  42533. declare module "babylonjs/Gamepads/gamepadManager" {
  42534. import { Observable } from "babylonjs/Misc/observable";
  42535. import { Nullable } from "babylonjs/types";
  42536. import { Scene } from "babylonjs/scene";
  42537. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42538. /**
  42539. * Manager for handling gamepads
  42540. */
  42541. export class GamepadManager {
  42542. private _scene?;
  42543. private _babylonGamepads;
  42544. private _oneGamepadConnected;
  42545. /** @hidden */
  42546. _isMonitoring: boolean;
  42547. private _gamepadEventSupported;
  42548. private _gamepadSupport?;
  42549. /**
  42550. * observable to be triggered when the gamepad controller has been connected
  42551. */
  42552. onGamepadConnectedObservable: Observable<Gamepad>;
  42553. /**
  42554. * observable to be triggered when the gamepad controller has been disconnected
  42555. */
  42556. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42557. private _onGamepadConnectedEvent;
  42558. private _onGamepadDisconnectedEvent;
  42559. /**
  42560. * Initializes the gamepad manager
  42561. * @param _scene BabylonJS scene
  42562. */
  42563. constructor(_scene?: Scene | undefined);
  42564. /**
  42565. * The gamepads in the game pad manager
  42566. */
  42567. get gamepads(): Gamepad[];
  42568. /**
  42569. * Get the gamepad controllers based on type
  42570. * @param type The type of gamepad controller
  42571. * @returns Nullable gamepad
  42572. */
  42573. getGamepadByType(type?: number): Nullable<Gamepad>;
  42574. /**
  42575. * Disposes the gamepad manager
  42576. */
  42577. dispose(): void;
  42578. private _addNewGamepad;
  42579. private _startMonitoringGamepads;
  42580. private _stopMonitoringGamepads;
  42581. /** @hidden */
  42582. _checkGamepadsStatus(): void;
  42583. private _updateGamepadObjects;
  42584. }
  42585. }
  42586. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42587. import { Nullable } from "babylonjs/types";
  42588. import { Scene } from "babylonjs/scene";
  42589. import { ISceneComponent } from "babylonjs/sceneComponent";
  42590. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42591. module "babylonjs/scene" {
  42592. interface Scene {
  42593. /** @hidden */
  42594. _gamepadManager: Nullable<GamepadManager>;
  42595. /**
  42596. * Gets the gamepad manager associated with the scene
  42597. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42598. */
  42599. gamepadManager: GamepadManager;
  42600. }
  42601. }
  42602. module "babylonjs/Cameras/freeCameraInputsManager" {
  42603. /**
  42604. * Interface representing a free camera inputs manager
  42605. */
  42606. interface FreeCameraInputsManager {
  42607. /**
  42608. * Adds gamepad input support to the FreeCameraInputsManager.
  42609. * @returns the FreeCameraInputsManager
  42610. */
  42611. addGamepad(): FreeCameraInputsManager;
  42612. }
  42613. }
  42614. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42615. /**
  42616. * Interface representing an arc rotate camera inputs manager
  42617. */
  42618. interface ArcRotateCameraInputsManager {
  42619. /**
  42620. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42621. * @returns the camera inputs manager
  42622. */
  42623. addGamepad(): ArcRotateCameraInputsManager;
  42624. }
  42625. }
  42626. /**
  42627. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42628. */
  42629. export class GamepadSystemSceneComponent implements ISceneComponent {
  42630. /**
  42631. * The component name helpfull to identify the component in the list of scene components.
  42632. */
  42633. readonly name: string;
  42634. /**
  42635. * The scene the component belongs to.
  42636. */
  42637. scene: Scene;
  42638. /**
  42639. * Creates a new instance of the component for the given scene
  42640. * @param scene Defines the scene to register the component in
  42641. */
  42642. constructor(scene: Scene);
  42643. /**
  42644. * Registers the component in a given scene
  42645. */
  42646. register(): void;
  42647. /**
  42648. * Rebuilds the elements related to this component in case of
  42649. * context lost for instance.
  42650. */
  42651. rebuild(): void;
  42652. /**
  42653. * Disposes the component and the associated ressources
  42654. */
  42655. dispose(): void;
  42656. private _beforeCameraUpdate;
  42657. }
  42658. }
  42659. declare module "babylonjs/Cameras/universalCamera" {
  42660. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42661. import { Scene } from "babylonjs/scene";
  42662. import { Vector3 } from "babylonjs/Maths/math.vector";
  42663. import "babylonjs/Gamepads/gamepadSceneComponent";
  42664. /**
  42665. * 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,
  42666. * which still works and will still be found in many Playgrounds.
  42667. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42668. */
  42669. export class UniversalCamera extends TouchCamera {
  42670. /**
  42671. * Defines the gamepad rotation sensiblity.
  42672. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42673. */
  42674. get gamepadAngularSensibility(): number;
  42675. set gamepadAngularSensibility(value: number);
  42676. /**
  42677. * Defines the gamepad move sensiblity.
  42678. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42679. */
  42680. get gamepadMoveSensibility(): number;
  42681. set gamepadMoveSensibility(value: number);
  42682. /**
  42683. * 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,
  42684. * which still works and will still be found in many Playgrounds.
  42685. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42686. * @param name Define the name of the camera in the scene
  42687. * @param position Define the start position of the camera in the scene
  42688. * @param scene Define the scene the camera belongs to
  42689. */
  42690. constructor(name: string, position: Vector3, scene: Scene);
  42691. /**
  42692. * Gets the current object class name.
  42693. * @return the class name
  42694. */
  42695. getClassName(): string;
  42696. }
  42697. }
  42698. declare module "babylonjs/Cameras/gamepadCamera" {
  42699. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42700. import { Scene } from "babylonjs/scene";
  42701. import { Vector3 } from "babylonjs/Maths/math.vector";
  42702. /**
  42703. * This represents a FPS type of camera. This is only here for back compat purpose.
  42704. * Please use the UniversalCamera instead as both are identical.
  42705. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42706. */
  42707. export class GamepadCamera extends UniversalCamera {
  42708. /**
  42709. * Instantiates a new Gamepad Camera
  42710. * This represents a FPS type of camera. This is only here for back compat purpose.
  42711. * Please use the UniversalCamera instead as both are identical.
  42712. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42713. * @param name Define the name of the camera in the scene
  42714. * @param position Define the start position of the camera in the scene
  42715. * @param scene Define the scene the camera belongs to
  42716. */
  42717. constructor(name: string, position: Vector3, scene: Scene);
  42718. /**
  42719. * Gets the current object class name.
  42720. * @return the class name
  42721. */
  42722. getClassName(): string;
  42723. }
  42724. }
  42725. declare module "babylonjs/Shaders/pass.fragment" {
  42726. /** @hidden */
  42727. export var passPixelShader: {
  42728. name: string;
  42729. shader: string;
  42730. };
  42731. }
  42732. declare module "babylonjs/Shaders/passCube.fragment" {
  42733. /** @hidden */
  42734. export var passCubePixelShader: {
  42735. name: string;
  42736. shader: string;
  42737. };
  42738. }
  42739. declare module "babylonjs/PostProcesses/passPostProcess" {
  42740. import { Nullable } from "babylonjs/types";
  42741. import { Camera } from "babylonjs/Cameras/camera";
  42742. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42743. import { Engine } from "babylonjs/Engines/engine";
  42744. import "babylonjs/Shaders/pass.fragment";
  42745. import "babylonjs/Shaders/passCube.fragment";
  42746. /**
  42747. * PassPostProcess which produces an output the same as it's input
  42748. */
  42749. export class PassPostProcess extends PostProcess {
  42750. /**
  42751. * Creates the PassPostProcess
  42752. * @param name The name of the effect.
  42753. * @param options The required width/height ratio to downsize to before computing the render pass.
  42754. * @param camera The camera to apply the render pass to.
  42755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42756. * @param engine The engine which the post process will be applied. (default: current engine)
  42757. * @param reusable If the post process can be reused on the same frame. (default: false)
  42758. * @param textureType The type of texture to be used when performing the post processing.
  42759. * @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)
  42760. */
  42761. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42762. }
  42763. /**
  42764. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42765. */
  42766. export class PassCubePostProcess extends PostProcess {
  42767. private _face;
  42768. /**
  42769. * Gets or sets the cube face to display.
  42770. * * 0 is +X
  42771. * * 1 is -X
  42772. * * 2 is +Y
  42773. * * 3 is -Y
  42774. * * 4 is +Z
  42775. * * 5 is -Z
  42776. */
  42777. get face(): number;
  42778. set face(value: number);
  42779. /**
  42780. * Creates the PassCubePostProcess
  42781. * @param name The name of the effect.
  42782. * @param options The required width/height ratio to downsize to before computing the render pass.
  42783. * @param camera The camera to apply the render pass to.
  42784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42785. * @param engine The engine which the post process will be applied. (default: current engine)
  42786. * @param reusable If the post process can be reused on the same frame. (default: false)
  42787. * @param textureType The type of texture to be used when performing the post processing.
  42788. * @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)
  42789. */
  42790. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42791. }
  42792. }
  42793. declare module "babylonjs/Shaders/anaglyph.fragment" {
  42794. /** @hidden */
  42795. export var anaglyphPixelShader: {
  42796. name: string;
  42797. shader: string;
  42798. };
  42799. }
  42800. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  42801. import { Engine } from "babylonjs/Engines/engine";
  42802. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42803. import { Camera } from "babylonjs/Cameras/camera";
  42804. import "babylonjs/Shaders/anaglyph.fragment";
  42805. /**
  42806. * Postprocess used to generate anaglyphic rendering
  42807. */
  42808. export class AnaglyphPostProcess extends PostProcess {
  42809. private _passedProcess;
  42810. /**
  42811. * Creates a new AnaglyphPostProcess
  42812. * @param name defines postprocess name
  42813. * @param options defines creation options or target ratio scale
  42814. * @param rigCameras defines cameras using this postprocess
  42815. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  42816. * @param engine defines hosting engine
  42817. * @param reusable defines if the postprocess will be reused multiple times per frame
  42818. */
  42819. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  42820. }
  42821. }
  42822. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  42823. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  42824. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42825. import { Scene } from "babylonjs/scene";
  42826. import { Vector3 } from "babylonjs/Maths/math.vector";
  42827. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42828. /**
  42829. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  42830. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42831. */
  42832. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  42833. /**
  42834. * Creates a new AnaglyphArcRotateCamera
  42835. * @param name defines camera name
  42836. * @param alpha defines alpha angle (in radians)
  42837. * @param beta defines beta angle (in radians)
  42838. * @param radius defines radius
  42839. * @param target defines camera target
  42840. * @param interaxialDistance defines distance between each color axis
  42841. * @param scene defines the hosting scene
  42842. */
  42843. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  42844. /**
  42845. * Gets camera class name
  42846. * @returns AnaglyphArcRotateCamera
  42847. */
  42848. getClassName(): string;
  42849. }
  42850. }
  42851. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  42852. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42853. import { Scene } from "babylonjs/scene";
  42854. import { Vector3 } from "babylonjs/Maths/math.vector";
  42855. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42856. /**
  42857. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  42858. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42859. */
  42860. export class AnaglyphFreeCamera extends FreeCamera {
  42861. /**
  42862. * Creates a new AnaglyphFreeCamera
  42863. * @param name defines camera name
  42864. * @param position defines initial position
  42865. * @param interaxialDistance defines distance between each color axis
  42866. * @param scene defines the hosting scene
  42867. */
  42868. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42869. /**
  42870. * Gets camera class name
  42871. * @returns AnaglyphFreeCamera
  42872. */
  42873. getClassName(): string;
  42874. }
  42875. }
  42876. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  42877. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  42878. import { Scene } from "babylonjs/scene";
  42879. import { Vector3 } from "babylonjs/Maths/math.vector";
  42880. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42881. /**
  42882. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  42883. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42884. */
  42885. export class AnaglyphGamepadCamera extends GamepadCamera {
  42886. /**
  42887. * Creates a new AnaglyphGamepadCamera
  42888. * @param name defines camera name
  42889. * @param position defines initial position
  42890. * @param interaxialDistance defines distance between each color axis
  42891. * @param scene defines the hosting scene
  42892. */
  42893. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42894. /**
  42895. * Gets camera class name
  42896. * @returns AnaglyphGamepadCamera
  42897. */
  42898. getClassName(): string;
  42899. }
  42900. }
  42901. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  42902. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42903. import { Scene } from "babylonjs/scene";
  42904. import { Vector3 } from "babylonjs/Maths/math.vector";
  42905. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42906. /**
  42907. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  42908. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  42909. */
  42910. export class AnaglyphUniversalCamera extends UniversalCamera {
  42911. /**
  42912. * Creates a new AnaglyphUniversalCamera
  42913. * @param name defines camera name
  42914. * @param position defines initial position
  42915. * @param interaxialDistance defines distance between each color axis
  42916. * @param scene defines the hosting scene
  42917. */
  42918. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  42919. /**
  42920. * Gets camera class name
  42921. * @returns AnaglyphUniversalCamera
  42922. */
  42923. getClassName(): string;
  42924. }
  42925. }
  42926. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  42927. /** @hidden */
  42928. export var stereoscopicInterlacePixelShader: {
  42929. name: string;
  42930. shader: string;
  42931. };
  42932. }
  42933. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  42934. import { Camera } from "babylonjs/Cameras/camera";
  42935. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42936. import { Engine } from "babylonjs/Engines/engine";
  42937. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  42938. /**
  42939. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  42940. */
  42941. export class StereoscopicInterlacePostProcess extends PostProcess {
  42942. private _stepSize;
  42943. private _passedProcess;
  42944. /**
  42945. * Initializes a StereoscopicInterlacePostProcess
  42946. * @param name The name of the effect.
  42947. * @param rigCameras The rig cameras to be appled to the post process
  42948. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  42949. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42950. * @param engine The engine which the post process will be applied. (default: current engine)
  42951. * @param reusable If the post process can be reused on the same frame. (default: false)
  42952. */
  42953. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  42954. }
  42955. }
  42956. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  42957. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  42958. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42959. import { Scene } from "babylonjs/scene";
  42960. import { Vector3 } from "babylonjs/Maths/math.vector";
  42961. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42962. /**
  42963. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  42964. * @see http://doc.babylonjs.com/features/cameras
  42965. */
  42966. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  42967. /**
  42968. * Creates a new StereoscopicArcRotateCamera
  42969. * @param name defines camera name
  42970. * @param alpha defines alpha angle (in radians)
  42971. * @param beta defines beta angle (in radians)
  42972. * @param radius defines radius
  42973. * @param target defines camera target
  42974. * @param interaxialDistance defines distance between each color axis
  42975. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  42976. * @param scene defines the hosting scene
  42977. */
  42978. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  42979. /**
  42980. * Gets camera class name
  42981. * @returns StereoscopicArcRotateCamera
  42982. */
  42983. getClassName(): string;
  42984. }
  42985. }
  42986. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  42987. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42988. import { Scene } from "babylonjs/scene";
  42989. import { Vector3 } from "babylonjs/Maths/math.vector";
  42990. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42991. /**
  42992. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  42993. * @see http://doc.babylonjs.com/features/cameras
  42994. */
  42995. export class StereoscopicFreeCamera extends FreeCamera {
  42996. /**
  42997. * Creates a new StereoscopicFreeCamera
  42998. * @param name defines camera name
  42999. * @param position defines initial position
  43000. * @param interaxialDistance defines distance between each color axis
  43001. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43002. * @param scene defines the hosting scene
  43003. */
  43004. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43005. /**
  43006. * Gets camera class name
  43007. * @returns StereoscopicFreeCamera
  43008. */
  43009. getClassName(): string;
  43010. }
  43011. }
  43012. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43013. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43014. import { Scene } from "babylonjs/scene";
  43015. import { Vector3 } from "babylonjs/Maths/math.vector";
  43016. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43017. /**
  43018. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43019. * @see http://doc.babylonjs.com/features/cameras
  43020. */
  43021. export class StereoscopicGamepadCamera extends GamepadCamera {
  43022. /**
  43023. * Creates a new StereoscopicGamepadCamera
  43024. * @param name defines camera name
  43025. * @param position defines initial position
  43026. * @param interaxialDistance defines distance between each color axis
  43027. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43028. * @param scene defines the hosting scene
  43029. */
  43030. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43031. /**
  43032. * Gets camera class name
  43033. * @returns StereoscopicGamepadCamera
  43034. */
  43035. getClassName(): string;
  43036. }
  43037. }
  43038. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43039. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43040. import { Scene } from "babylonjs/scene";
  43041. import { Vector3 } from "babylonjs/Maths/math.vector";
  43042. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43043. /**
  43044. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43045. * @see http://doc.babylonjs.com/features/cameras
  43046. */
  43047. export class StereoscopicUniversalCamera extends UniversalCamera {
  43048. /**
  43049. * Creates a new StereoscopicUniversalCamera
  43050. * @param name defines camera name
  43051. * @param position defines initial position
  43052. * @param interaxialDistance defines distance between each color axis
  43053. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43054. * @param scene defines the hosting scene
  43055. */
  43056. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43057. /**
  43058. * Gets camera class name
  43059. * @returns StereoscopicUniversalCamera
  43060. */
  43061. getClassName(): string;
  43062. }
  43063. }
  43064. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43065. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43066. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43067. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43068. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43069. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43070. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43071. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43072. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43073. }
  43074. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43075. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43076. import { Scene } from "babylonjs/scene";
  43077. import { Vector3 } from "babylonjs/Maths/math.vector";
  43078. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43079. /**
  43080. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43081. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43082. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43083. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43084. */
  43085. export class VirtualJoysticksCamera extends FreeCamera {
  43086. /**
  43087. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43088. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43089. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43090. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43091. * @param name Define the name of the camera in the scene
  43092. * @param position Define the start position of the camera in the scene
  43093. * @param scene Define the scene the camera belongs to
  43094. */
  43095. constructor(name: string, position: Vector3, scene: Scene);
  43096. /**
  43097. * Gets the current object class name.
  43098. * @return the class name
  43099. */
  43100. getClassName(): string;
  43101. }
  43102. }
  43103. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43104. import { Matrix } from "babylonjs/Maths/math.vector";
  43105. /**
  43106. * This represents all the required metrics to create a VR camera.
  43107. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43108. */
  43109. export class VRCameraMetrics {
  43110. /**
  43111. * Define the horizontal resolution off the screen.
  43112. */
  43113. hResolution: number;
  43114. /**
  43115. * Define the vertical resolution off the screen.
  43116. */
  43117. vResolution: number;
  43118. /**
  43119. * Define the horizontal screen size.
  43120. */
  43121. hScreenSize: number;
  43122. /**
  43123. * Define the vertical screen size.
  43124. */
  43125. vScreenSize: number;
  43126. /**
  43127. * Define the vertical screen center position.
  43128. */
  43129. vScreenCenter: number;
  43130. /**
  43131. * Define the distance of the eyes to the screen.
  43132. */
  43133. eyeToScreenDistance: number;
  43134. /**
  43135. * Define the distance between both lenses
  43136. */
  43137. lensSeparationDistance: number;
  43138. /**
  43139. * Define the distance between both viewer's eyes.
  43140. */
  43141. interpupillaryDistance: number;
  43142. /**
  43143. * Define the distortion factor of the VR postprocess.
  43144. * Please, touch with care.
  43145. */
  43146. distortionK: number[];
  43147. /**
  43148. * Define the chromatic aberration correction factors for the VR post process.
  43149. */
  43150. chromaAbCorrection: number[];
  43151. /**
  43152. * Define the scale factor of the post process.
  43153. * The smaller the better but the slower.
  43154. */
  43155. postProcessScaleFactor: number;
  43156. /**
  43157. * Define an offset for the lens center.
  43158. */
  43159. lensCenterOffset: number;
  43160. /**
  43161. * Define if the current vr camera should compensate the distortion of the lense or not.
  43162. */
  43163. compensateDistortion: boolean;
  43164. /**
  43165. * Defines if multiview should be enabled when rendering (Default: false)
  43166. */
  43167. multiviewEnabled: boolean;
  43168. /**
  43169. * Gets the rendering aspect ratio based on the provided resolutions.
  43170. */
  43171. get aspectRatio(): number;
  43172. /**
  43173. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43174. */
  43175. get aspectRatioFov(): number;
  43176. /**
  43177. * @hidden
  43178. */
  43179. get leftHMatrix(): Matrix;
  43180. /**
  43181. * @hidden
  43182. */
  43183. get rightHMatrix(): Matrix;
  43184. /**
  43185. * @hidden
  43186. */
  43187. get leftPreViewMatrix(): Matrix;
  43188. /**
  43189. * @hidden
  43190. */
  43191. get rightPreViewMatrix(): Matrix;
  43192. /**
  43193. * Get the default VRMetrics based on the most generic setup.
  43194. * @returns the default vr metrics
  43195. */
  43196. static GetDefault(): VRCameraMetrics;
  43197. }
  43198. }
  43199. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43200. /** @hidden */
  43201. export var vrDistortionCorrectionPixelShader: {
  43202. name: string;
  43203. shader: string;
  43204. };
  43205. }
  43206. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43207. import { Camera } from "babylonjs/Cameras/camera";
  43208. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43209. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43210. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43211. /**
  43212. * VRDistortionCorrectionPostProcess used for mobile VR
  43213. */
  43214. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43215. private _isRightEye;
  43216. private _distortionFactors;
  43217. private _postProcessScaleFactor;
  43218. private _lensCenterOffset;
  43219. private _scaleIn;
  43220. private _scaleFactor;
  43221. private _lensCenter;
  43222. /**
  43223. * Initializes the VRDistortionCorrectionPostProcess
  43224. * @param name The name of the effect.
  43225. * @param camera The camera to apply the render pass to.
  43226. * @param isRightEye If this is for the right eye distortion
  43227. * @param vrMetrics All the required metrics for the VR camera
  43228. */
  43229. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43230. }
  43231. }
  43232. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43233. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43234. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43235. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43236. import { Scene } from "babylonjs/scene";
  43237. import { Vector3 } from "babylonjs/Maths/math.vector";
  43238. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43239. import "babylonjs/Cameras/RigModes/vrRigMode";
  43240. /**
  43241. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43242. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43243. */
  43244. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43245. /**
  43246. * Creates a new VRDeviceOrientationArcRotateCamera
  43247. * @param name defines camera name
  43248. * @param alpha defines the camera rotation along the logitudinal axis
  43249. * @param beta defines the camera rotation along the latitudinal axis
  43250. * @param radius defines the camera distance from its target
  43251. * @param target defines the camera target
  43252. * @param scene defines the scene the camera belongs to
  43253. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43254. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43255. */
  43256. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43257. /**
  43258. * Gets camera class name
  43259. * @returns VRDeviceOrientationArcRotateCamera
  43260. */
  43261. getClassName(): string;
  43262. }
  43263. }
  43264. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43265. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43266. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43267. import { Scene } from "babylonjs/scene";
  43268. import { Vector3 } from "babylonjs/Maths/math.vector";
  43269. import "babylonjs/Cameras/RigModes/vrRigMode";
  43270. /**
  43271. * Camera used to simulate VR rendering (based on FreeCamera)
  43272. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43273. */
  43274. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43275. /**
  43276. * Creates a new VRDeviceOrientationFreeCamera
  43277. * @param name defines camera name
  43278. * @param position defines the start position of the camera
  43279. * @param scene defines the scene the camera belongs to
  43280. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43281. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43282. */
  43283. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43284. /**
  43285. * Gets camera class name
  43286. * @returns VRDeviceOrientationFreeCamera
  43287. */
  43288. getClassName(): string;
  43289. }
  43290. }
  43291. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43292. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43293. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43294. import { Scene } from "babylonjs/scene";
  43295. import { Vector3 } from "babylonjs/Maths/math.vector";
  43296. import "babylonjs/Gamepads/gamepadSceneComponent";
  43297. /**
  43298. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43299. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43300. */
  43301. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43302. /**
  43303. * Creates a new VRDeviceOrientationGamepadCamera
  43304. * @param name defines camera name
  43305. * @param position defines the start position of the camera
  43306. * @param scene defines the scene the camera belongs to
  43307. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43308. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43309. */
  43310. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43311. /**
  43312. * Gets camera class name
  43313. * @returns VRDeviceOrientationGamepadCamera
  43314. */
  43315. getClassName(): string;
  43316. }
  43317. }
  43318. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43319. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43320. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43321. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43322. /** @hidden */
  43323. export var imageProcessingPixelShader: {
  43324. name: string;
  43325. shader: string;
  43326. };
  43327. }
  43328. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43329. import { Nullable } from "babylonjs/types";
  43330. import { Color4 } from "babylonjs/Maths/math.color";
  43331. import { Camera } from "babylonjs/Cameras/camera";
  43332. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43333. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43334. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43335. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43336. import { Engine } from "babylonjs/Engines/engine";
  43337. import "babylonjs/Shaders/imageProcessing.fragment";
  43338. import "babylonjs/Shaders/postprocess.vertex";
  43339. /**
  43340. * ImageProcessingPostProcess
  43341. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43342. */
  43343. export class ImageProcessingPostProcess extends PostProcess {
  43344. /**
  43345. * Default configuration related to image processing available in the PBR Material.
  43346. */
  43347. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43348. /**
  43349. * Gets the image processing configuration used either in this material.
  43350. */
  43351. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43352. /**
  43353. * Sets the Default image processing configuration used either in the this material.
  43354. *
  43355. * If sets to null, the scene one is in use.
  43356. */
  43357. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43358. /**
  43359. * Keep track of the image processing observer to allow dispose and replace.
  43360. */
  43361. private _imageProcessingObserver;
  43362. /**
  43363. * Attaches a new image processing configuration to the PBR Material.
  43364. * @param configuration
  43365. */
  43366. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43367. /**
  43368. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43369. */
  43370. get colorCurves(): Nullable<ColorCurves>;
  43371. /**
  43372. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43373. */
  43374. set colorCurves(value: Nullable<ColorCurves>);
  43375. /**
  43376. * Gets wether the color curves effect is enabled.
  43377. */
  43378. get colorCurvesEnabled(): boolean;
  43379. /**
  43380. * Sets wether the color curves effect is enabled.
  43381. */
  43382. set colorCurvesEnabled(value: boolean);
  43383. /**
  43384. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43385. */
  43386. get colorGradingTexture(): Nullable<BaseTexture>;
  43387. /**
  43388. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43389. */
  43390. set colorGradingTexture(value: Nullable<BaseTexture>);
  43391. /**
  43392. * Gets wether the color grading effect is enabled.
  43393. */
  43394. get colorGradingEnabled(): boolean;
  43395. /**
  43396. * Gets wether the color grading effect is enabled.
  43397. */
  43398. set colorGradingEnabled(value: boolean);
  43399. /**
  43400. * Gets exposure used in the effect.
  43401. */
  43402. get exposure(): number;
  43403. /**
  43404. * Sets exposure used in the effect.
  43405. */
  43406. set exposure(value: number);
  43407. /**
  43408. * Gets wether tonemapping is enabled or not.
  43409. */
  43410. get toneMappingEnabled(): boolean;
  43411. /**
  43412. * Sets wether tonemapping is enabled or not
  43413. */
  43414. set toneMappingEnabled(value: boolean);
  43415. /**
  43416. * Gets the type of tone mapping effect.
  43417. */
  43418. get toneMappingType(): number;
  43419. /**
  43420. * Sets the type of tone mapping effect.
  43421. */
  43422. set toneMappingType(value: number);
  43423. /**
  43424. * Gets contrast used in the effect.
  43425. */
  43426. get contrast(): number;
  43427. /**
  43428. * Sets contrast used in the effect.
  43429. */
  43430. set contrast(value: number);
  43431. /**
  43432. * Gets Vignette stretch size.
  43433. */
  43434. get vignetteStretch(): number;
  43435. /**
  43436. * Sets Vignette stretch size.
  43437. */
  43438. set vignetteStretch(value: number);
  43439. /**
  43440. * Gets Vignette centre X Offset.
  43441. */
  43442. get vignetteCentreX(): number;
  43443. /**
  43444. * Sets Vignette centre X Offset.
  43445. */
  43446. set vignetteCentreX(value: number);
  43447. /**
  43448. * Gets Vignette centre Y Offset.
  43449. */
  43450. get vignetteCentreY(): number;
  43451. /**
  43452. * Sets Vignette centre Y Offset.
  43453. */
  43454. set vignetteCentreY(value: number);
  43455. /**
  43456. * Gets Vignette weight or intensity of the vignette effect.
  43457. */
  43458. get vignetteWeight(): number;
  43459. /**
  43460. * Sets Vignette weight or intensity of the vignette effect.
  43461. */
  43462. set vignetteWeight(value: number);
  43463. /**
  43464. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43465. * if vignetteEnabled is set to true.
  43466. */
  43467. get vignetteColor(): Color4;
  43468. /**
  43469. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43470. * if vignetteEnabled is set to true.
  43471. */
  43472. set vignetteColor(value: Color4);
  43473. /**
  43474. * Gets Camera field of view used by the Vignette effect.
  43475. */
  43476. get vignetteCameraFov(): number;
  43477. /**
  43478. * Sets Camera field of view used by the Vignette effect.
  43479. */
  43480. set vignetteCameraFov(value: number);
  43481. /**
  43482. * Gets the vignette blend mode allowing different kind of effect.
  43483. */
  43484. get vignetteBlendMode(): number;
  43485. /**
  43486. * Sets the vignette blend mode allowing different kind of effect.
  43487. */
  43488. set vignetteBlendMode(value: number);
  43489. /**
  43490. * Gets wether the vignette effect is enabled.
  43491. */
  43492. get vignetteEnabled(): boolean;
  43493. /**
  43494. * Sets wether the vignette effect is enabled.
  43495. */
  43496. set vignetteEnabled(value: boolean);
  43497. private _fromLinearSpace;
  43498. /**
  43499. * Gets wether the input of the processing is in Gamma or Linear Space.
  43500. */
  43501. get fromLinearSpace(): boolean;
  43502. /**
  43503. * Sets wether the input of the processing is in Gamma or Linear Space.
  43504. */
  43505. set fromLinearSpace(value: boolean);
  43506. /**
  43507. * Defines cache preventing GC.
  43508. */
  43509. private _defines;
  43510. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43511. /**
  43512. * "ImageProcessingPostProcess"
  43513. * @returns "ImageProcessingPostProcess"
  43514. */
  43515. getClassName(): string;
  43516. protected _updateParameters(): void;
  43517. dispose(camera?: Camera): void;
  43518. }
  43519. }
  43520. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43521. import { Scene } from "babylonjs/scene";
  43522. import { Color3 } from "babylonjs/Maths/math.color";
  43523. import { Mesh } from "babylonjs/Meshes/mesh";
  43524. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43525. import { Nullable } from "babylonjs/types";
  43526. /**
  43527. * Class containing static functions to help procedurally build meshes
  43528. */
  43529. export class GroundBuilder {
  43530. /**
  43531. * Creates a ground mesh
  43532. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43533. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43535. * @param name defines the name of the mesh
  43536. * @param options defines the options used to create the mesh
  43537. * @param scene defines the hosting scene
  43538. * @returns the ground mesh
  43539. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43540. */
  43541. static CreateGround(name: string, options: {
  43542. width?: number;
  43543. height?: number;
  43544. subdivisions?: number;
  43545. subdivisionsX?: number;
  43546. subdivisionsY?: number;
  43547. updatable?: boolean;
  43548. }, scene: any): Mesh;
  43549. /**
  43550. * Creates a tiled ground mesh
  43551. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43552. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43553. * * 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
  43554. * * 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
  43555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43556. * @param name defines the name of the mesh
  43557. * @param options defines the options used to create the mesh
  43558. * @param scene defines the hosting scene
  43559. * @returns the tiled ground mesh
  43560. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43561. */
  43562. static CreateTiledGround(name: string, options: {
  43563. xmin: number;
  43564. zmin: number;
  43565. xmax: number;
  43566. zmax: number;
  43567. subdivisions?: {
  43568. w: number;
  43569. h: number;
  43570. };
  43571. precision?: {
  43572. w: number;
  43573. h: number;
  43574. };
  43575. updatable?: boolean;
  43576. }, scene?: Nullable<Scene>): Mesh;
  43577. /**
  43578. * Creates a ground mesh from a height map
  43579. * * The parameter `url` sets the URL of the height map image resource.
  43580. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43581. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43582. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43583. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43584. * * 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.
  43585. * * 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).
  43586. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43588. * @param name defines the name of the mesh
  43589. * @param url defines the url to the height map
  43590. * @param options defines the options used to create the mesh
  43591. * @param scene defines the hosting scene
  43592. * @returns the ground mesh
  43593. * @see https://doc.babylonjs.com/babylon101/height_map
  43594. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43595. */
  43596. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43597. width?: number;
  43598. height?: number;
  43599. subdivisions?: number;
  43600. minHeight?: number;
  43601. maxHeight?: number;
  43602. colorFilter?: Color3;
  43603. alphaFilter?: number;
  43604. updatable?: boolean;
  43605. onReady?: (mesh: GroundMesh) => void;
  43606. }, scene?: Nullable<Scene>): GroundMesh;
  43607. }
  43608. }
  43609. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43610. import { Vector4 } from "babylonjs/Maths/math.vector";
  43611. import { Mesh } from "babylonjs/Meshes/mesh";
  43612. /**
  43613. * Class containing static functions to help procedurally build meshes
  43614. */
  43615. export class TorusBuilder {
  43616. /**
  43617. * Creates a torus mesh
  43618. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43619. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43620. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43621. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43622. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43623. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43624. * @param name defines the name of the mesh
  43625. * @param options defines the options used to create the mesh
  43626. * @param scene defines the hosting scene
  43627. * @returns the torus mesh
  43628. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43629. */
  43630. static CreateTorus(name: string, options: {
  43631. diameter?: number;
  43632. thickness?: number;
  43633. tessellation?: number;
  43634. updatable?: boolean;
  43635. sideOrientation?: number;
  43636. frontUVs?: Vector4;
  43637. backUVs?: Vector4;
  43638. }, scene: any): Mesh;
  43639. }
  43640. }
  43641. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43642. import { Vector4 } from "babylonjs/Maths/math.vector";
  43643. import { Color4 } from "babylonjs/Maths/math.color";
  43644. import { Mesh } from "babylonjs/Meshes/mesh";
  43645. /**
  43646. * Class containing static functions to help procedurally build meshes
  43647. */
  43648. export class CylinderBuilder {
  43649. /**
  43650. * Creates a cylinder or a cone mesh
  43651. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43652. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43653. * * 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.
  43654. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43655. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43656. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43657. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43658. * * 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).
  43659. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43660. * * 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).
  43661. * * 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
  43662. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43663. * * 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
  43664. * * 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.
  43665. * * If `enclose` is false, a ring surface is one element.
  43666. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43667. * * 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
  43668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43671. * @param name defines the name of the mesh
  43672. * @param options defines the options used to create the mesh
  43673. * @param scene defines the hosting scene
  43674. * @returns the cylinder mesh
  43675. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43676. */
  43677. static CreateCylinder(name: string, options: {
  43678. height?: number;
  43679. diameterTop?: number;
  43680. diameterBottom?: number;
  43681. diameter?: number;
  43682. tessellation?: number;
  43683. subdivisions?: number;
  43684. arc?: number;
  43685. faceColors?: Color4[];
  43686. faceUV?: Vector4[];
  43687. updatable?: boolean;
  43688. hasRings?: boolean;
  43689. enclose?: boolean;
  43690. cap?: number;
  43691. sideOrientation?: number;
  43692. frontUVs?: Vector4;
  43693. backUVs?: Vector4;
  43694. }, scene: any): Mesh;
  43695. }
  43696. }
  43697. declare module "babylonjs/Cameras/XR/webXRTypes" {
  43698. import { Nullable } from "babylonjs/types";
  43699. import { IDisposable } from "babylonjs/scene";
  43700. /**
  43701. * States of the webXR experience
  43702. */
  43703. export enum WebXRState {
  43704. /**
  43705. * Transitioning to being in XR mode
  43706. */
  43707. ENTERING_XR = 0,
  43708. /**
  43709. * Transitioning to non XR mode
  43710. */
  43711. EXITING_XR = 1,
  43712. /**
  43713. * In XR mode and presenting
  43714. */
  43715. IN_XR = 2,
  43716. /**
  43717. * Not entered XR mode
  43718. */
  43719. NOT_IN_XR = 3
  43720. }
  43721. /**
  43722. * Abstraction of the XR render target
  43723. */
  43724. export interface WebXRRenderTarget extends IDisposable {
  43725. /**
  43726. * xrpresent context of the canvas which can be used to display/mirror xr content
  43727. */
  43728. canvasContext: WebGLRenderingContext;
  43729. /**
  43730. * xr layer for the canvas
  43731. */
  43732. xrLayer: Nullable<XRWebGLLayer>;
  43733. /**
  43734. * Initializes the xr layer for the session
  43735. * @param xrSession xr session
  43736. * @returns a promise that will resolve once the XR Layer has been created
  43737. */
  43738. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  43739. }
  43740. }
  43741. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43742. import { Nullable } from "babylonjs/types";
  43743. import { Observable } from "babylonjs/Misc/observable";
  43744. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  43745. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  43746. /**
  43747. * COnfiguration object for WebXR output canvas
  43748. */
  43749. export class WebXRManagedOutputCanvasOptions {
  43750. /**
  43751. * Options for this XR Layer output
  43752. */
  43753. canvasOptions: XRWebGLLayerOptions;
  43754. /**
  43755. * CSS styling for a newly created canvas (if not provided)
  43756. */
  43757. newCanvasCssStyle?: string;
  43758. /**
  43759. * Get the default values of the configuration object
  43760. * @returns default values of this configuration object
  43761. */
  43762. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  43763. }
  43764. /**
  43765. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43766. */
  43767. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  43768. private configuration;
  43769. private _engine;
  43770. private _canvas;
  43771. /**
  43772. * xrpresent context of the canvas which can be used to display/mirror xr content
  43773. */
  43774. canvasContext: WebGLRenderingContext;
  43775. /**
  43776. * xr layer for the canvas
  43777. */
  43778. xrLayer: Nullable<XRWebGLLayer>;
  43779. /**
  43780. * Initializes the xr layer for the session
  43781. * @param xrSession xr session
  43782. * @returns a promise that will resolve once the XR Layer has been created
  43783. */
  43784. initializeXRLayerAsync(xrSession: any): any;
  43785. /**
  43786. * Initializes the canvas to be added/removed upon entering/exiting xr
  43787. * @param engine the Babylon engine
  43788. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43789. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  43790. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  43791. */
  43792. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  43793. /**
  43794. * Disposes of the object
  43795. */
  43796. dispose(): void;
  43797. private _setManagedOutputCanvas;
  43798. private _addCanvas;
  43799. private _removeCanvas;
  43800. }
  43801. }
  43802. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  43803. import { Observable } from "babylonjs/Misc/observable";
  43804. import { Nullable } from "babylonjs/types";
  43805. import { IDisposable, Scene } from "babylonjs/scene";
  43806. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43807. import { WebXRRenderTarget, WebXRState } from "babylonjs/Cameras/XR/webXRTypes";
  43808. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43809. /**
  43810. * Manages an XRSession to work with Babylon's engine
  43811. * @see https://doc.babylonjs.com/how_to/webxr
  43812. */
  43813. export class WebXRSessionManager implements IDisposable {
  43814. /** The scene which the session should be created for */
  43815. scene: Scene;
  43816. /**
  43817. * Fires every time a new xrFrame arrives which can be used to update the camera
  43818. */
  43819. onXRFrameObservable: Observable<XRFrame>;
  43820. /**
  43821. * Fires when the xr session is ended either by the device or manually done
  43822. */
  43823. onXRSessionEnded: Observable<any>;
  43824. /**
  43825. * Fires when the xr session is ended either by the device or manually done
  43826. */
  43827. onXRSessionInit: Observable<XRSession>;
  43828. /**
  43829. * Underlying xr session
  43830. */
  43831. session: XRSession;
  43832. /**
  43833. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  43834. * or get the offset the player is currently at.
  43835. */
  43836. viewerReferenceSpace: XRReferenceSpace;
  43837. /**
  43838. * The current reference space used in this session. This reference space can constantly change!
  43839. * It is mainly used to offset the camera's position.
  43840. */
  43841. referenceSpace: XRReferenceSpace;
  43842. /**
  43843. * The base reference space from which the session started. good if you want to reset your
  43844. * reference space
  43845. */
  43846. baseReferenceSpace: XRReferenceSpace;
  43847. /**
  43848. * Used just in case of a failure to initialize an immersive session.
  43849. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  43850. */
  43851. defaultHeightCompensation: number;
  43852. /**
  43853. * Current XR frame
  43854. */
  43855. currentFrame: Nullable<XRFrame>;
  43856. /** WebXR timestamp updated every frame */
  43857. currentTimestamp: number;
  43858. private _xrNavigator;
  43859. private baseLayer;
  43860. private _rttProvider;
  43861. private _sessionEnded;
  43862. /**
  43863. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  43864. * @param scene The scene which the session should be created for
  43865. */
  43866. constructor(
  43867. /** The scene which the session should be created for */
  43868. scene: Scene);
  43869. /**
  43870. * Initializes the manager
  43871. * After initialization enterXR can be called to start an XR session
  43872. * @returns Promise which resolves after it is initialized
  43873. */
  43874. initializeAsync(): Promise<void>;
  43875. /**
  43876. * Initializes an xr session
  43877. * @param xrSessionMode mode to initialize
  43878. * @param optionalFeatures defines optional values to pass to the session builder
  43879. * @returns a promise which will resolve once the session has been initialized
  43880. */
  43881. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  43882. /**
  43883. * Sets the reference space on the xr session
  43884. * @param referenceSpace space to set
  43885. * @returns a promise that will resolve once the reference space has been set
  43886. */
  43887. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  43888. /**
  43889. * Updates the render state of the session
  43890. * @param state state to set
  43891. * @returns a promise that resolves once the render state has been updated
  43892. */
  43893. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  43894. /**
  43895. * Starts rendering to the xr layer
  43896. * @returns a promise that will resolve once rendering has started
  43897. */
  43898. startRenderingToXRAsync(): Promise<void>;
  43899. /**
  43900. * Gets the correct render target texture to be rendered this frame for this eye
  43901. * @param eye the eye for which to get the render target
  43902. * @returns the render target for the specified eye
  43903. */
  43904. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  43905. /**
  43906. * Stops the xrSession and restores the renderloop
  43907. * @returns Promise which resolves after it exits XR
  43908. */
  43909. exitXRAsync(): Promise<void>;
  43910. /**
  43911. * Checks if a session would be supported for the creation options specified
  43912. * @param sessionMode session mode to check if supported eg. immersive-vr
  43913. * @returns true if supported
  43914. */
  43915. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43916. /**
  43917. * Creates a WebXRRenderTarget object for the XR session
  43918. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  43919. * @param options optional options to provide when creating a new render target
  43920. * @returns a WebXR render target to which the session can render
  43921. */
  43922. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  43923. /**
  43924. * @hidden
  43925. * Converts the render layer of xrSession to a render target
  43926. * @param session session to create render target for
  43927. * @param scene scene the new render target should be created for
  43928. * @param baseLayer the webgl layer to create the render target for
  43929. */
  43930. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  43931. /**
  43932. * Disposes of the session manager
  43933. */
  43934. dispose(): void;
  43935. /**
  43936. * Gets a promise returning true when fullfiled if the given session mode is supported
  43937. * @param sessionMode defines the session to test
  43938. * @returns a promise
  43939. */
  43940. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  43941. }
  43942. }
  43943. declare module "babylonjs/Cameras/XR/webXRCamera" {
  43944. import { Scene } from "babylonjs/scene";
  43945. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43946. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43947. /**
  43948. * WebXR Camera which holds the views for the xrSession
  43949. * @see https://doc.babylonjs.com/how_to/webxr
  43950. */
  43951. export class WebXRCamera extends FreeCamera {
  43952. private _xrSessionManager;
  43953. /**
  43954. * Is the camera in debug mode. Used when using an emulator
  43955. */
  43956. debugMode: boolean;
  43957. private _firstFrame;
  43958. private _referencedPosition;
  43959. private _referenceQuaternion;
  43960. private _xrInvPositionCache;
  43961. private _xrInvQuaternionCache;
  43962. /**
  43963. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  43964. * @param name the name of the camera
  43965. * @param scene the scene to add the camera to
  43966. */
  43967. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  43968. private _updateNumberOfRigCameras;
  43969. /** @hidden */
  43970. _updateForDualEyeDebugging(): void;
  43971. private _updateReferenceSpace;
  43972. private _updateReferenceSpaceOffset;
  43973. private _updateFromXRSession;
  43974. }
  43975. }
  43976. declare module "babylonjs/Cameras/XR/webXRFeaturesManager" {
  43977. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43978. import { IDisposable } from "babylonjs/scene";
  43979. /**
  43980. * Defining the interface required for a (webxr) feature
  43981. */
  43982. export interface IWebXRFeature extends IDisposable {
  43983. /**
  43984. * Attach the feature to the session
  43985. * Will usually be called by the features manager
  43986. *
  43987. * @returns true if successful.
  43988. */
  43989. attach(): boolean;
  43990. /**
  43991. * Detach the feature from the session
  43992. * Will usually be called by the features manager
  43993. *
  43994. * @returns true if successful.
  43995. */
  43996. detach(): boolean;
  43997. }
  43998. /**
  43999. * Defining the constructor of a feature. Used to register the modules.
  44000. */
  44001. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44002. /**
  44003. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44004. * It is mainly used in AR sessions.
  44005. *
  44006. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44007. */
  44008. export class WebXRFeaturesManager implements IDisposable {
  44009. private _xrSessionManager;
  44010. private static readonly _AvailableFeatures;
  44011. /**
  44012. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44013. * Mainly used internally.
  44014. *
  44015. * @param featureName the name of the feature to register
  44016. * @param constructorFunction the function used to construct the module
  44017. * @param version the (babylon) version of the module
  44018. * @param stable is that a stable version of this module
  44019. */
  44020. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44021. /**
  44022. * Returns a constructor of a specific feature.
  44023. *
  44024. * @param featureName the name of the feature to construct
  44025. * @param version the version of the feature to load
  44026. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44027. * @param options optional options provided to the module.
  44028. * @returns a function that, when called, will return a new instance of this feature
  44029. */
  44030. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44031. /**
  44032. * Return the latest unstable version of this feature
  44033. * @param featureName the name of the feature to search
  44034. * @returns the version number. if not found will return -1
  44035. */
  44036. static GetLatestVersionOfFeature(featureName: string): number;
  44037. /**
  44038. * Return the latest stable version of this feature
  44039. * @param featureName the name of the feature to search
  44040. * @returns the version number. if not found will return -1
  44041. */
  44042. static GetStableVersionOfFeature(featureName: string): number;
  44043. /**
  44044. * Can be used to return the list of features currently registered
  44045. *
  44046. * @returns an Array of available features
  44047. */
  44048. static GetAvailableFeatures(): string[];
  44049. /**
  44050. * Gets the versions available for a specific feature
  44051. * @param featureName the name of the feature
  44052. * @returns an array with the available versions
  44053. */
  44054. static GetAvailableVersions(featureName: string): string[];
  44055. private _features;
  44056. /**
  44057. * constructs a new features manages.
  44058. *
  44059. * @param _xrSessionManager an instance of WebXRSessionManager
  44060. */
  44061. constructor(_xrSessionManager: WebXRSessionManager);
  44062. /**
  44063. * 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.
  44064. *
  44065. * @param featureName the name of the feature to load or the class of the feature
  44066. * @param version optional version to load. if not provided the latest version will be enabled
  44067. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44068. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44069. * @returns a new constructed feature or throws an error if feature not found.
  44070. */
  44071. enableFeature(featureName: string | {
  44072. Name: string;
  44073. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44074. /**
  44075. * Used to disable an already-enabled feature
  44076. * @param featureName the feature to disable
  44077. * @returns true if disable was successful
  44078. */
  44079. disableFeature(featureName: string | {
  44080. Name: string;
  44081. }): boolean;
  44082. /**
  44083. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44084. * Can be used during a session to start a feature
  44085. * @param featureName the name of feature to attach
  44086. */
  44087. attachFeature(featureName: string): void;
  44088. /**
  44089. * Can be used inside a session or when the session ends to detach a specific feature
  44090. * @param featureName the name of the feature to detach
  44091. */
  44092. detachFeature(featureName: string): void;
  44093. /**
  44094. * Get the list of enabled features
  44095. * @returns an array of enabled features
  44096. */
  44097. getEnabledFeatures(): string[];
  44098. /**
  44099. * get the implementation of an enabled feature.
  44100. * @param featureName the name of the feature to load
  44101. * @returns the feature class, if found
  44102. */
  44103. getEnabledFeature(featureName: string): IWebXRFeature;
  44104. /**
  44105. * dispose this features manager
  44106. */
  44107. dispose(): void;
  44108. }
  44109. }
  44110. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  44111. import { Observable } from "babylonjs/Misc/observable";
  44112. import { IDisposable, Scene } from "babylonjs/scene";
  44113. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  44114. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  44115. import { WebXRState, WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  44116. import { WebXRFeaturesManager } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  44117. /**
  44118. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44119. * @see https://doc.babylonjs.com/how_to/webxr
  44120. */
  44121. export class WebXRExperienceHelper implements IDisposable {
  44122. private scene;
  44123. /**
  44124. * Camera used to render xr content
  44125. */
  44126. camera: WebXRCamera;
  44127. /**
  44128. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44129. */
  44130. state: WebXRState;
  44131. private _setState;
  44132. /**
  44133. * Fires when the state of the experience helper has changed
  44134. */
  44135. onStateChangedObservable: Observable<WebXRState>;
  44136. /**
  44137. * Observers registered here will be triggered after the camera's initial transformation is set
  44138. * This can be used to set a different ground level or an extra rotation.
  44139. *
  44140. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44141. * to the position set after this observable is done executing.
  44142. */
  44143. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44144. /** Session manager used to keep track of xr session */
  44145. sessionManager: WebXRSessionManager;
  44146. /** A features manager for this xr session */
  44147. featuresManager: WebXRFeaturesManager;
  44148. private _nonVRCamera;
  44149. private _originalSceneAutoClear;
  44150. private _supported;
  44151. /**
  44152. * Creates the experience helper
  44153. * @param scene the scene to attach the experience helper to
  44154. * @returns a promise for the experience helper
  44155. */
  44156. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44157. /**
  44158. * Creates a WebXRExperienceHelper
  44159. * @param scene The scene the helper should be created in
  44160. */
  44161. private constructor();
  44162. /**
  44163. * Exits XR mode and returns the scene to its original state
  44164. * @returns promise that resolves after xr mode has exited
  44165. */
  44166. exitXRAsync(): Promise<void>;
  44167. /**
  44168. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44169. * @param sessionMode options for the XR session
  44170. * @param referenceSpaceType frame of reference of the XR session
  44171. * @param renderTarget the output canvas that will be used to enter XR mode
  44172. * @returns promise that resolves after xr mode has entered
  44173. */
  44174. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44175. /**
  44176. * Disposes of the experience helper
  44177. */
  44178. dispose(): void;
  44179. private _nonXRToXRCamera;
  44180. }
  44181. }
  44182. declare module "babylonjs/Cameras/XR/motionController/webXRControllerComponent" {
  44183. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  44184. import { Observable } from "babylonjs/Misc/observable";
  44185. import { IDisposable } from "babylonjs/scene";
  44186. /**
  44187. * X-Y values for axes in WebXR
  44188. */
  44189. export interface IWebXRMotionControllerAxesValue {
  44190. /**
  44191. * The value of the x axis
  44192. */
  44193. x: number;
  44194. /**
  44195. * The value of the y-axis
  44196. */
  44197. y: number;
  44198. }
  44199. /**
  44200. * changed / previous values for the values of this component
  44201. */
  44202. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44203. /**
  44204. * current (this frame) value
  44205. */
  44206. current: T;
  44207. /**
  44208. * previous (last change) value
  44209. */
  44210. previous: T;
  44211. }
  44212. /**
  44213. * Represents changes in the component between current frame and last values recorded
  44214. */
  44215. export interface IWebXRMotionControllerComponentChanges {
  44216. /**
  44217. * will be populated with previous and current values if touched changed
  44218. */
  44219. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44220. /**
  44221. * will be populated with previous and current values if pressed changed
  44222. */
  44223. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44224. /**
  44225. * will be populated with previous and current values if value changed
  44226. */
  44227. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44228. /**
  44229. * will be populated with previous and current values if axes changed
  44230. */
  44231. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44232. }
  44233. /**
  44234. * This class represents a single component (for example button or thumbstick) of a motion controller
  44235. */
  44236. export class WebXRControllerComponent implements IDisposable {
  44237. /**
  44238. * the id of this component
  44239. */
  44240. id: string;
  44241. /**
  44242. * the type of the component
  44243. */
  44244. type: MotionControllerComponentType;
  44245. private _buttonIndex;
  44246. private _axesIndices;
  44247. /**
  44248. * Observers registered here will be triggered when the state of a button changes
  44249. * State change is either pressed / touched / value
  44250. */
  44251. onButtonStateChanged: Observable<WebXRControllerComponent>;
  44252. /**
  44253. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44254. * the axes data changes
  44255. */
  44256. onAxisValueChanged: Observable<{
  44257. x: number;
  44258. y: number;
  44259. }>;
  44260. private _currentValue;
  44261. private _touched;
  44262. private _pressed;
  44263. private _axes;
  44264. private _changes;
  44265. /**
  44266. * Creates a new component for a motion controller.
  44267. * It is created by the motion controller itself
  44268. *
  44269. * @param id the id of this component
  44270. * @param type the type of the component
  44271. * @param _buttonIndex index in the buttons array of the gamepad
  44272. * @param _axesIndices indices of the values in the axes array of the gamepad
  44273. */
  44274. constructor(
  44275. /**
  44276. * the id of this component
  44277. */
  44278. id: string,
  44279. /**
  44280. * the type of the component
  44281. */
  44282. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44283. /**
  44284. * Get the current value of this component
  44285. */
  44286. get value(): number;
  44287. /**
  44288. * is the button currently pressed
  44289. */
  44290. get pressed(): boolean;
  44291. /**
  44292. * is the button currently touched
  44293. */
  44294. get touched(): boolean;
  44295. /**
  44296. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44297. */
  44298. get axes(): IWebXRMotionControllerAxesValue;
  44299. /**
  44300. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44301. */
  44302. get changes(): IWebXRMotionControllerComponentChanges;
  44303. /**
  44304. * Is this component a button (hence - pressable)
  44305. * @returns true if can be pressed
  44306. */
  44307. isButton(): boolean;
  44308. /**
  44309. * Are there axes correlating to this component
  44310. * @return true is axes data is available
  44311. */
  44312. isAxes(): boolean;
  44313. /**
  44314. * update this component using the gamepad object it is in. Called on every frame
  44315. * @param nativeController the native gamepad controller object
  44316. */
  44317. update(nativeController: IMinimalMotionControllerObject): void;
  44318. /**
  44319. * Dispose this component
  44320. */
  44321. dispose(): void;
  44322. }
  44323. }
  44324. declare module "babylonjs/Loading/sceneLoader" {
  44325. import { Observable } from "babylonjs/Misc/observable";
  44326. import { Nullable } from "babylonjs/types";
  44327. import { Scene } from "babylonjs/scene";
  44328. import { Engine } from "babylonjs/Engines/engine";
  44329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44330. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44331. import { AssetContainer } from "babylonjs/assetContainer";
  44332. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44333. import { Skeleton } from "babylonjs/Bones/skeleton";
  44334. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44335. import { WebRequest } from "babylonjs/Misc/webRequest";
  44336. /**
  44337. * Class used to represent data loading progression
  44338. */
  44339. export class SceneLoaderProgressEvent {
  44340. /** defines if data length to load can be evaluated */
  44341. readonly lengthComputable: boolean;
  44342. /** defines the loaded data length */
  44343. readonly loaded: number;
  44344. /** defines the data length to load */
  44345. readonly total: number;
  44346. /**
  44347. * Create a new progress event
  44348. * @param lengthComputable defines if data length to load can be evaluated
  44349. * @param loaded defines the loaded data length
  44350. * @param total defines the data length to load
  44351. */
  44352. constructor(
  44353. /** defines if data length to load can be evaluated */
  44354. lengthComputable: boolean,
  44355. /** defines the loaded data length */
  44356. loaded: number,
  44357. /** defines the data length to load */
  44358. total: number);
  44359. /**
  44360. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44361. * @param event defines the source event
  44362. * @returns a new SceneLoaderProgressEvent
  44363. */
  44364. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44365. }
  44366. /**
  44367. * Interface used by SceneLoader plugins to define supported file extensions
  44368. */
  44369. export interface ISceneLoaderPluginExtensions {
  44370. /**
  44371. * Defines the list of supported extensions
  44372. */
  44373. [extension: string]: {
  44374. isBinary: boolean;
  44375. };
  44376. }
  44377. /**
  44378. * Interface used by SceneLoader plugin factory
  44379. */
  44380. export interface ISceneLoaderPluginFactory {
  44381. /**
  44382. * Defines the name of the factory
  44383. */
  44384. name: string;
  44385. /**
  44386. * Function called to create a new plugin
  44387. * @return the new plugin
  44388. */
  44389. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44390. /**
  44391. * The callback that returns true if the data can be directly loaded.
  44392. * @param data string containing the file data
  44393. * @returns if the data can be loaded directly
  44394. */
  44395. canDirectLoad?(data: string): boolean;
  44396. }
  44397. /**
  44398. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44399. */
  44400. export interface ISceneLoaderPluginBase {
  44401. /**
  44402. * The friendly name of this plugin.
  44403. */
  44404. name: string;
  44405. /**
  44406. * The file extensions supported by this plugin.
  44407. */
  44408. extensions: string | ISceneLoaderPluginExtensions;
  44409. /**
  44410. * The callback called when loading from a url.
  44411. * @param scene scene loading this url
  44412. * @param url url to load
  44413. * @param onSuccess callback called when the file successfully loads
  44414. * @param onProgress callback called while file is loading (if the server supports this mode)
  44415. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44416. * @param onError callback called when the file fails to load
  44417. * @returns a file request object
  44418. */
  44419. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44420. /**
  44421. * The callback called when loading from a file object.
  44422. * @param scene scene loading this file
  44423. * @param file defines the file to load
  44424. * @param onSuccess defines the callback to call when data is loaded
  44425. * @param onProgress defines the callback to call during loading process
  44426. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44427. * @param onError defines the callback to call when an error occurs
  44428. * @returns a file request object
  44429. */
  44430. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44431. /**
  44432. * The callback that returns true if the data can be directly loaded.
  44433. * @param data string containing the file data
  44434. * @returns if the data can be loaded directly
  44435. */
  44436. canDirectLoad?(data: string): boolean;
  44437. /**
  44438. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44439. * @param scene scene loading this data
  44440. * @param data string containing the data
  44441. * @returns data to pass to the plugin
  44442. */
  44443. directLoad?(scene: Scene, data: string): any;
  44444. /**
  44445. * The callback that allows custom handling of the root url based on the response url.
  44446. * @param rootUrl the original root url
  44447. * @param responseURL the response url if available
  44448. * @returns the new root url
  44449. */
  44450. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44451. }
  44452. /**
  44453. * Interface used to define a SceneLoader plugin
  44454. */
  44455. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44456. /**
  44457. * Import meshes into a scene.
  44458. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44459. * @param scene The scene to import into
  44460. * @param data The data to import
  44461. * @param rootUrl The root url for scene and resources
  44462. * @param meshes The meshes array to import into
  44463. * @param particleSystems The particle systems array to import into
  44464. * @param skeletons The skeletons array to import into
  44465. * @param onError The callback when import fails
  44466. * @returns True if successful or false otherwise
  44467. */
  44468. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44469. /**
  44470. * Load into a scene.
  44471. * @param scene The scene to load into
  44472. * @param data The data to import
  44473. * @param rootUrl The root url for scene and resources
  44474. * @param onError The callback when import fails
  44475. * @returns True if successful or false otherwise
  44476. */
  44477. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44478. /**
  44479. * Load into an asset container.
  44480. * @param scene The scene to load into
  44481. * @param data The data to import
  44482. * @param rootUrl The root url for scene and resources
  44483. * @param onError The callback when import fails
  44484. * @returns The loaded asset container
  44485. */
  44486. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44487. }
  44488. /**
  44489. * Interface used to define an async SceneLoader plugin
  44490. */
  44491. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44492. /**
  44493. * Import meshes into a scene.
  44494. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44495. * @param scene The scene to import into
  44496. * @param data The data to import
  44497. * @param rootUrl The root url for scene and resources
  44498. * @param onProgress The callback when the load progresses
  44499. * @param fileName Defines the name of the file to load
  44500. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44501. */
  44502. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44503. meshes: AbstractMesh[];
  44504. particleSystems: IParticleSystem[];
  44505. skeletons: Skeleton[];
  44506. animationGroups: AnimationGroup[];
  44507. }>;
  44508. /**
  44509. * Load into a scene.
  44510. * @param scene The scene to load into
  44511. * @param data The data to import
  44512. * @param rootUrl The root url for scene and resources
  44513. * @param onProgress The callback when the load progresses
  44514. * @param fileName Defines the name of the file to load
  44515. * @returns Nothing
  44516. */
  44517. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44518. /**
  44519. * Load into an asset container.
  44520. * @param scene The scene to load into
  44521. * @param data The data to import
  44522. * @param rootUrl The root url for scene and resources
  44523. * @param onProgress The callback when the load progresses
  44524. * @param fileName Defines the name of the file to load
  44525. * @returns The loaded asset container
  44526. */
  44527. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44528. }
  44529. /**
  44530. * Mode that determines how to handle old animation groups before loading new ones.
  44531. */
  44532. export enum SceneLoaderAnimationGroupLoadingMode {
  44533. /**
  44534. * Reset all old animations to initial state then dispose them.
  44535. */
  44536. Clean = 0,
  44537. /**
  44538. * Stop all old animations.
  44539. */
  44540. Stop = 1,
  44541. /**
  44542. * Restart old animations from first frame.
  44543. */
  44544. Sync = 2,
  44545. /**
  44546. * Old animations remains untouched.
  44547. */
  44548. NoSync = 3
  44549. }
  44550. /**
  44551. * Class used to load scene from various file formats using registered plugins
  44552. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44553. */
  44554. export class SceneLoader {
  44555. /**
  44556. * No logging while loading
  44557. */
  44558. static readonly NO_LOGGING: number;
  44559. /**
  44560. * Minimal logging while loading
  44561. */
  44562. static readonly MINIMAL_LOGGING: number;
  44563. /**
  44564. * Summary logging while loading
  44565. */
  44566. static readonly SUMMARY_LOGGING: number;
  44567. /**
  44568. * Detailled logging while loading
  44569. */
  44570. static readonly DETAILED_LOGGING: number;
  44571. /**
  44572. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44573. */
  44574. static get ForceFullSceneLoadingForIncremental(): boolean;
  44575. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44576. /**
  44577. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44578. */
  44579. static get ShowLoadingScreen(): boolean;
  44580. static set ShowLoadingScreen(value: boolean);
  44581. /**
  44582. * Defines the current logging level (while loading the scene)
  44583. * @ignorenaming
  44584. */
  44585. static get loggingLevel(): number;
  44586. static set loggingLevel(value: number);
  44587. /**
  44588. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44589. */
  44590. static get CleanBoneMatrixWeights(): boolean;
  44591. static set CleanBoneMatrixWeights(value: boolean);
  44592. /**
  44593. * Event raised when a plugin is used to load a scene
  44594. */
  44595. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44596. private static _registeredPlugins;
  44597. private static _getDefaultPlugin;
  44598. private static _getPluginForExtension;
  44599. private static _getPluginForDirectLoad;
  44600. private static _getPluginForFilename;
  44601. private static _getDirectLoad;
  44602. private static _loadData;
  44603. private static _getFileInfo;
  44604. /**
  44605. * Gets a plugin that can load the given extension
  44606. * @param extension defines the extension to load
  44607. * @returns a plugin or null if none works
  44608. */
  44609. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44610. /**
  44611. * Gets a boolean indicating that the given extension can be loaded
  44612. * @param extension defines the extension to load
  44613. * @returns true if the extension is supported
  44614. */
  44615. static IsPluginForExtensionAvailable(extension: string): boolean;
  44616. /**
  44617. * Adds a new plugin to the list of registered plugins
  44618. * @param plugin defines the plugin to add
  44619. */
  44620. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44621. /**
  44622. * Import meshes into a scene
  44623. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44624. * @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)
  44625. * @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)
  44626. * @param scene the instance of BABYLON.Scene to append to
  44627. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44628. * @param onProgress a callback with a progress event for each file being loaded
  44629. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44630. * @param pluginExtension the extension used to determine the plugin
  44631. * @returns The loaded plugin
  44632. */
  44633. 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>;
  44634. /**
  44635. * Import meshes into a scene
  44636. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44637. * @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)
  44638. * @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)
  44639. * @param scene the instance of BABYLON.Scene to append to
  44640. * @param onProgress a callback with a progress event for each file being loaded
  44641. * @param pluginExtension the extension used to determine the plugin
  44642. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44643. */
  44644. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44645. meshes: AbstractMesh[];
  44646. particleSystems: IParticleSystem[];
  44647. skeletons: Skeleton[];
  44648. animationGroups: AnimationGroup[];
  44649. }>;
  44650. /**
  44651. * Load a scene
  44652. * @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)
  44653. * @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)
  44654. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44655. * @param onSuccess a callback with the scene when import succeeds
  44656. * @param onProgress a callback with a progress event for each file being loaded
  44657. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44658. * @param pluginExtension the extension used to determine the plugin
  44659. * @returns The loaded plugin
  44660. */
  44661. 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>;
  44662. /**
  44663. * Load a scene
  44664. * @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)
  44665. * @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)
  44666. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44667. * @param onProgress a callback with a progress event for each file being loaded
  44668. * @param pluginExtension the extension used to determine the plugin
  44669. * @returns The loaded scene
  44670. */
  44671. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44672. /**
  44673. * Append a scene
  44674. * @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)
  44675. * @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)
  44676. * @param scene is the instance of BABYLON.Scene to append to
  44677. * @param onSuccess a callback with the scene when import succeeds
  44678. * @param onProgress a callback with a progress event for each file being loaded
  44679. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44680. * @param pluginExtension the extension used to determine the plugin
  44681. * @returns The loaded plugin
  44682. */
  44683. 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>;
  44684. /**
  44685. * Append a scene
  44686. * @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)
  44687. * @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)
  44688. * @param scene is the instance of BABYLON.Scene to append to
  44689. * @param onProgress a callback with a progress event for each file being loaded
  44690. * @param pluginExtension the extension used to determine the plugin
  44691. * @returns The given scene
  44692. */
  44693. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44694. /**
  44695. * Load a scene into an asset container
  44696. * @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)
  44697. * @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)
  44698. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44699. * @param onSuccess a callback with the scene when import succeeds
  44700. * @param onProgress a callback with a progress event for each file being loaded
  44701. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44702. * @param pluginExtension the extension used to determine the plugin
  44703. * @returns The loaded plugin
  44704. */
  44705. 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>;
  44706. /**
  44707. * Load a scene into an asset container
  44708. * @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)
  44709. * @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)
  44710. * @param scene is the instance of Scene to append to
  44711. * @param onProgress a callback with a progress event for each file being loaded
  44712. * @param pluginExtension the extension used to determine the plugin
  44713. * @returns The loaded asset container
  44714. */
  44715. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44716. /**
  44717. * Import animations from a file into a scene
  44718. * @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)
  44719. * @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)
  44720. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44721. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44722. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44723. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44724. * @param onSuccess a callback with the scene when import succeeds
  44725. * @param onProgress a callback with a progress event for each file being loaded
  44726. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44727. */
  44728. 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;
  44729. /**
  44730. * Import animations from a file into a scene
  44731. * @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)
  44732. * @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)
  44733. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44734. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  44735. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  44736. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  44737. * @param onSuccess a callback with the scene when import succeeds
  44738. * @param onProgress a callback with a progress event for each file being loaded
  44739. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44740. * @returns the updated scene with imported animations
  44741. */
  44742. 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>;
  44743. }
  44744. }
  44745. declare module "babylonjs/Cameras/XR/motionController/webXRAbstractController" {
  44746. import { IDisposable, Scene } from "babylonjs/scene";
  44747. import { WebXRControllerComponent } from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  44748. import { Observable } from "babylonjs/Misc/observable";
  44749. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44750. import { Nullable } from "babylonjs/types";
  44751. /**
  44752. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  44753. */
  44754. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  44755. /**
  44756. * The type of components available in motion controllers.
  44757. * This is not the name of the component.
  44758. */
  44759. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  44760. /**
  44761. * The schema of motion controller layout.
  44762. * No object will be initialized using this interface
  44763. * This is used just to define the profile.
  44764. */
  44765. export interface IMotionControllerLayout {
  44766. /**
  44767. * Defines the main button component id
  44768. */
  44769. selectComponentId: string;
  44770. /**
  44771. * Available components (unsorted)
  44772. */
  44773. components: {
  44774. /**
  44775. * A map of component Ids
  44776. */
  44777. [componentId: string]: {
  44778. /**
  44779. * The type of input the component outputs
  44780. */
  44781. type: MotionControllerComponentType;
  44782. };
  44783. };
  44784. /**
  44785. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  44786. */
  44787. gamepad?: {
  44788. /**
  44789. * Is the mapping based on the xr-standard defined here:
  44790. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  44791. */
  44792. mapping: "" | "xr-standard";
  44793. /**
  44794. * The buttons available in this input in the right order
  44795. * index of this button will be the index in the gamepadObject.buttons array
  44796. * correlates to the componentId in components
  44797. */
  44798. buttons: Array<string | null>;
  44799. /**
  44800. * Definition of the axes of the gamepad input, sorted
  44801. * Correlates to componentIds in the components map
  44802. */
  44803. axes: Array<{
  44804. /**
  44805. * The component id that the axis correlates to
  44806. */
  44807. componentId: string;
  44808. /**
  44809. * X or Y Axis
  44810. */
  44811. axis: "x-axis" | "y-axis";
  44812. } | null>;
  44813. };
  44814. }
  44815. /**
  44816. * A definition for the layout map in the input profile
  44817. */
  44818. export interface IMotionControllerLayoutMap {
  44819. /**
  44820. * Layouts with handness type as a key
  44821. */
  44822. [handness: string]: IMotionControllerLayout;
  44823. }
  44824. /**
  44825. * The XR Input profile schema
  44826. * Profiles can be found here:
  44827. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  44828. */
  44829. export interface IMotionControllerProfile {
  44830. /**
  44831. * The id of this profile
  44832. * correlates to the profile(s) in the xrInput.profiles array
  44833. */
  44834. profileId: string;
  44835. /**
  44836. * fallback profiles for this profileId
  44837. */
  44838. fallbackProfileIds: string[];
  44839. /**
  44840. * The layout map, with handness as key
  44841. */
  44842. layouts: IMotionControllerLayoutMap;
  44843. }
  44844. /**
  44845. * A helper-interface for the 3 meshes needed for controller button animation
  44846. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  44847. */
  44848. export interface IMotionControllerButtonMeshMap {
  44849. /**
  44850. * The mesh that will be changed when value changes
  44851. */
  44852. valueMesh: AbstractMesh;
  44853. /**
  44854. * the mesh that defines the pressed value mesh position.
  44855. * This is used to find the max-position of this button
  44856. */
  44857. pressedMesh: AbstractMesh;
  44858. /**
  44859. * the mesh that defines the unpressed value mesh position.
  44860. * This is used to find the min (or initial) position of this button
  44861. */
  44862. unpressedMesh: AbstractMesh;
  44863. }
  44864. /**
  44865. * A helper-interface for the 3 meshes needed for controller axis animation.
  44866. * This will be expanded when touchpad animations are fully supported
  44867. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  44868. */
  44869. export interface IMotionControllerAxisMeshMap {
  44870. /**
  44871. * The mesh that will be changed when axis value changes
  44872. */
  44873. valueMesh: AbstractMesh;
  44874. /**
  44875. * the mesh that defines the minimum value mesh position.
  44876. */
  44877. minMesh: AbstractMesh;
  44878. /**
  44879. * the mesh that defines the maximum value mesh position.
  44880. */
  44881. maxMesh: AbstractMesh;
  44882. }
  44883. /**
  44884. * The elements needed for change-detection of the gamepad objects in motion controllers
  44885. */
  44886. export interface IMinimalMotionControllerObject {
  44887. /**
  44888. * An array of available buttons
  44889. */
  44890. buttons: Array<{
  44891. /**
  44892. * Value of the button/trigger
  44893. */
  44894. value: number;
  44895. /**
  44896. * If the button/trigger is currently touched
  44897. */
  44898. touched: boolean;
  44899. /**
  44900. * If the button/trigger is currently pressed
  44901. */
  44902. pressed: boolean;
  44903. }>;
  44904. /**
  44905. * Available axes of this controller
  44906. */
  44907. axes: number[];
  44908. }
  44909. /**
  44910. * An Abstract Motion controller
  44911. * This class receives an xrInput and a profile layout and uses those to initialize the components
  44912. * Each component has an observable to check for changes in value and state
  44913. */
  44914. export abstract class WebXRAbstractMotionController implements IDisposable {
  44915. protected scene: Scene;
  44916. protected layout: IMotionControllerLayout;
  44917. /**
  44918. * The gamepad object correlating to this controller
  44919. */
  44920. gamepadObject: IMinimalMotionControllerObject;
  44921. /**
  44922. * handness (left/right/none) of this controller
  44923. */
  44924. handness: MotionControllerHandness;
  44925. /**
  44926. * Component type map
  44927. */
  44928. static ComponentType: {
  44929. TRIGGER: string;
  44930. SQUEEZE: string;
  44931. TOUCHPAD: string;
  44932. THUMBSTICK: string;
  44933. BUTTON: string;
  44934. };
  44935. /**
  44936. * The profile id of this motion controller
  44937. */
  44938. abstract profileId: string;
  44939. /**
  44940. * A map of components (WebXRControllerComponent) in this motion controller
  44941. * Components have a ComponentType and can also have both button and axis definitions
  44942. */
  44943. readonly components: {
  44944. [id: string]: WebXRControllerComponent;
  44945. };
  44946. /**
  44947. * Observers registered here will be triggered when the model of this controller is done loading
  44948. */
  44949. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  44950. /**
  44951. * The root mesh of the model. It is null if the model was not yet initialized
  44952. */
  44953. rootMesh: Nullable<AbstractMesh>;
  44954. private _modelReady;
  44955. /**
  44956. * constructs a new abstract motion controller
  44957. * @param scene the scene to which the model of the controller will be added
  44958. * @param layout The profile layout to load
  44959. * @param gamepadObject The gamepad object correlating to this controller
  44960. * @param handness handness (left/right/none) of this controller
  44961. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  44962. */
  44963. constructor(scene: Scene, layout: IMotionControllerLayout,
  44964. /**
  44965. * The gamepad object correlating to this controller
  44966. */
  44967. gamepadObject: IMinimalMotionControllerObject,
  44968. /**
  44969. * handness (left/right/none) of this controller
  44970. */
  44971. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  44972. private _initComponent;
  44973. /**
  44974. * Update this model using the current XRFrame
  44975. * @param xrFrame the current xr frame to use and update the model
  44976. */
  44977. updateFromXRFrame(xrFrame: XRFrame): void;
  44978. /**
  44979. * Get the list of components available in this motion controller
  44980. * @returns an array of strings correlating to available components
  44981. */
  44982. getComponentTypes(): string[];
  44983. /**
  44984. * Get the main (Select) component of this controller as defined in the layout
  44985. * @returns the main component of this controller
  44986. */
  44987. getMainComponent(): WebXRControllerComponent;
  44988. /**
  44989. * get a component based an its component id as defined in layout.components
  44990. * @param id the id of the component
  44991. * @returns the component correlates to the id or undefined if not found
  44992. */
  44993. getComponent(id: string): WebXRControllerComponent;
  44994. /**
  44995. * Loads the model correlating to this controller
  44996. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  44997. * @returns A promise fulfilled with the result of the model loading
  44998. */
  44999. loadModel(): Promise<boolean>;
  45000. /**
  45001. * Update the model itself with the current frame data
  45002. * @param xrFrame the frame to use for updating the model mesh
  45003. */
  45004. protected updateModel(xrFrame: XRFrame): void;
  45005. /**
  45006. * Moves the axis on the controller mesh based on its current state
  45007. * @param axis the index of the axis
  45008. * @param axisValue the value of the axis which determines the meshes new position
  45009. * @hidden
  45010. */
  45011. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  45012. /**
  45013. * Moves the buttons on the controller mesh based on their current state
  45014. * @param buttonName the name of the button to move
  45015. * @param buttonValue the value of the button which determines the buttons new position
  45016. */
  45017. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  45018. private _getGenericFilenameAndPath;
  45019. private _getGenericParentMesh;
  45020. /**
  45021. * Get the filename and path for this controller's model
  45022. * @returns a map of filename and path
  45023. */
  45024. protected abstract _getFilenameAndPath(): {
  45025. filename: string;
  45026. path: string;
  45027. };
  45028. /**
  45029. * This function will be called after the model was successfully loaded and can be used
  45030. * for mesh transformations before it is available for the user
  45031. * @param meshes the loaded meshes
  45032. */
  45033. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45034. /**
  45035. * Set the root mesh for this controller. Important for the WebXR controller class
  45036. * @param meshes the loaded meshes
  45037. */
  45038. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45039. /**
  45040. * A function executed each frame that updates the mesh (if needed)
  45041. * @param xrFrame the current xrFrame
  45042. */
  45043. protected abstract _updateModel(xrFrame: XRFrame): void;
  45044. /**
  45045. * This function is called before the mesh is loaded. It checks for loading constraints.
  45046. * For example, this function can check if the GLB loader is available
  45047. * If this function returns false, the generic controller will be loaded instead
  45048. * @returns Is the client ready to load the mesh
  45049. */
  45050. protected abstract _getModelLoadingConstraints(): boolean;
  45051. /**
  45052. * Dispose this controller, the model mesh and all its components
  45053. */
  45054. dispose(): void;
  45055. }
  45056. }
  45057. declare module "babylonjs/Cameras/XR/motionController/webXRGenericMotionController" {
  45058. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45060. import { Scene } from "babylonjs/scene";
  45061. /**
  45062. * A generic trigger-only motion controller for WebXR
  45063. */
  45064. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45065. /**
  45066. * Static version of the profile id of this controller
  45067. */
  45068. static ProfileId: string;
  45069. profileId: string;
  45070. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45071. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45072. protected _updateModel(): void;
  45073. protected _getFilenameAndPath(): {
  45074. filename: string;
  45075. path: string;
  45076. };
  45077. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45078. protected _getModelLoadingConstraints(): boolean;
  45079. }
  45080. }
  45081. declare module "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager" {
  45082. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45083. import { Scene } from "babylonjs/scene";
  45084. /**
  45085. * A construction function type to create a new controller based on an xrInput object
  45086. */
  45087. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45088. /**
  45089. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45090. *
  45091. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45092. * it should be replaced with auto-loaded controllers.
  45093. *
  45094. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45095. */
  45096. export class WebXRMotionControllerManager {
  45097. private static _AvailableControllers;
  45098. private static _Fallbacks;
  45099. /**
  45100. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45101. *
  45102. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45103. *
  45104. * @param type the profile type to register
  45105. * @param constructFunction the function to be called when loading this profile
  45106. */
  45107. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45108. /**
  45109. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45110. * The order of search:
  45111. *
  45112. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45113. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45114. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45115. * 4) return the generic trigger controller if none were found
  45116. *
  45117. * @param xrInput the xrInput to which a new controller is initialized
  45118. * @param scene the scene to which the model will be added
  45119. * @return the motion controller class for this profile id or the generic standard class if none was found
  45120. */
  45121. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene): WebXRAbstractMotionController;
  45122. /**
  45123. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45124. * @param profileId the profile to which a fallback needs to be found
  45125. * @return an array with corresponding fallback profiles
  45126. */
  45127. static FindFallbackWithProfileId(profileId: string): string[];
  45128. /**
  45129. * Register a fallback to a specific profile.
  45130. * @param profileId the profileId that will receive the fallbacks
  45131. * @param fallbacks A list of fallback profiles
  45132. */
  45133. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45134. /**
  45135. * Register the default fallbacks.
  45136. * This function is called automatically when this file is imported.
  45137. */
  45138. static DefaultFallbacks(): void;
  45139. }
  45140. }
  45141. declare module "babylonjs/Cameras/XR/webXRController" {
  45142. import { Observable } from "babylonjs/Misc/observable";
  45143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45144. import { Ray } from "babylonjs/Culling/ray";
  45145. import { Scene } from "babylonjs/scene";
  45146. import { WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  45147. /**
  45148. * Represents an XR input
  45149. */
  45150. export class WebXRController {
  45151. private scene;
  45152. /** The underlying input source for the controller */
  45153. inputSource: XRInputSource;
  45154. /**
  45155. * 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
  45156. */
  45157. grip?: AbstractMesh;
  45158. /**
  45159. * Pointer which can be used to select objects or attach a visible laser to
  45160. */
  45161. pointer: AbstractMesh;
  45162. private _gamepadMode;
  45163. /**
  45164. * If available, this is the gamepad object related to this controller.
  45165. * Using this object it is possible to get click events and trackpad changes of the
  45166. * webxr controller that is currently being used.
  45167. */
  45168. gamepadController?: WebXRAbstractMotionController;
  45169. /**
  45170. * Event that fires when the controller is removed/disposed
  45171. */
  45172. onDisposeObservable: Observable<{}>;
  45173. private _tmpQuaternion;
  45174. private _tmpVector;
  45175. /**
  45176. * Creates the controller
  45177. * @see https://doc.babylonjs.com/how_to/webxr
  45178. * @param scene the scene which the controller should be associated to
  45179. * @param inputSource the underlying input source for the controller
  45180. * @param parentContainer parent that the controller meshes should be children of
  45181. */
  45182. constructor(scene: Scene,
  45183. /** The underlying input source for the controller */
  45184. inputSource: XRInputSource);
  45185. /**
  45186. * Updates the controller pose based on the given XRFrame
  45187. * @param xrFrame xr frame to update the pose with
  45188. * @param referenceSpace reference space to use
  45189. */
  45190. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45191. /**
  45192. * Gets a world space ray coming from the controller
  45193. * @param result the resulting ray
  45194. */
  45195. getWorldPointerRayToRef(result: Ray): void;
  45196. /**
  45197. * Get the scene associated with this controller
  45198. * @returns the scene object
  45199. */
  45200. getScene(): Scene;
  45201. /**
  45202. * Disposes of the object
  45203. */
  45204. dispose(): void;
  45205. }
  45206. }
  45207. declare module "babylonjs/Cameras/XR/webXRInput" {
  45208. import { Observable } from "babylonjs/Misc/observable";
  45209. import { IDisposable } from "babylonjs/scene";
  45210. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  45211. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45212. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  45213. /**
  45214. * The schema for initialization options of the XR Input class
  45215. */
  45216. export interface IWebXRInputOptions {
  45217. /**
  45218. * If set to true no model will be automatically loaded
  45219. */
  45220. doNotLoadControllerMeshes?: boolean;
  45221. }
  45222. /**
  45223. * XR input used to track XR inputs such as controllers/rays
  45224. */
  45225. export class WebXRInput implements IDisposable {
  45226. /**
  45227. * the xr session manager for this session
  45228. */
  45229. xrSessionManager: WebXRSessionManager;
  45230. /**
  45231. * the WebXR camera for this session. Mainly used for teleportation
  45232. */
  45233. xrCamera: WebXRCamera;
  45234. private readonly options;
  45235. /**
  45236. * XR controllers being tracked
  45237. */
  45238. controllers: Array<WebXRController>;
  45239. private _frameObserver;
  45240. private _sessionEndedObserver;
  45241. private _sessionInitObserver;
  45242. /**
  45243. * Event when a controller has been connected/added
  45244. */
  45245. onControllerAddedObservable: Observable<WebXRController>;
  45246. /**
  45247. * Event when a controller has been removed/disconnected
  45248. */
  45249. onControllerRemovedObservable: Observable<WebXRController>;
  45250. /**
  45251. * Initializes the WebXRInput
  45252. * @param xrSessionManager the xr session manager for this session
  45253. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45254. * @param options = initialization options for this xr input
  45255. */
  45256. constructor(
  45257. /**
  45258. * the xr session manager for this session
  45259. */
  45260. xrSessionManager: WebXRSessionManager,
  45261. /**
  45262. * the WebXR camera for this session. Mainly used for teleportation
  45263. */
  45264. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45265. private _onInputSourcesChange;
  45266. private _addAndRemoveControllers;
  45267. /**
  45268. * Disposes of the object
  45269. */
  45270. dispose(): void;
  45271. }
  45272. }
  45273. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  45274. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45275. /**
  45276. * Handles pointer input automatically for the pointer of XR controllers
  45277. */
  45278. export class WebXRControllerPointerSelection {
  45279. private static _idCounter;
  45280. private _tmpRay;
  45281. /**
  45282. * Creates a WebXRControllerPointerSelection
  45283. * @param input input manager to setup pointer selection
  45284. */
  45285. constructor(input: WebXRInput);
  45286. private _convertNormalToDirectionOfRay;
  45287. private _updatePointerDistance;
  45288. }
  45289. }
  45290. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  45291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45292. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  45293. /**
  45294. * Enables teleportation
  45295. */
  45296. export class WebXRControllerTeleportation {
  45297. private _teleportationFillColor;
  45298. private _teleportationBorderColor;
  45299. private _tmpRay;
  45300. private _tmpVector;
  45301. /**
  45302. * when set to true (default) teleportation will wait for thumbstick changes.
  45303. * When set to false teleportation will be disabled.
  45304. *
  45305. * If set to false while teleporting results can be unexpected.
  45306. */
  45307. enabled: boolean;
  45308. /**
  45309. * Creates a WebXRControllerTeleportation
  45310. * @param input input manager to add teleportation to
  45311. * @param floorMeshes floormeshes which can be teleported to
  45312. */
  45313. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  45314. }
  45315. }
  45316. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  45317. import { Nullable } from "babylonjs/types";
  45318. import { Observable } from "babylonjs/Misc/observable";
  45319. import { IDisposable, Scene } from "babylonjs/scene";
  45320. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45321. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45322. /**
  45323. * Button which can be used to enter a different mode of XR
  45324. */
  45325. export class WebXREnterExitUIButton {
  45326. /** button element */
  45327. element: HTMLElement;
  45328. /** XR initialization options for the button */
  45329. sessionMode: XRSessionMode;
  45330. /** Reference space type */
  45331. referenceSpaceType: XRReferenceSpaceType;
  45332. /**
  45333. * Creates a WebXREnterExitUIButton
  45334. * @param element button element
  45335. * @param sessionMode XR initialization session mode
  45336. * @param referenceSpaceType the type of reference space to be used
  45337. */
  45338. constructor(
  45339. /** button element */
  45340. element: HTMLElement,
  45341. /** XR initialization options for the button */
  45342. sessionMode: XRSessionMode,
  45343. /** Reference space type */
  45344. referenceSpaceType: XRReferenceSpaceType);
  45345. /**
  45346. * Overwritable function which can be used to update the button's visuals when the state changes
  45347. * @param activeButton the current active button in the UI
  45348. */
  45349. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  45350. }
  45351. /**
  45352. * Options to create the webXR UI
  45353. */
  45354. export class WebXREnterExitUIOptions {
  45355. /**
  45356. * Context to enter xr with
  45357. */
  45358. renderTarget?: Nullable<WebXRRenderTarget>;
  45359. /**
  45360. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  45361. */
  45362. customButtons?: Array<WebXREnterExitUIButton>;
  45363. /**
  45364. * A session mode to use when creating the default button.
  45365. * Default is immersive-vr
  45366. */
  45367. sessionMode?: XRSessionMode;
  45368. /**
  45369. * A reference space type to use when creating the default button.
  45370. * Default is local-floor
  45371. */
  45372. referenceSpaceType?: XRReferenceSpaceType;
  45373. }
  45374. /**
  45375. * UI to allow the user to enter/exit XR mode
  45376. */
  45377. export class WebXREnterExitUI implements IDisposable {
  45378. private scene;
  45379. /** version of the options passed to this UI */
  45380. options: WebXREnterExitUIOptions;
  45381. private _overlay;
  45382. private _buttons;
  45383. private _activeButton;
  45384. /**
  45385. * Fired every time the active button is changed.
  45386. *
  45387. * When xr is entered via a button that launches xr that button will be the callback parameter
  45388. *
  45389. * When exiting xr the callback parameter will be null)
  45390. */
  45391. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  45392. /**
  45393. * Creates UI to allow the user to enter/exit XR mode
  45394. * @param scene the scene to add the ui to
  45395. * @param helper the xr experience helper to enter/exit xr with
  45396. * @param options options to configure the UI
  45397. * @returns the created ui
  45398. */
  45399. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  45400. /**
  45401. *
  45402. * @param scene babylon scene object to use
  45403. * @param options (read-only) version of the options passed to this UI
  45404. */
  45405. private constructor();
  45406. private _updateButtons;
  45407. /**
  45408. * Disposes of the object
  45409. */
  45410. dispose(): void;
  45411. }
  45412. }
  45413. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  45414. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  45415. import { Scene } from "babylonjs/scene";
  45416. import { WebXRInput, IWebXRInputOptions } from "babylonjs/Cameras/XR/webXRInput";
  45417. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  45418. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  45419. import { WebXRRenderTarget } from "babylonjs/Cameras/XR/webXRTypes";
  45420. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/Cameras/XR/webXREnterExitUI";
  45421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45422. import { WebXRManagedOutputCanvasOptions } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  45423. /**
  45424. * Options for the default xr helper
  45425. */
  45426. export class WebXRDefaultExperienceOptions {
  45427. /**
  45428. * Floor meshes that should be used for teleporting
  45429. */
  45430. floorMeshes?: Array<AbstractMesh>;
  45431. /**
  45432. * Enable or disable default UI to enter XR
  45433. */
  45434. disableDefaultUI?: boolean;
  45435. /**
  45436. * optional configuration for the output canvas
  45437. */
  45438. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  45439. /**
  45440. * optional UI options. This can be used among other to change session mode and reference space type
  45441. */
  45442. uiOptions?: WebXREnterExitUIOptions;
  45443. /**
  45444. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  45445. */
  45446. inputOptions?: IWebXRInputOptions;
  45447. }
  45448. /**
  45449. * Default experience which provides a similar setup to the previous webVRExperience
  45450. */
  45451. export class WebXRDefaultExperience {
  45452. /**
  45453. * Base experience
  45454. */
  45455. baseExperience: WebXRExperienceHelper;
  45456. /**
  45457. * Input experience extension
  45458. */
  45459. input: WebXRInput;
  45460. /**
  45461. * Enables laser pointer and selection
  45462. */
  45463. pointerSelection: WebXRControllerPointerSelection;
  45464. /**
  45465. * Enables teleportation
  45466. */
  45467. teleportation: WebXRControllerTeleportation;
  45468. /**
  45469. * Enables ui for entering/exiting xr
  45470. */
  45471. enterExitUI: WebXREnterExitUI;
  45472. /**
  45473. * Default target xr should render to
  45474. */
  45475. renderTarget: WebXRRenderTarget;
  45476. /**
  45477. * Creates the default xr experience
  45478. * @param scene scene
  45479. * @param options options for basic configuration
  45480. * @returns resulting WebXRDefaultExperience
  45481. */
  45482. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45483. private constructor();
  45484. /**
  45485. * DIsposes of the experience helper
  45486. */
  45487. dispose(): void;
  45488. }
  45489. }
  45490. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  45491. import { Observable } from "babylonjs/Misc/observable";
  45492. import { Nullable } from "babylonjs/types";
  45493. import { Camera } from "babylonjs/Cameras/camera";
  45494. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  45495. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45496. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  45497. import { Scene } from "babylonjs/scene";
  45498. import { Vector3 } from "babylonjs/Maths/math.vector";
  45499. import { Color3 } from "babylonjs/Maths/math.color";
  45500. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45502. import { Mesh } from "babylonjs/Meshes/mesh";
  45503. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  45504. import { EasingFunction } from "babylonjs/Animations/easing";
  45505. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  45506. import "babylonjs/Meshes/Builders/groundBuilder";
  45507. import "babylonjs/Meshes/Builders/torusBuilder";
  45508. import "babylonjs/Meshes/Builders/cylinderBuilder";
  45509. import "babylonjs/Gamepads/gamepadSceneComponent";
  45510. import "babylonjs/Animations/animatable";
  45511. import { WebXRDefaultExperience } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  45512. /**
  45513. * Options to modify the vr teleportation behavior.
  45514. */
  45515. export interface VRTeleportationOptions {
  45516. /**
  45517. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45518. */
  45519. floorMeshName?: string;
  45520. /**
  45521. * A list of meshes to be used as the teleportation floor. (default: empty)
  45522. */
  45523. floorMeshes?: Mesh[];
  45524. /**
  45525. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45526. */
  45527. teleportationMode?: number;
  45528. /**
  45529. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45530. */
  45531. teleportationTime?: number;
  45532. /**
  45533. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45534. */
  45535. teleportationSpeed?: number;
  45536. /**
  45537. * The easing function used in the animation or null for Linear. (default CircleEase)
  45538. */
  45539. easingFunction?: EasingFunction;
  45540. }
  45541. /**
  45542. * Options to modify the vr experience helper's behavior.
  45543. */
  45544. export interface VRExperienceHelperOptions extends WebVROptions {
  45545. /**
  45546. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45547. */
  45548. createDeviceOrientationCamera?: boolean;
  45549. /**
  45550. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45551. */
  45552. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45553. /**
  45554. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45555. */
  45556. laserToggle?: boolean;
  45557. /**
  45558. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45559. */
  45560. floorMeshes?: Mesh[];
  45561. /**
  45562. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45563. */
  45564. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45565. /**
  45566. * Defines if WebXR should be used instead of WebVR (if available)
  45567. */
  45568. useXR?: boolean;
  45569. }
  45570. /**
  45571. * Event containing information after VR has been entered
  45572. */
  45573. export class OnAfterEnteringVRObservableEvent {
  45574. /**
  45575. * If entering vr was successful
  45576. */
  45577. success: boolean;
  45578. }
  45579. /**
  45580. * Helps to quickly add VR support to an existing scene.
  45581. * See http://doc.babylonjs.com/how_to/webvr_helper
  45582. */
  45583. export class VRExperienceHelper {
  45584. /** Options to modify the vr experience helper's behavior. */
  45585. webVROptions: VRExperienceHelperOptions;
  45586. private _scene;
  45587. private _position;
  45588. private _btnVR;
  45589. private _btnVRDisplayed;
  45590. private _webVRsupported;
  45591. private _webVRready;
  45592. private _webVRrequesting;
  45593. private _webVRpresenting;
  45594. private _hasEnteredVR;
  45595. private _fullscreenVRpresenting;
  45596. private _inputElement;
  45597. private _webVRCamera;
  45598. private _vrDeviceOrientationCamera;
  45599. private _deviceOrientationCamera;
  45600. private _existingCamera;
  45601. private _onKeyDown;
  45602. private _onVrDisplayPresentChange;
  45603. private _onVRDisplayChanged;
  45604. private _onVRRequestPresentStart;
  45605. private _onVRRequestPresentComplete;
  45606. /**
  45607. * 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)
  45608. */
  45609. enableGazeEvenWhenNoPointerLock: boolean;
  45610. /**
  45611. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45612. */
  45613. exitVROnDoubleTap: boolean;
  45614. /**
  45615. * Observable raised right before entering VR.
  45616. */
  45617. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45618. /**
  45619. * Observable raised when entering VR has completed.
  45620. */
  45621. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45622. /**
  45623. * Observable raised when exiting VR.
  45624. */
  45625. onExitingVRObservable: Observable<VRExperienceHelper>;
  45626. /**
  45627. * Observable raised when controller mesh is loaded.
  45628. */
  45629. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45630. /** Return this.onEnteringVRObservable
  45631. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45632. */
  45633. get onEnteringVR(): Observable<VRExperienceHelper>;
  45634. /** Return this.onExitingVRObservable
  45635. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45636. */
  45637. get onExitingVR(): Observable<VRExperienceHelper>;
  45638. /** Return this.onControllerMeshLoadedObservable
  45639. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45640. */
  45641. get onControllerMeshLoaded(): Observable<WebVRController>;
  45642. private _rayLength;
  45643. private _useCustomVRButton;
  45644. private _teleportationRequested;
  45645. private _teleportActive;
  45646. private _floorMeshName;
  45647. private _floorMeshesCollection;
  45648. private _teleportationMode;
  45649. private _teleportationTime;
  45650. private _teleportationSpeed;
  45651. private _teleportationEasing;
  45652. private _rotationAllowed;
  45653. private _teleportBackwardsVector;
  45654. private _teleportationTarget;
  45655. private _isDefaultTeleportationTarget;
  45656. private _postProcessMove;
  45657. private _teleportationFillColor;
  45658. private _teleportationBorderColor;
  45659. private _rotationAngle;
  45660. private _haloCenter;
  45661. private _cameraGazer;
  45662. private _padSensibilityUp;
  45663. private _padSensibilityDown;
  45664. private _leftController;
  45665. private _rightController;
  45666. private _gazeColor;
  45667. private _laserColor;
  45668. private _pickedLaserColor;
  45669. private _pickedGazeColor;
  45670. /**
  45671. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45672. */
  45673. onNewMeshSelected: Observable<AbstractMesh>;
  45674. /**
  45675. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45676. * This observable will provide the mesh and the controller used to select the mesh
  45677. */
  45678. onMeshSelectedWithController: Observable<{
  45679. mesh: AbstractMesh;
  45680. controller: WebVRController;
  45681. }>;
  45682. /**
  45683. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45684. */
  45685. onNewMeshPicked: Observable<PickingInfo>;
  45686. private _circleEase;
  45687. /**
  45688. * Observable raised before camera teleportation
  45689. */
  45690. onBeforeCameraTeleport: Observable<Vector3>;
  45691. /**
  45692. * Observable raised after camera teleportation
  45693. */
  45694. onAfterCameraTeleport: Observable<Vector3>;
  45695. /**
  45696. * Observable raised when current selected mesh gets unselected
  45697. */
  45698. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45699. private _raySelectionPredicate;
  45700. /**
  45701. * To be optionaly changed by user to define custom ray selection
  45702. */
  45703. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45704. /**
  45705. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45706. */
  45707. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45708. /**
  45709. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45710. */
  45711. teleportationEnabled: boolean;
  45712. private _defaultHeight;
  45713. private _teleportationInitialized;
  45714. private _interactionsEnabled;
  45715. private _interactionsRequested;
  45716. private _displayGaze;
  45717. private _displayLaserPointer;
  45718. /**
  45719. * The mesh used to display where the user is going to teleport.
  45720. */
  45721. get teleportationTarget(): Mesh;
  45722. /**
  45723. * Sets the mesh to be used to display where the user is going to teleport.
  45724. */
  45725. set teleportationTarget(value: Mesh);
  45726. /**
  45727. * 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
  45728. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45729. * See http://doc.babylonjs.com/resources/baking_transformations
  45730. */
  45731. get gazeTrackerMesh(): Mesh;
  45732. set gazeTrackerMesh(value: Mesh);
  45733. /**
  45734. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45735. */
  45736. updateGazeTrackerScale: boolean;
  45737. /**
  45738. * If the gaze trackers color should be updated when selecting meshes
  45739. */
  45740. updateGazeTrackerColor: boolean;
  45741. /**
  45742. * If the controller laser color should be updated when selecting meshes
  45743. */
  45744. updateControllerLaserColor: boolean;
  45745. /**
  45746. * The gaze tracking mesh corresponding to the left controller
  45747. */
  45748. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45749. /**
  45750. * The gaze tracking mesh corresponding to the right controller
  45751. */
  45752. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45753. /**
  45754. * If the ray of the gaze should be displayed.
  45755. */
  45756. get displayGaze(): boolean;
  45757. /**
  45758. * Sets if the ray of the gaze should be displayed.
  45759. */
  45760. set displayGaze(value: boolean);
  45761. /**
  45762. * If the ray of the LaserPointer should be displayed.
  45763. */
  45764. get displayLaserPointer(): boolean;
  45765. /**
  45766. * Sets if the ray of the LaserPointer should be displayed.
  45767. */
  45768. set displayLaserPointer(value: boolean);
  45769. /**
  45770. * The deviceOrientationCamera used as the camera when not in VR.
  45771. */
  45772. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45773. /**
  45774. * Based on the current WebVR support, returns the current VR camera used.
  45775. */
  45776. get currentVRCamera(): Nullable<Camera>;
  45777. /**
  45778. * The webVRCamera which is used when in VR.
  45779. */
  45780. get webVRCamera(): WebVRFreeCamera;
  45781. /**
  45782. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45783. */
  45784. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45785. /**
  45786. * The html button that is used to trigger entering into VR.
  45787. */
  45788. get vrButton(): Nullable<HTMLButtonElement>;
  45789. private get _teleportationRequestInitiated();
  45790. /**
  45791. * Defines wether or not Pointer lock should be requested when switching to
  45792. * full screen.
  45793. */
  45794. requestPointerLockOnFullScreen: boolean;
  45795. /**
  45796. * If asking to force XR, this will be populated with the default xr experience
  45797. */
  45798. xr: WebXRDefaultExperience;
  45799. /**
  45800. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45801. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45802. */
  45803. xrTestDone: boolean;
  45804. /**
  45805. * Instantiates a VRExperienceHelper.
  45806. * Helps to quickly add VR support to an existing scene.
  45807. * @param scene The scene the VRExperienceHelper belongs to.
  45808. * @param webVROptions Options to modify the vr experience helper's behavior.
  45809. */
  45810. constructor(scene: Scene,
  45811. /** Options to modify the vr experience helper's behavior. */
  45812. webVROptions?: VRExperienceHelperOptions);
  45813. private completeVRInit;
  45814. private _onDefaultMeshLoaded;
  45815. private _onResize;
  45816. private _onFullscreenChange;
  45817. /**
  45818. * Gets a value indicating if we are currently in VR mode.
  45819. */
  45820. get isInVRMode(): boolean;
  45821. private onVrDisplayPresentChange;
  45822. private onVRDisplayChanged;
  45823. private moveButtonToBottomRight;
  45824. private displayVRButton;
  45825. private updateButtonVisibility;
  45826. private _cachedAngularSensibility;
  45827. /**
  45828. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45829. * Otherwise, will use the fullscreen API.
  45830. */
  45831. enterVR(): void;
  45832. /**
  45833. * Attempt to exit VR, or fullscreen.
  45834. */
  45835. exitVR(): void;
  45836. /**
  45837. * The position of the vr experience helper.
  45838. */
  45839. get position(): Vector3;
  45840. /**
  45841. * Sets the position of the vr experience helper.
  45842. */
  45843. set position(value: Vector3);
  45844. /**
  45845. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45846. */
  45847. enableInteractions(): void;
  45848. private get _noControllerIsActive();
  45849. private beforeRender;
  45850. private _isTeleportationFloor;
  45851. /**
  45852. * Adds a floor mesh to be used for teleportation.
  45853. * @param floorMesh the mesh to be used for teleportation.
  45854. */
  45855. addFloorMesh(floorMesh: Mesh): void;
  45856. /**
  45857. * Removes a floor mesh from being used for teleportation.
  45858. * @param floorMesh the mesh to be removed.
  45859. */
  45860. removeFloorMesh(floorMesh: Mesh): void;
  45861. /**
  45862. * Enables interactions and teleportation using the VR controllers and gaze.
  45863. * @param vrTeleportationOptions options to modify teleportation behavior.
  45864. */
  45865. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45866. private _onNewGamepadConnected;
  45867. private _tryEnableInteractionOnController;
  45868. private _onNewGamepadDisconnected;
  45869. private _enableInteractionOnController;
  45870. private _checkTeleportWithRay;
  45871. private _checkRotate;
  45872. private _checkTeleportBackwards;
  45873. private _enableTeleportationOnController;
  45874. private _createTeleportationCircles;
  45875. private _displayTeleportationTarget;
  45876. private _hideTeleportationTarget;
  45877. private _rotateCamera;
  45878. private _moveTeleportationSelectorTo;
  45879. private _workingVector;
  45880. private _workingQuaternion;
  45881. private _workingMatrix;
  45882. /**
  45883. * Time Constant Teleportation Mode
  45884. */
  45885. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45886. /**
  45887. * Speed Constant Teleportation Mode
  45888. */
  45889. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45890. /**
  45891. * Teleports the users feet to the desired location
  45892. * @param location The location where the user's feet should be placed
  45893. */
  45894. teleportCamera(location: Vector3): void;
  45895. private _convertNormalToDirectionOfRay;
  45896. private _castRayAndSelectObject;
  45897. private _notifySelectedMeshUnselected;
  45898. /**
  45899. * Permanently set new colors for the laser pointer
  45900. * @param color the new laser color
  45901. * @param pickedColor the new laser color when picked mesh detected
  45902. */
  45903. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45904. /**
  45905. * Permanently set new colors for the gaze pointer
  45906. * @param color the new gaze color
  45907. * @param pickedColor the new gaze color when picked mesh detected
  45908. */
  45909. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45910. /**
  45911. * Sets the color of the laser ray from the vr controllers.
  45912. * @param color new color for the ray.
  45913. */
  45914. changeLaserColor(color: Color3): void;
  45915. /**
  45916. * Sets the color of the ray from the vr headsets gaze.
  45917. * @param color new color for the ray.
  45918. */
  45919. changeGazeColor(color: Color3): void;
  45920. /**
  45921. * Exits VR and disposes of the vr experience helper
  45922. */
  45923. dispose(): void;
  45924. /**
  45925. * Gets the name of the VRExperienceHelper class
  45926. * @returns "VRExperienceHelper"
  45927. */
  45928. getClassName(): string;
  45929. }
  45930. }
  45931. declare module "babylonjs/Cameras/VR/index" {
  45932. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  45933. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  45934. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  45935. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  45936. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  45937. export * from "babylonjs/Cameras/VR/webVRCamera";
  45938. }
  45939. declare module "babylonjs/Cameras/XR/features/WebXRHitTestLegacy" {
  45940. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  45941. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  45942. import { Observable } from "babylonjs/Misc/observable";
  45943. import { Matrix } from "babylonjs/Maths/math.vector";
  45944. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45945. /**
  45946. * Options used for hit testing
  45947. */
  45948. export interface IWebXRHitTestOptions {
  45949. /**
  45950. * Only test when user interacted with the scene. Default - hit test every frame
  45951. */
  45952. testOnPointerDownOnly?: boolean;
  45953. /**
  45954. * The node to use to transform the local results to world coordinates
  45955. */
  45956. worldParentNode?: TransformNode;
  45957. }
  45958. /**
  45959. * Interface defining the babylon result of raycasting/hit-test
  45960. */
  45961. export interface IWebXRHitResult {
  45962. /**
  45963. * The native hit test result
  45964. */
  45965. xrHitResult: XRHitResult;
  45966. /**
  45967. * Transformation matrix that can be applied to a node that will put it in the hit point location
  45968. */
  45969. transformationMatrix: Matrix;
  45970. }
  45971. /**
  45972. * The currently-working hit-test module.
  45973. * Hit test (or raycasting) is used to interact with the real world.
  45974. * For further information read here - https://github.com/immersive-web/hit-test
  45975. */
  45976. export class WebXRHitTestLegacy implements IWebXRFeature {
  45977. private _xrSessionManager;
  45978. /**
  45979. * options to use when constructing this feature
  45980. */
  45981. readonly options: IWebXRHitTestOptions;
  45982. /**
  45983. * The module's name
  45984. */
  45985. static readonly Name: string;
  45986. /**
  45987. * The (Babylon) version of this module.
  45988. * This is an integer representing the implementation version.
  45989. * This number does not correspond to the webxr specs version
  45990. */
  45991. static readonly Version: number;
  45992. /**
  45993. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  45994. * @param event the (select) event to use to select with
  45995. * @param referenceSpace the reference space to use for this hit test
  45996. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  45997. */
  45998. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  45999. /**
  46000. * execute a hit test with an XR Ray
  46001. *
  46002. * @param xrSession a native xrSession that will execute this hit test
  46003. * @param xrRay the ray (position and direction) to use for raycasting
  46004. * @param referenceSpace native XR reference space to use for the hit-test
  46005. * @param filter filter function that will filter the results
  46006. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  46007. */
  46008. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  46009. /**
  46010. * Triggered when new babylon (transformed) hit test results are available
  46011. */
  46012. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  46013. /**
  46014. * Creates a new instance of the (legacy version) hit test feature
  46015. * @param _xrSessionManager an instance of WebXRSessionManager
  46016. * @param options options to use when constructing this feature
  46017. */
  46018. constructor(_xrSessionManager: WebXRSessionManager,
  46019. /**
  46020. * options to use when constructing this feature
  46021. */
  46022. options?: IWebXRHitTestOptions);
  46023. private _onSelectEnabled;
  46024. private _xrFrameObserver;
  46025. private _attached;
  46026. /**
  46027. * Populated with the last native XR Hit Results
  46028. */
  46029. lastNativeXRHitResults: XRHitResult[];
  46030. /**
  46031. * attach this feature
  46032. * Will usually be called by the features manager
  46033. *
  46034. * @returns true if successful.
  46035. */
  46036. attach(): boolean;
  46037. /**
  46038. * detach this feature.
  46039. * Will usually be called by the features manager
  46040. *
  46041. * @returns true if successful.
  46042. */
  46043. detach(): boolean;
  46044. private _onHitTestResults;
  46045. private _onSelect;
  46046. /**
  46047. * Dispose this feature and all of the resources attached
  46048. */
  46049. dispose(): void;
  46050. }
  46051. }
  46052. declare module "babylonjs/Cameras/XR/features/WebXRPlaneDetector" {
  46053. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46054. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46055. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46056. import { Observable } from "babylonjs/Misc/observable";
  46057. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  46058. /**
  46059. * Options used in the plane detector module
  46060. */
  46061. export interface IWebXRPlaneDetectorOptions {
  46062. /**
  46063. * The node to use to transform the local results to world coordinates
  46064. */
  46065. worldParentNode?: TransformNode;
  46066. }
  46067. /**
  46068. * A babylon interface for a webxr plane.
  46069. * A Plane is actually a polygon, built from N points in space
  46070. */
  46071. export interface IWebXRPlane {
  46072. /**
  46073. * a babylon-assigned ID for this polygon
  46074. */
  46075. id: number;
  46076. /**
  46077. * the native xr-plane object
  46078. */
  46079. xrPlane: XRPlane;
  46080. /**
  46081. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  46082. */
  46083. polygonDefinition: Array<Vector3>;
  46084. /**
  46085. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  46086. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  46087. */
  46088. transformationMatrix: Matrix;
  46089. }
  46090. /**
  46091. * The plane detector is used to detect planes in the real world when in AR
  46092. * For more information see https://github.com/immersive-web/real-world-geometry/
  46093. */
  46094. export class WebXRPlaneDetector implements IWebXRFeature {
  46095. private _xrSessionManager;
  46096. private _options;
  46097. /**
  46098. * The module's name
  46099. */
  46100. static readonly Name: string;
  46101. /**
  46102. * The (Babylon) version of this module.
  46103. * This is an integer representing the implementation version.
  46104. * This number does not correspond to the webxr specs version
  46105. */
  46106. static readonly Version: number;
  46107. /**
  46108. * Observers registered here will be executed when a new plane was added to the session
  46109. */
  46110. onPlaneAddedObservable: Observable<IWebXRPlane>;
  46111. /**
  46112. * Observers registered here will be executed when a plane is no longer detected in the session
  46113. */
  46114. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  46115. /**
  46116. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  46117. * This can execute N times every frame
  46118. */
  46119. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  46120. private _enabled;
  46121. private _attached;
  46122. private _detectedPlanes;
  46123. private _lastFrameDetected;
  46124. private _observerTracked;
  46125. /**
  46126. * construct a new Plane Detector
  46127. * @param _xrSessionManager an instance of xr Session manager
  46128. * @param _options configuration to use when constructing this feature
  46129. */
  46130. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  46131. /**
  46132. * attach this feature
  46133. * Will usually be called by the features manager
  46134. *
  46135. * @returns true if successful.
  46136. */
  46137. attach(): boolean;
  46138. /**
  46139. * detach this feature.
  46140. * Will usually be called by the features manager
  46141. *
  46142. * @returns true if successful.
  46143. */
  46144. detach(): boolean;
  46145. /**
  46146. * Dispose this feature and all of the resources attached
  46147. */
  46148. dispose(): void;
  46149. private _updatePlaneWithXRPlane;
  46150. /**
  46151. * avoiding using Array.find for global support.
  46152. * @param xrPlane the plane to find in the array
  46153. */
  46154. private findIndexInPlaneArray;
  46155. }
  46156. }
  46157. declare module "babylonjs/Cameras/XR/features/WebXRAnchorSystem" {
  46158. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46159. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46160. import { Observable } from "babylonjs/Misc/observable";
  46161. import { Matrix } from "babylonjs/Maths/math.vector";
  46162. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46163. import { WebXRPlaneDetector } from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46164. import { WebXRHitTestLegacy } from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46165. /**
  46166. * Configuration options of the anchor system
  46167. */
  46168. export interface IWebXRAnchorSystemOptions {
  46169. /**
  46170. * a node that will be used to convert local to world coordinates
  46171. */
  46172. worldParentNode?: TransformNode;
  46173. /**
  46174. * should the anchor system use plane detection.
  46175. * If set to true, the plane-detection feature should be set using setPlaneDetector
  46176. */
  46177. usePlaneDetection?: boolean;
  46178. /**
  46179. * Should a new anchor be added every time a select event is triggered
  46180. */
  46181. addAnchorOnSelect?: boolean;
  46182. }
  46183. /**
  46184. * A babylon container for an XR Anchor
  46185. */
  46186. export interface IWebXRAnchor {
  46187. /**
  46188. * A babylon-assigned ID for this anchor
  46189. */
  46190. id: number;
  46191. /**
  46192. * The native anchor object
  46193. */
  46194. xrAnchor: XRAnchor;
  46195. /**
  46196. * Transformation matrix to apply to an object attached to this anchor
  46197. */
  46198. transformationMatrix: Matrix;
  46199. }
  46200. /**
  46201. * An implementation of the anchor system of WebXR.
  46202. * Note that the current documented implementation is not available in any browser. Future implementations
  46203. * will use the frame to create an anchor and not the session or a detected plane
  46204. * For further information see https://github.com/immersive-web/anchors/
  46205. */
  46206. export class WebXRAnchorSystem implements IWebXRFeature {
  46207. private _xrSessionManager;
  46208. private _options;
  46209. /**
  46210. * The module's name
  46211. */
  46212. static readonly Name: string;
  46213. /**
  46214. * The (Babylon) version of this module.
  46215. * This is an integer representing the implementation version.
  46216. * This number does not correspond to the webxr specs version
  46217. */
  46218. static readonly Version: number;
  46219. /**
  46220. * Observers registered here will be executed when a new anchor was added to the session
  46221. */
  46222. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  46223. /**
  46224. * Observers registered here will be executed when an existing anchor updates
  46225. * This can execute N times every frame
  46226. */
  46227. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  46228. /**
  46229. * Observers registered here will be executed when an anchor was removed from the session
  46230. */
  46231. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  46232. private _planeDetector;
  46233. private _hitTestModule;
  46234. private _enabled;
  46235. private _attached;
  46236. private _trackedAnchors;
  46237. private _lastFrameDetected;
  46238. private _observerTracked;
  46239. /**
  46240. * constructs a new anchor system
  46241. * @param _xrSessionManager an instance of WebXRSessionManager
  46242. * @param _options configuration object for this feature
  46243. */
  46244. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  46245. /**
  46246. * set the plane detector to use in order to create anchors from frames
  46247. * @param planeDetector the plane-detector module to use
  46248. * @param enable enable plane-anchors. default is true
  46249. */
  46250. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  46251. /**
  46252. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  46253. * @param hitTestModule the hit-test module to use.
  46254. */
  46255. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  46256. /**
  46257. * attach this feature
  46258. * Will usually be called by the features manager
  46259. *
  46260. * @returns true if successful.
  46261. */
  46262. attach(): boolean;
  46263. /**
  46264. * detach this feature.
  46265. * Will usually be called by the features manager
  46266. *
  46267. * @returns true if successful.
  46268. */
  46269. detach(): boolean;
  46270. /**
  46271. * Dispose this feature and all of the resources attached
  46272. */
  46273. dispose(): void;
  46274. private _onSelect;
  46275. /**
  46276. * Add anchor at a specific XR point.
  46277. *
  46278. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  46279. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  46280. * @returns a promise the fulfills when the anchor was created
  46281. */
  46282. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  46283. private _updateAnchorWithXRFrame;
  46284. /**
  46285. * avoiding using Array.find for global support.
  46286. * @param xrAnchor the plane to find in the array
  46287. */
  46288. private _findIndexInAnchorArray;
  46289. }
  46290. }
  46291. declare module "babylonjs/Cameras/XR/features/WebXRBackgroundRemover" {
  46292. import { IWebXRFeature } from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46293. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  46294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46295. import { Observable } from "babylonjs/Misc/observable";
  46296. /**
  46297. * Options interface for the background remover plugin
  46298. */
  46299. export interface IWebXRBackgroundRemoverOptions {
  46300. /**
  46301. * don't disable the environment helper
  46302. */
  46303. ignoreEnvironmentHelper?: boolean;
  46304. /**
  46305. * flags to configure the removal of the environment helper.
  46306. * If not set, the entire background will be removed. If set, flags should be set as well.
  46307. */
  46308. environmentHelperRemovalFlags?: {
  46309. /**
  46310. * Should the skybox be removed (default false)
  46311. */
  46312. skyBox?: boolean;
  46313. /**
  46314. * Should the ground be removed (default false)
  46315. */
  46316. ground?: boolean;
  46317. };
  46318. /**
  46319. * Further background meshes to disable when entering AR
  46320. */
  46321. backgroundMeshes?: AbstractMesh[];
  46322. }
  46323. /**
  46324. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  46325. */
  46326. export class WebXRBackgroundRemover implements IWebXRFeature {
  46327. private _xrSessionManager;
  46328. /**
  46329. * read-only options to be used in this module
  46330. */
  46331. readonly options: IWebXRBackgroundRemoverOptions;
  46332. /**
  46333. * The module's name
  46334. */
  46335. static readonly Name: string;
  46336. /**
  46337. * The (Babylon) version of this module.
  46338. * This is an integer representing the implementation version.
  46339. * This number does not correspond to the webxr specs version
  46340. */
  46341. static readonly Version: number;
  46342. /**
  46343. * registered observers will be triggered when the background state changes
  46344. */
  46345. onBackgroundStateChangedObservable: Observable<boolean>;
  46346. /**
  46347. * constructs a new background remover module
  46348. * @param _xrSessionManager the session manager for this module
  46349. * @param options read-only options to be used in this module
  46350. */
  46351. constructor(_xrSessionManager: WebXRSessionManager,
  46352. /**
  46353. * read-only options to be used in this module
  46354. */
  46355. options?: IWebXRBackgroundRemoverOptions);
  46356. /**
  46357. * attach this feature
  46358. * Will usually be called by the features manager
  46359. *
  46360. * @returns true if successful.
  46361. */
  46362. attach(): boolean;
  46363. /**
  46364. * detach this feature.
  46365. * Will usually be called by the features manager
  46366. *
  46367. * @returns true if successful.
  46368. */
  46369. detach(): boolean;
  46370. private _setBackgroundState;
  46371. /**
  46372. * Dispose this feature and all of the resources attached
  46373. */
  46374. dispose(): void;
  46375. }
  46376. }
  46377. declare module "babylonjs/Cameras/XR/features/index" {
  46378. export * from "babylonjs/Cameras/XR/features/WebXRHitTestLegacy";
  46379. export * from "babylonjs/Cameras/XR/features/WebXRAnchorSystem";
  46380. export * from "babylonjs/Cameras/XR/features/WebXRPlaneDetector";
  46381. export * from "babylonjs/Cameras/XR/features/WebXRBackgroundRemover";
  46382. }
  46383. declare module "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController" {
  46384. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46386. import { Scene } from "babylonjs/scene";
  46387. /**
  46388. * The motion controller class for all microsoft mixed reality controllers
  46389. */
  46390. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  46391. /**
  46392. * The base url used to load the left and right controller models
  46393. */
  46394. static MODEL_BASE_URL: string;
  46395. /**
  46396. * The name of the left controller model file
  46397. */
  46398. static MODEL_LEFT_FILENAME: string;
  46399. /**
  46400. * The name of the right controller model file
  46401. */
  46402. static MODEL_RIGHT_FILENAME: string;
  46403. profileId: string;
  46404. protected readonly _mapping: {
  46405. defaultButton: {
  46406. "valueNodeName": string;
  46407. "unpressedNodeName": string;
  46408. "pressedNodeName": string;
  46409. };
  46410. defaultAxis: {
  46411. "valueNodeName": string;
  46412. "minNodeName": string;
  46413. "maxNodeName": string;
  46414. };
  46415. buttons: {
  46416. "xr-standard-trigger": {
  46417. "rootNodeName": string;
  46418. "componentProperty": string;
  46419. "states": string[];
  46420. };
  46421. "xr-standard-squeeze": {
  46422. "rootNodeName": string;
  46423. "componentProperty": string;
  46424. "states": string[];
  46425. };
  46426. "xr-standard-touchpad": {
  46427. "rootNodeName": string;
  46428. "labelAnchorNodeName": string;
  46429. "touchPointNodeName": string;
  46430. };
  46431. "xr-standard-thumbstick": {
  46432. "rootNodeName": string;
  46433. "componentProperty": string;
  46434. "states": string[];
  46435. };
  46436. "menu": {
  46437. "rootNodeName": string;
  46438. "componentProperty": string;
  46439. "states": string[];
  46440. };
  46441. };
  46442. axes: {
  46443. "xr-standard-touchpad": {
  46444. "x-axis": {
  46445. "rootNodeName": string;
  46446. };
  46447. "y-axis": {
  46448. "rootNodeName": string;
  46449. };
  46450. };
  46451. "xr-standard-thumbstick": {
  46452. "x-axis": {
  46453. "rootNodeName": string;
  46454. };
  46455. "y-axis": {
  46456. "rootNodeName": string;
  46457. };
  46458. };
  46459. };
  46460. };
  46461. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  46462. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46463. private _getChildByName;
  46464. private _getImmediateChildByName;
  46465. protected _getFilenameAndPath(): {
  46466. filename: string;
  46467. path: string;
  46468. };
  46469. protected _updateModel(): void;
  46470. protected _getModelLoadingConstraints(): boolean;
  46471. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46472. }
  46473. }
  46474. declare module "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController" {
  46475. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46477. import { Scene } from "babylonjs/scene";
  46478. /**
  46479. * The motion controller class for oculus touch (quest, rift).
  46480. * This class supports legacy mapping as well the standard xr mapping
  46481. */
  46482. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  46483. private _forceLegacyControllers;
  46484. /**
  46485. * The base url used to load the left and right controller models
  46486. */
  46487. static MODEL_BASE_URL: string;
  46488. /**
  46489. * The name of the left controller model file
  46490. */
  46491. static MODEL_LEFT_FILENAME: string;
  46492. /**
  46493. * The name of the right controller model file
  46494. */
  46495. static MODEL_RIGHT_FILENAME: string;
  46496. /**
  46497. * Base Url for the Quest controller model.
  46498. */
  46499. static QUEST_MODEL_BASE_URL: string;
  46500. profileId: string;
  46501. private _modelRootNode;
  46502. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  46503. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46504. protected _getFilenameAndPath(): {
  46505. filename: string;
  46506. path: string;
  46507. };
  46508. /**
  46509. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  46510. * between the touch and touch 2.
  46511. */
  46512. private _isQuest;
  46513. protected _updateModel(): void;
  46514. protected _getModelLoadingConstraints(): boolean;
  46515. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46516. }
  46517. }
  46518. declare module "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController" {
  46519. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46520. import { Scene } from "babylonjs/scene";
  46521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46522. /**
  46523. * The motion controller class for the standard HTC-Vive controllers
  46524. */
  46525. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  46526. /**
  46527. * The base url used to load the left and right controller models
  46528. */
  46529. static MODEL_BASE_URL: string;
  46530. /**
  46531. * File name for the controller model.
  46532. */
  46533. static MODEL_FILENAME: string;
  46534. profileId: string;
  46535. private _modelRootNode;
  46536. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  46537. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  46538. protected _getFilenameAndPath(): {
  46539. filename: string;
  46540. path: string;
  46541. };
  46542. protected _updateModel(): void;
  46543. protected _getModelLoadingConstraints(): boolean;
  46544. protected _setRootMesh(meshes: AbstractMesh[]): void;
  46545. }
  46546. }
  46547. declare module "babylonjs/Cameras/XR/motionController/index" {
  46548. export * from "babylonjs/Cameras/XR/motionController/webXRAbstractController";
  46549. export * from "babylonjs/Cameras/XR/motionController/webXRControllerComponent";
  46550. export * from "babylonjs/Cameras/XR/motionController/webXRGenericMotionController";
  46551. export * from "babylonjs/Cameras/XR/motionController/webXRMicrosoftMixedRealityController";
  46552. export * from "babylonjs/Cameras/XR/motionController/webXRMotionControllerManager";
  46553. export * from "babylonjs/Cameras/XR/motionController/webXROculusTouchMotionController";
  46554. export * from "babylonjs/Cameras/XR/motionController/webXRHTCViveMotionController";
  46555. }
  46556. declare module "babylonjs/Cameras/XR/index" {
  46557. export * from "babylonjs/Cameras/XR/webXRCamera";
  46558. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  46559. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  46560. export * from "babylonjs/Cameras/XR/webXRInput";
  46561. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  46562. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  46563. export * from "babylonjs/Cameras/XR/webXRController";
  46564. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  46565. export * from "babylonjs/Cameras/XR/webXRTypes";
  46566. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  46567. export * from "babylonjs/Cameras/XR/webXRDefaultExperience";
  46568. export * from "babylonjs/Cameras/XR/webXRFeaturesManager";
  46569. export * from "babylonjs/Cameras/XR/features/index";
  46570. export * from "babylonjs/Cameras/XR/motionController/index";
  46571. }
  46572. declare module "babylonjs/Cameras/RigModes/index" {
  46573. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46574. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46575. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  46576. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  46577. }
  46578. declare module "babylonjs/Cameras/index" {
  46579. export * from "babylonjs/Cameras/Inputs/index";
  46580. export * from "babylonjs/Cameras/cameraInputsManager";
  46581. export * from "babylonjs/Cameras/camera";
  46582. export * from "babylonjs/Cameras/targetCamera";
  46583. export * from "babylonjs/Cameras/freeCamera";
  46584. export * from "babylonjs/Cameras/freeCameraInputsManager";
  46585. export * from "babylonjs/Cameras/touchCamera";
  46586. export * from "babylonjs/Cameras/arcRotateCamera";
  46587. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  46588. export * from "babylonjs/Cameras/deviceOrientationCamera";
  46589. export * from "babylonjs/Cameras/flyCamera";
  46590. export * from "babylonjs/Cameras/flyCameraInputsManager";
  46591. export * from "babylonjs/Cameras/followCamera";
  46592. export * from "babylonjs/Cameras/followCameraInputsManager";
  46593. export * from "babylonjs/Cameras/gamepadCamera";
  46594. export * from "babylonjs/Cameras/Stereoscopic/index";
  46595. export * from "babylonjs/Cameras/universalCamera";
  46596. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  46597. export * from "babylonjs/Cameras/VR/index";
  46598. export * from "babylonjs/Cameras/XR/index";
  46599. export * from "babylonjs/Cameras/RigModes/index";
  46600. }
  46601. declare module "babylonjs/Collisions/index" {
  46602. export * from "babylonjs/Collisions/collider";
  46603. export * from "babylonjs/Collisions/collisionCoordinator";
  46604. export * from "babylonjs/Collisions/pickingInfo";
  46605. export * from "babylonjs/Collisions/intersectionInfo";
  46606. export * from "babylonjs/Collisions/meshCollisionData";
  46607. }
  46608. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  46609. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  46610. import { Vector3 } from "babylonjs/Maths/math.vector";
  46611. import { Ray } from "babylonjs/Culling/ray";
  46612. import { Plane } from "babylonjs/Maths/math.plane";
  46613. /**
  46614. * Contains an array of blocks representing the octree
  46615. */
  46616. export interface IOctreeContainer<T> {
  46617. /**
  46618. * Blocks within the octree
  46619. */
  46620. blocks: Array<OctreeBlock<T>>;
  46621. }
  46622. /**
  46623. * Class used to store a cell in an octree
  46624. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46625. */
  46626. export class OctreeBlock<T> {
  46627. /**
  46628. * Gets the content of the current block
  46629. */
  46630. entries: T[];
  46631. /**
  46632. * Gets the list of block children
  46633. */
  46634. blocks: Array<OctreeBlock<T>>;
  46635. private _depth;
  46636. private _maxDepth;
  46637. private _capacity;
  46638. private _minPoint;
  46639. private _maxPoint;
  46640. private _boundingVectors;
  46641. private _creationFunc;
  46642. /**
  46643. * Creates a new block
  46644. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  46645. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  46646. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46647. * @param depth defines the current depth of this block in the octree
  46648. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  46649. * @param creationFunc defines a callback to call when an element is added to the block
  46650. */
  46651. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  46652. /**
  46653. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  46654. */
  46655. get capacity(): number;
  46656. /**
  46657. * Gets the minimum vector (in world space) of the block's bounding box
  46658. */
  46659. get minPoint(): Vector3;
  46660. /**
  46661. * Gets the maximum vector (in world space) of the block's bounding box
  46662. */
  46663. get maxPoint(): Vector3;
  46664. /**
  46665. * Add a new element to this block
  46666. * @param entry defines the element to add
  46667. */
  46668. addEntry(entry: T): void;
  46669. /**
  46670. * Remove an element from this block
  46671. * @param entry defines the element to remove
  46672. */
  46673. removeEntry(entry: T): void;
  46674. /**
  46675. * Add an array of elements to this block
  46676. * @param entries defines the array of elements to add
  46677. */
  46678. addEntries(entries: T[]): void;
  46679. /**
  46680. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  46681. * @param frustumPlanes defines the frustum planes to test
  46682. * @param selection defines the array to store current content if selection is positive
  46683. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46684. */
  46685. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46686. /**
  46687. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  46688. * @param sphereCenter defines the bounding sphere center
  46689. * @param sphereRadius defines the bounding sphere radius
  46690. * @param selection defines the array to store current content if selection is positive
  46691. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46692. */
  46693. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  46694. /**
  46695. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  46696. * @param ray defines the ray to test with
  46697. * @param selection defines the array to store current content if selection is positive
  46698. */
  46699. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  46700. /**
  46701. * Subdivide the content into child blocks (this block will then be empty)
  46702. */
  46703. createInnerBlocks(): void;
  46704. /**
  46705. * @hidden
  46706. */
  46707. 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;
  46708. }
  46709. }
  46710. declare module "babylonjs/Culling/Octrees/octree" {
  46711. import { SmartArray } from "babylonjs/Misc/smartArray";
  46712. import { Vector3 } from "babylonjs/Maths/math.vector";
  46713. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46715. import { Ray } from "babylonjs/Culling/ray";
  46716. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  46717. import { Plane } from "babylonjs/Maths/math.plane";
  46718. /**
  46719. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  46720. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46721. */
  46722. export class Octree<T> {
  46723. /** 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.) */
  46724. maxDepth: number;
  46725. /**
  46726. * Blocks within the octree containing objects
  46727. */
  46728. blocks: Array<OctreeBlock<T>>;
  46729. /**
  46730. * Content stored in the octree
  46731. */
  46732. dynamicContent: T[];
  46733. private _maxBlockCapacity;
  46734. private _selectionContent;
  46735. private _creationFunc;
  46736. /**
  46737. * Creates a octree
  46738. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46739. * @param creationFunc function to be used to instatiate the octree
  46740. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  46741. * @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.)
  46742. */
  46743. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  46744. /** 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.) */
  46745. maxDepth?: number);
  46746. /**
  46747. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  46748. * @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);
  46749. * @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);
  46750. * @param entries meshes to be added to the octree blocks
  46751. */
  46752. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  46753. /**
  46754. * Adds a mesh to the octree
  46755. * @param entry Mesh to add to the octree
  46756. */
  46757. addMesh(entry: T): void;
  46758. /**
  46759. * Remove an element from the octree
  46760. * @param entry defines the element to remove
  46761. */
  46762. removeMesh(entry: T): void;
  46763. /**
  46764. * Selects an array of meshes within the frustum
  46765. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  46766. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  46767. * @returns array of meshes within the frustum
  46768. */
  46769. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  46770. /**
  46771. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  46772. * @param sphereCenter defines the bounding sphere center
  46773. * @param sphereRadius defines the bounding sphere radius
  46774. * @param allowDuplicate defines if the selection array can contains duplicated entries
  46775. * @returns an array of objects that intersect the sphere
  46776. */
  46777. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  46778. /**
  46779. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  46780. * @param ray defines the ray to test with
  46781. * @returns array of intersected objects
  46782. */
  46783. intersectsRay(ray: Ray): SmartArray<T>;
  46784. /**
  46785. * Adds a mesh into the octree block if it intersects the block
  46786. */
  46787. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  46788. /**
  46789. * Adds a submesh into the octree block if it intersects the block
  46790. */
  46791. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  46792. }
  46793. }
  46794. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  46795. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  46796. import { Scene } from "babylonjs/scene";
  46797. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46799. import { Ray } from "babylonjs/Culling/ray";
  46800. import { Octree } from "babylonjs/Culling/Octrees/octree";
  46801. import { Collider } from "babylonjs/Collisions/collider";
  46802. module "babylonjs/scene" {
  46803. interface Scene {
  46804. /**
  46805. * @hidden
  46806. * Backing Filed
  46807. */
  46808. _selectionOctree: Octree<AbstractMesh>;
  46809. /**
  46810. * Gets the octree used to boost mesh selection (picking)
  46811. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46812. */
  46813. selectionOctree: Octree<AbstractMesh>;
  46814. /**
  46815. * Creates or updates the octree used to boost selection (picking)
  46816. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46817. * @param maxCapacity defines the maximum capacity per leaf
  46818. * @param maxDepth defines the maximum depth of the octree
  46819. * @returns an octree of AbstractMesh
  46820. */
  46821. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  46822. }
  46823. }
  46824. module "babylonjs/Meshes/abstractMesh" {
  46825. interface AbstractMesh {
  46826. /**
  46827. * @hidden
  46828. * Backing Field
  46829. */
  46830. _submeshesOctree: Octree<SubMesh>;
  46831. /**
  46832. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  46833. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  46834. * @param maxCapacity defines the maximum size of each block (64 by default)
  46835. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  46836. * @returns the new octree
  46837. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  46838. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  46839. */
  46840. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  46841. }
  46842. }
  46843. /**
  46844. * Defines the octree scene component responsible to manage any octrees
  46845. * in a given scene.
  46846. */
  46847. export class OctreeSceneComponent {
  46848. /**
  46849. * The component name help to identify the component in the list of scene components.
  46850. */
  46851. readonly name: string;
  46852. /**
  46853. * The scene the component belongs to.
  46854. */
  46855. scene: Scene;
  46856. /**
  46857. * Indicates if the meshes have been checked to make sure they are isEnabled()
  46858. */
  46859. readonly checksIsEnabled: boolean;
  46860. /**
  46861. * Creates a new instance of the component for the given scene
  46862. * @param scene Defines the scene to register the component in
  46863. */
  46864. constructor(scene: Scene);
  46865. /**
  46866. * Registers the component in a given scene
  46867. */
  46868. register(): void;
  46869. /**
  46870. * Return the list of active meshes
  46871. * @returns the list of active meshes
  46872. */
  46873. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46874. /**
  46875. * Return the list of active sub meshes
  46876. * @param mesh The mesh to get the candidates sub meshes from
  46877. * @returns the list of active sub meshes
  46878. */
  46879. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46880. private _tempRay;
  46881. /**
  46882. * Return the list of sub meshes intersecting with a given local ray
  46883. * @param mesh defines the mesh to find the submesh for
  46884. * @param localRay defines the ray in local space
  46885. * @returns the list of intersecting sub meshes
  46886. */
  46887. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  46888. /**
  46889. * Return the list of sub meshes colliding with a collider
  46890. * @param mesh defines the mesh to find the submesh for
  46891. * @param collider defines the collider to evaluate the collision against
  46892. * @returns the list of colliding sub meshes
  46893. */
  46894. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  46895. /**
  46896. * Rebuilds the elements related to this component in case of
  46897. * context lost for instance.
  46898. */
  46899. rebuild(): void;
  46900. /**
  46901. * Disposes the component and the associated ressources.
  46902. */
  46903. dispose(): void;
  46904. }
  46905. }
  46906. declare module "babylonjs/Culling/Octrees/index" {
  46907. export * from "babylonjs/Culling/Octrees/octree";
  46908. export * from "babylonjs/Culling/Octrees/octreeBlock";
  46909. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  46910. }
  46911. declare module "babylonjs/Culling/index" {
  46912. export * from "babylonjs/Culling/boundingBox";
  46913. export * from "babylonjs/Culling/boundingInfo";
  46914. export * from "babylonjs/Culling/boundingSphere";
  46915. export * from "babylonjs/Culling/Octrees/index";
  46916. export * from "babylonjs/Culling/ray";
  46917. }
  46918. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46919. import { IDisposable, Scene } from "babylonjs/scene";
  46920. import { Nullable } from "babylonjs/types";
  46921. import { Observable } from "babylonjs/Misc/observable";
  46922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46923. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46924. import { Camera } from "babylonjs/Cameras/camera";
  46925. /**
  46926. * Renders a layer on top of an existing scene
  46927. */
  46928. export class UtilityLayerRenderer implements IDisposable {
  46929. /** the original scene that will be rendered on top of */
  46930. originalScene: Scene;
  46931. private _pointerCaptures;
  46932. private _lastPointerEvents;
  46933. private static _DefaultUtilityLayer;
  46934. private static _DefaultKeepDepthUtilityLayer;
  46935. private _sharedGizmoLight;
  46936. private _renderCamera;
  46937. /**
  46938. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46939. * @returns the camera that is used when rendering the utility layer
  46940. */
  46941. getRenderCamera(): Nullable<Camera>;
  46942. /**
  46943. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46944. * @param cam the camera that should be used when rendering the utility layer
  46945. */
  46946. setRenderCamera(cam: Nullable<Camera>): void;
  46947. /**
  46948. * @hidden
  46949. * Light which used by gizmos to get light shading
  46950. */
  46951. _getSharedGizmoLight(): HemisphericLight;
  46952. /**
  46953. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46954. */
  46955. pickUtilitySceneFirst: boolean;
  46956. /**
  46957. * 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)
  46958. */
  46959. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46960. /**
  46961. * 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)
  46962. */
  46963. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46964. /**
  46965. * The scene that is rendered on top of the original scene
  46966. */
  46967. utilityLayerScene: Scene;
  46968. /**
  46969. * If the utility layer should automatically be rendered on top of existing scene
  46970. */
  46971. shouldRender: boolean;
  46972. /**
  46973. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46974. */
  46975. onlyCheckPointerDownEvents: boolean;
  46976. /**
  46977. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46978. */
  46979. processAllEvents: boolean;
  46980. /**
  46981. * Observable raised when the pointer move from the utility layer scene to the main scene
  46982. */
  46983. onPointerOutObservable: Observable<number>;
  46984. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46985. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46986. private _afterRenderObserver;
  46987. private _sceneDisposeObserver;
  46988. private _originalPointerObserver;
  46989. /**
  46990. * Instantiates a UtilityLayerRenderer
  46991. * @param originalScene the original scene that will be rendered on top of
  46992. * @param handleEvents boolean indicating if the utility layer should handle events
  46993. */
  46994. constructor(
  46995. /** the original scene that will be rendered on top of */
  46996. originalScene: Scene, handleEvents?: boolean);
  46997. private _notifyObservers;
  46998. /**
  46999. * Renders the utility layers scene on top of the original scene
  47000. */
  47001. render(): void;
  47002. /**
  47003. * Disposes of the renderer
  47004. */
  47005. dispose(): void;
  47006. private _updateCamera;
  47007. }
  47008. }
  47009. declare module "babylonjs/Gizmos/gizmo" {
  47010. import { Nullable } from "babylonjs/types";
  47011. import { IDisposable } from "babylonjs/scene";
  47012. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47013. import { Mesh } from "babylonjs/Meshes/mesh";
  47014. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47015. /**
  47016. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47017. */
  47018. export class Gizmo implements IDisposable {
  47019. /** The utility layer the gizmo will be added to */
  47020. gizmoLayer: UtilityLayerRenderer;
  47021. /**
  47022. * The root mesh of the gizmo
  47023. */
  47024. _rootMesh: Mesh;
  47025. private _attachedMesh;
  47026. /**
  47027. * Ratio for the scale of the gizmo (Default: 1)
  47028. */
  47029. scaleRatio: number;
  47030. /**
  47031. * If a custom mesh has been set (Default: false)
  47032. */
  47033. protected _customMeshSet: boolean;
  47034. /**
  47035. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47036. * * When set, interactions will be enabled
  47037. */
  47038. get attachedMesh(): Nullable<AbstractMesh>;
  47039. set attachedMesh(value: Nullable<AbstractMesh>);
  47040. /**
  47041. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47042. * @param mesh The mesh to replace the default mesh of the gizmo
  47043. */
  47044. setCustomMesh(mesh: Mesh): void;
  47045. /**
  47046. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47047. */
  47048. updateGizmoRotationToMatchAttachedMesh: boolean;
  47049. /**
  47050. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47051. */
  47052. updateGizmoPositionToMatchAttachedMesh: boolean;
  47053. /**
  47054. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47055. */
  47056. updateScale: boolean;
  47057. protected _interactionsEnabled: boolean;
  47058. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47059. private _beforeRenderObserver;
  47060. private _tempVector;
  47061. /**
  47062. * Creates a gizmo
  47063. * @param gizmoLayer The utility layer the gizmo will be added to
  47064. */
  47065. constructor(
  47066. /** The utility layer the gizmo will be added to */
  47067. gizmoLayer?: UtilityLayerRenderer);
  47068. /**
  47069. * Updates the gizmo to match the attached mesh's position/rotation
  47070. */
  47071. protected _update(): void;
  47072. /**
  47073. * Disposes of the gizmo
  47074. */
  47075. dispose(): void;
  47076. }
  47077. }
  47078. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47079. import { Observable } from "babylonjs/Misc/observable";
  47080. import { Nullable } from "babylonjs/types";
  47081. import { Vector3 } from "babylonjs/Maths/math.vector";
  47082. import { Color3 } from "babylonjs/Maths/math.color";
  47083. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47085. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47086. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47087. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47088. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47089. import { Scene } from "babylonjs/scene";
  47090. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47091. /**
  47092. * Single plane drag gizmo
  47093. */
  47094. export class PlaneDragGizmo extends Gizmo {
  47095. /**
  47096. * Drag behavior responsible for the gizmos dragging interactions
  47097. */
  47098. dragBehavior: PointerDragBehavior;
  47099. private _pointerObserver;
  47100. /**
  47101. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47102. */
  47103. snapDistance: number;
  47104. /**
  47105. * Event that fires each time the gizmo snaps to a new location.
  47106. * * snapDistance is the the change in distance
  47107. */
  47108. onSnapObservable: Observable<{
  47109. snapDistance: number;
  47110. }>;
  47111. private _plane;
  47112. private _coloredMaterial;
  47113. private _hoverMaterial;
  47114. private _isEnabled;
  47115. private _parent;
  47116. /** @hidden */
  47117. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47118. /** @hidden */
  47119. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47120. /**
  47121. * Creates a PlaneDragGizmo
  47122. * @param gizmoLayer The utility layer the gizmo will be added to
  47123. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47124. * @param color The color of the gizmo
  47125. */
  47126. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47127. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47128. /**
  47129. * If the gizmo is enabled
  47130. */
  47131. set isEnabled(value: boolean);
  47132. get isEnabled(): boolean;
  47133. /**
  47134. * Disposes of the gizmo
  47135. */
  47136. dispose(): void;
  47137. }
  47138. }
  47139. declare module "babylonjs/Gizmos/positionGizmo" {
  47140. import { Observable } from "babylonjs/Misc/observable";
  47141. import { Nullable } from "babylonjs/types";
  47142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47143. import { Mesh } from "babylonjs/Meshes/mesh";
  47144. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47145. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47146. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47147. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47148. /**
  47149. * Gizmo that enables dragging a mesh along 3 axis
  47150. */
  47151. export class PositionGizmo extends Gizmo {
  47152. /**
  47153. * Internal gizmo used for interactions on the x axis
  47154. */
  47155. xGizmo: AxisDragGizmo;
  47156. /**
  47157. * Internal gizmo used for interactions on the y axis
  47158. */
  47159. yGizmo: AxisDragGizmo;
  47160. /**
  47161. * Internal gizmo used for interactions on the z axis
  47162. */
  47163. zGizmo: AxisDragGizmo;
  47164. /**
  47165. * Internal gizmo used for interactions on the yz plane
  47166. */
  47167. xPlaneGizmo: PlaneDragGizmo;
  47168. /**
  47169. * Internal gizmo used for interactions on the xz plane
  47170. */
  47171. yPlaneGizmo: PlaneDragGizmo;
  47172. /**
  47173. * Internal gizmo used for interactions on the xy plane
  47174. */
  47175. zPlaneGizmo: PlaneDragGizmo;
  47176. /**
  47177. * private variables
  47178. */
  47179. private _meshAttached;
  47180. private _updateGizmoRotationToMatchAttachedMesh;
  47181. private _snapDistance;
  47182. private _scaleRatio;
  47183. /** Fires an event when any of it's sub gizmos are dragged */
  47184. onDragStartObservable: Observable<unknown>;
  47185. /** Fires an event when any of it's sub gizmos are released from dragging */
  47186. onDragEndObservable: Observable<unknown>;
  47187. /**
  47188. * If set to true, planar drag is enabled
  47189. */
  47190. private _planarGizmoEnabled;
  47191. get attachedMesh(): Nullable<AbstractMesh>;
  47192. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47193. /**
  47194. * Creates a PositionGizmo
  47195. * @param gizmoLayer The utility layer the gizmo will be added to
  47196. */
  47197. constructor(gizmoLayer?: UtilityLayerRenderer);
  47198. /**
  47199. * If the planar drag gizmo is enabled
  47200. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47201. */
  47202. set planarGizmoEnabled(value: boolean);
  47203. get planarGizmoEnabled(): boolean;
  47204. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47205. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47206. /**
  47207. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47208. */
  47209. set snapDistance(value: number);
  47210. get snapDistance(): number;
  47211. /**
  47212. * Ratio for the scale of the gizmo (Default: 1)
  47213. */
  47214. set scaleRatio(value: number);
  47215. get scaleRatio(): number;
  47216. /**
  47217. * Disposes of the gizmo
  47218. */
  47219. dispose(): void;
  47220. /**
  47221. * CustomMeshes are not supported by this gizmo
  47222. * @param mesh The mesh to replace the default mesh of the gizmo
  47223. */
  47224. setCustomMesh(mesh: Mesh): void;
  47225. }
  47226. }
  47227. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47228. import { Observable } from "babylonjs/Misc/observable";
  47229. import { Nullable } from "babylonjs/types";
  47230. import { Vector3 } from "babylonjs/Maths/math.vector";
  47231. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47232. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47233. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47234. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47235. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47236. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47237. import { Scene } from "babylonjs/scene";
  47238. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47239. import { Color3 } from "babylonjs/Maths/math.color";
  47240. /**
  47241. * Single axis drag gizmo
  47242. */
  47243. export class AxisDragGizmo extends Gizmo {
  47244. /**
  47245. * Drag behavior responsible for the gizmos dragging interactions
  47246. */
  47247. dragBehavior: PointerDragBehavior;
  47248. private _pointerObserver;
  47249. /**
  47250. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47251. */
  47252. snapDistance: number;
  47253. /**
  47254. * Event that fires each time the gizmo snaps to a new location.
  47255. * * snapDistance is the the change in distance
  47256. */
  47257. onSnapObservable: Observable<{
  47258. snapDistance: number;
  47259. }>;
  47260. private _isEnabled;
  47261. private _parent;
  47262. private _arrow;
  47263. private _coloredMaterial;
  47264. private _hoverMaterial;
  47265. /** @hidden */
  47266. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47267. /** @hidden */
  47268. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47269. /**
  47270. * Creates an AxisDragGizmo
  47271. * @param gizmoLayer The utility layer the gizmo will be added to
  47272. * @param dragAxis The axis which the gizmo will be able to drag on
  47273. * @param color The color of the gizmo
  47274. */
  47275. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47276. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47277. /**
  47278. * If the gizmo is enabled
  47279. */
  47280. set isEnabled(value: boolean);
  47281. get isEnabled(): boolean;
  47282. /**
  47283. * Disposes of the gizmo
  47284. */
  47285. dispose(): void;
  47286. }
  47287. }
  47288. declare module "babylonjs/Debug/axesViewer" {
  47289. import { Vector3 } from "babylonjs/Maths/math.vector";
  47290. import { Nullable } from "babylonjs/types";
  47291. import { Scene } from "babylonjs/scene";
  47292. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47293. /**
  47294. * The Axes viewer will show 3 axes in a specific point in space
  47295. */
  47296. export class AxesViewer {
  47297. private _xAxis;
  47298. private _yAxis;
  47299. private _zAxis;
  47300. private _scaleLinesFactor;
  47301. private _instanced;
  47302. /**
  47303. * Gets the hosting scene
  47304. */
  47305. scene: Scene;
  47306. /**
  47307. * Gets or sets a number used to scale line length
  47308. */
  47309. scaleLines: number;
  47310. /** Gets the node hierarchy used to render x-axis */
  47311. get xAxis(): TransformNode;
  47312. /** Gets the node hierarchy used to render y-axis */
  47313. get yAxis(): TransformNode;
  47314. /** Gets the node hierarchy used to render z-axis */
  47315. get zAxis(): TransformNode;
  47316. /**
  47317. * Creates a new AxesViewer
  47318. * @param scene defines the hosting scene
  47319. * @param scaleLines defines a number used to scale line length (1 by default)
  47320. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47321. * @param xAxis defines the node hierarchy used to render the x-axis
  47322. * @param yAxis defines the node hierarchy used to render the y-axis
  47323. * @param zAxis defines the node hierarchy used to render the z-axis
  47324. */
  47325. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47326. /**
  47327. * Force the viewer to update
  47328. * @param position defines the position of the viewer
  47329. * @param xaxis defines the x axis of the viewer
  47330. * @param yaxis defines the y axis of the viewer
  47331. * @param zaxis defines the z axis of the viewer
  47332. */
  47333. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47334. /**
  47335. * Creates an instance of this axes viewer.
  47336. * @returns a new axes viewer with instanced meshes
  47337. */
  47338. createInstance(): AxesViewer;
  47339. /** Releases resources */
  47340. dispose(): void;
  47341. private static _SetRenderingGroupId;
  47342. }
  47343. }
  47344. declare module "babylonjs/Debug/boneAxesViewer" {
  47345. import { Nullable } from "babylonjs/types";
  47346. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47347. import { Vector3 } from "babylonjs/Maths/math.vector";
  47348. import { Mesh } from "babylonjs/Meshes/mesh";
  47349. import { Bone } from "babylonjs/Bones/bone";
  47350. import { Scene } from "babylonjs/scene";
  47351. /**
  47352. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47353. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47354. */
  47355. export class BoneAxesViewer extends AxesViewer {
  47356. /**
  47357. * Gets or sets the target mesh where to display the axes viewer
  47358. */
  47359. mesh: Nullable<Mesh>;
  47360. /**
  47361. * Gets or sets the target bone where to display the axes viewer
  47362. */
  47363. bone: Nullable<Bone>;
  47364. /** Gets current position */
  47365. pos: Vector3;
  47366. /** Gets direction of X axis */
  47367. xaxis: Vector3;
  47368. /** Gets direction of Y axis */
  47369. yaxis: Vector3;
  47370. /** Gets direction of Z axis */
  47371. zaxis: Vector3;
  47372. /**
  47373. * Creates a new BoneAxesViewer
  47374. * @param scene defines the hosting scene
  47375. * @param bone defines the target bone
  47376. * @param mesh defines the target mesh
  47377. * @param scaleLines defines a scaling factor for line length (1 by default)
  47378. */
  47379. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47380. /**
  47381. * Force the viewer to update
  47382. */
  47383. update(): void;
  47384. /** Releases resources */
  47385. dispose(): void;
  47386. }
  47387. }
  47388. declare module "babylonjs/Debug/debugLayer" {
  47389. import { Scene } from "babylonjs/scene";
  47390. /**
  47391. * Interface used to define scene explorer extensibility option
  47392. */
  47393. export interface IExplorerExtensibilityOption {
  47394. /**
  47395. * Define the option label
  47396. */
  47397. label: string;
  47398. /**
  47399. * Defines the action to execute on click
  47400. */
  47401. action: (entity: any) => void;
  47402. }
  47403. /**
  47404. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47405. */
  47406. export interface IExplorerExtensibilityGroup {
  47407. /**
  47408. * Defines a predicate to test if a given type mut be extended
  47409. */
  47410. predicate: (entity: any) => boolean;
  47411. /**
  47412. * Gets the list of options added to a type
  47413. */
  47414. entries: IExplorerExtensibilityOption[];
  47415. }
  47416. /**
  47417. * Interface used to define the options to use to create the Inspector
  47418. */
  47419. export interface IInspectorOptions {
  47420. /**
  47421. * Display in overlay mode (default: false)
  47422. */
  47423. overlay?: boolean;
  47424. /**
  47425. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47426. */
  47427. globalRoot?: HTMLElement;
  47428. /**
  47429. * Display the Scene explorer
  47430. */
  47431. showExplorer?: boolean;
  47432. /**
  47433. * Display the property inspector
  47434. */
  47435. showInspector?: boolean;
  47436. /**
  47437. * Display in embed mode (both panes on the right)
  47438. */
  47439. embedMode?: boolean;
  47440. /**
  47441. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47442. */
  47443. handleResize?: boolean;
  47444. /**
  47445. * Allow the panes to popup (default: true)
  47446. */
  47447. enablePopup?: boolean;
  47448. /**
  47449. * Allow the panes to be closed by users (default: true)
  47450. */
  47451. enableClose?: boolean;
  47452. /**
  47453. * Optional list of extensibility entries
  47454. */
  47455. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47456. /**
  47457. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47458. */
  47459. inspectorURL?: string;
  47460. /**
  47461. * Optional initial tab (default to DebugLayerTab.Properties)
  47462. */
  47463. initialTab?: DebugLayerTab;
  47464. }
  47465. module "babylonjs/scene" {
  47466. interface Scene {
  47467. /**
  47468. * @hidden
  47469. * Backing field
  47470. */
  47471. _debugLayer: DebugLayer;
  47472. /**
  47473. * Gets the debug layer (aka Inspector) associated with the scene
  47474. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47475. */
  47476. debugLayer: DebugLayer;
  47477. }
  47478. }
  47479. /**
  47480. * Enum of inspector action tab
  47481. */
  47482. export enum DebugLayerTab {
  47483. /**
  47484. * Properties tag (default)
  47485. */
  47486. Properties = 0,
  47487. /**
  47488. * Debug tab
  47489. */
  47490. Debug = 1,
  47491. /**
  47492. * Statistics tab
  47493. */
  47494. Statistics = 2,
  47495. /**
  47496. * Tools tab
  47497. */
  47498. Tools = 3,
  47499. /**
  47500. * Settings tab
  47501. */
  47502. Settings = 4
  47503. }
  47504. /**
  47505. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47506. * what is happening in your scene
  47507. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47508. */
  47509. export class DebugLayer {
  47510. /**
  47511. * Define the url to get the inspector script from.
  47512. * By default it uses the babylonjs CDN.
  47513. * @ignoreNaming
  47514. */
  47515. static InspectorURL: string;
  47516. private _scene;
  47517. private BJSINSPECTOR;
  47518. private _onPropertyChangedObservable?;
  47519. /**
  47520. * Observable triggered when a property is changed through the inspector.
  47521. */
  47522. get onPropertyChangedObservable(): any;
  47523. /**
  47524. * Instantiates a new debug layer.
  47525. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47526. * what is happening in your scene
  47527. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47528. * @param scene Defines the scene to inspect
  47529. */
  47530. constructor(scene: Scene);
  47531. /** Creates the inspector window. */
  47532. private _createInspector;
  47533. /**
  47534. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47535. * @param entity defines the entity to select
  47536. * @param lineContainerTitle defines the specific block to highlight
  47537. */
  47538. select(entity: any, lineContainerTitle?: string): void;
  47539. /** Get the inspector from bundle or global */
  47540. private _getGlobalInspector;
  47541. /**
  47542. * Get if the inspector is visible or not.
  47543. * @returns true if visible otherwise, false
  47544. */
  47545. isVisible(): boolean;
  47546. /**
  47547. * Hide the inspector and close its window.
  47548. */
  47549. hide(): void;
  47550. /**
  47551. * Launch the debugLayer.
  47552. * @param config Define the configuration of the inspector
  47553. * @return a promise fulfilled when the debug layer is visible
  47554. */
  47555. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47556. }
  47557. }
  47558. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47559. import { Nullable } from "babylonjs/types";
  47560. import { Scene } from "babylonjs/scene";
  47561. import { Vector4 } from "babylonjs/Maths/math.vector";
  47562. import { Color4 } from "babylonjs/Maths/math.color";
  47563. import { Mesh } from "babylonjs/Meshes/mesh";
  47564. /**
  47565. * Class containing static functions to help procedurally build meshes
  47566. */
  47567. export class BoxBuilder {
  47568. /**
  47569. * Creates a box mesh
  47570. * * The parameter `size` sets the size (float) of each box side (default 1)
  47571. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47572. * * 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)
  47573. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47574. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47575. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47576. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47577. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47578. * @param name defines the name of the mesh
  47579. * @param options defines the options used to create the mesh
  47580. * @param scene defines the hosting scene
  47581. * @returns the box mesh
  47582. */
  47583. static CreateBox(name: string, options: {
  47584. size?: number;
  47585. width?: number;
  47586. height?: number;
  47587. depth?: number;
  47588. faceUV?: Vector4[];
  47589. faceColors?: Color4[];
  47590. sideOrientation?: number;
  47591. frontUVs?: Vector4;
  47592. backUVs?: Vector4;
  47593. wrap?: boolean;
  47594. topBaseAt?: number;
  47595. bottomBaseAt?: number;
  47596. updatable?: boolean;
  47597. }, scene?: Nullable<Scene>): Mesh;
  47598. }
  47599. }
  47600. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  47601. import { Vector4 } from "babylonjs/Maths/math.vector";
  47602. import { Mesh } from "babylonjs/Meshes/mesh";
  47603. import { Scene } from "babylonjs/scene";
  47604. import { Nullable } from "babylonjs/types";
  47605. /**
  47606. * Class containing static functions to help procedurally build meshes
  47607. */
  47608. export class SphereBuilder {
  47609. /**
  47610. * Creates a sphere mesh
  47611. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  47612. * * 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`)
  47613. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  47614. * * 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
  47615. * * 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)
  47616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47617. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47619. * @param name defines the name of the mesh
  47620. * @param options defines the options used to create the mesh
  47621. * @param scene defines the hosting scene
  47622. * @returns the sphere mesh
  47623. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  47624. */
  47625. static CreateSphere(name: string, options: {
  47626. segments?: number;
  47627. diameter?: number;
  47628. diameterX?: number;
  47629. diameterY?: number;
  47630. diameterZ?: number;
  47631. arc?: number;
  47632. slice?: number;
  47633. sideOrientation?: number;
  47634. frontUVs?: Vector4;
  47635. backUVs?: Vector4;
  47636. updatable?: boolean;
  47637. }, scene?: Nullable<Scene>): Mesh;
  47638. }
  47639. }
  47640. declare module "babylonjs/Debug/physicsViewer" {
  47641. import { Nullable } from "babylonjs/types";
  47642. import { Scene } from "babylonjs/scene";
  47643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47644. import { Mesh } from "babylonjs/Meshes/mesh";
  47645. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47646. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47647. /**
  47648. * Used to show the physics impostor around the specific mesh
  47649. */
  47650. export class PhysicsViewer {
  47651. /** @hidden */
  47652. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47653. /** @hidden */
  47654. protected _meshes: Array<Nullable<AbstractMesh>>;
  47655. /** @hidden */
  47656. protected _scene: Nullable<Scene>;
  47657. /** @hidden */
  47658. protected _numMeshes: number;
  47659. /** @hidden */
  47660. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47661. private _renderFunction;
  47662. private _utilityLayer;
  47663. private _debugBoxMesh;
  47664. private _debugSphereMesh;
  47665. private _debugCylinderMesh;
  47666. private _debugMaterial;
  47667. private _debugMeshMeshes;
  47668. /**
  47669. * Creates a new PhysicsViewer
  47670. * @param scene defines the hosting scene
  47671. */
  47672. constructor(scene: Scene);
  47673. /** @hidden */
  47674. protected _updateDebugMeshes(): void;
  47675. /**
  47676. * Renders a specified physic impostor
  47677. * @param impostor defines the impostor to render
  47678. * @param targetMesh defines the mesh represented by the impostor
  47679. * @returns the new debug mesh used to render the impostor
  47680. */
  47681. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  47682. /**
  47683. * Hides a specified physic impostor
  47684. * @param impostor defines the impostor to hide
  47685. */
  47686. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  47687. private _getDebugMaterial;
  47688. private _getDebugBoxMesh;
  47689. private _getDebugSphereMesh;
  47690. private _getDebugCylinderMesh;
  47691. private _getDebugMeshMesh;
  47692. private _getDebugMesh;
  47693. /** Releases all resources */
  47694. dispose(): void;
  47695. }
  47696. }
  47697. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  47698. import { Vector3 } from "babylonjs/Maths/math.vector";
  47699. import { Color4 } from "babylonjs/Maths/math.color";
  47700. import { Nullable } from "babylonjs/types";
  47701. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47702. import { Scene } from "babylonjs/scene";
  47703. /**
  47704. * Class containing static functions to help procedurally build meshes
  47705. */
  47706. export class LinesBuilder {
  47707. /**
  47708. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  47709. * * 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
  47710. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  47711. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  47712. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  47713. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  47714. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  47715. * * 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
  47716. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  47717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47718. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  47719. * @param name defines the name of the new line system
  47720. * @param options defines the options used to create the line system
  47721. * @param scene defines the hosting scene
  47722. * @returns a new line system mesh
  47723. */
  47724. static CreateLineSystem(name: string, options: {
  47725. lines: Vector3[][];
  47726. updatable?: boolean;
  47727. instance?: Nullable<LinesMesh>;
  47728. colors?: Nullable<Color4[][]>;
  47729. useVertexAlpha?: boolean;
  47730. }, scene: Nullable<Scene>): LinesMesh;
  47731. /**
  47732. * Creates a line mesh
  47733. * 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
  47734. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47735. * * The parameter `points` is an array successive Vector3
  47736. * * 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
  47737. * * The optional parameter `colors` is an array of successive Color4, one per line point
  47738. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  47739. * * When updating an instance, remember that only point positions can change, not the number of points
  47740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47741. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  47742. * @param name defines the name of the new line system
  47743. * @param options defines the options used to create the line system
  47744. * @param scene defines the hosting scene
  47745. * @returns a new line mesh
  47746. */
  47747. static CreateLines(name: string, options: {
  47748. points: Vector3[];
  47749. updatable?: boolean;
  47750. instance?: Nullable<LinesMesh>;
  47751. colors?: Color4[];
  47752. useVertexAlpha?: boolean;
  47753. }, scene?: Nullable<Scene>): LinesMesh;
  47754. /**
  47755. * Creates a dashed line mesh
  47756. * * 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
  47757. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  47758. * * The parameter `points` is an array successive Vector3
  47759. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  47760. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  47761. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  47762. * * 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
  47763. * * When updating an instance, remember that only point positions can change, not the number of points
  47764. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47765. * @param name defines the name of the mesh
  47766. * @param options defines the options used to create the mesh
  47767. * @param scene defines the hosting scene
  47768. * @returns the dashed line mesh
  47769. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  47770. */
  47771. static CreateDashedLines(name: string, options: {
  47772. points: Vector3[];
  47773. dashSize?: number;
  47774. gapSize?: number;
  47775. dashNb?: number;
  47776. updatable?: boolean;
  47777. instance?: LinesMesh;
  47778. }, scene?: Nullable<Scene>): LinesMesh;
  47779. }
  47780. }
  47781. declare module "babylonjs/Debug/rayHelper" {
  47782. import { Nullable } from "babylonjs/types";
  47783. import { Ray } from "babylonjs/Culling/ray";
  47784. import { Vector3 } from "babylonjs/Maths/math.vector";
  47785. import { Color3 } from "babylonjs/Maths/math.color";
  47786. import { Scene } from "babylonjs/scene";
  47787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47788. import "babylonjs/Meshes/Builders/linesBuilder";
  47789. /**
  47790. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47791. * in order to better appreciate the issue one might have.
  47792. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47793. */
  47794. export class RayHelper {
  47795. /**
  47796. * Defines the ray we are currently tryin to visualize.
  47797. */
  47798. ray: Nullable<Ray>;
  47799. private _renderPoints;
  47800. private _renderLine;
  47801. private _renderFunction;
  47802. private _scene;
  47803. private _updateToMeshFunction;
  47804. private _attachedToMesh;
  47805. private _meshSpaceDirection;
  47806. private _meshSpaceOrigin;
  47807. /**
  47808. * Helper function to create a colored helper in a scene in one line.
  47809. * @param ray Defines the ray we are currently tryin to visualize
  47810. * @param scene Defines the scene the ray is used in
  47811. * @param color Defines the color we want to see the ray in
  47812. * @returns The newly created ray helper.
  47813. */
  47814. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  47815. /**
  47816. * Instantiate a new ray helper.
  47817. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  47818. * in order to better appreciate the issue one might have.
  47819. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  47820. * @param ray Defines the ray we are currently tryin to visualize
  47821. */
  47822. constructor(ray: Ray);
  47823. /**
  47824. * Shows the ray we are willing to debug.
  47825. * @param scene Defines the scene the ray needs to be rendered in
  47826. * @param color Defines the color the ray needs to be rendered in
  47827. */
  47828. show(scene: Scene, color?: Color3): void;
  47829. /**
  47830. * Hides the ray we are debugging.
  47831. */
  47832. hide(): void;
  47833. private _render;
  47834. /**
  47835. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  47836. * @param mesh Defines the mesh we want the helper attached to
  47837. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  47838. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  47839. * @param length Defines the length of the ray
  47840. */
  47841. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  47842. /**
  47843. * Detach the ray helper from the mesh it has previously been attached to.
  47844. */
  47845. detachFromMesh(): void;
  47846. private _updateToMesh;
  47847. /**
  47848. * Dispose the helper and release its associated resources.
  47849. */
  47850. dispose(): void;
  47851. }
  47852. }
  47853. declare module "babylonjs/Debug/skeletonViewer" {
  47854. import { Color3 } from "babylonjs/Maths/math.color";
  47855. import { Scene } from "babylonjs/scene";
  47856. import { Nullable } from "babylonjs/types";
  47857. import { Skeleton } from "babylonjs/Bones/skeleton";
  47858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47859. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  47860. /**
  47861. * Class used to render a debug view of a given skeleton
  47862. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  47863. */
  47864. export class SkeletonViewer {
  47865. /** defines the skeleton to render */
  47866. skeleton: Skeleton;
  47867. /** defines the mesh attached to the skeleton */
  47868. mesh: AbstractMesh;
  47869. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47870. autoUpdateBonesMatrices: boolean;
  47871. /** defines the rendering group id to use with the viewer */
  47872. renderingGroupId: number;
  47873. /** Gets or sets the color used to render the skeleton */
  47874. color: Color3;
  47875. private _scene;
  47876. private _debugLines;
  47877. private _debugMesh;
  47878. private _isEnabled;
  47879. private _renderFunction;
  47880. private _utilityLayer;
  47881. /**
  47882. * Returns the mesh used to render the bones
  47883. */
  47884. get debugMesh(): Nullable<LinesMesh>;
  47885. /**
  47886. * Creates a new SkeletonViewer
  47887. * @param skeleton defines the skeleton to render
  47888. * @param mesh defines the mesh attached to the skeleton
  47889. * @param scene defines the hosting scene
  47890. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  47891. * @param renderingGroupId defines the rendering group id to use with the viewer
  47892. */
  47893. constructor(
  47894. /** defines the skeleton to render */
  47895. skeleton: Skeleton,
  47896. /** defines the mesh attached to the skeleton */
  47897. mesh: AbstractMesh, scene: Scene,
  47898. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  47899. autoUpdateBonesMatrices?: boolean,
  47900. /** defines the rendering group id to use with the viewer */
  47901. renderingGroupId?: number);
  47902. /** Gets or sets a boolean indicating if the viewer is enabled */
  47903. set isEnabled(value: boolean);
  47904. get isEnabled(): boolean;
  47905. private _getBonePosition;
  47906. private _getLinesForBonesWithLength;
  47907. private _getLinesForBonesNoLength;
  47908. /** Update the viewer to sync with current skeleton state */
  47909. update(): void;
  47910. /** Release associated resources */
  47911. dispose(): void;
  47912. }
  47913. }
  47914. declare module "babylonjs/Debug/index" {
  47915. export * from "babylonjs/Debug/axesViewer";
  47916. export * from "babylonjs/Debug/boneAxesViewer";
  47917. export * from "babylonjs/Debug/debugLayer";
  47918. export * from "babylonjs/Debug/physicsViewer";
  47919. export * from "babylonjs/Debug/rayHelper";
  47920. export * from "babylonjs/Debug/skeletonViewer";
  47921. }
  47922. declare module "babylonjs/Engines/nullEngine" {
  47923. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  47924. import { Scene } from "babylonjs/scene";
  47925. import { Engine } from "babylonjs/Engines/engine";
  47926. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  47927. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  47928. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47929. import { Effect } from "babylonjs/Materials/effect";
  47930. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  47931. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  47932. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  47933. /**
  47934. * Options to create the null engine
  47935. */
  47936. export class NullEngineOptions {
  47937. /**
  47938. * Render width (Default: 512)
  47939. */
  47940. renderWidth: number;
  47941. /**
  47942. * Render height (Default: 256)
  47943. */
  47944. renderHeight: number;
  47945. /**
  47946. * Texture size (Default: 512)
  47947. */
  47948. textureSize: number;
  47949. /**
  47950. * If delta time between frames should be constant
  47951. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47952. */
  47953. deterministicLockstep: boolean;
  47954. /**
  47955. * Maximum about of steps between frames (Default: 4)
  47956. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47957. */
  47958. lockstepMaxSteps: number;
  47959. }
  47960. /**
  47961. * The null engine class provides support for headless version of babylon.js.
  47962. * This can be used in server side scenario or for testing purposes
  47963. */
  47964. export class NullEngine extends Engine {
  47965. private _options;
  47966. /**
  47967. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  47968. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47969. * @returns true if engine is in deterministic lock step mode
  47970. */
  47971. isDeterministicLockStep(): boolean;
  47972. /**
  47973. * Gets the max steps when engine is running in deterministic lock step
  47974. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  47975. * @returns the max steps
  47976. */
  47977. getLockstepMaxSteps(): number;
  47978. /**
  47979. * Gets the current hardware scaling level.
  47980. * By default the hardware scaling level is computed from the window device ratio.
  47981. * 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.
  47982. * @returns a number indicating the current hardware scaling level
  47983. */
  47984. getHardwareScalingLevel(): number;
  47985. constructor(options?: NullEngineOptions);
  47986. /**
  47987. * Creates a vertex buffer
  47988. * @param vertices the data for the vertex buffer
  47989. * @returns the new WebGL static buffer
  47990. */
  47991. createVertexBuffer(vertices: FloatArray): DataBuffer;
  47992. /**
  47993. * Creates a new index buffer
  47994. * @param indices defines the content of the index buffer
  47995. * @param updatable defines if the index buffer must be updatable
  47996. * @returns a new webGL buffer
  47997. */
  47998. createIndexBuffer(indices: IndicesArray): DataBuffer;
  47999. /**
  48000. * Clear the current render buffer or the current render target (if any is set up)
  48001. * @param color defines the color to use
  48002. * @param backBuffer defines if the back buffer must be cleared
  48003. * @param depth defines if the depth buffer must be cleared
  48004. * @param stencil defines if the stencil buffer must be cleared
  48005. */
  48006. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48007. /**
  48008. * Gets the current render width
  48009. * @param useScreen defines if screen size must be used (or the current render target if any)
  48010. * @returns a number defining the current render width
  48011. */
  48012. getRenderWidth(useScreen?: boolean): number;
  48013. /**
  48014. * Gets the current render height
  48015. * @param useScreen defines if screen size must be used (or the current render target if any)
  48016. * @returns a number defining the current render height
  48017. */
  48018. getRenderHeight(useScreen?: boolean): number;
  48019. /**
  48020. * Set the WebGL's viewport
  48021. * @param viewport defines the viewport element to be used
  48022. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48023. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48024. */
  48025. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48026. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48027. /**
  48028. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48029. * @param pipelineContext defines the pipeline context to use
  48030. * @param uniformsNames defines the list of uniform names
  48031. * @returns an array of webGL uniform locations
  48032. */
  48033. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48034. /**
  48035. * Gets the lsit of active attributes for a given webGL program
  48036. * @param pipelineContext defines the pipeline context to use
  48037. * @param attributesNames defines the list of attribute names to get
  48038. * @returns an array of indices indicating the offset of each attribute
  48039. */
  48040. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48041. /**
  48042. * Binds an effect to the webGL context
  48043. * @param effect defines the effect to bind
  48044. */
  48045. bindSamplers(effect: Effect): void;
  48046. /**
  48047. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48048. * @param effect defines the effect to activate
  48049. */
  48050. enableEffect(effect: Effect): void;
  48051. /**
  48052. * Set various states to the webGL context
  48053. * @param culling defines backface culling state
  48054. * @param zOffset defines the value to apply to zOffset (0 by default)
  48055. * @param force defines if states must be applied even if cache is up to date
  48056. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48057. */
  48058. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48059. /**
  48060. * Set the value of an uniform to an array of int32
  48061. * @param uniform defines the webGL uniform location where to store the value
  48062. * @param array defines the array of int32 to store
  48063. */
  48064. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48065. /**
  48066. * Set the value of an uniform to an array of int32 (stored as vec2)
  48067. * @param uniform defines the webGL uniform location where to store the value
  48068. * @param array defines the array of int32 to store
  48069. */
  48070. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48071. /**
  48072. * Set the value of an uniform to an array of int32 (stored as vec3)
  48073. * @param uniform defines the webGL uniform location where to store the value
  48074. * @param array defines the array of int32 to store
  48075. */
  48076. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48077. /**
  48078. * Set the value of an uniform to an array of int32 (stored as vec4)
  48079. * @param uniform defines the webGL uniform location where to store the value
  48080. * @param array defines the array of int32 to store
  48081. */
  48082. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48083. /**
  48084. * Set the value of an uniform to an array of float32
  48085. * @param uniform defines the webGL uniform location where to store the value
  48086. * @param array defines the array of float32 to store
  48087. */
  48088. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48089. /**
  48090. * Set the value of an uniform to an array of float32 (stored as vec2)
  48091. * @param uniform defines the webGL uniform location where to store the value
  48092. * @param array defines the array of float32 to store
  48093. */
  48094. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48095. /**
  48096. * Set the value of an uniform to an array of float32 (stored as vec3)
  48097. * @param uniform defines the webGL uniform location where to store the value
  48098. * @param array defines the array of float32 to store
  48099. */
  48100. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48101. /**
  48102. * Set the value of an uniform to an array of float32 (stored as vec4)
  48103. * @param uniform defines the webGL uniform location where to store the value
  48104. * @param array defines the array of float32 to store
  48105. */
  48106. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48107. /**
  48108. * Set the value of an uniform to an array of number
  48109. * @param uniform defines the webGL uniform location where to store the value
  48110. * @param array defines the array of number to store
  48111. */
  48112. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48113. /**
  48114. * Set the value of an uniform to an array of number (stored as vec2)
  48115. * @param uniform defines the webGL uniform location where to store the value
  48116. * @param array defines the array of number to store
  48117. */
  48118. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48119. /**
  48120. * Set the value of an uniform to an array of number (stored as vec3)
  48121. * @param uniform defines the webGL uniform location where to store the value
  48122. * @param array defines the array of number to store
  48123. */
  48124. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48125. /**
  48126. * Set the value of an uniform to an array of number (stored as vec4)
  48127. * @param uniform defines the webGL uniform location where to store the value
  48128. * @param array defines the array of number to store
  48129. */
  48130. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48131. /**
  48132. * Set the value of an uniform to an array of float32 (stored as matrices)
  48133. * @param uniform defines the webGL uniform location where to store the value
  48134. * @param matrices defines the array of float32 to store
  48135. */
  48136. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48137. /**
  48138. * Set the value of an uniform to a matrix (3x3)
  48139. * @param uniform defines the webGL uniform location where to store the value
  48140. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48141. */
  48142. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48143. /**
  48144. * Set the value of an uniform to a matrix (2x2)
  48145. * @param uniform defines the webGL uniform location where to store the value
  48146. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48147. */
  48148. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48149. /**
  48150. * Set the value of an uniform to a number (float)
  48151. * @param uniform defines the webGL uniform location where to store the value
  48152. * @param value defines the float number to store
  48153. */
  48154. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48155. /**
  48156. * Set the value of an uniform to a vec2
  48157. * @param uniform defines the webGL uniform location where to store the value
  48158. * @param x defines the 1st component of the value
  48159. * @param y defines the 2nd component of the value
  48160. */
  48161. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48162. /**
  48163. * Set the value of an uniform to a vec3
  48164. * @param uniform defines the webGL uniform location where to store the value
  48165. * @param x defines the 1st component of the value
  48166. * @param y defines the 2nd component of the value
  48167. * @param z defines the 3rd component of the value
  48168. */
  48169. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48170. /**
  48171. * Set the value of an uniform to a boolean
  48172. * @param uniform defines the webGL uniform location where to store the value
  48173. * @param bool defines the boolean to store
  48174. */
  48175. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48176. /**
  48177. * Set the value of an uniform to a vec4
  48178. * @param uniform defines the webGL uniform location where to store the value
  48179. * @param x defines the 1st component of the value
  48180. * @param y defines the 2nd component of the value
  48181. * @param z defines the 3rd component of the value
  48182. * @param w defines the 4th component of the value
  48183. */
  48184. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48185. /**
  48186. * Sets the current alpha mode
  48187. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48188. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48189. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48190. */
  48191. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48192. /**
  48193. * Bind webGl buffers directly to the webGL context
  48194. * @param vertexBuffers defines the vertex buffer to bind
  48195. * @param indexBuffer defines the index buffer to bind
  48196. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48197. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48198. * @param effect defines the effect associated with the vertex buffer
  48199. */
  48200. bindBuffers(vertexBuffers: {
  48201. [key: string]: VertexBuffer;
  48202. }, indexBuffer: DataBuffer, effect: Effect): void;
  48203. /**
  48204. * Force the entire cache to be cleared
  48205. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48206. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48207. */
  48208. wipeCaches(bruteForce?: boolean): void;
  48209. /**
  48210. * Send a draw order
  48211. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48212. * @param indexStart defines the starting index
  48213. * @param indexCount defines the number of index to draw
  48214. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48215. */
  48216. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48217. /**
  48218. * Draw a list of indexed primitives
  48219. * @param fillMode defines the primitive to use
  48220. * @param indexStart defines the starting index
  48221. * @param indexCount defines the number of index to draw
  48222. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48223. */
  48224. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48225. /**
  48226. * Draw a list of unindexed primitives
  48227. * @param fillMode defines the primitive to use
  48228. * @param verticesStart defines the index of first vertex to draw
  48229. * @param verticesCount defines the count of vertices to draw
  48230. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48231. */
  48232. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48233. /** @hidden */
  48234. _createTexture(): WebGLTexture;
  48235. /** @hidden */
  48236. _releaseTexture(texture: InternalTexture): void;
  48237. /**
  48238. * Usually called from Texture.ts.
  48239. * Passed information to create a WebGLTexture
  48240. * @param urlArg defines a value which contains one of the following:
  48241. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48242. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48243. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48244. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48245. * @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)
  48246. * @param scene needed for loading to the correct scene
  48247. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48248. * @param onLoad optional callback to be called upon successful completion
  48249. * @param onError optional callback to be called upon failure
  48250. * @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
  48251. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48252. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48253. * @param forcedExtension defines the extension to use to pick the right loader
  48254. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48255. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48256. */
  48257. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  48258. /**
  48259. * Creates a new render target texture
  48260. * @param size defines the size of the texture
  48261. * @param options defines the options used to create the texture
  48262. * @returns a new render target texture stored in an InternalTexture
  48263. */
  48264. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48265. /**
  48266. * Update the sampling mode of a given texture
  48267. * @param samplingMode defines the required sampling mode
  48268. * @param texture defines the texture to update
  48269. */
  48270. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48271. /**
  48272. * Binds the frame buffer to the specified texture.
  48273. * @param texture The texture to render to or null for the default canvas
  48274. * @param faceIndex The face of the texture to render to in case of cube texture
  48275. * @param requiredWidth The width of the target to render to
  48276. * @param requiredHeight The height of the target to render to
  48277. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48278. * @param depthStencilTexture The depth stencil texture to use to render
  48279. * @param lodLevel defines le lod level to bind to the frame buffer
  48280. */
  48281. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48282. /**
  48283. * Unbind the current render target texture from the webGL context
  48284. * @param texture defines the render target texture to unbind
  48285. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48286. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48287. */
  48288. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48289. /**
  48290. * Creates a dynamic vertex buffer
  48291. * @param vertices the data for the dynamic vertex buffer
  48292. * @returns the new WebGL dynamic buffer
  48293. */
  48294. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48295. /**
  48296. * Update the content of a dynamic texture
  48297. * @param texture defines the texture to update
  48298. * @param canvas defines the canvas containing the source
  48299. * @param invertY defines if data must be stored with Y axis inverted
  48300. * @param premulAlpha defines if alpha is stored as premultiplied
  48301. * @param format defines the format of the data
  48302. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48303. */
  48304. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48305. /**
  48306. * Gets a boolean indicating if all created effects are ready
  48307. * @returns true if all effects are ready
  48308. */
  48309. areAllEffectsReady(): boolean;
  48310. /**
  48311. * @hidden
  48312. * Get the current error code of the webGL context
  48313. * @returns the error code
  48314. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48315. */
  48316. getError(): number;
  48317. /** @hidden */
  48318. _getUnpackAlignement(): number;
  48319. /** @hidden */
  48320. _unpackFlipY(value: boolean): void;
  48321. /**
  48322. * Update a dynamic index buffer
  48323. * @param indexBuffer defines the target index buffer
  48324. * @param indices defines the data to update
  48325. * @param offset defines the offset in the target index buffer where update should start
  48326. */
  48327. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48328. /**
  48329. * Updates a dynamic vertex buffer.
  48330. * @param vertexBuffer the vertex buffer to update
  48331. * @param vertices the data used to update the vertex buffer
  48332. * @param byteOffset the byte offset of the data (optional)
  48333. * @param byteLength the byte length of the data (optional)
  48334. */
  48335. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48336. /** @hidden */
  48337. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48338. /** @hidden */
  48339. _bindTexture(channel: number, texture: InternalTexture): void;
  48340. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48341. /**
  48342. * 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
  48343. */
  48344. releaseEffects(): void;
  48345. displayLoadingUI(): void;
  48346. hideLoadingUI(): void;
  48347. /** @hidden */
  48348. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48349. /** @hidden */
  48350. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48351. /** @hidden */
  48352. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48353. /** @hidden */
  48354. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48355. }
  48356. }
  48357. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48358. import { Nullable, int } from "babylonjs/types";
  48359. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48360. /** @hidden */
  48361. export class _OcclusionDataStorage {
  48362. /** @hidden */
  48363. occlusionInternalRetryCounter: number;
  48364. /** @hidden */
  48365. isOcclusionQueryInProgress: boolean;
  48366. /** @hidden */
  48367. isOccluded: boolean;
  48368. /** @hidden */
  48369. occlusionRetryCount: number;
  48370. /** @hidden */
  48371. occlusionType: number;
  48372. /** @hidden */
  48373. occlusionQueryAlgorithmType: number;
  48374. }
  48375. module "babylonjs/Engines/engine" {
  48376. interface Engine {
  48377. /**
  48378. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48379. * @return the new query
  48380. */
  48381. createQuery(): WebGLQuery;
  48382. /**
  48383. * Delete and release a webGL query
  48384. * @param query defines the query to delete
  48385. * @return the current engine
  48386. */
  48387. deleteQuery(query: WebGLQuery): Engine;
  48388. /**
  48389. * Check if a given query has resolved and got its value
  48390. * @param query defines the query to check
  48391. * @returns true if the query got its value
  48392. */
  48393. isQueryResultAvailable(query: WebGLQuery): boolean;
  48394. /**
  48395. * Gets the value of a given query
  48396. * @param query defines the query to check
  48397. * @returns the value of the query
  48398. */
  48399. getQueryResult(query: WebGLQuery): number;
  48400. /**
  48401. * Initiates an occlusion query
  48402. * @param algorithmType defines the algorithm to use
  48403. * @param query defines the query to use
  48404. * @returns the current engine
  48405. * @see http://doc.babylonjs.com/features/occlusionquery
  48406. */
  48407. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48408. /**
  48409. * Ends an occlusion query
  48410. * @see http://doc.babylonjs.com/features/occlusionquery
  48411. * @param algorithmType defines the algorithm to use
  48412. * @returns the current engine
  48413. */
  48414. endOcclusionQuery(algorithmType: number): Engine;
  48415. /**
  48416. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48417. * Please note that only one query can be issued at a time
  48418. * @returns a time token used to track the time span
  48419. */
  48420. startTimeQuery(): Nullable<_TimeToken>;
  48421. /**
  48422. * Ends a time query
  48423. * @param token defines the token used to measure the time span
  48424. * @returns the time spent (in ns)
  48425. */
  48426. endTimeQuery(token: _TimeToken): int;
  48427. /** @hidden */
  48428. _currentNonTimestampToken: Nullable<_TimeToken>;
  48429. /** @hidden */
  48430. _createTimeQuery(): WebGLQuery;
  48431. /** @hidden */
  48432. _deleteTimeQuery(query: WebGLQuery): void;
  48433. /** @hidden */
  48434. _getGlAlgorithmType(algorithmType: number): number;
  48435. /** @hidden */
  48436. _getTimeQueryResult(query: WebGLQuery): any;
  48437. /** @hidden */
  48438. _getTimeQueryAvailability(query: WebGLQuery): any;
  48439. }
  48440. }
  48441. module "babylonjs/Meshes/abstractMesh" {
  48442. interface AbstractMesh {
  48443. /**
  48444. * Backing filed
  48445. * @hidden
  48446. */
  48447. __occlusionDataStorage: _OcclusionDataStorage;
  48448. /**
  48449. * Access property
  48450. * @hidden
  48451. */
  48452. _occlusionDataStorage: _OcclusionDataStorage;
  48453. /**
  48454. * 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.
  48455. * The default value is -1 which means don't break the query and wait till the result
  48456. * @see http://doc.babylonjs.com/features/occlusionquery
  48457. */
  48458. occlusionRetryCount: number;
  48459. /**
  48460. * 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:
  48461. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48462. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48463. * * 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.
  48464. * @see http://doc.babylonjs.com/features/occlusionquery
  48465. */
  48466. occlusionType: number;
  48467. /**
  48468. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48469. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48470. * * 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.
  48471. * @see http://doc.babylonjs.com/features/occlusionquery
  48472. */
  48473. occlusionQueryAlgorithmType: number;
  48474. /**
  48475. * 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
  48476. * @see http://doc.babylonjs.com/features/occlusionquery
  48477. */
  48478. isOccluded: boolean;
  48479. /**
  48480. * Flag to check the progress status of the query
  48481. * @see http://doc.babylonjs.com/features/occlusionquery
  48482. */
  48483. isOcclusionQueryInProgress: boolean;
  48484. }
  48485. }
  48486. }
  48487. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48488. import { Nullable } from "babylonjs/types";
  48489. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48490. /** @hidden */
  48491. export var _forceTransformFeedbackToBundle: boolean;
  48492. module "babylonjs/Engines/engine" {
  48493. interface Engine {
  48494. /**
  48495. * Creates a webGL transform feedback object
  48496. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48497. * @returns the webGL transform feedback object
  48498. */
  48499. createTransformFeedback(): WebGLTransformFeedback;
  48500. /**
  48501. * Delete a webGL transform feedback object
  48502. * @param value defines the webGL transform feedback object to delete
  48503. */
  48504. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48505. /**
  48506. * Bind a webGL transform feedback object to the webgl context
  48507. * @param value defines the webGL transform feedback object to bind
  48508. */
  48509. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48510. /**
  48511. * Begins a transform feedback operation
  48512. * @param usePoints defines if points or triangles must be used
  48513. */
  48514. beginTransformFeedback(usePoints: boolean): void;
  48515. /**
  48516. * Ends a transform feedback operation
  48517. */
  48518. endTransformFeedback(): void;
  48519. /**
  48520. * Specify the varyings to use with transform feedback
  48521. * @param program defines the associated webGL program
  48522. * @param value defines the list of strings representing the varying names
  48523. */
  48524. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48525. /**
  48526. * Bind a webGL buffer for a transform feedback operation
  48527. * @param value defines the webGL buffer to bind
  48528. */
  48529. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48530. }
  48531. }
  48532. }
  48533. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48534. import { Scene } from "babylonjs/scene";
  48535. import { Engine } from "babylonjs/Engines/engine";
  48536. import { Texture } from "babylonjs/Materials/Textures/texture";
  48537. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48538. import "babylonjs/Engines/Extensions/engine.multiRender";
  48539. /**
  48540. * Creation options of the multi render target texture.
  48541. */
  48542. export interface IMultiRenderTargetOptions {
  48543. /**
  48544. * Define if the texture needs to create mip maps after render.
  48545. */
  48546. generateMipMaps?: boolean;
  48547. /**
  48548. * Define the types of all the draw buffers we want to create
  48549. */
  48550. types?: number[];
  48551. /**
  48552. * Define the sampling modes of all the draw buffers we want to create
  48553. */
  48554. samplingModes?: number[];
  48555. /**
  48556. * Define if a depth buffer is required
  48557. */
  48558. generateDepthBuffer?: boolean;
  48559. /**
  48560. * Define if a stencil buffer is required
  48561. */
  48562. generateStencilBuffer?: boolean;
  48563. /**
  48564. * Define if a depth texture is required instead of a depth buffer
  48565. */
  48566. generateDepthTexture?: boolean;
  48567. /**
  48568. * Define the number of desired draw buffers
  48569. */
  48570. textureCount?: number;
  48571. /**
  48572. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48573. */
  48574. doNotChangeAspectRatio?: boolean;
  48575. /**
  48576. * Define the default type of the buffers we are creating
  48577. */
  48578. defaultType?: number;
  48579. }
  48580. /**
  48581. * A multi render target, like a render target provides the ability to render to a texture.
  48582. * Unlike the render target, it can render to several draw buffers in one draw.
  48583. * This is specially interesting in deferred rendering or for any effects requiring more than
  48584. * just one color from a single pass.
  48585. */
  48586. export class MultiRenderTarget extends RenderTargetTexture {
  48587. private _internalTextures;
  48588. private _textures;
  48589. private _multiRenderTargetOptions;
  48590. /**
  48591. * Get if draw buffers are currently supported by the used hardware and browser.
  48592. */
  48593. get isSupported(): boolean;
  48594. /**
  48595. * Get the list of textures generated by the multi render target.
  48596. */
  48597. get textures(): Texture[];
  48598. /**
  48599. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48600. */
  48601. get depthTexture(): Texture;
  48602. /**
  48603. * Set the wrapping mode on U of all the textures we are rendering to.
  48604. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48605. */
  48606. set wrapU(wrap: number);
  48607. /**
  48608. * Set the wrapping mode on V of all the textures we are rendering to.
  48609. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48610. */
  48611. set wrapV(wrap: number);
  48612. /**
  48613. * Instantiate a new multi render target texture.
  48614. * A multi render target, like a render target provides the ability to render to a texture.
  48615. * Unlike the render target, it can render to several draw buffers in one draw.
  48616. * This is specially interesting in deferred rendering or for any effects requiring more than
  48617. * just one color from a single pass.
  48618. * @param name Define the name of the texture
  48619. * @param size Define the size of the buffers to render to
  48620. * @param count Define the number of target we are rendering into
  48621. * @param scene Define the scene the texture belongs to
  48622. * @param options Define the options used to create the multi render target
  48623. */
  48624. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48625. /** @hidden */
  48626. _rebuild(): void;
  48627. private _createInternalTextures;
  48628. private _createTextures;
  48629. /**
  48630. * Define the number of samples used if MSAA is enabled.
  48631. */
  48632. get samples(): number;
  48633. set samples(value: number);
  48634. /**
  48635. * Resize all the textures in the multi render target.
  48636. * Be carrefull as it will recreate all the data in the new texture.
  48637. * @param size Define the new size
  48638. */
  48639. resize(size: any): void;
  48640. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48641. /**
  48642. * Dispose the render targets and their associated resources
  48643. */
  48644. dispose(): void;
  48645. /**
  48646. * Release all the underlying texture used as draw buffers.
  48647. */
  48648. releaseInternalTextures(): void;
  48649. }
  48650. }
  48651. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48652. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48653. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48654. import { Nullable } from "babylonjs/types";
  48655. module "babylonjs/Engines/thinEngine" {
  48656. interface ThinEngine {
  48657. /**
  48658. * Unbind a list of render target textures from the webGL context
  48659. * This is used only when drawBuffer extension or webGL2 are active
  48660. * @param textures defines the render target textures to unbind
  48661. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48662. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48663. */
  48664. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48665. /**
  48666. * Create a multi render target texture
  48667. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48668. * @param size defines the size of the texture
  48669. * @param options defines the creation options
  48670. * @returns the cube texture as an InternalTexture
  48671. */
  48672. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48673. /**
  48674. * Update the sample count for a given multiple render target texture
  48675. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48676. * @param textures defines the textures to update
  48677. * @param samples defines the sample count to set
  48678. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48679. */
  48680. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48681. }
  48682. }
  48683. }
  48684. declare module "babylonjs/Engines/Extensions/engine.views" {
  48685. import { Camera } from "babylonjs/Cameras/camera";
  48686. import { Nullable } from "babylonjs/types";
  48687. /**
  48688. * Class used to define an additional view for the engine
  48689. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48690. */
  48691. export class EngineView {
  48692. /** Defines the canvas where to render the view */
  48693. target: HTMLCanvasElement;
  48694. /** Defines an optional camera used to render the view (will use active camera else) */
  48695. camera?: Camera;
  48696. }
  48697. module "babylonjs/Engines/engine" {
  48698. interface Engine {
  48699. /**
  48700. * Gets or sets the HTML element to use for attaching events
  48701. */
  48702. inputElement: Nullable<HTMLElement>;
  48703. /**
  48704. * Gets the current engine view
  48705. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48706. */
  48707. activeView: Nullable<EngineView>;
  48708. /** Gets or sets the list of views */
  48709. views: EngineView[];
  48710. /**
  48711. * Register a new child canvas
  48712. * @param canvas defines the canvas to register
  48713. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48714. * @returns the associated view
  48715. */
  48716. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48717. /**
  48718. * Remove a registered child canvas
  48719. * @param canvas defines the canvas to remove
  48720. * @returns the current engine
  48721. */
  48722. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48723. }
  48724. }
  48725. }
  48726. declare module "babylonjs/Engines/Extensions/index" {
  48727. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48728. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48729. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48730. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48731. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48732. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48733. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48734. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48735. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48736. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48737. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48738. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48739. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48740. export * from "babylonjs/Engines/Extensions/engine.views";
  48741. }
  48742. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48743. import { Nullable } from "babylonjs/types";
  48744. /**
  48745. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48746. */
  48747. export interface CubeMapInfo {
  48748. /**
  48749. * The pixel array for the front face.
  48750. * This is stored in format, left to right, up to down format.
  48751. */
  48752. front: Nullable<ArrayBufferView>;
  48753. /**
  48754. * The pixel array for the back face.
  48755. * This is stored in format, left to right, up to down format.
  48756. */
  48757. back: Nullable<ArrayBufferView>;
  48758. /**
  48759. * The pixel array for the left face.
  48760. * This is stored in format, left to right, up to down format.
  48761. */
  48762. left: Nullable<ArrayBufferView>;
  48763. /**
  48764. * The pixel array for the right face.
  48765. * This is stored in format, left to right, up to down format.
  48766. */
  48767. right: Nullable<ArrayBufferView>;
  48768. /**
  48769. * The pixel array for the up face.
  48770. * This is stored in format, left to right, up to down format.
  48771. */
  48772. up: Nullable<ArrayBufferView>;
  48773. /**
  48774. * The pixel array for the down face.
  48775. * This is stored in format, left to right, up to down format.
  48776. */
  48777. down: Nullable<ArrayBufferView>;
  48778. /**
  48779. * The size of the cubemap stored.
  48780. *
  48781. * Each faces will be size * size pixels.
  48782. */
  48783. size: number;
  48784. /**
  48785. * The format of the texture.
  48786. *
  48787. * RGBA, RGB.
  48788. */
  48789. format: number;
  48790. /**
  48791. * The type of the texture data.
  48792. *
  48793. * UNSIGNED_INT, FLOAT.
  48794. */
  48795. type: number;
  48796. /**
  48797. * Specifies whether the texture is in gamma space.
  48798. */
  48799. gammaSpace: boolean;
  48800. }
  48801. /**
  48802. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  48803. */
  48804. export class PanoramaToCubeMapTools {
  48805. private static FACE_FRONT;
  48806. private static FACE_BACK;
  48807. private static FACE_RIGHT;
  48808. private static FACE_LEFT;
  48809. private static FACE_DOWN;
  48810. private static FACE_UP;
  48811. /**
  48812. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  48813. *
  48814. * @param float32Array The source data.
  48815. * @param inputWidth The width of the input panorama.
  48816. * @param inputHeight The height of the input panorama.
  48817. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  48818. * @return The cubemap data
  48819. */
  48820. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  48821. private static CreateCubemapTexture;
  48822. private static CalcProjectionSpherical;
  48823. }
  48824. }
  48825. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  48826. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48827. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48828. import { Nullable } from "babylonjs/types";
  48829. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  48830. /**
  48831. * Helper class dealing with the extraction of spherical polynomial dataArray
  48832. * from a cube map.
  48833. */
  48834. export class CubeMapToSphericalPolynomialTools {
  48835. private static FileFaces;
  48836. /**
  48837. * Converts a texture to the according Spherical Polynomial data.
  48838. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48839. *
  48840. * @param texture The texture to extract the information from.
  48841. * @return The Spherical Polynomial data.
  48842. */
  48843. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  48844. /**
  48845. * Converts a cubemap to the according Spherical Polynomial data.
  48846. * This extracts the first 3 orders only as they are the only one used in the lighting.
  48847. *
  48848. * @param cubeInfo The Cube map to extract the information from.
  48849. * @return The Spherical Polynomial data.
  48850. */
  48851. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  48852. }
  48853. }
  48854. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  48855. import { Nullable } from "babylonjs/types";
  48856. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48857. module "babylonjs/Materials/Textures/baseTexture" {
  48858. interface BaseTexture {
  48859. /**
  48860. * Get the polynomial representation of the texture data.
  48861. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  48862. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  48863. */
  48864. sphericalPolynomial: Nullable<SphericalPolynomial>;
  48865. }
  48866. }
  48867. }
  48868. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48869. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48870. /** @hidden */
  48871. export var rgbdEncodePixelShader: {
  48872. name: string;
  48873. shader: string;
  48874. };
  48875. }
  48876. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  48877. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48878. /** @hidden */
  48879. export var rgbdDecodePixelShader: {
  48880. name: string;
  48881. shader: string;
  48882. };
  48883. }
  48884. declare module "babylonjs/Misc/environmentTextureTools" {
  48885. import { Nullable } from "babylonjs/types";
  48886. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48887. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48888. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48889. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48890. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  48891. import "babylonjs/Shaders/rgbdEncode.fragment";
  48892. import "babylonjs/Shaders/rgbdDecode.fragment";
  48893. /**
  48894. * Raw texture data and descriptor sufficient for WebGL texture upload
  48895. */
  48896. export interface EnvironmentTextureInfo {
  48897. /**
  48898. * Version of the environment map
  48899. */
  48900. version: number;
  48901. /**
  48902. * Width of image
  48903. */
  48904. width: number;
  48905. /**
  48906. * Irradiance information stored in the file.
  48907. */
  48908. irradiance: any;
  48909. /**
  48910. * Specular information stored in the file.
  48911. */
  48912. specular: any;
  48913. }
  48914. /**
  48915. * Defines One Image in the file. It requires only the position in the file
  48916. * as well as the length.
  48917. */
  48918. interface BufferImageData {
  48919. /**
  48920. * Length of the image data.
  48921. */
  48922. length: number;
  48923. /**
  48924. * Position of the data from the null terminator delimiting the end of the JSON.
  48925. */
  48926. position: number;
  48927. }
  48928. /**
  48929. * Defines the specular data enclosed in the file.
  48930. * This corresponds to the version 1 of the data.
  48931. */
  48932. export interface EnvironmentTextureSpecularInfoV1 {
  48933. /**
  48934. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  48935. */
  48936. specularDataPosition?: number;
  48937. /**
  48938. * This contains all the images data needed to reconstruct the cubemap.
  48939. */
  48940. mipmaps: Array<BufferImageData>;
  48941. /**
  48942. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  48943. */
  48944. lodGenerationScale: number;
  48945. }
  48946. /**
  48947. * Sets of helpers addressing the serialization and deserialization of environment texture
  48948. * stored in a BabylonJS env file.
  48949. * Those files are usually stored as .env files.
  48950. */
  48951. export class EnvironmentTextureTools {
  48952. /**
  48953. * Magic number identifying the env file.
  48954. */
  48955. private static _MagicBytes;
  48956. /**
  48957. * Gets the environment info from an env file.
  48958. * @param data The array buffer containing the .env bytes.
  48959. * @returns the environment file info (the json header) if successfully parsed.
  48960. */
  48961. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48962. /**
  48963. * Creates an environment texture from a loaded cube texture.
  48964. * @param texture defines the cube texture to convert in env file
  48965. * @return a promise containing the environment data if succesfull.
  48966. */
  48967. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48968. /**
  48969. * Creates a JSON representation of the spherical data.
  48970. * @param texture defines the texture containing the polynomials
  48971. * @return the JSON representation of the spherical info
  48972. */
  48973. private static _CreateEnvTextureIrradiance;
  48974. /**
  48975. * Creates the ArrayBufferViews used for initializing environment texture image data.
  48976. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  48977. * @param info parameters that determine what views will be created for accessing the underlying buffer
  48978. * @return the views described by info providing access to the underlying buffer
  48979. */
  48980. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  48981. /**
  48982. * Uploads the texture info contained in the env file to the GPU.
  48983. * @param texture defines the internal texture to upload to
  48984. * @param arrayBuffer defines the buffer cotaining the data to load
  48985. * @param info defines the texture info retrieved through the GetEnvInfo method
  48986. * @returns a promise
  48987. */
  48988. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48989. private static _OnImageReadyAsync;
  48990. /**
  48991. * Uploads the levels of image data to the GPU.
  48992. * @param texture defines the internal texture to upload to
  48993. * @param imageData defines the array buffer views of image data [mipmap][face]
  48994. * @returns a promise
  48995. */
  48996. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48997. /**
  48998. * Uploads spherical polynomials information to the texture.
  48999. * @param texture defines the texture we are trying to upload the information to
  49000. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49001. */
  49002. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49003. /** @hidden */
  49004. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49005. }
  49006. }
  49007. declare module "babylonjs/Maths/math.vertexFormat" {
  49008. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49009. /**
  49010. * Contains position and normal vectors for a vertex
  49011. */
  49012. export class PositionNormalVertex {
  49013. /** the position of the vertex (defaut: 0,0,0) */
  49014. position: Vector3;
  49015. /** the normal of the vertex (defaut: 0,1,0) */
  49016. normal: Vector3;
  49017. /**
  49018. * Creates a PositionNormalVertex
  49019. * @param position the position of the vertex (defaut: 0,0,0)
  49020. * @param normal the normal of the vertex (defaut: 0,1,0)
  49021. */
  49022. constructor(
  49023. /** the position of the vertex (defaut: 0,0,0) */
  49024. position?: Vector3,
  49025. /** the normal of the vertex (defaut: 0,1,0) */
  49026. normal?: Vector3);
  49027. /**
  49028. * Clones the PositionNormalVertex
  49029. * @returns the cloned PositionNormalVertex
  49030. */
  49031. clone(): PositionNormalVertex;
  49032. }
  49033. /**
  49034. * Contains position, normal and uv vectors for a vertex
  49035. */
  49036. export class PositionNormalTextureVertex {
  49037. /** the position of the vertex (defaut: 0,0,0) */
  49038. position: Vector3;
  49039. /** the normal of the vertex (defaut: 0,1,0) */
  49040. normal: Vector3;
  49041. /** the uv of the vertex (default: 0,0) */
  49042. uv: Vector2;
  49043. /**
  49044. * Creates a PositionNormalTextureVertex
  49045. * @param position the position of the vertex (defaut: 0,0,0)
  49046. * @param normal the normal of the vertex (defaut: 0,1,0)
  49047. * @param uv the uv of the vertex (default: 0,0)
  49048. */
  49049. constructor(
  49050. /** the position of the vertex (defaut: 0,0,0) */
  49051. position?: Vector3,
  49052. /** the normal of the vertex (defaut: 0,1,0) */
  49053. normal?: Vector3,
  49054. /** the uv of the vertex (default: 0,0) */
  49055. uv?: Vector2);
  49056. /**
  49057. * Clones the PositionNormalTextureVertex
  49058. * @returns the cloned PositionNormalTextureVertex
  49059. */
  49060. clone(): PositionNormalTextureVertex;
  49061. }
  49062. }
  49063. declare module "babylonjs/Maths/math" {
  49064. export * from "babylonjs/Maths/math.axis";
  49065. export * from "babylonjs/Maths/math.color";
  49066. export * from "babylonjs/Maths/math.constants";
  49067. export * from "babylonjs/Maths/math.frustum";
  49068. export * from "babylonjs/Maths/math.path";
  49069. export * from "babylonjs/Maths/math.plane";
  49070. export * from "babylonjs/Maths/math.size";
  49071. export * from "babylonjs/Maths/math.vector";
  49072. export * from "babylonjs/Maths/math.vertexFormat";
  49073. export * from "babylonjs/Maths/math.viewport";
  49074. }
  49075. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49076. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49077. /** @hidden */
  49078. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49079. private _genericAttributeLocation;
  49080. private _varyingLocationCount;
  49081. private _varyingLocationMap;
  49082. private _replacements;
  49083. private _textureCount;
  49084. private _uniforms;
  49085. lineProcessor(line: string): string;
  49086. attributeProcessor(attribute: string): string;
  49087. varyingProcessor(varying: string, isFragment: boolean): string;
  49088. uniformProcessor(uniform: string): string;
  49089. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49090. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49091. }
  49092. }
  49093. declare module "babylonjs/Engines/nativeEngine" {
  49094. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49095. import { Engine } from "babylonjs/Engines/engine";
  49096. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49097. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49098. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49099. import { Effect } from "babylonjs/Materials/effect";
  49100. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49101. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49102. import { IColor4Like } from "babylonjs/Maths/math.like";
  49103. import { Scene } from "babylonjs/scene";
  49104. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49105. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49106. /**
  49107. * Container for accessors for natively-stored mesh data buffers.
  49108. */
  49109. class NativeDataBuffer extends DataBuffer {
  49110. /**
  49111. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49112. */
  49113. nativeIndexBuffer?: any;
  49114. /**
  49115. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49116. */
  49117. nativeVertexBuffer?: any;
  49118. }
  49119. /** @hidden */
  49120. class NativeTexture extends InternalTexture {
  49121. getInternalTexture(): InternalTexture;
  49122. getViewCount(): number;
  49123. }
  49124. /** @hidden */
  49125. export class NativeEngine extends Engine {
  49126. private readonly _native;
  49127. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49128. private readonly INVALID_HANDLE;
  49129. getHardwareScalingLevel(): number;
  49130. constructor();
  49131. /**
  49132. * Can be used to override the current requestAnimationFrame requester.
  49133. * @hidden
  49134. */
  49135. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49136. /**
  49137. * Override default engine behavior.
  49138. * @param color
  49139. * @param backBuffer
  49140. * @param depth
  49141. * @param stencil
  49142. */
  49143. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49144. /**
  49145. * Gets host document
  49146. * @returns the host document object
  49147. */
  49148. getHostDocument(): Nullable<Document>;
  49149. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49150. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49151. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49152. recordVertexArrayObject(vertexBuffers: {
  49153. [key: string]: VertexBuffer;
  49154. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49155. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49156. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49157. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49158. /**
  49159. * Draw a list of indexed primitives
  49160. * @param fillMode defines the primitive to use
  49161. * @param indexStart defines the starting index
  49162. * @param indexCount defines the number of index to draw
  49163. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49164. */
  49165. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49166. /**
  49167. * Draw a list of unindexed primitives
  49168. * @param fillMode defines the primitive to use
  49169. * @param verticesStart defines the index of first vertex to draw
  49170. * @param verticesCount defines the count of vertices to draw
  49171. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49172. */
  49173. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49174. createPipelineContext(): IPipelineContext;
  49175. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49176. /** @hidden */
  49177. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49178. /** @hidden */
  49179. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49180. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49181. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49182. protected _setProgram(program: WebGLProgram): void;
  49183. _releaseEffect(effect: Effect): void;
  49184. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49185. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49186. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49187. bindSamplers(effect: Effect): void;
  49188. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49189. getRenderWidth(useScreen?: boolean): number;
  49190. getRenderHeight(useScreen?: boolean): number;
  49191. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49192. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49193. /**
  49194. * Set the z offset to apply to current rendering
  49195. * @param value defines the offset to apply
  49196. */
  49197. setZOffset(value: number): void;
  49198. /**
  49199. * Gets the current value of the zOffset
  49200. * @returns the current zOffset state
  49201. */
  49202. getZOffset(): number;
  49203. /**
  49204. * Enable or disable depth buffering
  49205. * @param enable defines the state to set
  49206. */
  49207. setDepthBuffer(enable: boolean): void;
  49208. /**
  49209. * Gets a boolean indicating if depth writing is enabled
  49210. * @returns the current depth writing state
  49211. */
  49212. getDepthWrite(): boolean;
  49213. /**
  49214. * Enable or disable depth writing
  49215. * @param enable defines the state to set
  49216. */
  49217. setDepthWrite(enable: boolean): void;
  49218. /**
  49219. * Enable or disable color writing
  49220. * @param enable defines the state to set
  49221. */
  49222. setColorWrite(enable: boolean): void;
  49223. /**
  49224. * Gets a boolean indicating if color writing is enabled
  49225. * @returns the current color writing state
  49226. */
  49227. getColorWrite(): boolean;
  49228. /**
  49229. * Sets alpha constants used by some alpha blending modes
  49230. * @param r defines the red component
  49231. * @param g defines the green component
  49232. * @param b defines the blue component
  49233. * @param a defines the alpha component
  49234. */
  49235. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49236. /**
  49237. * Sets the current alpha mode
  49238. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49239. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49240. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49241. */
  49242. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49243. /**
  49244. * Gets the current alpha mode
  49245. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49246. * @returns the current alpha mode
  49247. */
  49248. getAlphaMode(): number;
  49249. setInt(uniform: WebGLUniformLocation, int: number): void;
  49250. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49251. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49252. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49253. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49254. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49255. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49256. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49257. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49258. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49259. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49260. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49261. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49262. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49263. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49264. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49265. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49266. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49267. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49268. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49269. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49270. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49271. wipeCaches(bruteForce?: boolean): void;
  49272. _createTexture(): WebGLTexture;
  49273. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49274. /**
  49275. * Usually called from BABYLON.Texture.ts.
  49276. * Passed information to create a WebGLTexture
  49277. * @param urlArg defines a value which contains one of the following:
  49278. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49279. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49280. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49281. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49282. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49283. * @param scene needed for loading to the correct scene
  49284. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49285. * @param onLoad optional callback to be called upon successful completion
  49286. * @param onError optional callback to be called upon failure
  49287. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49288. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49289. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49290. * @param forcedExtension defines the extension to use to pick the right loader
  49291. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49292. */
  49293. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  49294. /**
  49295. * Creates a cube texture
  49296. * @param rootUrl defines the url where the files to load is located
  49297. * @param scene defines the current scene
  49298. * @param files defines the list of files to load (1 per face)
  49299. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49300. * @param onLoad defines an optional callback raised when the texture is loaded
  49301. * @param onError defines an optional callback raised if there is an issue to load the texture
  49302. * @param format defines the format of the data
  49303. * @param forcedExtension defines the extension to use to pick the right loader
  49304. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49305. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49306. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49307. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49308. * @returns the cube texture as an InternalTexture
  49309. */
  49310. 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;
  49311. private _getSamplingFilter;
  49312. private static _GetNativeTextureFormat;
  49313. createRenderTargetTexture(size: number | {
  49314. width: number;
  49315. height: number;
  49316. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49317. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49318. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49319. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49320. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49321. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49322. /**
  49323. * Updates a dynamic vertex buffer.
  49324. * @param vertexBuffer the vertex buffer to update
  49325. * @param data the data used to update the vertex buffer
  49326. * @param byteOffset the byte offset of the data (optional)
  49327. * @param byteLength the byte length of the data (optional)
  49328. */
  49329. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49330. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49331. private _updateAnisotropicLevel;
  49332. private _getAddressMode;
  49333. /** @hidden */
  49334. _bindTexture(channel: number, texture: InternalTexture): void;
  49335. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49336. releaseEffects(): void;
  49337. /** @hidden */
  49338. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49339. /** @hidden */
  49340. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49341. /** @hidden */
  49342. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49343. /** @hidden */
  49344. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49345. }
  49346. }
  49347. declare module "babylonjs/Engines/index" {
  49348. export * from "babylonjs/Engines/constants";
  49349. export * from "babylonjs/Engines/engineCapabilities";
  49350. export * from "babylonjs/Engines/instancingAttributeInfo";
  49351. export * from "babylonjs/Engines/thinEngine";
  49352. export * from "babylonjs/Engines/engine";
  49353. export * from "babylonjs/Engines/engineStore";
  49354. export * from "babylonjs/Engines/nullEngine";
  49355. export * from "babylonjs/Engines/Extensions/index";
  49356. export * from "babylonjs/Engines/IPipelineContext";
  49357. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49358. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49359. export * from "babylonjs/Engines/nativeEngine";
  49360. }
  49361. declare module "babylonjs/Events/clipboardEvents" {
  49362. /**
  49363. * Gather the list of clipboard event types as constants.
  49364. */
  49365. export class ClipboardEventTypes {
  49366. /**
  49367. * The clipboard event is fired when a copy command is active (pressed).
  49368. */
  49369. static readonly COPY: number;
  49370. /**
  49371. * The clipboard event is fired when a cut command is active (pressed).
  49372. */
  49373. static readonly CUT: number;
  49374. /**
  49375. * The clipboard event is fired when a paste command is active (pressed).
  49376. */
  49377. static readonly PASTE: number;
  49378. }
  49379. /**
  49380. * This class is used to store clipboard related info for the onClipboardObservable event.
  49381. */
  49382. export class ClipboardInfo {
  49383. /**
  49384. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49385. */
  49386. type: number;
  49387. /**
  49388. * Defines the related dom event
  49389. */
  49390. event: ClipboardEvent;
  49391. /**
  49392. *Creates an instance of ClipboardInfo.
  49393. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49394. * @param event Defines the related dom event
  49395. */
  49396. constructor(
  49397. /**
  49398. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49399. */
  49400. type: number,
  49401. /**
  49402. * Defines the related dom event
  49403. */
  49404. event: ClipboardEvent);
  49405. /**
  49406. * Get the clipboard event's type from the keycode.
  49407. * @param keyCode Defines the keyCode for the current keyboard event.
  49408. * @return {number}
  49409. */
  49410. static GetTypeFromCharacter(keyCode: number): number;
  49411. }
  49412. }
  49413. declare module "babylonjs/Events/index" {
  49414. export * from "babylonjs/Events/keyboardEvents";
  49415. export * from "babylonjs/Events/pointerEvents";
  49416. export * from "babylonjs/Events/clipboardEvents";
  49417. }
  49418. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49419. import { Scene } from "babylonjs/scene";
  49420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49421. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49422. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49423. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49424. /**
  49425. * Google Daydream controller
  49426. */
  49427. export class DaydreamController extends WebVRController {
  49428. /**
  49429. * Base Url for the controller model.
  49430. */
  49431. static MODEL_BASE_URL: string;
  49432. /**
  49433. * File name for the controller model.
  49434. */
  49435. static MODEL_FILENAME: string;
  49436. /**
  49437. * Gamepad Id prefix used to identify Daydream Controller.
  49438. */
  49439. static readonly GAMEPAD_ID_PREFIX: string;
  49440. /**
  49441. * Creates a new DaydreamController from a gamepad
  49442. * @param vrGamepad the gamepad that the controller should be created from
  49443. */
  49444. constructor(vrGamepad: any);
  49445. /**
  49446. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49447. * @param scene scene in which to add meshes
  49448. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49449. */
  49450. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49451. /**
  49452. * Called once for each button that changed state since the last frame
  49453. * @param buttonIdx Which button index changed
  49454. * @param state New state of the button
  49455. * @param changes Which properties on the state changed since last frame
  49456. */
  49457. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49458. }
  49459. }
  49460. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49461. import { Scene } from "babylonjs/scene";
  49462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49463. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49464. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49465. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49466. /**
  49467. * Gear VR Controller
  49468. */
  49469. export class GearVRController extends WebVRController {
  49470. /**
  49471. * Base Url for the controller model.
  49472. */
  49473. static MODEL_BASE_URL: string;
  49474. /**
  49475. * File name for the controller model.
  49476. */
  49477. static MODEL_FILENAME: string;
  49478. /**
  49479. * Gamepad Id prefix used to identify this controller.
  49480. */
  49481. static readonly GAMEPAD_ID_PREFIX: string;
  49482. private readonly _buttonIndexToObservableNameMap;
  49483. /**
  49484. * Creates a new GearVRController from a gamepad
  49485. * @param vrGamepad the gamepad that the controller should be created from
  49486. */
  49487. constructor(vrGamepad: any);
  49488. /**
  49489. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49490. * @param scene scene in which to add meshes
  49491. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49492. */
  49493. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49494. /**
  49495. * Called once for each button that changed state since the last frame
  49496. * @param buttonIdx Which button index changed
  49497. * @param state New state of the button
  49498. * @param changes Which properties on the state changed since last frame
  49499. */
  49500. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49501. }
  49502. }
  49503. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49504. import { Scene } from "babylonjs/scene";
  49505. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49506. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49507. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49508. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49509. /**
  49510. * Generic Controller
  49511. */
  49512. export class GenericController extends WebVRController {
  49513. /**
  49514. * Base Url for the controller model.
  49515. */
  49516. static readonly MODEL_BASE_URL: string;
  49517. /**
  49518. * File name for the controller model.
  49519. */
  49520. static readonly MODEL_FILENAME: string;
  49521. /**
  49522. * Creates a new GenericController from a gamepad
  49523. * @param vrGamepad the gamepad that the controller should be created from
  49524. */
  49525. constructor(vrGamepad: any);
  49526. /**
  49527. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49528. * @param scene scene in which to add meshes
  49529. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49530. */
  49531. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49532. /**
  49533. * Called once for each button that changed state since the last frame
  49534. * @param buttonIdx Which button index changed
  49535. * @param state New state of the button
  49536. * @param changes Which properties on the state changed since last frame
  49537. */
  49538. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49539. }
  49540. }
  49541. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49542. import { Observable } from "babylonjs/Misc/observable";
  49543. import { Scene } from "babylonjs/scene";
  49544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49545. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49546. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49547. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49548. /**
  49549. * Oculus Touch Controller
  49550. */
  49551. export class OculusTouchController extends WebVRController {
  49552. /**
  49553. * Base Url for the controller model.
  49554. */
  49555. static MODEL_BASE_URL: string;
  49556. /**
  49557. * File name for the left controller model.
  49558. */
  49559. static MODEL_LEFT_FILENAME: string;
  49560. /**
  49561. * File name for the right controller model.
  49562. */
  49563. static MODEL_RIGHT_FILENAME: string;
  49564. /**
  49565. * Base Url for the Quest controller model.
  49566. */
  49567. static QUEST_MODEL_BASE_URL: string;
  49568. /**
  49569. * @hidden
  49570. * If the controllers are running on a device that needs the updated Quest controller models
  49571. */
  49572. static _IsQuest: boolean;
  49573. /**
  49574. * Fired when the secondary trigger on this controller is modified
  49575. */
  49576. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49577. /**
  49578. * Fired when the thumb rest on this controller is modified
  49579. */
  49580. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49581. /**
  49582. * Creates a new OculusTouchController from a gamepad
  49583. * @param vrGamepad the gamepad that the controller should be created from
  49584. */
  49585. constructor(vrGamepad: any);
  49586. /**
  49587. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49588. * @param scene scene in which to add meshes
  49589. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49590. */
  49591. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49592. /**
  49593. * Fired when the A button on this controller is modified
  49594. */
  49595. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49596. /**
  49597. * Fired when the B button on this controller is modified
  49598. */
  49599. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49600. /**
  49601. * Fired when the X button on this controller is modified
  49602. */
  49603. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49604. /**
  49605. * Fired when the Y button on this controller is modified
  49606. */
  49607. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49608. /**
  49609. * Called once for each button that changed state since the last frame
  49610. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49611. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49612. * 2) secondary trigger (same)
  49613. * 3) A (right) X (left), touch, pressed = value
  49614. * 4) B / Y
  49615. * 5) thumb rest
  49616. * @param buttonIdx Which button index changed
  49617. * @param state New state of the button
  49618. * @param changes Which properties on the state changed since last frame
  49619. */
  49620. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49621. }
  49622. }
  49623. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49624. import { Scene } from "babylonjs/scene";
  49625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49626. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49627. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49628. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49629. import { Observable } from "babylonjs/Misc/observable";
  49630. /**
  49631. * Vive Controller
  49632. */
  49633. export class ViveController extends WebVRController {
  49634. /**
  49635. * Base Url for the controller model.
  49636. */
  49637. static MODEL_BASE_URL: string;
  49638. /**
  49639. * File name for the controller model.
  49640. */
  49641. static MODEL_FILENAME: string;
  49642. /**
  49643. * Creates a new ViveController from a gamepad
  49644. * @param vrGamepad the gamepad that the controller should be created from
  49645. */
  49646. constructor(vrGamepad: any);
  49647. /**
  49648. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49649. * @param scene scene in which to add meshes
  49650. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49651. */
  49652. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49653. /**
  49654. * Fired when the left button on this controller is modified
  49655. */
  49656. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49657. /**
  49658. * Fired when the right button on this controller is modified
  49659. */
  49660. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49661. /**
  49662. * Fired when the menu button on this controller is modified
  49663. */
  49664. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49665. /**
  49666. * Called once for each button that changed state since the last frame
  49667. * Vive mapping:
  49668. * 0: touchpad
  49669. * 1: trigger
  49670. * 2: left AND right buttons
  49671. * 3: menu button
  49672. * @param buttonIdx Which button index changed
  49673. * @param state New state of the button
  49674. * @param changes Which properties on the state changed since last frame
  49675. */
  49676. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49677. }
  49678. }
  49679. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49680. import { Observable } from "babylonjs/Misc/observable";
  49681. import { Scene } from "babylonjs/scene";
  49682. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49683. import { Ray } from "babylonjs/Culling/ray";
  49684. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49685. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49686. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49687. /**
  49688. * Defines the WindowsMotionController object that the state of the windows motion controller
  49689. */
  49690. export class WindowsMotionController extends WebVRController {
  49691. /**
  49692. * The base url used to load the left and right controller models
  49693. */
  49694. static MODEL_BASE_URL: string;
  49695. /**
  49696. * The name of the left controller model file
  49697. */
  49698. static MODEL_LEFT_FILENAME: string;
  49699. /**
  49700. * The name of the right controller model file
  49701. */
  49702. static MODEL_RIGHT_FILENAME: string;
  49703. /**
  49704. * The controller name prefix for this controller type
  49705. */
  49706. static readonly GAMEPAD_ID_PREFIX: string;
  49707. /**
  49708. * The controller id pattern for this controller type
  49709. */
  49710. private static readonly GAMEPAD_ID_PATTERN;
  49711. private _loadedMeshInfo;
  49712. protected readonly _mapping: {
  49713. buttons: string[];
  49714. buttonMeshNames: {
  49715. 'trigger': string;
  49716. 'menu': string;
  49717. 'grip': string;
  49718. 'thumbstick': string;
  49719. 'trackpad': string;
  49720. };
  49721. buttonObservableNames: {
  49722. 'trigger': string;
  49723. 'menu': string;
  49724. 'grip': string;
  49725. 'thumbstick': string;
  49726. 'trackpad': string;
  49727. };
  49728. axisMeshNames: string[];
  49729. pointingPoseMeshName: string;
  49730. };
  49731. /**
  49732. * Fired when the trackpad on this controller is clicked
  49733. */
  49734. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49735. /**
  49736. * Fired when the trackpad on this controller is modified
  49737. */
  49738. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49739. /**
  49740. * The current x and y values of this controller's trackpad
  49741. */
  49742. trackpad: StickValues;
  49743. /**
  49744. * Creates a new WindowsMotionController from a gamepad
  49745. * @param vrGamepad the gamepad that the controller should be created from
  49746. */
  49747. constructor(vrGamepad: any);
  49748. /**
  49749. * Fired when the trigger on this controller is modified
  49750. */
  49751. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49752. /**
  49753. * Fired when the menu button on this controller is modified
  49754. */
  49755. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49756. /**
  49757. * Fired when the grip button on this controller is modified
  49758. */
  49759. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49760. /**
  49761. * Fired when the thumbstick button on this controller is modified
  49762. */
  49763. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49764. /**
  49765. * Fired when the touchpad button on this controller is modified
  49766. */
  49767. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49768. /**
  49769. * Fired when the touchpad values on this controller are modified
  49770. */
  49771. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  49772. protected _updateTrackpad(): void;
  49773. /**
  49774. * Called once per frame by the engine.
  49775. */
  49776. update(): void;
  49777. /**
  49778. * Called once for each button that changed state since the last frame
  49779. * @param buttonIdx Which button index changed
  49780. * @param state New state of the button
  49781. * @param changes Which properties on the state changed since last frame
  49782. */
  49783. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49784. /**
  49785. * Moves the buttons on the controller mesh based on their current state
  49786. * @param buttonName the name of the button to move
  49787. * @param buttonValue the value of the button which determines the buttons new position
  49788. */
  49789. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  49790. /**
  49791. * Moves the axis on the controller mesh based on its current state
  49792. * @param axis the index of the axis
  49793. * @param axisValue the value of the axis which determines the meshes new position
  49794. * @hidden
  49795. */
  49796. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  49797. /**
  49798. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49799. * @param scene scene in which to add meshes
  49800. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49801. */
  49802. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  49803. /**
  49804. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  49805. * can be transformed by button presses and axes values, based on this._mapping.
  49806. *
  49807. * @param scene scene in which the meshes exist
  49808. * @param meshes list of meshes that make up the controller model to process
  49809. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  49810. */
  49811. private processModel;
  49812. private createMeshInfo;
  49813. /**
  49814. * Gets the ray of the controller in the direction the controller is pointing
  49815. * @param length the length the resulting ray should be
  49816. * @returns a ray in the direction the controller is pointing
  49817. */
  49818. getForwardRay(length?: number): Ray;
  49819. /**
  49820. * Disposes of the controller
  49821. */
  49822. dispose(): void;
  49823. }
  49824. /**
  49825. * This class represents a new windows motion controller in XR.
  49826. */
  49827. export class XRWindowsMotionController extends WindowsMotionController {
  49828. /**
  49829. * Changing the original WIndowsMotionController mapping to fir the new mapping
  49830. */
  49831. protected readonly _mapping: {
  49832. buttons: string[];
  49833. buttonMeshNames: {
  49834. 'trigger': string;
  49835. 'menu': string;
  49836. 'grip': string;
  49837. 'thumbstick': string;
  49838. 'trackpad': string;
  49839. };
  49840. buttonObservableNames: {
  49841. 'trigger': string;
  49842. 'menu': string;
  49843. 'grip': string;
  49844. 'thumbstick': string;
  49845. 'trackpad': string;
  49846. };
  49847. axisMeshNames: string[];
  49848. pointingPoseMeshName: string;
  49849. };
  49850. /**
  49851. * Construct a new XR-Based windows motion controller
  49852. *
  49853. * @param gamepadInfo the gamepad object from the browser
  49854. */
  49855. constructor(gamepadInfo: any);
  49856. /**
  49857. * holds the thumbstick values (X,Y)
  49858. */
  49859. thumbstickValues: StickValues;
  49860. /**
  49861. * Fired when the thumbstick on this controller is clicked
  49862. */
  49863. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  49864. /**
  49865. * Fired when the thumbstick on this controller is modified
  49866. */
  49867. onThumbstickValuesChangedObservable: Observable<StickValues>;
  49868. /**
  49869. * Fired when the touchpad button on this controller is modified
  49870. */
  49871. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49872. /**
  49873. * Fired when the touchpad values on this controller are modified
  49874. */
  49875. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49876. /**
  49877. * Fired when the thumbstick button on this controller is modified
  49878. * here to prevent breaking changes
  49879. */
  49880. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49881. /**
  49882. * updating the thumbstick(!) and not the trackpad.
  49883. * This is named this way due to the difference between WebVR and XR and to avoid
  49884. * changing the parent class.
  49885. */
  49886. protected _updateTrackpad(): void;
  49887. /**
  49888. * Disposes the class with joy
  49889. */
  49890. dispose(): void;
  49891. }
  49892. }
  49893. declare module "babylonjs/Gamepads/Controllers/index" {
  49894. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  49895. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  49896. export * from "babylonjs/Gamepads/Controllers/genericController";
  49897. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  49898. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49899. export * from "babylonjs/Gamepads/Controllers/viveController";
  49900. export * from "babylonjs/Gamepads/Controllers/webVRController";
  49901. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  49902. }
  49903. declare module "babylonjs/Gamepads/index" {
  49904. export * from "babylonjs/Gamepads/Controllers/index";
  49905. export * from "babylonjs/Gamepads/gamepad";
  49906. export * from "babylonjs/Gamepads/gamepadManager";
  49907. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  49908. export * from "babylonjs/Gamepads/xboxGamepad";
  49909. export * from "babylonjs/Gamepads/dualShockGamepad";
  49910. }
  49911. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  49912. import { Scene } from "babylonjs/scene";
  49913. import { Vector4 } from "babylonjs/Maths/math.vector";
  49914. import { Color4 } from "babylonjs/Maths/math.color";
  49915. import { Mesh } from "babylonjs/Meshes/mesh";
  49916. import { Nullable } from "babylonjs/types";
  49917. /**
  49918. * Class containing static functions to help procedurally build meshes
  49919. */
  49920. export class PolyhedronBuilder {
  49921. /**
  49922. * Creates a polyhedron mesh
  49923. * * 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
  49924. * * The parameter `size` (positive float, default 1) sets the polygon size
  49925. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49926. * * 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`
  49927. * * 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
  49928. * * 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)`)
  49929. * * 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
  49930. * * 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
  49931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49932. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49934. * @param name defines the name of the mesh
  49935. * @param options defines the options used to create the mesh
  49936. * @param scene defines the hosting scene
  49937. * @returns the polyhedron mesh
  49938. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49939. */
  49940. static CreatePolyhedron(name: string, options: {
  49941. type?: number;
  49942. size?: number;
  49943. sizeX?: number;
  49944. sizeY?: number;
  49945. sizeZ?: number;
  49946. custom?: any;
  49947. faceUV?: Vector4[];
  49948. faceColors?: Color4[];
  49949. flat?: boolean;
  49950. updatable?: boolean;
  49951. sideOrientation?: number;
  49952. frontUVs?: Vector4;
  49953. backUVs?: Vector4;
  49954. }, scene?: Nullable<Scene>): Mesh;
  49955. }
  49956. }
  49957. declare module "babylonjs/Gizmos/scaleGizmo" {
  49958. import { Observable } from "babylonjs/Misc/observable";
  49959. import { Nullable } from "babylonjs/types";
  49960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49961. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  49962. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  49963. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  49964. /**
  49965. * Gizmo that enables scaling a mesh along 3 axis
  49966. */
  49967. export class ScaleGizmo extends Gizmo {
  49968. /**
  49969. * Internal gizmo used for interactions on the x axis
  49970. */
  49971. xGizmo: AxisScaleGizmo;
  49972. /**
  49973. * Internal gizmo used for interactions on the y axis
  49974. */
  49975. yGizmo: AxisScaleGizmo;
  49976. /**
  49977. * Internal gizmo used for interactions on the z axis
  49978. */
  49979. zGizmo: AxisScaleGizmo;
  49980. /**
  49981. * Internal gizmo used to scale all axis equally
  49982. */
  49983. uniformScaleGizmo: AxisScaleGizmo;
  49984. private _meshAttached;
  49985. private _updateGizmoRotationToMatchAttachedMesh;
  49986. private _snapDistance;
  49987. private _scaleRatio;
  49988. private _uniformScalingMesh;
  49989. private _octahedron;
  49990. private _sensitivity;
  49991. /** Fires an event when any of it's sub gizmos are dragged */
  49992. onDragStartObservable: Observable<unknown>;
  49993. /** Fires an event when any of it's sub gizmos are released from dragging */
  49994. onDragEndObservable: Observable<unknown>;
  49995. get attachedMesh(): Nullable<AbstractMesh>;
  49996. set attachedMesh(mesh: Nullable<AbstractMesh>);
  49997. /**
  49998. * Creates a ScaleGizmo
  49999. * @param gizmoLayer The utility layer the gizmo will be added to
  50000. */
  50001. constructor(gizmoLayer?: UtilityLayerRenderer);
  50002. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50003. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50004. /**
  50005. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50006. */
  50007. set snapDistance(value: number);
  50008. get snapDistance(): number;
  50009. /**
  50010. * Ratio for the scale of the gizmo (Default: 1)
  50011. */
  50012. set scaleRatio(value: number);
  50013. get scaleRatio(): number;
  50014. /**
  50015. * Sensitivity factor for dragging (Default: 1)
  50016. */
  50017. set sensitivity(value: number);
  50018. get sensitivity(): number;
  50019. /**
  50020. * Disposes of the gizmo
  50021. */
  50022. dispose(): void;
  50023. }
  50024. }
  50025. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50026. import { Observable } from "babylonjs/Misc/observable";
  50027. import { Nullable } from "babylonjs/types";
  50028. import { Vector3 } from "babylonjs/Maths/math.vector";
  50029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50030. import { Mesh } from "babylonjs/Meshes/mesh";
  50031. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50032. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50033. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50034. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50035. import { Color3 } from "babylonjs/Maths/math.color";
  50036. /**
  50037. * Single axis scale gizmo
  50038. */
  50039. export class AxisScaleGizmo extends Gizmo {
  50040. /**
  50041. * Drag behavior responsible for the gizmos dragging interactions
  50042. */
  50043. dragBehavior: PointerDragBehavior;
  50044. private _pointerObserver;
  50045. /**
  50046. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50047. */
  50048. snapDistance: number;
  50049. /**
  50050. * Event that fires each time the gizmo snaps to a new location.
  50051. * * snapDistance is the the change in distance
  50052. */
  50053. onSnapObservable: Observable<{
  50054. snapDistance: number;
  50055. }>;
  50056. /**
  50057. * If the scaling operation should be done on all axis (default: false)
  50058. */
  50059. uniformScaling: boolean;
  50060. /**
  50061. * Custom sensitivity value for the drag strength
  50062. */
  50063. sensitivity: number;
  50064. private _isEnabled;
  50065. private _parent;
  50066. private _arrow;
  50067. private _coloredMaterial;
  50068. private _hoverMaterial;
  50069. /**
  50070. * Creates an AxisScaleGizmo
  50071. * @param gizmoLayer The utility layer the gizmo will be added to
  50072. * @param dragAxis The axis which the gizmo will be able to scale on
  50073. * @param color The color of the gizmo
  50074. */
  50075. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50076. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50077. /**
  50078. * If the gizmo is enabled
  50079. */
  50080. set isEnabled(value: boolean);
  50081. get isEnabled(): boolean;
  50082. /**
  50083. * Disposes of the gizmo
  50084. */
  50085. dispose(): void;
  50086. /**
  50087. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50088. * @param mesh The mesh to replace the default mesh of the gizmo
  50089. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50090. */
  50091. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50092. }
  50093. }
  50094. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50095. import { Observable } from "babylonjs/Misc/observable";
  50096. import { Nullable } from "babylonjs/types";
  50097. import { Vector3 } from "babylonjs/Maths/math.vector";
  50098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50099. import { Mesh } from "babylonjs/Meshes/mesh";
  50100. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50101. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50102. import { Color3 } from "babylonjs/Maths/math.color";
  50103. import "babylonjs/Meshes/Builders/boxBuilder";
  50104. /**
  50105. * Bounding box gizmo
  50106. */
  50107. export class BoundingBoxGizmo extends Gizmo {
  50108. private _lineBoundingBox;
  50109. private _rotateSpheresParent;
  50110. private _scaleBoxesParent;
  50111. private _boundingDimensions;
  50112. private _renderObserver;
  50113. private _pointerObserver;
  50114. private _scaleDragSpeed;
  50115. private _tmpQuaternion;
  50116. private _tmpVector;
  50117. private _tmpRotationMatrix;
  50118. /**
  50119. * 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)
  50120. */
  50121. ignoreChildren: boolean;
  50122. /**
  50123. * 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)
  50124. */
  50125. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50126. /**
  50127. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50128. */
  50129. rotationSphereSize: number;
  50130. /**
  50131. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50132. */
  50133. scaleBoxSize: number;
  50134. /**
  50135. * 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)
  50136. */
  50137. fixedDragMeshScreenSize: boolean;
  50138. /**
  50139. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50140. */
  50141. fixedDragMeshScreenSizeDistanceFactor: number;
  50142. /**
  50143. * Fired when a rotation sphere or scale box is dragged
  50144. */
  50145. onDragStartObservable: Observable<{}>;
  50146. /**
  50147. * Fired when a scale box is dragged
  50148. */
  50149. onScaleBoxDragObservable: Observable<{}>;
  50150. /**
  50151. * Fired when a scale box drag is ended
  50152. */
  50153. onScaleBoxDragEndObservable: Observable<{}>;
  50154. /**
  50155. * Fired when a rotation sphere is dragged
  50156. */
  50157. onRotationSphereDragObservable: Observable<{}>;
  50158. /**
  50159. * Fired when a rotation sphere drag is ended
  50160. */
  50161. onRotationSphereDragEndObservable: Observable<{}>;
  50162. /**
  50163. * 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)
  50164. */
  50165. scalePivot: Nullable<Vector3>;
  50166. /**
  50167. * Mesh used as a pivot to rotate the attached mesh
  50168. */
  50169. private _anchorMesh;
  50170. private _existingMeshScale;
  50171. private _dragMesh;
  50172. private pointerDragBehavior;
  50173. private coloredMaterial;
  50174. private hoverColoredMaterial;
  50175. /**
  50176. * Sets the color of the bounding box gizmo
  50177. * @param color the color to set
  50178. */
  50179. setColor(color: Color3): void;
  50180. /**
  50181. * Creates an BoundingBoxGizmo
  50182. * @param gizmoLayer The utility layer the gizmo will be added to
  50183. * @param color The color of the gizmo
  50184. */
  50185. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50186. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50187. private _selectNode;
  50188. /**
  50189. * Updates the bounding box information for the Gizmo
  50190. */
  50191. updateBoundingBox(): void;
  50192. private _updateRotationSpheres;
  50193. private _updateScaleBoxes;
  50194. /**
  50195. * Enables rotation on the specified axis and disables rotation on the others
  50196. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50197. */
  50198. setEnabledRotationAxis(axis: string): void;
  50199. /**
  50200. * Enables/disables scaling
  50201. * @param enable if scaling should be enabled
  50202. */
  50203. setEnabledScaling(enable: boolean): void;
  50204. private _updateDummy;
  50205. /**
  50206. * Enables a pointer drag behavior on the bounding box of the gizmo
  50207. */
  50208. enableDragBehavior(): void;
  50209. /**
  50210. * Disposes of the gizmo
  50211. */
  50212. dispose(): void;
  50213. /**
  50214. * 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)
  50215. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50216. * @returns the bounding box mesh with the passed in mesh as a child
  50217. */
  50218. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50219. /**
  50220. * CustomMeshes are not supported by this gizmo
  50221. * @param mesh The mesh to replace the default mesh of the gizmo
  50222. */
  50223. setCustomMesh(mesh: Mesh): void;
  50224. }
  50225. }
  50226. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50227. import { Observable } from "babylonjs/Misc/observable";
  50228. import { Nullable } from "babylonjs/types";
  50229. import { Vector3 } from "babylonjs/Maths/math.vector";
  50230. import { Color3 } from "babylonjs/Maths/math.color";
  50231. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50232. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50233. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50234. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50235. import "babylonjs/Meshes/Builders/linesBuilder";
  50236. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50237. /**
  50238. * Single plane rotation gizmo
  50239. */
  50240. export class PlaneRotationGizmo extends Gizmo {
  50241. /**
  50242. * Drag behavior responsible for the gizmos dragging interactions
  50243. */
  50244. dragBehavior: PointerDragBehavior;
  50245. private _pointerObserver;
  50246. /**
  50247. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50248. */
  50249. snapDistance: number;
  50250. /**
  50251. * Event that fires each time the gizmo snaps to a new location.
  50252. * * snapDistance is the the change in distance
  50253. */
  50254. onSnapObservable: Observable<{
  50255. snapDistance: number;
  50256. }>;
  50257. private _isEnabled;
  50258. private _parent;
  50259. /**
  50260. * Creates a PlaneRotationGizmo
  50261. * @param gizmoLayer The utility layer the gizmo will be added to
  50262. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50263. * @param color The color of the gizmo
  50264. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50265. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50266. */
  50267. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50268. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50269. /**
  50270. * If the gizmo is enabled
  50271. */
  50272. set isEnabled(value: boolean);
  50273. get isEnabled(): boolean;
  50274. /**
  50275. * Disposes of the gizmo
  50276. */
  50277. dispose(): void;
  50278. }
  50279. }
  50280. declare module "babylonjs/Gizmos/rotationGizmo" {
  50281. import { Observable } from "babylonjs/Misc/observable";
  50282. import { Nullable } from "babylonjs/types";
  50283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50284. import { Mesh } from "babylonjs/Meshes/mesh";
  50285. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50286. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50287. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50288. /**
  50289. * Gizmo that enables rotating a mesh along 3 axis
  50290. */
  50291. export class RotationGizmo extends Gizmo {
  50292. /**
  50293. * Internal gizmo used for interactions on the x axis
  50294. */
  50295. xGizmo: PlaneRotationGizmo;
  50296. /**
  50297. * Internal gizmo used for interactions on the y axis
  50298. */
  50299. yGizmo: PlaneRotationGizmo;
  50300. /**
  50301. * Internal gizmo used for interactions on the z axis
  50302. */
  50303. zGizmo: PlaneRotationGizmo;
  50304. /** Fires an event when any of it's sub gizmos are dragged */
  50305. onDragStartObservable: Observable<unknown>;
  50306. /** Fires an event when any of it's sub gizmos are released from dragging */
  50307. onDragEndObservable: Observable<unknown>;
  50308. private _meshAttached;
  50309. get attachedMesh(): Nullable<AbstractMesh>;
  50310. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50311. /**
  50312. * Creates a RotationGizmo
  50313. * @param gizmoLayer The utility layer the gizmo will be added to
  50314. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50315. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50316. */
  50317. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50318. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50319. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50320. /**
  50321. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50322. */
  50323. set snapDistance(value: number);
  50324. get snapDistance(): number;
  50325. /**
  50326. * Ratio for the scale of the gizmo (Default: 1)
  50327. */
  50328. set scaleRatio(value: number);
  50329. get scaleRatio(): number;
  50330. /**
  50331. * Disposes of the gizmo
  50332. */
  50333. dispose(): void;
  50334. /**
  50335. * CustomMeshes are not supported by this gizmo
  50336. * @param mesh The mesh to replace the default mesh of the gizmo
  50337. */
  50338. setCustomMesh(mesh: Mesh): void;
  50339. }
  50340. }
  50341. declare module "babylonjs/Gizmos/gizmoManager" {
  50342. import { Observable } from "babylonjs/Misc/observable";
  50343. import { Nullable } from "babylonjs/types";
  50344. import { Scene, IDisposable } from "babylonjs/scene";
  50345. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50346. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50347. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50348. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50349. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50350. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50351. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50352. /**
  50353. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50354. */
  50355. export class GizmoManager implements IDisposable {
  50356. private scene;
  50357. /**
  50358. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50359. */
  50360. gizmos: {
  50361. positionGizmo: Nullable<PositionGizmo>;
  50362. rotationGizmo: Nullable<RotationGizmo>;
  50363. scaleGizmo: Nullable<ScaleGizmo>;
  50364. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50365. };
  50366. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50367. clearGizmoOnEmptyPointerEvent: boolean;
  50368. /** Fires an event when the manager is attached to a mesh */
  50369. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50370. private _gizmosEnabled;
  50371. private _pointerObserver;
  50372. private _attachedMesh;
  50373. private _boundingBoxColor;
  50374. private _defaultUtilityLayer;
  50375. private _defaultKeepDepthUtilityLayer;
  50376. /**
  50377. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50378. */
  50379. boundingBoxDragBehavior: SixDofDragBehavior;
  50380. /**
  50381. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50382. */
  50383. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50384. /**
  50385. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50386. */
  50387. usePointerToAttachGizmos: boolean;
  50388. /**
  50389. * Utility layer that the bounding box gizmo belongs to
  50390. */
  50391. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50392. /**
  50393. * Utility layer that all gizmos besides bounding box belong to
  50394. */
  50395. get utilityLayer(): UtilityLayerRenderer;
  50396. /**
  50397. * Instatiates a gizmo manager
  50398. * @param scene the scene to overlay the gizmos on top of
  50399. */
  50400. constructor(scene: Scene);
  50401. /**
  50402. * Attaches a set of gizmos to the specified mesh
  50403. * @param mesh The mesh the gizmo's should be attached to
  50404. */
  50405. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50406. /**
  50407. * If the position gizmo is enabled
  50408. */
  50409. set positionGizmoEnabled(value: boolean);
  50410. get positionGizmoEnabled(): boolean;
  50411. /**
  50412. * If the rotation gizmo is enabled
  50413. */
  50414. set rotationGizmoEnabled(value: boolean);
  50415. get rotationGizmoEnabled(): boolean;
  50416. /**
  50417. * If the scale gizmo is enabled
  50418. */
  50419. set scaleGizmoEnabled(value: boolean);
  50420. get scaleGizmoEnabled(): boolean;
  50421. /**
  50422. * If the boundingBox gizmo is enabled
  50423. */
  50424. set boundingBoxGizmoEnabled(value: boolean);
  50425. get boundingBoxGizmoEnabled(): boolean;
  50426. /**
  50427. * Disposes of the gizmo manager
  50428. */
  50429. dispose(): void;
  50430. }
  50431. }
  50432. declare module "babylonjs/Lights/directionalLight" {
  50433. import { Camera } from "babylonjs/Cameras/camera";
  50434. import { Scene } from "babylonjs/scene";
  50435. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50437. import { Light } from "babylonjs/Lights/light";
  50438. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50439. import { Effect } from "babylonjs/Materials/effect";
  50440. /**
  50441. * A directional light is defined by a direction (what a surprise!).
  50442. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50443. * 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.
  50444. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50445. */
  50446. export class DirectionalLight extends ShadowLight {
  50447. private _shadowFrustumSize;
  50448. /**
  50449. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50450. */
  50451. get shadowFrustumSize(): number;
  50452. /**
  50453. * Specifies a fix frustum size for the shadow generation.
  50454. */
  50455. set shadowFrustumSize(value: number);
  50456. private _shadowOrthoScale;
  50457. /**
  50458. * Gets the shadow projection scale against the optimal computed one.
  50459. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50460. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50461. */
  50462. get shadowOrthoScale(): number;
  50463. /**
  50464. * Sets the shadow projection scale against the optimal computed one.
  50465. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50466. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50467. */
  50468. set shadowOrthoScale(value: number);
  50469. /**
  50470. * Automatically compute the projection matrix to best fit (including all the casters)
  50471. * on each frame.
  50472. */
  50473. autoUpdateExtends: boolean;
  50474. /**
  50475. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50476. * on each frame. autoUpdateExtends must be set to true for this to work
  50477. */
  50478. autoCalcShadowZBounds: boolean;
  50479. private _orthoLeft;
  50480. private _orthoRight;
  50481. private _orthoTop;
  50482. private _orthoBottom;
  50483. /**
  50484. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50485. * The directional light is emitted from everywhere in the given direction.
  50486. * It can cast shadows.
  50487. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50488. * @param name The friendly name of the light
  50489. * @param direction The direction of the light
  50490. * @param scene The scene the light belongs to
  50491. */
  50492. constructor(name: string, direction: Vector3, scene: Scene);
  50493. /**
  50494. * Returns the string "DirectionalLight".
  50495. * @return The class name
  50496. */
  50497. getClassName(): string;
  50498. /**
  50499. * Returns the integer 1.
  50500. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50501. */
  50502. getTypeID(): number;
  50503. /**
  50504. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50505. * Returns the DirectionalLight Shadow projection matrix.
  50506. */
  50507. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50508. /**
  50509. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50510. * Returns the DirectionalLight Shadow projection matrix.
  50511. */
  50512. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50513. /**
  50514. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50515. * Returns the DirectionalLight Shadow projection matrix.
  50516. */
  50517. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50518. protected _buildUniformLayout(): void;
  50519. /**
  50520. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50521. * @param effect The effect to update
  50522. * @param lightIndex The index of the light in the effect to update
  50523. * @returns The directional light
  50524. */
  50525. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50526. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50527. /**
  50528. * Gets the minZ used for shadow according to both the scene and the light.
  50529. *
  50530. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50531. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50532. * @param activeCamera The camera we are returning the min for
  50533. * @returns the depth min z
  50534. */
  50535. getDepthMinZ(activeCamera: Camera): number;
  50536. /**
  50537. * Gets the maxZ used for shadow according to both the scene and the light.
  50538. *
  50539. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50540. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50541. * @param activeCamera The camera we are returning the max for
  50542. * @returns the depth max z
  50543. */
  50544. getDepthMaxZ(activeCamera: Camera): number;
  50545. /**
  50546. * Prepares the list of defines specific to the light type.
  50547. * @param defines the list of defines
  50548. * @param lightIndex defines the index of the light for the effect
  50549. */
  50550. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50551. }
  50552. }
  50553. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50554. import { Mesh } from "babylonjs/Meshes/mesh";
  50555. /**
  50556. * Class containing static functions to help procedurally build meshes
  50557. */
  50558. export class HemisphereBuilder {
  50559. /**
  50560. * Creates a hemisphere mesh
  50561. * @param name defines the name of the mesh
  50562. * @param options defines the options used to create the mesh
  50563. * @param scene defines the hosting scene
  50564. * @returns the hemisphere mesh
  50565. */
  50566. static CreateHemisphere(name: string, options: {
  50567. segments?: number;
  50568. diameter?: number;
  50569. sideOrientation?: number;
  50570. }, scene: any): Mesh;
  50571. }
  50572. }
  50573. declare module "babylonjs/Lights/spotLight" {
  50574. import { Nullable } from "babylonjs/types";
  50575. import { Scene } from "babylonjs/scene";
  50576. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50578. import { Effect } from "babylonjs/Materials/effect";
  50579. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50580. import { Light } from "babylonjs/Lights/light";
  50581. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50582. /**
  50583. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50584. * These values define a cone of light starting from the position, emitting toward the direction.
  50585. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50586. * and the exponent defines the speed of the decay of the light with distance (reach).
  50587. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50588. */
  50589. export class SpotLight extends ShadowLight {
  50590. private _angle;
  50591. private _innerAngle;
  50592. private _cosHalfAngle;
  50593. private _lightAngleScale;
  50594. private _lightAngleOffset;
  50595. /**
  50596. * Gets the cone angle of the spot light in Radians.
  50597. */
  50598. get angle(): number;
  50599. /**
  50600. * Sets the cone angle of the spot light in Radians.
  50601. */
  50602. set angle(value: number);
  50603. /**
  50604. * Only used in gltf falloff mode, this defines the angle where
  50605. * the directional falloff will start before cutting at angle which could be seen
  50606. * as outer angle.
  50607. */
  50608. get innerAngle(): number;
  50609. /**
  50610. * Only used in gltf falloff mode, this defines the angle where
  50611. * the directional falloff will start before cutting at angle which could be seen
  50612. * as outer angle.
  50613. */
  50614. set innerAngle(value: number);
  50615. private _shadowAngleScale;
  50616. /**
  50617. * Allows scaling the angle of the light for shadow generation only.
  50618. */
  50619. get shadowAngleScale(): number;
  50620. /**
  50621. * Allows scaling the angle of the light for shadow generation only.
  50622. */
  50623. set shadowAngleScale(value: number);
  50624. /**
  50625. * The light decay speed with the distance from the emission spot.
  50626. */
  50627. exponent: number;
  50628. private _projectionTextureMatrix;
  50629. /**
  50630. * Allows reading the projecton texture
  50631. */
  50632. get projectionTextureMatrix(): Matrix;
  50633. protected _projectionTextureLightNear: number;
  50634. /**
  50635. * Gets the near clip of the Spotlight for texture projection.
  50636. */
  50637. get projectionTextureLightNear(): number;
  50638. /**
  50639. * Sets the near clip of the Spotlight for texture projection.
  50640. */
  50641. set projectionTextureLightNear(value: number);
  50642. protected _projectionTextureLightFar: number;
  50643. /**
  50644. * Gets the far clip of the Spotlight for texture projection.
  50645. */
  50646. get projectionTextureLightFar(): number;
  50647. /**
  50648. * Sets the far clip of the Spotlight for texture projection.
  50649. */
  50650. set projectionTextureLightFar(value: number);
  50651. protected _projectionTextureUpDirection: Vector3;
  50652. /**
  50653. * Gets the Up vector of the Spotlight for texture projection.
  50654. */
  50655. get projectionTextureUpDirection(): Vector3;
  50656. /**
  50657. * Sets the Up vector of the Spotlight for texture projection.
  50658. */
  50659. set projectionTextureUpDirection(value: Vector3);
  50660. private _projectionTexture;
  50661. /**
  50662. * Gets the projection texture of the light.
  50663. */
  50664. get projectionTexture(): Nullable<BaseTexture>;
  50665. /**
  50666. * Sets the projection texture of the light.
  50667. */
  50668. set projectionTexture(value: Nullable<BaseTexture>);
  50669. private _projectionTextureViewLightDirty;
  50670. private _projectionTextureProjectionLightDirty;
  50671. private _projectionTextureDirty;
  50672. private _projectionTextureViewTargetVector;
  50673. private _projectionTextureViewLightMatrix;
  50674. private _projectionTextureProjectionLightMatrix;
  50675. private _projectionTextureScalingMatrix;
  50676. /**
  50677. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50678. * It can cast shadows.
  50679. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50680. * @param name The light friendly name
  50681. * @param position The position of the spot light in the scene
  50682. * @param direction The direction of the light in the scene
  50683. * @param angle The cone angle of the light in Radians
  50684. * @param exponent The light decay speed with the distance from the emission spot
  50685. * @param scene The scene the lights belongs to
  50686. */
  50687. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50688. /**
  50689. * Returns the string "SpotLight".
  50690. * @returns the class name
  50691. */
  50692. getClassName(): string;
  50693. /**
  50694. * Returns the integer 2.
  50695. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50696. */
  50697. getTypeID(): number;
  50698. /**
  50699. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50700. */
  50701. protected _setDirection(value: Vector3): void;
  50702. /**
  50703. * Overrides the position setter to recompute the projection texture view light Matrix.
  50704. */
  50705. protected _setPosition(value: Vector3): void;
  50706. /**
  50707. * 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.
  50708. * Returns the SpotLight.
  50709. */
  50710. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50711. protected _computeProjectionTextureViewLightMatrix(): void;
  50712. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50713. /**
  50714. * Main function for light texture projection matrix computing.
  50715. */
  50716. protected _computeProjectionTextureMatrix(): void;
  50717. protected _buildUniformLayout(): void;
  50718. private _computeAngleValues;
  50719. /**
  50720. * Sets the passed Effect "effect" with the Light textures.
  50721. * @param effect The effect to update
  50722. * @param lightIndex The index of the light in the effect to update
  50723. * @returns The light
  50724. */
  50725. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50726. /**
  50727. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50728. * @param effect The effect to update
  50729. * @param lightIndex The index of the light in the effect to update
  50730. * @returns The spot light
  50731. */
  50732. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50733. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50734. /**
  50735. * Disposes the light and the associated resources.
  50736. */
  50737. dispose(): void;
  50738. /**
  50739. * Prepares the list of defines specific to the light type.
  50740. * @param defines the list of defines
  50741. * @param lightIndex defines the index of the light for the effect
  50742. */
  50743. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50744. }
  50745. }
  50746. declare module "babylonjs/Gizmos/lightGizmo" {
  50747. import { Nullable } from "babylonjs/types";
  50748. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50749. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50750. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  50751. import { Light } from "babylonjs/Lights/light";
  50752. /**
  50753. * Gizmo that enables viewing a light
  50754. */
  50755. export class LightGizmo extends Gizmo {
  50756. private _lightMesh;
  50757. private _material;
  50758. private _cachedPosition;
  50759. private _cachedForward;
  50760. private _attachedMeshParent;
  50761. /**
  50762. * Creates a LightGizmo
  50763. * @param gizmoLayer The utility layer the gizmo will be added to
  50764. */
  50765. constructor(gizmoLayer?: UtilityLayerRenderer);
  50766. private _light;
  50767. /**
  50768. * The light that the gizmo is attached to
  50769. */
  50770. set light(light: Nullable<Light>);
  50771. get light(): Nullable<Light>;
  50772. /**
  50773. * Gets the material used to render the light gizmo
  50774. */
  50775. get material(): StandardMaterial;
  50776. /**
  50777. * @hidden
  50778. * Updates the gizmo to match the attached mesh's position/rotation
  50779. */
  50780. protected _update(): void;
  50781. private static _Scale;
  50782. /**
  50783. * Creates the lines for a light mesh
  50784. */
  50785. private static _CreateLightLines;
  50786. /**
  50787. * Disposes of the light gizmo
  50788. */
  50789. dispose(): void;
  50790. private static _CreateHemisphericLightMesh;
  50791. private static _CreatePointLightMesh;
  50792. private static _CreateSpotLightMesh;
  50793. private static _CreateDirectionalLightMesh;
  50794. }
  50795. }
  50796. declare module "babylonjs/Gizmos/index" {
  50797. export * from "babylonjs/Gizmos/axisDragGizmo";
  50798. export * from "babylonjs/Gizmos/axisScaleGizmo";
  50799. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  50800. export * from "babylonjs/Gizmos/gizmo";
  50801. export * from "babylonjs/Gizmos/gizmoManager";
  50802. export * from "babylonjs/Gizmos/planeRotationGizmo";
  50803. export * from "babylonjs/Gizmos/positionGizmo";
  50804. export * from "babylonjs/Gizmos/rotationGizmo";
  50805. export * from "babylonjs/Gizmos/scaleGizmo";
  50806. export * from "babylonjs/Gizmos/lightGizmo";
  50807. export * from "babylonjs/Gizmos/planeDragGizmo";
  50808. }
  50809. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  50810. /** @hidden */
  50811. export var backgroundFragmentDeclaration: {
  50812. name: string;
  50813. shader: string;
  50814. };
  50815. }
  50816. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  50817. /** @hidden */
  50818. export var backgroundUboDeclaration: {
  50819. name: string;
  50820. shader: string;
  50821. };
  50822. }
  50823. declare module "babylonjs/Shaders/background.fragment" {
  50824. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  50825. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50826. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  50827. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50828. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50829. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50830. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50831. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  50832. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  50833. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50834. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  50835. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  50836. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50837. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  50838. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  50839. /** @hidden */
  50840. export var backgroundPixelShader: {
  50841. name: string;
  50842. shader: string;
  50843. };
  50844. }
  50845. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  50846. /** @hidden */
  50847. export var backgroundVertexDeclaration: {
  50848. name: string;
  50849. shader: string;
  50850. };
  50851. }
  50852. declare module "babylonjs/Shaders/background.vertex" {
  50853. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  50854. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  50855. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50856. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  50857. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  50858. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  50859. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  50860. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  50861. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  50862. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  50863. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  50864. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50865. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  50866. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  50867. /** @hidden */
  50868. export var backgroundVertexShader: {
  50869. name: string;
  50870. shader: string;
  50871. };
  50872. }
  50873. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  50874. import { Nullable, int, float } from "babylonjs/types";
  50875. import { Scene } from "babylonjs/scene";
  50876. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50877. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50879. import { Mesh } from "babylonjs/Meshes/mesh";
  50880. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  50881. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50882. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50883. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50884. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  50885. import { Color3 } from "babylonjs/Maths/math.color";
  50886. import "babylonjs/Shaders/background.fragment";
  50887. import "babylonjs/Shaders/background.vertex";
  50888. /**
  50889. * Background material used to create an efficient environement around your scene.
  50890. */
  50891. export class BackgroundMaterial extends PushMaterial {
  50892. /**
  50893. * Standard reflectance value at parallel view angle.
  50894. */
  50895. static StandardReflectance0: number;
  50896. /**
  50897. * Standard reflectance value at grazing angle.
  50898. */
  50899. static StandardReflectance90: number;
  50900. protected _primaryColor: Color3;
  50901. /**
  50902. * Key light Color (multiply against the environement texture)
  50903. */
  50904. primaryColor: Color3;
  50905. protected __perceptualColor: Nullable<Color3>;
  50906. /**
  50907. * Experimental Internal Use Only.
  50908. *
  50909. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  50910. * This acts as a helper to set the primary color to a more "human friendly" value.
  50911. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  50912. * output color as close as possible from the chosen value.
  50913. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  50914. * part of lighting setup.)
  50915. */
  50916. get _perceptualColor(): Nullable<Color3>;
  50917. set _perceptualColor(value: Nullable<Color3>);
  50918. protected _primaryColorShadowLevel: float;
  50919. /**
  50920. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  50921. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  50922. */
  50923. get primaryColorShadowLevel(): float;
  50924. set primaryColorShadowLevel(value: float);
  50925. protected _primaryColorHighlightLevel: float;
  50926. /**
  50927. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  50928. * The primary color is used at the level chosen to define what the white area would look.
  50929. */
  50930. get primaryColorHighlightLevel(): float;
  50931. set primaryColorHighlightLevel(value: float);
  50932. protected _reflectionTexture: Nullable<BaseTexture>;
  50933. /**
  50934. * Reflection Texture used in the material.
  50935. * Should be author in a specific way for the best result (refer to the documentation).
  50936. */
  50937. reflectionTexture: Nullable<BaseTexture>;
  50938. protected _reflectionBlur: float;
  50939. /**
  50940. * Reflection Texture level of blur.
  50941. *
  50942. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  50943. * texture twice.
  50944. */
  50945. reflectionBlur: float;
  50946. protected _diffuseTexture: Nullable<BaseTexture>;
  50947. /**
  50948. * Diffuse Texture used in the material.
  50949. * Should be author in a specific way for the best result (refer to the documentation).
  50950. */
  50951. diffuseTexture: Nullable<BaseTexture>;
  50952. protected _shadowLights: Nullable<IShadowLight[]>;
  50953. /**
  50954. * Specify the list of lights casting shadow on the material.
  50955. * All scene shadow lights will be included if null.
  50956. */
  50957. shadowLights: Nullable<IShadowLight[]>;
  50958. protected _shadowLevel: float;
  50959. /**
  50960. * Helps adjusting the shadow to a softer level if required.
  50961. * 0 means black shadows and 1 means no shadows.
  50962. */
  50963. shadowLevel: float;
  50964. protected _sceneCenter: Vector3;
  50965. /**
  50966. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  50967. * It is usually zero but might be interesting to modify according to your setup.
  50968. */
  50969. sceneCenter: Vector3;
  50970. protected _opacityFresnel: boolean;
  50971. /**
  50972. * This helps specifying that the material is falling off to the sky box at grazing angle.
  50973. * This helps ensuring a nice transition when the camera goes under the ground.
  50974. */
  50975. opacityFresnel: boolean;
  50976. protected _reflectionFresnel: boolean;
  50977. /**
  50978. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  50979. * This helps adding a mirror texture on the ground.
  50980. */
  50981. reflectionFresnel: boolean;
  50982. protected _reflectionFalloffDistance: number;
  50983. /**
  50984. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  50985. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  50986. */
  50987. reflectionFalloffDistance: number;
  50988. protected _reflectionAmount: number;
  50989. /**
  50990. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  50991. */
  50992. reflectionAmount: number;
  50993. protected _reflectionReflectance0: number;
  50994. /**
  50995. * This specifies the weight of the reflection at grazing angle.
  50996. */
  50997. reflectionReflectance0: number;
  50998. protected _reflectionReflectance90: number;
  50999. /**
  51000. * This specifies the weight of the reflection at a perpendicular point of view.
  51001. */
  51002. reflectionReflectance90: number;
  51003. /**
  51004. * Sets the reflection reflectance fresnel values according to the default standard
  51005. * empirically know to work well :-)
  51006. */
  51007. set reflectionStandardFresnelWeight(value: number);
  51008. protected _useRGBColor: boolean;
  51009. /**
  51010. * Helps to directly use the maps channels instead of their level.
  51011. */
  51012. useRGBColor: boolean;
  51013. protected _enableNoise: boolean;
  51014. /**
  51015. * This helps reducing the banding effect that could occur on the background.
  51016. */
  51017. enableNoise: boolean;
  51018. /**
  51019. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51020. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51021. * Recommended to be keep at 1.0 except for special cases.
  51022. */
  51023. get fovMultiplier(): number;
  51024. set fovMultiplier(value: number);
  51025. private _fovMultiplier;
  51026. /**
  51027. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51028. */
  51029. useEquirectangularFOV: boolean;
  51030. private _maxSimultaneousLights;
  51031. /**
  51032. * Number of Simultaneous lights allowed on the material.
  51033. */
  51034. maxSimultaneousLights: int;
  51035. /**
  51036. * Default configuration related to image processing available in the Background Material.
  51037. */
  51038. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51039. /**
  51040. * Keep track of the image processing observer to allow dispose and replace.
  51041. */
  51042. private _imageProcessingObserver;
  51043. /**
  51044. * Attaches a new image processing configuration to the PBR Material.
  51045. * @param configuration (if null the scene configuration will be use)
  51046. */
  51047. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51048. /**
  51049. * Gets the image processing configuration used either in this material.
  51050. */
  51051. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51052. /**
  51053. * Sets the Default image processing configuration used either in the this material.
  51054. *
  51055. * If sets to null, the scene one is in use.
  51056. */
  51057. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51058. /**
  51059. * Gets wether the color curves effect is enabled.
  51060. */
  51061. get cameraColorCurvesEnabled(): boolean;
  51062. /**
  51063. * Sets wether the color curves effect is enabled.
  51064. */
  51065. set cameraColorCurvesEnabled(value: boolean);
  51066. /**
  51067. * Gets wether the color grading effect is enabled.
  51068. */
  51069. get cameraColorGradingEnabled(): boolean;
  51070. /**
  51071. * Gets wether the color grading effect is enabled.
  51072. */
  51073. set cameraColorGradingEnabled(value: boolean);
  51074. /**
  51075. * Gets wether tonemapping is enabled or not.
  51076. */
  51077. get cameraToneMappingEnabled(): boolean;
  51078. /**
  51079. * Sets wether tonemapping is enabled or not
  51080. */
  51081. set cameraToneMappingEnabled(value: boolean);
  51082. /**
  51083. * The camera exposure used on this material.
  51084. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51085. * This corresponds to a photographic exposure.
  51086. */
  51087. get cameraExposure(): float;
  51088. /**
  51089. * The camera exposure used on this material.
  51090. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51091. * This corresponds to a photographic exposure.
  51092. */
  51093. set cameraExposure(value: float);
  51094. /**
  51095. * Gets The camera contrast used on this material.
  51096. */
  51097. get cameraContrast(): float;
  51098. /**
  51099. * Sets The camera contrast used on this material.
  51100. */
  51101. set cameraContrast(value: float);
  51102. /**
  51103. * Gets the Color Grading 2D Lookup Texture.
  51104. */
  51105. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51106. /**
  51107. * Sets the Color Grading 2D Lookup Texture.
  51108. */
  51109. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51110. /**
  51111. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51112. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51113. * 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;
  51114. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51115. */
  51116. get cameraColorCurves(): Nullable<ColorCurves>;
  51117. /**
  51118. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51119. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51120. * 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;
  51121. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51122. */
  51123. set cameraColorCurves(value: Nullable<ColorCurves>);
  51124. /**
  51125. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51126. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51127. */
  51128. switchToBGR: boolean;
  51129. private _renderTargets;
  51130. private _reflectionControls;
  51131. private _white;
  51132. private _primaryShadowColor;
  51133. private _primaryHighlightColor;
  51134. /**
  51135. * Instantiates a Background Material in the given scene
  51136. * @param name The friendly name of the material
  51137. * @param scene The scene to add the material to
  51138. */
  51139. constructor(name: string, scene: Scene);
  51140. /**
  51141. * Gets a boolean indicating that current material needs to register RTT
  51142. */
  51143. get hasRenderTargetTextures(): boolean;
  51144. /**
  51145. * The entire material has been created in order to prevent overdraw.
  51146. * @returns false
  51147. */
  51148. needAlphaTesting(): boolean;
  51149. /**
  51150. * The entire material has been created in order to prevent overdraw.
  51151. * @returns true if blending is enable
  51152. */
  51153. needAlphaBlending(): boolean;
  51154. /**
  51155. * Checks wether the material is ready to be rendered for a given mesh.
  51156. * @param mesh The mesh to render
  51157. * @param subMesh The submesh to check against
  51158. * @param useInstances Specify wether or not the material is used with instances
  51159. * @returns true if all the dependencies are ready (Textures, Effects...)
  51160. */
  51161. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51162. /**
  51163. * Compute the primary color according to the chosen perceptual color.
  51164. */
  51165. private _computePrimaryColorFromPerceptualColor;
  51166. /**
  51167. * Compute the highlights and shadow colors according to their chosen levels.
  51168. */
  51169. private _computePrimaryColors;
  51170. /**
  51171. * Build the uniform buffer used in the material.
  51172. */
  51173. buildUniformLayout(): void;
  51174. /**
  51175. * Unbind the material.
  51176. */
  51177. unbind(): void;
  51178. /**
  51179. * Bind only the world matrix to the material.
  51180. * @param world The world matrix to bind.
  51181. */
  51182. bindOnlyWorldMatrix(world: Matrix): void;
  51183. /**
  51184. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51185. * @param world The world matrix to bind.
  51186. * @param subMesh The submesh to bind for.
  51187. */
  51188. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51189. /**
  51190. * Checks to see if a texture is used in the material.
  51191. * @param texture - Base texture to use.
  51192. * @returns - Boolean specifying if a texture is used in the material.
  51193. */
  51194. hasTexture(texture: BaseTexture): boolean;
  51195. /**
  51196. * Dispose the material.
  51197. * @param forceDisposeEffect Force disposal of the associated effect.
  51198. * @param forceDisposeTextures Force disposal of the associated textures.
  51199. */
  51200. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51201. /**
  51202. * Clones the material.
  51203. * @param name The cloned name.
  51204. * @returns The cloned material.
  51205. */
  51206. clone(name: string): BackgroundMaterial;
  51207. /**
  51208. * Serializes the current material to its JSON representation.
  51209. * @returns The JSON representation.
  51210. */
  51211. serialize(): any;
  51212. /**
  51213. * Gets the class name of the material
  51214. * @returns "BackgroundMaterial"
  51215. */
  51216. getClassName(): string;
  51217. /**
  51218. * Parse a JSON input to create back a background material.
  51219. * @param source The JSON data to parse
  51220. * @param scene The scene to create the parsed material in
  51221. * @param rootUrl The root url of the assets the material depends upon
  51222. * @returns the instantiated BackgroundMaterial.
  51223. */
  51224. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51225. }
  51226. }
  51227. declare module "babylonjs/Helpers/environmentHelper" {
  51228. import { Observable } from "babylonjs/Misc/observable";
  51229. import { Nullable } from "babylonjs/types";
  51230. import { Scene } from "babylonjs/scene";
  51231. import { Vector3 } from "babylonjs/Maths/math.vector";
  51232. import { Color3 } from "babylonjs/Maths/math.color";
  51233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51234. import { Mesh } from "babylonjs/Meshes/mesh";
  51235. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51236. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51237. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51238. import "babylonjs/Meshes/Builders/planeBuilder";
  51239. import "babylonjs/Meshes/Builders/boxBuilder";
  51240. /**
  51241. * Represents the different options available during the creation of
  51242. * a Environment helper.
  51243. *
  51244. * This can control the default ground, skybox and image processing setup of your scene.
  51245. */
  51246. export interface IEnvironmentHelperOptions {
  51247. /**
  51248. * Specifies wether or not to create a ground.
  51249. * True by default.
  51250. */
  51251. createGround: boolean;
  51252. /**
  51253. * Specifies the ground size.
  51254. * 15 by default.
  51255. */
  51256. groundSize: number;
  51257. /**
  51258. * The texture used on the ground for the main color.
  51259. * Comes from the BabylonJS CDN by default.
  51260. *
  51261. * Remarks: Can be either a texture or a url.
  51262. */
  51263. groundTexture: string | BaseTexture;
  51264. /**
  51265. * The color mixed in the ground texture by default.
  51266. * BabylonJS clearColor by default.
  51267. */
  51268. groundColor: Color3;
  51269. /**
  51270. * Specifies the ground opacity.
  51271. * 1 by default.
  51272. */
  51273. groundOpacity: number;
  51274. /**
  51275. * Enables the ground to receive shadows.
  51276. * True by default.
  51277. */
  51278. enableGroundShadow: boolean;
  51279. /**
  51280. * Helps preventing the shadow to be fully black on the ground.
  51281. * 0.5 by default.
  51282. */
  51283. groundShadowLevel: number;
  51284. /**
  51285. * Creates a mirror texture attach to the ground.
  51286. * false by default.
  51287. */
  51288. enableGroundMirror: boolean;
  51289. /**
  51290. * Specifies the ground mirror size ratio.
  51291. * 0.3 by default as the default kernel is 64.
  51292. */
  51293. groundMirrorSizeRatio: number;
  51294. /**
  51295. * Specifies the ground mirror blur kernel size.
  51296. * 64 by default.
  51297. */
  51298. groundMirrorBlurKernel: number;
  51299. /**
  51300. * Specifies the ground mirror visibility amount.
  51301. * 1 by default
  51302. */
  51303. groundMirrorAmount: number;
  51304. /**
  51305. * Specifies the ground mirror reflectance weight.
  51306. * This uses the standard weight of the background material to setup the fresnel effect
  51307. * of the mirror.
  51308. * 1 by default.
  51309. */
  51310. groundMirrorFresnelWeight: number;
  51311. /**
  51312. * Specifies the ground mirror Falloff distance.
  51313. * This can helps reducing the size of the reflection.
  51314. * 0 by Default.
  51315. */
  51316. groundMirrorFallOffDistance: number;
  51317. /**
  51318. * Specifies the ground mirror texture type.
  51319. * Unsigned Int by Default.
  51320. */
  51321. groundMirrorTextureType: number;
  51322. /**
  51323. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51324. * the shown objects.
  51325. */
  51326. groundYBias: number;
  51327. /**
  51328. * Specifies wether or not to create a skybox.
  51329. * True by default.
  51330. */
  51331. createSkybox: boolean;
  51332. /**
  51333. * Specifies the skybox size.
  51334. * 20 by default.
  51335. */
  51336. skyboxSize: number;
  51337. /**
  51338. * The texture used on the skybox for the main color.
  51339. * Comes from the BabylonJS CDN by default.
  51340. *
  51341. * Remarks: Can be either a texture or a url.
  51342. */
  51343. skyboxTexture: string | BaseTexture;
  51344. /**
  51345. * The color mixed in the skybox texture by default.
  51346. * BabylonJS clearColor by default.
  51347. */
  51348. skyboxColor: Color3;
  51349. /**
  51350. * The background rotation around the Y axis of the scene.
  51351. * This helps aligning the key lights of your scene with the background.
  51352. * 0 by default.
  51353. */
  51354. backgroundYRotation: number;
  51355. /**
  51356. * Compute automatically the size of the elements to best fit with the scene.
  51357. */
  51358. sizeAuto: boolean;
  51359. /**
  51360. * Default position of the rootMesh if autoSize is not true.
  51361. */
  51362. rootPosition: Vector3;
  51363. /**
  51364. * Sets up the image processing in the scene.
  51365. * true by default.
  51366. */
  51367. setupImageProcessing: boolean;
  51368. /**
  51369. * The texture used as your environment texture in the scene.
  51370. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51371. *
  51372. * Remarks: Can be either a texture or a url.
  51373. */
  51374. environmentTexture: string | BaseTexture;
  51375. /**
  51376. * The value of the exposure to apply to the scene.
  51377. * 0.6 by default if setupImageProcessing is true.
  51378. */
  51379. cameraExposure: number;
  51380. /**
  51381. * The value of the contrast to apply to the scene.
  51382. * 1.6 by default if setupImageProcessing is true.
  51383. */
  51384. cameraContrast: number;
  51385. /**
  51386. * Specifies wether or not tonemapping should be enabled in the scene.
  51387. * true by default if setupImageProcessing is true.
  51388. */
  51389. toneMappingEnabled: boolean;
  51390. }
  51391. /**
  51392. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51393. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51394. * It also helps with the default setup of your imageProcessing configuration.
  51395. */
  51396. export class EnvironmentHelper {
  51397. /**
  51398. * Default ground texture URL.
  51399. */
  51400. private static _groundTextureCDNUrl;
  51401. /**
  51402. * Default skybox texture URL.
  51403. */
  51404. private static _skyboxTextureCDNUrl;
  51405. /**
  51406. * Default environment texture URL.
  51407. */
  51408. private static _environmentTextureCDNUrl;
  51409. /**
  51410. * Creates the default options for the helper.
  51411. */
  51412. private static _getDefaultOptions;
  51413. private _rootMesh;
  51414. /**
  51415. * Gets the root mesh created by the helper.
  51416. */
  51417. get rootMesh(): Mesh;
  51418. private _skybox;
  51419. /**
  51420. * Gets the skybox created by the helper.
  51421. */
  51422. get skybox(): Nullable<Mesh>;
  51423. private _skyboxTexture;
  51424. /**
  51425. * Gets the skybox texture created by the helper.
  51426. */
  51427. get skyboxTexture(): Nullable<BaseTexture>;
  51428. private _skyboxMaterial;
  51429. /**
  51430. * Gets the skybox material created by the helper.
  51431. */
  51432. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51433. private _ground;
  51434. /**
  51435. * Gets the ground mesh created by the helper.
  51436. */
  51437. get ground(): Nullable<Mesh>;
  51438. private _groundTexture;
  51439. /**
  51440. * Gets the ground texture created by the helper.
  51441. */
  51442. get groundTexture(): Nullable<BaseTexture>;
  51443. private _groundMirror;
  51444. /**
  51445. * Gets the ground mirror created by the helper.
  51446. */
  51447. get groundMirror(): Nullable<MirrorTexture>;
  51448. /**
  51449. * Gets the ground mirror render list to helps pushing the meshes
  51450. * you wish in the ground reflection.
  51451. */
  51452. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51453. private _groundMaterial;
  51454. /**
  51455. * Gets the ground material created by the helper.
  51456. */
  51457. get groundMaterial(): Nullable<BackgroundMaterial>;
  51458. /**
  51459. * Stores the creation options.
  51460. */
  51461. private readonly _scene;
  51462. private _options;
  51463. /**
  51464. * This observable will be notified with any error during the creation of the environment,
  51465. * mainly texture creation errors.
  51466. */
  51467. onErrorObservable: Observable<{
  51468. message?: string;
  51469. exception?: any;
  51470. }>;
  51471. /**
  51472. * constructor
  51473. * @param options Defines the options we want to customize the helper
  51474. * @param scene The scene to add the material to
  51475. */
  51476. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51477. /**
  51478. * Updates the background according to the new options
  51479. * @param options
  51480. */
  51481. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51482. /**
  51483. * Sets the primary color of all the available elements.
  51484. * @param color the main color to affect to the ground and the background
  51485. */
  51486. setMainColor(color: Color3): void;
  51487. /**
  51488. * Setup the image processing according to the specified options.
  51489. */
  51490. private _setupImageProcessing;
  51491. /**
  51492. * Setup the environment texture according to the specified options.
  51493. */
  51494. private _setupEnvironmentTexture;
  51495. /**
  51496. * Setup the background according to the specified options.
  51497. */
  51498. private _setupBackground;
  51499. /**
  51500. * Get the scene sizes according to the setup.
  51501. */
  51502. private _getSceneSize;
  51503. /**
  51504. * Setup the ground according to the specified options.
  51505. */
  51506. private _setupGround;
  51507. /**
  51508. * Setup the ground material according to the specified options.
  51509. */
  51510. private _setupGroundMaterial;
  51511. /**
  51512. * Setup the ground diffuse texture according to the specified options.
  51513. */
  51514. private _setupGroundDiffuseTexture;
  51515. /**
  51516. * Setup the ground mirror texture according to the specified options.
  51517. */
  51518. private _setupGroundMirrorTexture;
  51519. /**
  51520. * Setup the ground to receive the mirror texture.
  51521. */
  51522. private _setupMirrorInGroundMaterial;
  51523. /**
  51524. * Setup the skybox according to the specified options.
  51525. */
  51526. private _setupSkybox;
  51527. /**
  51528. * Setup the skybox material according to the specified options.
  51529. */
  51530. private _setupSkyboxMaterial;
  51531. /**
  51532. * Setup the skybox reflection texture according to the specified options.
  51533. */
  51534. private _setupSkyboxReflectionTexture;
  51535. private _errorHandler;
  51536. /**
  51537. * Dispose all the elements created by the Helper.
  51538. */
  51539. dispose(): void;
  51540. }
  51541. }
  51542. declare module "babylonjs/Helpers/photoDome" {
  51543. import { Observable } from "babylonjs/Misc/observable";
  51544. import { Nullable } from "babylonjs/types";
  51545. import { Scene } from "babylonjs/scene";
  51546. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51547. import { Mesh } from "babylonjs/Meshes/mesh";
  51548. import { Texture } from "babylonjs/Materials/Textures/texture";
  51549. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51550. import "babylonjs/Meshes/Builders/sphereBuilder";
  51551. /**
  51552. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51553. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51554. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51555. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51556. */
  51557. export class PhotoDome extends TransformNode {
  51558. /**
  51559. * Define the image as a Monoscopic panoramic 360 image.
  51560. */
  51561. static readonly MODE_MONOSCOPIC: number;
  51562. /**
  51563. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51564. */
  51565. static readonly MODE_TOPBOTTOM: number;
  51566. /**
  51567. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51568. */
  51569. static readonly MODE_SIDEBYSIDE: number;
  51570. private _useDirectMapping;
  51571. /**
  51572. * The texture being displayed on the sphere
  51573. */
  51574. protected _photoTexture: Texture;
  51575. /**
  51576. * Gets or sets the texture being displayed on the sphere
  51577. */
  51578. get photoTexture(): Texture;
  51579. set photoTexture(value: Texture);
  51580. /**
  51581. * Observable raised when an error occured while loading the 360 image
  51582. */
  51583. onLoadErrorObservable: Observable<string>;
  51584. /**
  51585. * The skybox material
  51586. */
  51587. protected _material: BackgroundMaterial;
  51588. /**
  51589. * The surface used for the skybox
  51590. */
  51591. protected _mesh: Mesh;
  51592. /**
  51593. * Gets the mesh used for the skybox.
  51594. */
  51595. get mesh(): Mesh;
  51596. /**
  51597. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51598. * Also see the options.resolution property.
  51599. */
  51600. get fovMultiplier(): number;
  51601. set fovMultiplier(value: number);
  51602. private _imageMode;
  51603. /**
  51604. * Gets or set the current video mode for the video. It can be:
  51605. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51606. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51607. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51608. */
  51609. get imageMode(): number;
  51610. set imageMode(value: number);
  51611. /**
  51612. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51613. * @param name Element's name, child elements will append suffixes for their own names.
  51614. * @param urlsOfPhoto defines the url of the photo to display
  51615. * @param options defines an object containing optional or exposed sub element properties
  51616. * @param onError defines a callback called when an error occured while loading the texture
  51617. */
  51618. constructor(name: string, urlOfPhoto: string, options: {
  51619. resolution?: number;
  51620. size?: number;
  51621. useDirectMapping?: boolean;
  51622. faceForward?: boolean;
  51623. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51624. private _onBeforeCameraRenderObserver;
  51625. private _changeImageMode;
  51626. /**
  51627. * Releases resources associated with this node.
  51628. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51629. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51630. */
  51631. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51632. }
  51633. }
  51634. declare module "babylonjs/Misc/rgbdTextureTools" {
  51635. import "babylonjs/Shaders/rgbdDecode.fragment";
  51636. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51637. import { Texture } from "babylonjs/Materials/Textures/texture";
  51638. /**
  51639. * Class used to host RGBD texture specific utilities
  51640. */
  51641. export class RGBDTextureTools {
  51642. /**
  51643. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51644. * @param texture the texture to expand.
  51645. */
  51646. static ExpandRGBDTexture(texture: Texture): void;
  51647. }
  51648. }
  51649. declare module "babylonjs/Misc/brdfTextureTools" {
  51650. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51651. import { Scene } from "babylonjs/scene";
  51652. /**
  51653. * Class used to host texture specific utilities
  51654. */
  51655. export class BRDFTextureTools {
  51656. /**
  51657. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51658. * @param scene defines the hosting scene
  51659. * @returns the environment BRDF texture
  51660. */
  51661. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51662. private static _environmentBRDFBase64Texture;
  51663. }
  51664. }
  51665. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51666. import { Nullable } from "babylonjs/types";
  51667. import { Color3 } from "babylonjs/Maths/math.color";
  51668. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51669. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51670. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51671. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51672. import { Engine } from "babylonjs/Engines/engine";
  51673. import { Scene } from "babylonjs/scene";
  51674. /**
  51675. * @hidden
  51676. */
  51677. export interface IMaterialClearCoatDefines {
  51678. CLEARCOAT: boolean;
  51679. CLEARCOAT_DEFAULTIOR: boolean;
  51680. CLEARCOAT_TEXTURE: boolean;
  51681. CLEARCOAT_TEXTUREDIRECTUV: number;
  51682. CLEARCOAT_BUMP: boolean;
  51683. CLEARCOAT_BUMPDIRECTUV: number;
  51684. CLEARCOAT_TINT: boolean;
  51685. CLEARCOAT_TINT_TEXTURE: boolean;
  51686. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51687. /** @hidden */
  51688. _areTexturesDirty: boolean;
  51689. }
  51690. /**
  51691. * Define the code related to the clear coat parameters of the pbr material.
  51692. */
  51693. export class PBRClearCoatConfiguration {
  51694. /**
  51695. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51696. * The default fits with a polyurethane material.
  51697. */
  51698. private static readonly _DefaultIndexOfRefraction;
  51699. private _isEnabled;
  51700. /**
  51701. * Defines if the clear coat is enabled in the material.
  51702. */
  51703. isEnabled: boolean;
  51704. /**
  51705. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51706. */
  51707. intensity: number;
  51708. /**
  51709. * Defines the clear coat layer roughness.
  51710. */
  51711. roughness: number;
  51712. private _indexOfRefraction;
  51713. /**
  51714. * Defines the index of refraction of the clear coat.
  51715. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51716. * The default fits with a polyurethane material.
  51717. * Changing the default value is more performance intensive.
  51718. */
  51719. indexOfRefraction: number;
  51720. private _texture;
  51721. /**
  51722. * Stores the clear coat values in a texture.
  51723. */
  51724. texture: Nullable<BaseTexture>;
  51725. private _bumpTexture;
  51726. /**
  51727. * Define the clear coat specific bump texture.
  51728. */
  51729. bumpTexture: Nullable<BaseTexture>;
  51730. private _isTintEnabled;
  51731. /**
  51732. * Defines if the clear coat tint is enabled in the material.
  51733. */
  51734. isTintEnabled: boolean;
  51735. /**
  51736. * Defines the clear coat tint of the material.
  51737. * This is only use if tint is enabled
  51738. */
  51739. tintColor: Color3;
  51740. /**
  51741. * Defines the distance at which the tint color should be found in the
  51742. * clear coat media.
  51743. * This is only use if tint is enabled
  51744. */
  51745. tintColorAtDistance: number;
  51746. /**
  51747. * Defines the clear coat layer thickness.
  51748. * This is only use if tint is enabled
  51749. */
  51750. tintThickness: number;
  51751. private _tintTexture;
  51752. /**
  51753. * Stores the clear tint values in a texture.
  51754. * rgb is tint
  51755. * a is a thickness factor
  51756. */
  51757. tintTexture: Nullable<BaseTexture>;
  51758. /** @hidden */
  51759. private _internalMarkAllSubMeshesAsTexturesDirty;
  51760. /** @hidden */
  51761. _markAllSubMeshesAsTexturesDirty(): void;
  51762. /**
  51763. * Instantiate a new istance of clear coat configuration.
  51764. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51765. */
  51766. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51767. /**
  51768. * Gets wehter the submesh is ready to be used or not.
  51769. * @param defines the list of "defines" to update.
  51770. * @param scene defines the scene the material belongs to.
  51771. * @param engine defines the engine the material belongs to.
  51772. * @param disableBumpMap defines wether the material disables bump or not.
  51773. * @returns - boolean indicating that the submesh is ready or not.
  51774. */
  51775. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  51776. /**
  51777. * Checks to see if a texture is used in the material.
  51778. * @param defines the list of "defines" to update.
  51779. * @param scene defines the scene to the material belongs to.
  51780. */
  51781. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  51782. /**
  51783. * Binds the material data.
  51784. * @param uniformBuffer defines the Uniform buffer to fill in.
  51785. * @param scene defines the scene the material belongs to.
  51786. * @param engine defines the engine the material belongs to.
  51787. * @param disableBumpMap defines wether the material disables bump or not.
  51788. * @param isFrozen defines wether the material is frozen or not.
  51789. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51790. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51791. */
  51792. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  51793. /**
  51794. * Checks to see if a texture is used in the material.
  51795. * @param texture - Base texture to use.
  51796. * @returns - Boolean specifying if a texture is used in the material.
  51797. */
  51798. hasTexture(texture: BaseTexture): boolean;
  51799. /**
  51800. * Returns an array of the actively used textures.
  51801. * @param activeTextures Array of BaseTextures
  51802. */
  51803. getActiveTextures(activeTextures: BaseTexture[]): void;
  51804. /**
  51805. * Returns the animatable textures.
  51806. * @param animatables Array of animatable textures.
  51807. */
  51808. getAnimatables(animatables: IAnimatable[]): void;
  51809. /**
  51810. * Disposes the resources of the material.
  51811. * @param forceDisposeTextures - Forces the disposal of all textures.
  51812. */
  51813. dispose(forceDisposeTextures?: boolean): void;
  51814. /**
  51815. * Get the current class name of the texture useful for serialization or dynamic coding.
  51816. * @returns "PBRClearCoatConfiguration"
  51817. */
  51818. getClassName(): string;
  51819. /**
  51820. * Add fallbacks to the effect fallbacks list.
  51821. * @param defines defines the Base texture to use.
  51822. * @param fallbacks defines the current fallback list.
  51823. * @param currentRank defines the current fallback rank.
  51824. * @returns the new fallback rank.
  51825. */
  51826. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51827. /**
  51828. * Add the required uniforms to the current list.
  51829. * @param uniforms defines the current uniform list.
  51830. */
  51831. static AddUniforms(uniforms: string[]): void;
  51832. /**
  51833. * Add the required samplers to the current list.
  51834. * @param samplers defines the current sampler list.
  51835. */
  51836. static AddSamplers(samplers: string[]): void;
  51837. /**
  51838. * Add the required uniforms to the current buffer.
  51839. * @param uniformBuffer defines the current uniform buffer.
  51840. */
  51841. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51842. /**
  51843. * Makes a duplicate of the current configuration into another one.
  51844. * @param clearCoatConfiguration define the config where to copy the info
  51845. */
  51846. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  51847. /**
  51848. * Serializes this clear coat configuration.
  51849. * @returns - An object with the serialized config.
  51850. */
  51851. serialize(): any;
  51852. /**
  51853. * Parses a anisotropy Configuration from a serialized object.
  51854. * @param source - Serialized object.
  51855. * @param scene Defines the scene we are parsing for
  51856. * @param rootUrl Defines the rootUrl to load from
  51857. */
  51858. parse(source: any, scene: Scene, rootUrl: string): void;
  51859. }
  51860. }
  51861. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  51862. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51863. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51864. import { Vector2 } from "babylonjs/Maths/math.vector";
  51865. import { Scene } from "babylonjs/scene";
  51866. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51867. import { Nullable } from "babylonjs/types";
  51868. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51869. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51870. /**
  51871. * @hidden
  51872. */
  51873. export interface IMaterialAnisotropicDefines {
  51874. ANISOTROPIC: boolean;
  51875. ANISOTROPIC_TEXTURE: boolean;
  51876. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51877. MAINUV1: boolean;
  51878. _areTexturesDirty: boolean;
  51879. _needUVs: boolean;
  51880. }
  51881. /**
  51882. * Define the code related to the anisotropic parameters of the pbr material.
  51883. */
  51884. export class PBRAnisotropicConfiguration {
  51885. private _isEnabled;
  51886. /**
  51887. * Defines if the anisotropy is enabled in the material.
  51888. */
  51889. isEnabled: boolean;
  51890. /**
  51891. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  51892. */
  51893. intensity: number;
  51894. /**
  51895. * Defines if the effect is along the tangents, bitangents or in between.
  51896. * By default, the effect is "strectching" the highlights along the tangents.
  51897. */
  51898. direction: Vector2;
  51899. private _texture;
  51900. /**
  51901. * Stores the anisotropy values in a texture.
  51902. * rg is direction (like normal from -1 to 1)
  51903. * b is a intensity
  51904. */
  51905. texture: Nullable<BaseTexture>;
  51906. /** @hidden */
  51907. private _internalMarkAllSubMeshesAsTexturesDirty;
  51908. /** @hidden */
  51909. _markAllSubMeshesAsTexturesDirty(): void;
  51910. /**
  51911. * Instantiate a new istance of anisotropy configuration.
  51912. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  51913. */
  51914. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  51915. /**
  51916. * Specifies that the submesh is ready to be used.
  51917. * @param defines the list of "defines" to update.
  51918. * @param scene defines the scene the material belongs to.
  51919. * @returns - boolean indicating that the submesh is ready or not.
  51920. */
  51921. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  51922. /**
  51923. * Checks to see if a texture is used in the material.
  51924. * @param defines the list of "defines" to update.
  51925. * @param mesh the mesh we are preparing the defines for.
  51926. * @param scene defines the scene the material belongs to.
  51927. */
  51928. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  51929. /**
  51930. * Binds the material data.
  51931. * @param uniformBuffer defines the Uniform buffer to fill in.
  51932. * @param scene defines the scene the material belongs to.
  51933. * @param isFrozen defines wether the material is frozen or not.
  51934. */
  51935. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  51936. /**
  51937. * Checks to see if a texture is used in the material.
  51938. * @param texture - Base texture to use.
  51939. * @returns - Boolean specifying if a texture is used in the material.
  51940. */
  51941. hasTexture(texture: BaseTexture): boolean;
  51942. /**
  51943. * Returns an array of the actively used textures.
  51944. * @param activeTextures Array of BaseTextures
  51945. */
  51946. getActiveTextures(activeTextures: BaseTexture[]): void;
  51947. /**
  51948. * Returns the animatable textures.
  51949. * @param animatables Array of animatable textures.
  51950. */
  51951. getAnimatables(animatables: IAnimatable[]): void;
  51952. /**
  51953. * Disposes the resources of the material.
  51954. * @param forceDisposeTextures - Forces the disposal of all textures.
  51955. */
  51956. dispose(forceDisposeTextures?: boolean): void;
  51957. /**
  51958. * Get the current class name of the texture useful for serialization or dynamic coding.
  51959. * @returns "PBRAnisotropicConfiguration"
  51960. */
  51961. getClassName(): string;
  51962. /**
  51963. * Add fallbacks to the effect fallbacks list.
  51964. * @param defines defines the Base texture to use.
  51965. * @param fallbacks defines the current fallback list.
  51966. * @param currentRank defines the current fallback rank.
  51967. * @returns the new fallback rank.
  51968. */
  51969. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  51970. /**
  51971. * Add the required uniforms to the current list.
  51972. * @param uniforms defines the current uniform list.
  51973. */
  51974. static AddUniforms(uniforms: string[]): void;
  51975. /**
  51976. * Add the required uniforms to the current buffer.
  51977. * @param uniformBuffer defines the current uniform buffer.
  51978. */
  51979. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  51980. /**
  51981. * Add the required samplers to the current list.
  51982. * @param samplers defines the current sampler list.
  51983. */
  51984. static AddSamplers(samplers: string[]): void;
  51985. /**
  51986. * Makes a duplicate of the current configuration into another one.
  51987. * @param anisotropicConfiguration define the config where to copy the info
  51988. */
  51989. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  51990. /**
  51991. * Serializes this anisotropy configuration.
  51992. * @returns - An object with the serialized config.
  51993. */
  51994. serialize(): any;
  51995. /**
  51996. * Parses a anisotropy Configuration from a serialized object.
  51997. * @param source - Serialized object.
  51998. * @param scene Defines the scene we are parsing for
  51999. * @param rootUrl Defines the rootUrl to load from
  52000. */
  52001. parse(source: any, scene: Scene, rootUrl: string): void;
  52002. }
  52003. }
  52004. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52005. import { Scene } from "babylonjs/scene";
  52006. /**
  52007. * @hidden
  52008. */
  52009. export interface IMaterialBRDFDefines {
  52010. BRDF_V_HEIGHT_CORRELATED: boolean;
  52011. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52012. SPHERICAL_HARMONICS: boolean;
  52013. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52014. /** @hidden */
  52015. _areMiscDirty: boolean;
  52016. }
  52017. /**
  52018. * Define the code related to the BRDF parameters of the pbr material.
  52019. */
  52020. export class PBRBRDFConfiguration {
  52021. /**
  52022. * Default value used for the energy conservation.
  52023. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52024. */
  52025. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52026. /**
  52027. * Default value used for the Smith Visibility Height Correlated mode.
  52028. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52029. */
  52030. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52031. /**
  52032. * Default value used for the IBL diffuse part.
  52033. * This can help switching back to the polynomials mode globally which is a tiny bit
  52034. * less GPU intensive at the drawback of a lower quality.
  52035. */
  52036. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52037. /**
  52038. * Default value used for activating energy conservation for the specular workflow.
  52039. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52040. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52041. */
  52042. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52043. private _useEnergyConservation;
  52044. /**
  52045. * Defines if the material uses energy conservation.
  52046. */
  52047. useEnergyConservation: boolean;
  52048. private _useSmithVisibilityHeightCorrelated;
  52049. /**
  52050. * LEGACY Mode set to false
  52051. * Defines if the material uses height smith correlated visibility term.
  52052. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52053. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52054. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52055. * Not relying on height correlated will also disable energy conservation.
  52056. */
  52057. useSmithVisibilityHeightCorrelated: boolean;
  52058. private _useSphericalHarmonics;
  52059. /**
  52060. * LEGACY Mode set to false
  52061. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52062. * diffuse part of the IBL.
  52063. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52064. * to the ground truth.
  52065. */
  52066. useSphericalHarmonics: boolean;
  52067. private _useSpecularGlossinessInputEnergyConservation;
  52068. /**
  52069. * Defines if the material uses energy conservation, when the specular workflow is active.
  52070. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52071. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52072. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52073. */
  52074. useSpecularGlossinessInputEnergyConservation: boolean;
  52075. /** @hidden */
  52076. private _internalMarkAllSubMeshesAsMiscDirty;
  52077. /** @hidden */
  52078. _markAllSubMeshesAsMiscDirty(): void;
  52079. /**
  52080. * Instantiate a new istance of clear coat configuration.
  52081. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52082. */
  52083. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52084. /**
  52085. * Checks to see if a texture is used in the material.
  52086. * @param defines the list of "defines" to update.
  52087. */
  52088. prepareDefines(defines: IMaterialBRDFDefines): void;
  52089. /**
  52090. * Get the current class name of the texture useful for serialization or dynamic coding.
  52091. * @returns "PBRClearCoatConfiguration"
  52092. */
  52093. getClassName(): string;
  52094. /**
  52095. * Makes a duplicate of the current configuration into another one.
  52096. * @param brdfConfiguration define the config where to copy the info
  52097. */
  52098. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52099. /**
  52100. * Serializes this BRDF configuration.
  52101. * @returns - An object with the serialized config.
  52102. */
  52103. serialize(): any;
  52104. /**
  52105. * Parses a anisotropy Configuration from a serialized object.
  52106. * @param source - Serialized object.
  52107. * @param scene Defines the scene we are parsing for
  52108. * @param rootUrl Defines the rootUrl to load from
  52109. */
  52110. parse(source: any, scene: Scene, rootUrl: string): void;
  52111. }
  52112. }
  52113. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52114. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52115. import { Color3 } from "babylonjs/Maths/math.color";
  52116. import { Scene } from "babylonjs/scene";
  52117. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52118. import { Nullable } from "babylonjs/types";
  52119. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52120. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52121. /**
  52122. * @hidden
  52123. */
  52124. export interface IMaterialSheenDefines {
  52125. SHEEN: boolean;
  52126. SHEEN_TEXTURE: boolean;
  52127. SHEEN_TEXTUREDIRECTUV: number;
  52128. SHEEN_LINKWITHALBEDO: boolean;
  52129. /** @hidden */
  52130. _areTexturesDirty: boolean;
  52131. }
  52132. /**
  52133. * Define the code related to the Sheen parameters of the pbr material.
  52134. */
  52135. export class PBRSheenConfiguration {
  52136. private _isEnabled;
  52137. /**
  52138. * Defines if the material uses sheen.
  52139. */
  52140. isEnabled: boolean;
  52141. private _linkSheenWithAlbedo;
  52142. /**
  52143. * Defines if the sheen is linked to the sheen color.
  52144. */
  52145. linkSheenWithAlbedo: boolean;
  52146. /**
  52147. * Defines the sheen intensity.
  52148. */
  52149. intensity: number;
  52150. /**
  52151. * Defines the sheen color.
  52152. */
  52153. color: Color3;
  52154. private _texture;
  52155. /**
  52156. * Stores the sheen tint values in a texture.
  52157. * rgb is tint
  52158. * a is a intensity
  52159. */
  52160. texture: Nullable<BaseTexture>;
  52161. /** @hidden */
  52162. private _internalMarkAllSubMeshesAsTexturesDirty;
  52163. /** @hidden */
  52164. _markAllSubMeshesAsTexturesDirty(): void;
  52165. /**
  52166. * Instantiate a new istance of clear coat configuration.
  52167. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52168. */
  52169. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52170. /**
  52171. * Specifies that the submesh is ready to be used.
  52172. * @param defines the list of "defines" to update.
  52173. * @param scene defines the scene the material belongs to.
  52174. * @returns - boolean indicating that the submesh is ready or not.
  52175. */
  52176. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52177. /**
  52178. * Checks to see if a texture is used in the material.
  52179. * @param defines the list of "defines" to update.
  52180. * @param scene defines the scene the material belongs to.
  52181. */
  52182. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52183. /**
  52184. * Binds the material data.
  52185. * @param uniformBuffer defines the Uniform buffer to fill in.
  52186. * @param scene defines the scene the material belongs to.
  52187. * @param isFrozen defines wether the material is frozen or not.
  52188. */
  52189. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52190. /**
  52191. * Checks to see if a texture is used in the material.
  52192. * @param texture - Base texture to use.
  52193. * @returns - Boolean specifying if a texture is used in the material.
  52194. */
  52195. hasTexture(texture: BaseTexture): boolean;
  52196. /**
  52197. * Returns an array of the actively used textures.
  52198. * @param activeTextures Array of BaseTextures
  52199. */
  52200. getActiveTextures(activeTextures: BaseTexture[]): void;
  52201. /**
  52202. * Returns the animatable textures.
  52203. * @param animatables Array of animatable textures.
  52204. */
  52205. getAnimatables(animatables: IAnimatable[]): void;
  52206. /**
  52207. * Disposes the resources of the material.
  52208. * @param forceDisposeTextures - Forces the disposal of all textures.
  52209. */
  52210. dispose(forceDisposeTextures?: boolean): void;
  52211. /**
  52212. * Get the current class name of the texture useful for serialization or dynamic coding.
  52213. * @returns "PBRSheenConfiguration"
  52214. */
  52215. getClassName(): string;
  52216. /**
  52217. * Add fallbacks to the effect fallbacks list.
  52218. * @param defines defines the Base texture to use.
  52219. * @param fallbacks defines the current fallback list.
  52220. * @param currentRank defines the current fallback rank.
  52221. * @returns the new fallback rank.
  52222. */
  52223. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52224. /**
  52225. * Add the required uniforms to the current list.
  52226. * @param uniforms defines the current uniform list.
  52227. */
  52228. static AddUniforms(uniforms: string[]): void;
  52229. /**
  52230. * Add the required uniforms to the current buffer.
  52231. * @param uniformBuffer defines the current uniform buffer.
  52232. */
  52233. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52234. /**
  52235. * Add the required samplers to the current list.
  52236. * @param samplers defines the current sampler list.
  52237. */
  52238. static AddSamplers(samplers: string[]): void;
  52239. /**
  52240. * Makes a duplicate of the current configuration into another one.
  52241. * @param sheenConfiguration define the config where to copy the info
  52242. */
  52243. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52244. /**
  52245. * Serializes this BRDF configuration.
  52246. * @returns - An object with the serialized config.
  52247. */
  52248. serialize(): any;
  52249. /**
  52250. * Parses a anisotropy Configuration from a serialized object.
  52251. * @param source - Serialized object.
  52252. * @param scene Defines the scene we are parsing for
  52253. * @param rootUrl Defines the rootUrl to load from
  52254. */
  52255. parse(source: any, scene: Scene, rootUrl: string): void;
  52256. }
  52257. }
  52258. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52259. import { Nullable } from "babylonjs/types";
  52260. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52261. import { Color3 } from "babylonjs/Maths/math.color";
  52262. import { SmartArray } from "babylonjs/Misc/smartArray";
  52263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52265. import { Effect } from "babylonjs/Materials/effect";
  52266. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52267. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52268. import { Engine } from "babylonjs/Engines/engine";
  52269. import { Scene } from "babylonjs/scene";
  52270. /**
  52271. * @hidden
  52272. */
  52273. export interface IMaterialSubSurfaceDefines {
  52274. SUBSURFACE: boolean;
  52275. SS_REFRACTION: boolean;
  52276. SS_TRANSLUCENCY: boolean;
  52277. SS_SCATERRING: boolean;
  52278. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52279. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52280. SS_REFRACTIONMAP_3D: boolean;
  52281. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52282. SS_LODINREFRACTIONALPHA: boolean;
  52283. SS_GAMMAREFRACTION: boolean;
  52284. SS_RGBDREFRACTION: boolean;
  52285. SS_LINEARSPECULARREFRACTION: boolean;
  52286. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52287. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52288. /** @hidden */
  52289. _areTexturesDirty: boolean;
  52290. }
  52291. /**
  52292. * Define the code related to the sub surface parameters of the pbr material.
  52293. */
  52294. export class PBRSubSurfaceConfiguration {
  52295. private _isRefractionEnabled;
  52296. /**
  52297. * Defines if the refraction is enabled in the material.
  52298. */
  52299. isRefractionEnabled: boolean;
  52300. private _isTranslucencyEnabled;
  52301. /**
  52302. * Defines if the translucency is enabled in the material.
  52303. */
  52304. isTranslucencyEnabled: boolean;
  52305. private _isScatteringEnabled;
  52306. /**
  52307. * Defines the refraction intensity of the material.
  52308. * The refraction when enabled replaces the Diffuse part of the material.
  52309. * The intensity helps transitionning between diffuse and refraction.
  52310. */
  52311. refractionIntensity: number;
  52312. /**
  52313. * Defines the translucency intensity of the material.
  52314. * When translucency has been enabled, this defines how much of the "translucency"
  52315. * is addded to the diffuse part of the material.
  52316. */
  52317. translucencyIntensity: number;
  52318. /**
  52319. * Defines the scattering intensity of the material.
  52320. * When scattering has been enabled, this defines how much of the "scattered light"
  52321. * is addded to the diffuse part of the material.
  52322. */
  52323. scatteringIntensity: number;
  52324. private _thicknessTexture;
  52325. /**
  52326. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52327. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52328. * 0 would mean minimumThickness
  52329. * 1 would mean maximumThickness
  52330. * The other channels might be use as a mask to vary the different effects intensity.
  52331. */
  52332. thicknessTexture: Nullable<BaseTexture>;
  52333. private _refractionTexture;
  52334. /**
  52335. * Defines the texture to use for refraction.
  52336. */
  52337. refractionTexture: Nullable<BaseTexture>;
  52338. private _indexOfRefraction;
  52339. /**
  52340. * Defines the index of refraction used in the material.
  52341. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52342. */
  52343. indexOfRefraction: number;
  52344. private _invertRefractionY;
  52345. /**
  52346. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52347. */
  52348. invertRefractionY: boolean;
  52349. private _linkRefractionWithTransparency;
  52350. /**
  52351. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52352. * Materials half opaque for instance using refraction could benefit from this control.
  52353. */
  52354. linkRefractionWithTransparency: boolean;
  52355. /**
  52356. * Defines the minimum thickness stored in the thickness map.
  52357. * If no thickness map is defined, this value will be used to simulate thickness.
  52358. */
  52359. minimumThickness: number;
  52360. /**
  52361. * Defines the maximum thickness stored in the thickness map.
  52362. */
  52363. maximumThickness: number;
  52364. /**
  52365. * Defines the volume tint of the material.
  52366. * This is used for both translucency and scattering.
  52367. */
  52368. tintColor: Color3;
  52369. /**
  52370. * Defines the distance at which the tint color should be found in the media.
  52371. * This is used for refraction only.
  52372. */
  52373. tintColorAtDistance: number;
  52374. /**
  52375. * Defines how far each channel transmit through the media.
  52376. * It is defined as a color to simplify it selection.
  52377. */
  52378. diffusionDistance: Color3;
  52379. private _useMaskFromThicknessTexture;
  52380. /**
  52381. * Stores the intensity of the different subsurface effects in the thickness texture.
  52382. * * the green channel is the translucency intensity.
  52383. * * the blue channel is the scattering intensity.
  52384. * * the alpha channel is the refraction intensity.
  52385. */
  52386. useMaskFromThicknessTexture: boolean;
  52387. /** @hidden */
  52388. private _internalMarkAllSubMeshesAsTexturesDirty;
  52389. /** @hidden */
  52390. _markAllSubMeshesAsTexturesDirty(): void;
  52391. /**
  52392. * Instantiate a new istance of sub surface configuration.
  52393. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52394. */
  52395. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52396. /**
  52397. * Gets wehter the submesh is ready to be used or not.
  52398. * @param defines the list of "defines" to update.
  52399. * @param scene defines the scene the material belongs to.
  52400. * @returns - boolean indicating that the submesh is ready or not.
  52401. */
  52402. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52403. /**
  52404. * Checks to see if a texture is used in the material.
  52405. * @param defines the list of "defines" to update.
  52406. * @param scene defines the scene to the material belongs to.
  52407. */
  52408. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52409. /**
  52410. * Binds the material data.
  52411. * @param uniformBuffer defines the Uniform buffer to fill in.
  52412. * @param scene defines the scene the material belongs to.
  52413. * @param engine defines the engine the material belongs to.
  52414. * @param isFrozen defines wether the material is frozen or not.
  52415. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52416. */
  52417. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52418. /**
  52419. * Unbinds the material from the mesh.
  52420. * @param activeEffect defines the effect that should be unbound from.
  52421. * @returns true if unbound, otherwise false
  52422. */
  52423. unbind(activeEffect: Effect): boolean;
  52424. /**
  52425. * Returns the texture used for refraction or null if none is used.
  52426. * @param scene defines the scene the material belongs to.
  52427. * @returns - Refraction texture if present. If no refraction texture and refraction
  52428. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52429. */
  52430. private _getRefractionTexture;
  52431. /**
  52432. * Returns true if alpha blending should be disabled.
  52433. */
  52434. get disableAlphaBlending(): boolean;
  52435. /**
  52436. * Fills the list of render target textures.
  52437. * @param renderTargets the list of render targets to update
  52438. */
  52439. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52440. /**
  52441. * Checks to see if a texture is used in the material.
  52442. * @param texture - Base texture to use.
  52443. * @returns - Boolean specifying if a texture is used in the material.
  52444. */
  52445. hasTexture(texture: BaseTexture): boolean;
  52446. /**
  52447. * Gets a boolean indicating that current material needs to register RTT
  52448. * @returns true if this uses a render target otherwise false.
  52449. */
  52450. hasRenderTargetTextures(): boolean;
  52451. /**
  52452. * Returns an array of the actively used textures.
  52453. * @param activeTextures Array of BaseTextures
  52454. */
  52455. getActiveTextures(activeTextures: BaseTexture[]): void;
  52456. /**
  52457. * Returns the animatable textures.
  52458. * @param animatables Array of animatable textures.
  52459. */
  52460. getAnimatables(animatables: IAnimatable[]): void;
  52461. /**
  52462. * Disposes the resources of the material.
  52463. * @param forceDisposeTextures - Forces the disposal of all textures.
  52464. */
  52465. dispose(forceDisposeTextures?: boolean): void;
  52466. /**
  52467. * Get the current class name of the texture useful for serialization or dynamic coding.
  52468. * @returns "PBRSubSurfaceConfiguration"
  52469. */
  52470. getClassName(): string;
  52471. /**
  52472. * Add fallbacks to the effect fallbacks list.
  52473. * @param defines defines the Base texture to use.
  52474. * @param fallbacks defines the current fallback list.
  52475. * @param currentRank defines the current fallback rank.
  52476. * @returns the new fallback rank.
  52477. */
  52478. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52479. /**
  52480. * Add the required uniforms to the current list.
  52481. * @param uniforms defines the current uniform list.
  52482. */
  52483. static AddUniforms(uniforms: string[]): void;
  52484. /**
  52485. * Add the required samplers to the current list.
  52486. * @param samplers defines the current sampler list.
  52487. */
  52488. static AddSamplers(samplers: string[]): void;
  52489. /**
  52490. * Add the required uniforms to the current buffer.
  52491. * @param uniformBuffer defines the current uniform buffer.
  52492. */
  52493. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52494. /**
  52495. * Makes a duplicate of the current configuration into another one.
  52496. * @param configuration define the config where to copy the info
  52497. */
  52498. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52499. /**
  52500. * Serializes this Sub Surface configuration.
  52501. * @returns - An object with the serialized config.
  52502. */
  52503. serialize(): any;
  52504. /**
  52505. * Parses a anisotropy Configuration from a serialized object.
  52506. * @param source - Serialized object.
  52507. * @param scene Defines the scene we are parsing for
  52508. * @param rootUrl Defines the rootUrl to load from
  52509. */
  52510. parse(source: any, scene: Scene, rootUrl: string): void;
  52511. }
  52512. }
  52513. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52514. /** @hidden */
  52515. export var pbrFragmentDeclaration: {
  52516. name: string;
  52517. shader: string;
  52518. };
  52519. }
  52520. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52521. /** @hidden */
  52522. export var pbrUboDeclaration: {
  52523. name: string;
  52524. shader: string;
  52525. };
  52526. }
  52527. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52528. /** @hidden */
  52529. export var pbrFragmentExtraDeclaration: {
  52530. name: string;
  52531. shader: string;
  52532. };
  52533. }
  52534. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52535. /** @hidden */
  52536. export var pbrFragmentSamplersDeclaration: {
  52537. name: string;
  52538. shader: string;
  52539. };
  52540. }
  52541. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52542. /** @hidden */
  52543. export var pbrHelperFunctions: {
  52544. name: string;
  52545. shader: string;
  52546. };
  52547. }
  52548. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52549. /** @hidden */
  52550. export var harmonicsFunctions: {
  52551. name: string;
  52552. shader: string;
  52553. };
  52554. }
  52555. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52556. /** @hidden */
  52557. export var pbrDirectLightingSetupFunctions: {
  52558. name: string;
  52559. shader: string;
  52560. };
  52561. }
  52562. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52563. /** @hidden */
  52564. export var pbrDirectLightingFalloffFunctions: {
  52565. name: string;
  52566. shader: string;
  52567. };
  52568. }
  52569. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52570. /** @hidden */
  52571. export var pbrBRDFFunctions: {
  52572. name: string;
  52573. shader: string;
  52574. };
  52575. }
  52576. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52577. /** @hidden */
  52578. export var pbrDirectLightingFunctions: {
  52579. name: string;
  52580. shader: string;
  52581. };
  52582. }
  52583. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52584. /** @hidden */
  52585. export var pbrIBLFunctions: {
  52586. name: string;
  52587. shader: string;
  52588. };
  52589. }
  52590. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52591. /** @hidden */
  52592. export var pbrDebug: {
  52593. name: string;
  52594. shader: string;
  52595. };
  52596. }
  52597. declare module "babylonjs/Shaders/pbr.fragment" {
  52598. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52599. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52600. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52601. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52602. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52603. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52604. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52605. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52606. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52607. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52608. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52609. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52610. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52611. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52612. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52613. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52614. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52615. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52616. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52617. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52618. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52619. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52620. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52621. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52622. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52623. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52624. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52625. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52626. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52627. /** @hidden */
  52628. export var pbrPixelShader: {
  52629. name: string;
  52630. shader: string;
  52631. };
  52632. }
  52633. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52634. /** @hidden */
  52635. export var pbrVertexDeclaration: {
  52636. name: string;
  52637. shader: string;
  52638. };
  52639. }
  52640. declare module "babylonjs/Shaders/pbr.vertex" {
  52641. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52642. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52643. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52644. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52645. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52646. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52647. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52648. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52649. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52650. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52651. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52652. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52653. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52654. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52655. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52656. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52657. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52658. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52659. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52660. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52661. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52662. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52663. /** @hidden */
  52664. export var pbrVertexShader: {
  52665. name: string;
  52666. shader: string;
  52667. };
  52668. }
  52669. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52670. import { Nullable } from "babylonjs/types";
  52671. import { Scene } from "babylonjs/scene";
  52672. import { Matrix } from "babylonjs/Maths/math.vector";
  52673. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52675. import { Mesh } from "babylonjs/Meshes/mesh";
  52676. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52677. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52678. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52679. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52680. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52681. import { Color3 } from "babylonjs/Maths/math.color";
  52682. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52683. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52684. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52685. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52686. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52687. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52688. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52689. import "babylonjs/Shaders/pbr.fragment";
  52690. import "babylonjs/Shaders/pbr.vertex";
  52691. /**
  52692. * Manages the defines for the PBR Material.
  52693. * @hidden
  52694. */
  52695. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52696. PBR: boolean;
  52697. MAINUV1: boolean;
  52698. MAINUV2: boolean;
  52699. UV1: boolean;
  52700. UV2: boolean;
  52701. ALBEDO: boolean;
  52702. ALBEDODIRECTUV: number;
  52703. VERTEXCOLOR: boolean;
  52704. AMBIENT: boolean;
  52705. AMBIENTDIRECTUV: number;
  52706. AMBIENTINGRAYSCALE: boolean;
  52707. OPACITY: boolean;
  52708. VERTEXALPHA: boolean;
  52709. OPACITYDIRECTUV: number;
  52710. OPACITYRGB: boolean;
  52711. ALPHATEST: boolean;
  52712. DEPTHPREPASS: boolean;
  52713. ALPHABLEND: boolean;
  52714. ALPHAFROMALBEDO: boolean;
  52715. ALPHATESTVALUE: string;
  52716. SPECULAROVERALPHA: boolean;
  52717. RADIANCEOVERALPHA: boolean;
  52718. ALPHAFRESNEL: boolean;
  52719. LINEARALPHAFRESNEL: boolean;
  52720. PREMULTIPLYALPHA: boolean;
  52721. EMISSIVE: boolean;
  52722. EMISSIVEDIRECTUV: number;
  52723. REFLECTIVITY: boolean;
  52724. REFLECTIVITYDIRECTUV: number;
  52725. SPECULARTERM: boolean;
  52726. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52727. MICROSURFACEAUTOMATIC: boolean;
  52728. LODBASEDMICROSFURACE: boolean;
  52729. MICROSURFACEMAP: boolean;
  52730. MICROSURFACEMAPDIRECTUV: number;
  52731. METALLICWORKFLOW: boolean;
  52732. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52733. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52734. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52735. AOSTOREINMETALMAPRED: boolean;
  52736. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52737. ENVIRONMENTBRDF: boolean;
  52738. ENVIRONMENTBRDF_RGBD: boolean;
  52739. NORMAL: boolean;
  52740. TANGENT: boolean;
  52741. BUMP: boolean;
  52742. BUMPDIRECTUV: number;
  52743. OBJECTSPACE_NORMALMAP: boolean;
  52744. PARALLAX: boolean;
  52745. PARALLAXOCCLUSION: boolean;
  52746. NORMALXYSCALE: boolean;
  52747. LIGHTMAP: boolean;
  52748. LIGHTMAPDIRECTUV: number;
  52749. USELIGHTMAPASSHADOWMAP: boolean;
  52750. GAMMALIGHTMAP: boolean;
  52751. RGBDLIGHTMAP: boolean;
  52752. REFLECTION: boolean;
  52753. REFLECTIONMAP_3D: boolean;
  52754. REFLECTIONMAP_SPHERICAL: boolean;
  52755. REFLECTIONMAP_PLANAR: boolean;
  52756. REFLECTIONMAP_CUBIC: boolean;
  52757. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  52758. REFLECTIONMAP_PROJECTION: boolean;
  52759. REFLECTIONMAP_SKYBOX: boolean;
  52760. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  52761. REFLECTIONMAP_EXPLICIT: boolean;
  52762. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  52763. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  52764. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  52765. INVERTCUBICMAP: boolean;
  52766. USESPHERICALFROMREFLECTIONMAP: boolean;
  52767. USEIRRADIANCEMAP: boolean;
  52768. SPHERICAL_HARMONICS: boolean;
  52769. USESPHERICALINVERTEX: boolean;
  52770. REFLECTIONMAP_OPPOSITEZ: boolean;
  52771. LODINREFLECTIONALPHA: boolean;
  52772. GAMMAREFLECTION: boolean;
  52773. RGBDREFLECTION: boolean;
  52774. LINEARSPECULARREFLECTION: boolean;
  52775. RADIANCEOCCLUSION: boolean;
  52776. HORIZONOCCLUSION: boolean;
  52777. INSTANCES: boolean;
  52778. NUM_BONE_INFLUENCERS: number;
  52779. BonesPerMesh: number;
  52780. BONETEXTURE: boolean;
  52781. NONUNIFORMSCALING: boolean;
  52782. MORPHTARGETS: boolean;
  52783. MORPHTARGETS_NORMAL: boolean;
  52784. MORPHTARGETS_TANGENT: boolean;
  52785. MORPHTARGETS_UV: boolean;
  52786. NUM_MORPH_INFLUENCERS: number;
  52787. IMAGEPROCESSING: boolean;
  52788. VIGNETTE: boolean;
  52789. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52790. VIGNETTEBLENDMODEOPAQUE: boolean;
  52791. TONEMAPPING: boolean;
  52792. TONEMAPPING_ACES: boolean;
  52793. CONTRAST: boolean;
  52794. COLORCURVES: boolean;
  52795. COLORGRADING: boolean;
  52796. COLORGRADING3D: boolean;
  52797. SAMPLER3DGREENDEPTH: boolean;
  52798. SAMPLER3DBGRMAP: boolean;
  52799. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52800. EXPOSURE: boolean;
  52801. MULTIVIEW: boolean;
  52802. USEPHYSICALLIGHTFALLOFF: boolean;
  52803. USEGLTFLIGHTFALLOFF: boolean;
  52804. TWOSIDEDLIGHTING: boolean;
  52805. SHADOWFLOAT: boolean;
  52806. CLIPPLANE: boolean;
  52807. CLIPPLANE2: boolean;
  52808. CLIPPLANE3: boolean;
  52809. CLIPPLANE4: boolean;
  52810. CLIPPLANE5: boolean;
  52811. CLIPPLANE6: boolean;
  52812. POINTSIZE: boolean;
  52813. FOG: boolean;
  52814. LOGARITHMICDEPTH: boolean;
  52815. FORCENORMALFORWARD: boolean;
  52816. SPECULARAA: boolean;
  52817. CLEARCOAT: boolean;
  52818. CLEARCOAT_DEFAULTIOR: boolean;
  52819. CLEARCOAT_TEXTURE: boolean;
  52820. CLEARCOAT_TEXTUREDIRECTUV: number;
  52821. CLEARCOAT_BUMP: boolean;
  52822. CLEARCOAT_BUMPDIRECTUV: number;
  52823. CLEARCOAT_TINT: boolean;
  52824. CLEARCOAT_TINT_TEXTURE: boolean;
  52825. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52826. ANISOTROPIC: boolean;
  52827. ANISOTROPIC_TEXTURE: boolean;
  52828. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52829. BRDF_V_HEIGHT_CORRELATED: boolean;
  52830. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52831. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52832. SHEEN: boolean;
  52833. SHEEN_TEXTURE: boolean;
  52834. SHEEN_TEXTUREDIRECTUV: number;
  52835. SHEEN_LINKWITHALBEDO: boolean;
  52836. SUBSURFACE: boolean;
  52837. SS_REFRACTION: boolean;
  52838. SS_TRANSLUCENCY: boolean;
  52839. SS_SCATERRING: boolean;
  52840. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52841. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52842. SS_REFRACTIONMAP_3D: boolean;
  52843. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52844. SS_LODINREFRACTIONALPHA: boolean;
  52845. SS_GAMMAREFRACTION: boolean;
  52846. SS_RGBDREFRACTION: boolean;
  52847. SS_LINEARSPECULARREFRACTION: boolean;
  52848. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52849. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52850. UNLIT: boolean;
  52851. DEBUGMODE: number;
  52852. /**
  52853. * Initializes the PBR Material defines.
  52854. */
  52855. constructor();
  52856. /**
  52857. * Resets the PBR Material defines.
  52858. */
  52859. reset(): void;
  52860. }
  52861. /**
  52862. * The Physically based material base class of BJS.
  52863. *
  52864. * This offers the main features of a standard PBR material.
  52865. * For more information, please refer to the documentation :
  52866. * https://doc.babylonjs.com/how_to/physically_based_rendering
  52867. */
  52868. export abstract class PBRBaseMaterial extends PushMaterial {
  52869. /**
  52870. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52871. */
  52872. static readonly PBRMATERIAL_OPAQUE: number;
  52873. /**
  52874. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52875. */
  52876. static readonly PBRMATERIAL_ALPHATEST: number;
  52877. /**
  52878. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52879. */
  52880. static readonly PBRMATERIAL_ALPHABLEND: number;
  52881. /**
  52882. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52883. * They are also discarded below the alpha cutoff threshold to improve performances.
  52884. */
  52885. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  52886. /**
  52887. * Defines the default value of how much AO map is occluding the analytical lights
  52888. * (point spot...).
  52889. */
  52890. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  52891. /**
  52892. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  52893. */
  52894. static readonly LIGHTFALLOFF_PHYSICAL: number;
  52895. /**
  52896. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  52897. * to enhance interoperability with other engines.
  52898. */
  52899. static readonly LIGHTFALLOFF_GLTF: number;
  52900. /**
  52901. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  52902. * to enhance interoperability with other materials.
  52903. */
  52904. static readonly LIGHTFALLOFF_STANDARD: number;
  52905. /**
  52906. * Intensity of the direct lights e.g. the four lights available in your scene.
  52907. * This impacts both the direct diffuse and specular highlights.
  52908. */
  52909. protected _directIntensity: number;
  52910. /**
  52911. * Intensity of the emissive part of the material.
  52912. * This helps controlling the emissive effect without modifying the emissive color.
  52913. */
  52914. protected _emissiveIntensity: number;
  52915. /**
  52916. * Intensity of the environment e.g. how much the environment will light the object
  52917. * either through harmonics for rough material or through the refelction for shiny ones.
  52918. */
  52919. protected _environmentIntensity: number;
  52920. /**
  52921. * This is a special control allowing the reduction of the specular highlights coming from the
  52922. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52923. */
  52924. protected _specularIntensity: number;
  52925. /**
  52926. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  52927. */
  52928. private _lightingInfos;
  52929. /**
  52930. * Debug Control allowing disabling the bump map on this material.
  52931. */
  52932. protected _disableBumpMap: boolean;
  52933. /**
  52934. * AKA Diffuse Texture in standard nomenclature.
  52935. */
  52936. protected _albedoTexture: Nullable<BaseTexture>;
  52937. /**
  52938. * AKA Occlusion Texture in other nomenclature.
  52939. */
  52940. protected _ambientTexture: Nullable<BaseTexture>;
  52941. /**
  52942. * AKA Occlusion Texture Intensity in other nomenclature.
  52943. */
  52944. protected _ambientTextureStrength: number;
  52945. /**
  52946. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52947. * 1 means it completely occludes it
  52948. * 0 mean it has no impact
  52949. */
  52950. protected _ambientTextureImpactOnAnalyticalLights: number;
  52951. /**
  52952. * Stores the alpha values in a texture.
  52953. */
  52954. protected _opacityTexture: Nullable<BaseTexture>;
  52955. /**
  52956. * Stores the reflection values in a texture.
  52957. */
  52958. protected _reflectionTexture: Nullable<BaseTexture>;
  52959. /**
  52960. * Stores the emissive values in a texture.
  52961. */
  52962. protected _emissiveTexture: Nullable<BaseTexture>;
  52963. /**
  52964. * AKA Specular texture in other nomenclature.
  52965. */
  52966. protected _reflectivityTexture: Nullable<BaseTexture>;
  52967. /**
  52968. * Used to switch from specular/glossiness to metallic/roughness workflow.
  52969. */
  52970. protected _metallicTexture: Nullable<BaseTexture>;
  52971. /**
  52972. * Specifies the metallic scalar of the metallic/roughness workflow.
  52973. * Can also be used to scale the metalness values of the metallic texture.
  52974. */
  52975. protected _metallic: Nullable<number>;
  52976. /**
  52977. * Specifies the roughness scalar of the metallic/roughness workflow.
  52978. * Can also be used to scale the roughness values of the metallic texture.
  52979. */
  52980. protected _roughness: Nullable<number>;
  52981. /**
  52982. * Specifies the an F0 factor to help configuring the material F0.
  52983. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  52984. * to 0.5 the previously hard coded value stays the same.
  52985. * Can also be used to scale the F0 values of the metallic texture.
  52986. */
  52987. protected _metallicF0Factor: number;
  52988. /**
  52989. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  52990. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  52991. * your expectation as it multiplies with the texture data.
  52992. */
  52993. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  52994. /**
  52995. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  52996. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  52997. */
  52998. protected _microSurfaceTexture: Nullable<BaseTexture>;
  52999. /**
  53000. * Stores surface normal data used to displace a mesh in a texture.
  53001. */
  53002. protected _bumpTexture: Nullable<BaseTexture>;
  53003. /**
  53004. * Stores the pre-calculated light information of a mesh in a texture.
  53005. */
  53006. protected _lightmapTexture: Nullable<BaseTexture>;
  53007. /**
  53008. * The color of a material in ambient lighting.
  53009. */
  53010. protected _ambientColor: Color3;
  53011. /**
  53012. * AKA Diffuse Color in other nomenclature.
  53013. */
  53014. protected _albedoColor: Color3;
  53015. /**
  53016. * AKA Specular Color in other nomenclature.
  53017. */
  53018. protected _reflectivityColor: Color3;
  53019. /**
  53020. * The color applied when light is reflected from a material.
  53021. */
  53022. protected _reflectionColor: Color3;
  53023. /**
  53024. * The color applied when light is emitted from a material.
  53025. */
  53026. protected _emissiveColor: Color3;
  53027. /**
  53028. * AKA Glossiness in other nomenclature.
  53029. */
  53030. protected _microSurface: number;
  53031. /**
  53032. * Specifies that the material will use the light map as a show map.
  53033. */
  53034. protected _useLightmapAsShadowmap: boolean;
  53035. /**
  53036. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53037. * makes the reflect vector face the model (under horizon).
  53038. */
  53039. protected _useHorizonOcclusion: boolean;
  53040. /**
  53041. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53042. * too much the area relying on ambient texture to define their ambient occlusion.
  53043. */
  53044. protected _useRadianceOcclusion: boolean;
  53045. /**
  53046. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53047. */
  53048. protected _useAlphaFromAlbedoTexture: boolean;
  53049. /**
  53050. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53051. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53052. */
  53053. protected _useSpecularOverAlpha: boolean;
  53054. /**
  53055. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53056. */
  53057. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53058. /**
  53059. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53060. */
  53061. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53062. /**
  53063. * Specifies if the metallic texture contains the roughness information in its green channel.
  53064. */
  53065. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53066. /**
  53067. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53068. */
  53069. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53070. /**
  53071. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53072. */
  53073. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53074. /**
  53075. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53076. */
  53077. protected _useAmbientInGrayScale: boolean;
  53078. /**
  53079. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53080. * The material will try to infer what glossiness each pixel should be.
  53081. */
  53082. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53083. /**
  53084. * Defines the falloff type used in this material.
  53085. * It by default is Physical.
  53086. */
  53087. protected _lightFalloff: number;
  53088. /**
  53089. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53090. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53091. */
  53092. protected _useRadianceOverAlpha: boolean;
  53093. /**
  53094. * Allows using an object space normal map (instead of tangent space).
  53095. */
  53096. protected _useObjectSpaceNormalMap: boolean;
  53097. /**
  53098. * Allows using the bump map in parallax mode.
  53099. */
  53100. protected _useParallax: boolean;
  53101. /**
  53102. * Allows using the bump map in parallax occlusion mode.
  53103. */
  53104. protected _useParallaxOcclusion: boolean;
  53105. /**
  53106. * Controls the scale bias of the parallax mode.
  53107. */
  53108. protected _parallaxScaleBias: number;
  53109. /**
  53110. * If sets to true, disables all the lights affecting the material.
  53111. */
  53112. protected _disableLighting: boolean;
  53113. /**
  53114. * Number of Simultaneous lights allowed on the material.
  53115. */
  53116. protected _maxSimultaneousLights: number;
  53117. /**
  53118. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53119. */
  53120. protected _invertNormalMapX: boolean;
  53121. /**
  53122. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53123. */
  53124. protected _invertNormalMapY: boolean;
  53125. /**
  53126. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53127. */
  53128. protected _twoSidedLighting: boolean;
  53129. /**
  53130. * Defines the alpha limits in alpha test mode.
  53131. */
  53132. protected _alphaCutOff: number;
  53133. /**
  53134. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53135. */
  53136. protected _forceAlphaTest: boolean;
  53137. /**
  53138. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53139. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53140. */
  53141. protected _useAlphaFresnel: boolean;
  53142. /**
  53143. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53144. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53145. */
  53146. protected _useLinearAlphaFresnel: boolean;
  53147. /**
  53148. * The transparency mode of the material.
  53149. */
  53150. protected _transparencyMode: Nullable<number>;
  53151. /**
  53152. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53153. * from cos thetav and roughness:
  53154. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53155. */
  53156. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53157. /**
  53158. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53159. */
  53160. protected _forceIrradianceInFragment: boolean;
  53161. /**
  53162. * Force normal to face away from face.
  53163. */
  53164. protected _forceNormalForward: boolean;
  53165. /**
  53166. * Enables specular anti aliasing in the PBR shader.
  53167. * It will both interacts on the Geometry for analytical and IBL lighting.
  53168. * It also prefilter the roughness map based on the bump values.
  53169. */
  53170. protected _enableSpecularAntiAliasing: boolean;
  53171. /**
  53172. * Default configuration related to image processing available in the PBR Material.
  53173. */
  53174. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53175. /**
  53176. * Keep track of the image processing observer to allow dispose and replace.
  53177. */
  53178. private _imageProcessingObserver;
  53179. /**
  53180. * Attaches a new image processing configuration to the PBR Material.
  53181. * @param configuration
  53182. */
  53183. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53184. /**
  53185. * Stores the available render targets.
  53186. */
  53187. private _renderTargets;
  53188. /**
  53189. * Sets the global ambient color for the material used in lighting calculations.
  53190. */
  53191. private _globalAmbientColor;
  53192. /**
  53193. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53194. */
  53195. private _useLogarithmicDepth;
  53196. /**
  53197. * If set to true, no lighting calculations will be applied.
  53198. */
  53199. private _unlit;
  53200. private _debugMode;
  53201. /**
  53202. * @hidden
  53203. * This is reserved for the inspector.
  53204. * Defines the material debug mode.
  53205. * It helps seeing only some components of the material while troubleshooting.
  53206. */
  53207. debugMode: number;
  53208. /**
  53209. * @hidden
  53210. * This is reserved for the inspector.
  53211. * Specify from where on screen the debug mode should start.
  53212. * The value goes from -1 (full screen) to 1 (not visible)
  53213. * It helps with side by side comparison against the final render
  53214. * This defaults to -1
  53215. */
  53216. private debugLimit;
  53217. /**
  53218. * @hidden
  53219. * This is reserved for the inspector.
  53220. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53221. * You can use the factor to better multiply the final value.
  53222. */
  53223. private debugFactor;
  53224. /**
  53225. * Defines the clear coat layer parameters for the material.
  53226. */
  53227. readonly clearCoat: PBRClearCoatConfiguration;
  53228. /**
  53229. * Defines the anisotropic parameters for the material.
  53230. */
  53231. readonly anisotropy: PBRAnisotropicConfiguration;
  53232. /**
  53233. * Defines the BRDF parameters for the material.
  53234. */
  53235. readonly brdf: PBRBRDFConfiguration;
  53236. /**
  53237. * Defines the Sheen parameters for the material.
  53238. */
  53239. readonly sheen: PBRSheenConfiguration;
  53240. /**
  53241. * Defines the SubSurface parameters for the material.
  53242. */
  53243. readonly subSurface: PBRSubSurfaceConfiguration;
  53244. /**
  53245. * Custom callback helping to override the default shader used in the material.
  53246. */
  53247. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53248. protected _rebuildInParallel: boolean;
  53249. /**
  53250. * Instantiates a new PBRMaterial instance.
  53251. *
  53252. * @param name The material name
  53253. * @param scene The scene the material will be use in.
  53254. */
  53255. constructor(name: string, scene: Scene);
  53256. /**
  53257. * Gets a boolean indicating that current material needs to register RTT
  53258. */
  53259. get hasRenderTargetTextures(): boolean;
  53260. /**
  53261. * Gets the name of the material class.
  53262. */
  53263. getClassName(): string;
  53264. /**
  53265. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53266. */
  53267. get useLogarithmicDepth(): boolean;
  53268. /**
  53269. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53270. */
  53271. set useLogarithmicDepth(value: boolean);
  53272. /**
  53273. * Gets the current transparency mode.
  53274. */
  53275. get transparencyMode(): Nullable<number>;
  53276. /**
  53277. * Sets the transparency mode of the material.
  53278. *
  53279. * | Value | Type | Description |
  53280. * | ----- | ----------------------------------- | ----------- |
  53281. * | 0 | OPAQUE | |
  53282. * | 1 | ALPHATEST | |
  53283. * | 2 | ALPHABLEND | |
  53284. * | 3 | ALPHATESTANDBLEND | |
  53285. *
  53286. */
  53287. set transparencyMode(value: Nullable<number>);
  53288. /**
  53289. * Returns true if alpha blending should be disabled.
  53290. */
  53291. private get _disableAlphaBlending();
  53292. /**
  53293. * Specifies whether or not this material should be rendered in alpha blend mode.
  53294. */
  53295. needAlphaBlending(): boolean;
  53296. /**
  53297. * Specifies if the mesh will require alpha blending.
  53298. * @param mesh - BJS mesh.
  53299. */
  53300. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53301. /**
  53302. * Specifies whether or not this material should be rendered in alpha test mode.
  53303. */
  53304. needAlphaTesting(): boolean;
  53305. /**
  53306. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53307. */
  53308. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53309. /**
  53310. * Gets the texture used for the alpha test.
  53311. */
  53312. getAlphaTestTexture(): Nullable<BaseTexture>;
  53313. /**
  53314. * Specifies that the submesh is ready to be used.
  53315. * @param mesh - BJS mesh.
  53316. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53317. * @param useInstances - Specifies that instances should be used.
  53318. * @returns - boolean indicating that the submesh is ready or not.
  53319. */
  53320. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53321. /**
  53322. * Specifies if the material uses metallic roughness workflow.
  53323. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53324. */
  53325. isMetallicWorkflow(): boolean;
  53326. private _prepareEffect;
  53327. private _prepareDefines;
  53328. /**
  53329. * Force shader compilation
  53330. */
  53331. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53332. /**
  53333. * Initializes the uniform buffer layout for the shader.
  53334. */
  53335. buildUniformLayout(): void;
  53336. /**
  53337. * Unbinds the material from the mesh
  53338. */
  53339. unbind(): void;
  53340. /**
  53341. * Binds the submesh data.
  53342. * @param world - The world matrix.
  53343. * @param mesh - The BJS mesh.
  53344. * @param subMesh - A submesh of the BJS mesh.
  53345. */
  53346. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53347. /**
  53348. * Returns the animatable textures.
  53349. * @returns - Array of animatable textures.
  53350. */
  53351. getAnimatables(): IAnimatable[];
  53352. /**
  53353. * Returns the texture used for reflections.
  53354. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53355. */
  53356. private _getReflectionTexture;
  53357. /**
  53358. * Returns an array of the actively used textures.
  53359. * @returns - Array of BaseTextures
  53360. */
  53361. getActiveTextures(): BaseTexture[];
  53362. /**
  53363. * Checks to see if a texture is used in the material.
  53364. * @param texture - Base texture to use.
  53365. * @returns - Boolean specifying if a texture is used in the material.
  53366. */
  53367. hasTexture(texture: BaseTexture): boolean;
  53368. /**
  53369. * Disposes the resources of the material.
  53370. * @param forceDisposeEffect - Forces the disposal of effects.
  53371. * @param forceDisposeTextures - Forces the disposal of all textures.
  53372. */
  53373. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53374. }
  53375. }
  53376. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53377. import { Nullable } from "babylonjs/types";
  53378. import { Scene } from "babylonjs/scene";
  53379. import { Color3 } from "babylonjs/Maths/math.color";
  53380. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53381. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53383. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53384. /**
  53385. * The Physically based material of BJS.
  53386. *
  53387. * This offers the main features of a standard PBR material.
  53388. * For more information, please refer to the documentation :
  53389. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53390. */
  53391. export class PBRMaterial extends PBRBaseMaterial {
  53392. /**
  53393. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53394. */
  53395. static readonly PBRMATERIAL_OPAQUE: number;
  53396. /**
  53397. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53398. */
  53399. static readonly PBRMATERIAL_ALPHATEST: number;
  53400. /**
  53401. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53402. */
  53403. static readonly PBRMATERIAL_ALPHABLEND: number;
  53404. /**
  53405. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53406. * They are also discarded below the alpha cutoff threshold to improve performances.
  53407. */
  53408. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53409. /**
  53410. * Defines the default value of how much AO map is occluding the analytical lights
  53411. * (point spot...).
  53412. */
  53413. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53414. /**
  53415. * Intensity of the direct lights e.g. the four lights available in your scene.
  53416. * This impacts both the direct diffuse and specular highlights.
  53417. */
  53418. directIntensity: number;
  53419. /**
  53420. * Intensity of the emissive part of the material.
  53421. * This helps controlling the emissive effect without modifying the emissive color.
  53422. */
  53423. emissiveIntensity: number;
  53424. /**
  53425. * Intensity of the environment e.g. how much the environment will light the object
  53426. * either through harmonics for rough material or through the refelction for shiny ones.
  53427. */
  53428. environmentIntensity: number;
  53429. /**
  53430. * This is a special control allowing the reduction of the specular highlights coming from the
  53431. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53432. */
  53433. specularIntensity: number;
  53434. /**
  53435. * Debug Control allowing disabling the bump map on this material.
  53436. */
  53437. disableBumpMap: boolean;
  53438. /**
  53439. * AKA Diffuse Texture in standard nomenclature.
  53440. */
  53441. albedoTexture: BaseTexture;
  53442. /**
  53443. * AKA Occlusion Texture in other nomenclature.
  53444. */
  53445. ambientTexture: BaseTexture;
  53446. /**
  53447. * AKA Occlusion Texture Intensity in other nomenclature.
  53448. */
  53449. ambientTextureStrength: number;
  53450. /**
  53451. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53452. * 1 means it completely occludes it
  53453. * 0 mean it has no impact
  53454. */
  53455. ambientTextureImpactOnAnalyticalLights: number;
  53456. /**
  53457. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53458. */
  53459. opacityTexture: BaseTexture;
  53460. /**
  53461. * Stores the reflection values in a texture.
  53462. */
  53463. reflectionTexture: Nullable<BaseTexture>;
  53464. /**
  53465. * Stores the emissive values in a texture.
  53466. */
  53467. emissiveTexture: BaseTexture;
  53468. /**
  53469. * AKA Specular texture in other nomenclature.
  53470. */
  53471. reflectivityTexture: BaseTexture;
  53472. /**
  53473. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53474. */
  53475. metallicTexture: BaseTexture;
  53476. /**
  53477. * Specifies the metallic scalar of the metallic/roughness workflow.
  53478. * Can also be used to scale the metalness values of the metallic texture.
  53479. */
  53480. metallic: Nullable<number>;
  53481. /**
  53482. * Specifies the roughness scalar of the metallic/roughness workflow.
  53483. * Can also be used to scale the roughness values of the metallic texture.
  53484. */
  53485. roughness: Nullable<number>;
  53486. /**
  53487. * Specifies the an F0 factor to help configuring the material F0.
  53488. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53489. * to 0.5 the previously hard coded value stays the same.
  53490. * Can also be used to scale the F0 values of the metallic texture.
  53491. */
  53492. metallicF0Factor: number;
  53493. /**
  53494. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53495. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53496. * your expectation as it multiplies with the texture data.
  53497. */
  53498. useMetallicF0FactorFromMetallicTexture: boolean;
  53499. /**
  53500. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53501. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53502. */
  53503. microSurfaceTexture: BaseTexture;
  53504. /**
  53505. * Stores surface normal data used to displace a mesh in a texture.
  53506. */
  53507. bumpTexture: BaseTexture;
  53508. /**
  53509. * Stores the pre-calculated light information of a mesh in a texture.
  53510. */
  53511. lightmapTexture: BaseTexture;
  53512. /**
  53513. * Stores the refracted light information in a texture.
  53514. */
  53515. get refractionTexture(): Nullable<BaseTexture>;
  53516. set refractionTexture(value: Nullable<BaseTexture>);
  53517. /**
  53518. * The color of a material in ambient lighting.
  53519. */
  53520. ambientColor: Color3;
  53521. /**
  53522. * AKA Diffuse Color in other nomenclature.
  53523. */
  53524. albedoColor: Color3;
  53525. /**
  53526. * AKA Specular Color in other nomenclature.
  53527. */
  53528. reflectivityColor: Color3;
  53529. /**
  53530. * The color reflected from the material.
  53531. */
  53532. reflectionColor: Color3;
  53533. /**
  53534. * The color emitted from the material.
  53535. */
  53536. emissiveColor: Color3;
  53537. /**
  53538. * AKA Glossiness in other nomenclature.
  53539. */
  53540. microSurface: number;
  53541. /**
  53542. * source material index of refraction (IOR)' / 'destination material IOR.
  53543. */
  53544. get indexOfRefraction(): number;
  53545. set indexOfRefraction(value: number);
  53546. /**
  53547. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53548. */
  53549. get invertRefractionY(): boolean;
  53550. set invertRefractionY(value: boolean);
  53551. /**
  53552. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53553. * Materials half opaque for instance using refraction could benefit from this control.
  53554. */
  53555. get linkRefractionWithTransparency(): boolean;
  53556. set linkRefractionWithTransparency(value: boolean);
  53557. /**
  53558. * If true, the light map contains occlusion information instead of lighting info.
  53559. */
  53560. useLightmapAsShadowmap: boolean;
  53561. /**
  53562. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53563. */
  53564. useAlphaFromAlbedoTexture: boolean;
  53565. /**
  53566. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53567. */
  53568. forceAlphaTest: boolean;
  53569. /**
  53570. * Defines the alpha limits in alpha test mode.
  53571. */
  53572. alphaCutOff: number;
  53573. /**
  53574. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53575. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53576. */
  53577. useSpecularOverAlpha: boolean;
  53578. /**
  53579. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53580. */
  53581. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53582. /**
  53583. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53584. */
  53585. useRoughnessFromMetallicTextureAlpha: boolean;
  53586. /**
  53587. * Specifies if the metallic texture contains the roughness information in its green channel.
  53588. */
  53589. useRoughnessFromMetallicTextureGreen: boolean;
  53590. /**
  53591. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53592. */
  53593. useMetallnessFromMetallicTextureBlue: boolean;
  53594. /**
  53595. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53596. */
  53597. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53598. /**
  53599. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53600. */
  53601. useAmbientInGrayScale: boolean;
  53602. /**
  53603. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53604. * The material will try to infer what glossiness each pixel should be.
  53605. */
  53606. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53607. /**
  53608. * BJS is using an harcoded light falloff based on a manually sets up range.
  53609. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53610. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53611. */
  53612. get usePhysicalLightFalloff(): boolean;
  53613. /**
  53614. * BJS is using an harcoded light falloff based on a manually sets up range.
  53615. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53616. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53617. */
  53618. set usePhysicalLightFalloff(value: boolean);
  53619. /**
  53620. * In order to support the falloff compatibility with gltf, a special mode has been added
  53621. * to reproduce the gltf light falloff.
  53622. */
  53623. get useGLTFLightFalloff(): boolean;
  53624. /**
  53625. * In order to support the falloff compatibility with gltf, a special mode has been added
  53626. * to reproduce the gltf light falloff.
  53627. */
  53628. set useGLTFLightFalloff(value: boolean);
  53629. /**
  53630. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53631. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53632. */
  53633. useRadianceOverAlpha: boolean;
  53634. /**
  53635. * Allows using an object space normal map (instead of tangent space).
  53636. */
  53637. useObjectSpaceNormalMap: boolean;
  53638. /**
  53639. * Allows using the bump map in parallax mode.
  53640. */
  53641. useParallax: boolean;
  53642. /**
  53643. * Allows using the bump map in parallax occlusion mode.
  53644. */
  53645. useParallaxOcclusion: boolean;
  53646. /**
  53647. * Controls the scale bias of the parallax mode.
  53648. */
  53649. parallaxScaleBias: number;
  53650. /**
  53651. * If sets to true, disables all the lights affecting the material.
  53652. */
  53653. disableLighting: boolean;
  53654. /**
  53655. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53656. */
  53657. forceIrradianceInFragment: boolean;
  53658. /**
  53659. * Number of Simultaneous lights allowed on the material.
  53660. */
  53661. maxSimultaneousLights: number;
  53662. /**
  53663. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53664. */
  53665. invertNormalMapX: boolean;
  53666. /**
  53667. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53668. */
  53669. invertNormalMapY: boolean;
  53670. /**
  53671. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53672. */
  53673. twoSidedLighting: boolean;
  53674. /**
  53675. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53676. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53677. */
  53678. useAlphaFresnel: boolean;
  53679. /**
  53680. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53681. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53682. */
  53683. useLinearAlphaFresnel: boolean;
  53684. /**
  53685. * Let user defines the brdf lookup texture used for IBL.
  53686. * A default 8bit version is embedded but you could point at :
  53687. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53688. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53689. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53690. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53691. */
  53692. environmentBRDFTexture: Nullable<BaseTexture>;
  53693. /**
  53694. * Force normal to face away from face.
  53695. */
  53696. forceNormalForward: boolean;
  53697. /**
  53698. * Enables specular anti aliasing in the PBR shader.
  53699. * It will both interacts on the Geometry for analytical and IBL lighting.
  53700. * It also prefilter the roughness map based on the bump values.
  53701. */
  53702. enableSpecularAntiAliasing: boolean;
  53703. /**
  53704. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53705. * makes the reflect vector face the model (under horizon).
  53706. */
  53707. useHorizonOcclusion: boolean;
  53708. /**
  53709. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53710. * too much the area relying on ambient texture to define their ambient occlusion.
  53711. */
  53712. useRadianceOcclusion: boolean;
  53713. /**
  53714. * If set to true, no lighting calculations will be applied.
  53715. */
  53716. unlit: boolean;
  53717. /**
  53718. * Gets the image processing configuration used either in this material.
  53719. */
  53720. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53721. /**
  53722. * Sets the Default image processing configuration used either in the this material.
  53723. *
  53724. * If sets to null, the scene one is in use.
  53725. */
  53726. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53727. /**
  53728. * Gets wether the color curves effect is enabled.
  53729. */
  53730. get cameraColorCurvesEnabled(): boolean;
  53731. /**
  53732. * Sets wether the color curves effect is enabled.
  53733. */
  53734. set cameraColorCurvesEnabled(value: boolean);
  53735. /**
  53736. * Gets wether the color grading effect is enabled.
  53737. */
  53738. get cameraColorGradingEnabled(): boolean;
  53739. /**
  53740. * Gets wether the color grading effect is enabled.
  53741. */
  53742. set cameraColorGradingEnabled(value: boolean);
  53743. /**
  53744. * Gets wether tonemapping is enabled or not.
  53745. */
  53746. get cameraToneMappingEnabled(): boolean;
  53747. /**
  53748. * Sets wether tonemapping is enabled or not
  53749. */
  53750. set cameraToneMappingEnabled(value: boolean);
  53751. /**
  53752. * The camera exposure used on this material.
  53753. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53754. * This corresponds to a photographic exposure.
  53755. */
  53756. get cameraExposure(): number;
  53757. /**
  53758. * The camera exposure used on this material.
  53759. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53760. * This corresponds to a photographic exposure.
  53761. */
  53762. set cameraExposure(value: number);
  53763. /**
  53764. * Gets The camera contrast used on this material.
  53765. */
  53766. get cameraContrast(): number;
  53767. /**
  53768. * Sets The camera contrast used on this material.
  53769. */
  53770. set cameraContrast(value: number);
  53771. /**
  53772. * Gets the Color Grading 2D Lookup Texture.
  53773. */
  53774. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53775. /**
  53776. * Sets the Color Grading 2D Lookup Texture.
  53777. */
  53778. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53779. /**
  53780. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53781. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53782. * 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;
  53783. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53784. */
  53785. get cameraColorCurves(): Nullable<ColorCurves>;
  53786. /**
  53787. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53788. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53789. * 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;
  53790. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53791. */
  53792. set cameraColorCurves(value: Nullable<ColorCurves>);
  53793. /**
  53794. * Instantiates a new PBRMaterial instance.
  53795. *
  53796. * @param name The material name
  53797. * @param scene The scene the material will be use in.
  53798. */
  53799. constructor(name: string, scene: Scene);
  53800. /**
  53801. * Returns the name of this material class.
  53802. */
  53803. getClassName(): string;
  53804. /**
  53805. * Makes a duplicate of the current material.
  53806. * @param name - name to use for the new material.
  53807. */
  53808. clone(name: string): PBRMaterial;
  53809. /**
  53810. * Serializes this PBR Material.
  53811. * @returns - An object with the serialized material.
  53812. */
  53813. serialize(): any;
  53814. /**
  53815. * Parses a PBR Material from a serialized object.
  53816. * @param source - Serialized object.
  53817. * @param scene - BJS scene instance.
  53818. * @param rootUrl - url for the scene object
  53819. * @returns - PBRMaterial
  53820. */
  53821. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  53822. }
  53823. }
  53824. declare module "babylonjs/Misc/dds" {
  53825. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53826. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53827. import { Nullable } from "babylonjs/types";
  53828. import { Scene } from "babylonjs/scene";
  53829. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  53830. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  53831. /**
  53832. * Direct draw surface info
  53833. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  53834. */
  53835. export interface DDSInfo {
  53836. /**
  53837. * Width of the texture
  53838. */
  53839. width: number;
  53840. /**
  53841. * Width of the texture
  53842. */
  53843. height: number;
  53844. /**
  53845. * Number of Mipmaps for the texture
  53846. * @see https://en.wikipedia.org/wiki/Mipmap
  53847. */
  53848. mipmapCount: number;
  53849. /**
  53850. * If the textures format is a known fourCC format
  53851. * @see https://www.fourcc.org/
  53852. */
  53853. isFourCC: boolean;
  53854. /**
  53855. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  53856. */
  53857. isRGB: boolean;
  53858. /**
  53859. * If the texture is a lumincance format
  53860. */
  53861. isLuminance: boolean;
  53862. /**
  53863. * If this is a cube texture
  53864. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  53865. */
  53866. isCube: boolean;
  53867. /**
  53868. * If the texture is a compressed format eg. FOURCC_DXT1
  53869. */
  53870. isCompressed: boolean;
  53871. /**
  53872. * The dxgiFormat of the texture
  53873. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  53874. */
  53875. dxgiFormat: number;
  53876. /**
  53877. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  53878. */
  53879. textureType: number;
  53880. /**
  53881. * Sphericle polynomial created for the dds texture
  53882. */
  53883. sphericalPolynomial?: SphericalPolynomial;
  53884. }
  53885. /**
  53886. * Class used to provide DDS decompression tools
  53887. */
  53888. export class DDSTools {
  53889. /**
  53890. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  53891. */
  53892. static StoreLODInAlphaChannel: boolean;
  53893. /**
  53894. * Gets DDS information from an array buffer
  53895. * @param arrayBuffer defines the array buffer to read data from
  53896. * @returns the DDS information
  53897. */
  53898. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  53899. private static _FloatView;
  53900. private static _Int32View;
  53901. private static _ToHalfFloat;
  53902. private static _FromHalfFloat;
  53903. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  53904. private static _GetHalfFloatRGBAArrayBuffer;
  53905. private static _GetFloatRGBAArrayBuffer;
  53906. private static _GetFloatAsUIntRGBAArrayBuffer;
  53907. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  53908. private static _GetRGBAArrayBuffer;
  53909. private static _ExtractLongWordOrder;
  53910. private static _GetRGBArrayBuffer;
  53911. private static _GetLuminanceArrayBuffer;
  53912. /**
  53913. * Uploads DDS Levels to a Babylon Texture
  53914. * @hidden
  53915. */
  53916. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  53917. }
  53918. module "babylonjs/Engines/thinEngine" {
  53919. interface ThinEngine {
  53920. /**
  53921. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  53922. * @param rootUrl defines the url where the file to load is located
  53923. * @param scene defines the current scene
  53924. * @param lodScale defines scale to apply to the mip map selection
  53925. * @param lodOffset defines offset to apply to the mip map selection
  53926. * @param onLoad defines an optional callback raised when the texture is loaded
  53927. * @param onError defines an optional callback raised if there is an issue to load the texture
  53928. * @param format defines the format of the data
  53929. * @param forcedExtension defines the extension to use to pick the right loader
  53930. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  53931. * @returns the cube texture as an InternalTexture
  53932. */
  53933. 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;
  53934. }
  53935. }
  53936. }
  53937. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  53938. import { Nullable } from "babylonjs/types";
  53939. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53940. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53941. /**
  53942. * Implementation of the DDS Texture Loader.
  53943. * @hidden
  53944. */
  53945. export class _DDSTextureLoader implements IInternalTextureLoader {
  53946. /**
  53947. * Defines wether the loader supports cascade loading the different faces.
  53948. */
  53949. readonly supportCascades: boolean;
  53950. /**
  53951. * This returns if the loader support the current file information.
  53952. * @param extension defines the file extension of the file being loaded
  53953. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53954. * @param fallback defines the fallback internal texture if any
  53955. * @param isBase64 defines whether the texture is encoded as a base64
  53956. * @param isBuffer defines whether the texture data are stored as a buffer
  53957. * @returns true if the loader can load the specified file
  53958. */
  53959. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53960. /**
  53961. * Transform the url before loading if required.
  53962. * @param rootUrl the url of the texture
  53963. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53964. * @returns the transformed texture
  53965. */
  53966. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53967. /**
  53968. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53969. * @param rootUrl the url of the texture
  53970. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53971. * @returns the fallback texture
  53972. */
  53973. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53974. /**
  53975. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53976. * @param data contains the texture data
  53977. * @param texture defines the BabylonJS internal texture
  53978. * @param createPolynomials will be true if polynomials have been requested
  53979. * @param onLoad defines the callback to trigger once the texture is ready
  53980. * @param onError defines the callback to trigger in case of error
  53981. */
  53982. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53983. /**
  53984. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53985. * @param data contains the texture data
  53986. * @param texture defines the BabylonJS internal texture
  53987. * @param callback defines the method to call once ready to upload
  53988. */
  53989. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53990. }
  53991. }
  53992. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  53993. import { Nullable } from "babylonjs/types";
  53994. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53995. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53996. /**
  53997. * Implementation of the ENV Texture Loader.
  53998. * @hidden
  53999. */
  54000. export class _ENVTextureLoader implements IInternalTextureLoader {
  54001. /**
  54002. * Defines wether the loader supports cascade loading the different faces.
  54003. */
  54004. readonly supportCascades: boolean;
  54005. /**
  54006. * This returns if the loader support the current file information.
  54007. * @param extension defines the file extension of the file being loaded
  54008. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54009. * @param fallback defines the fallback internal texture if any
  54010. * @param isBase64 defines whether the texture is encoded as a base64
  54011. * @param isBuffer defines whether the texture data are stored as a buffer
  54012. * @returns true if the loader can load the specified file
  54013. */
  54014. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54015. /**
  54016. * Transform the url before loading if required.
  54017. * @param rootUrl the url of the texture
  54018. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54019. * @returns the transformed texture
  54020. */
  54021. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54022. /**
  54023. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54024. * @param rootUrl the url of the texture
  54025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54026. * @returns the fallback texture
  54027. */
  54028. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54029. /**
  54030. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54031. * @param data contains the texture data
  54032. * @param texture defines the BabylonJS internal texture
  54033. * @param createPolynomials will be true if polynomials have been requested
  54034. * @param onLoad defines the callback to trigger once the texture is ready
  54035. * @param onError defines the callback to trigger in case of error
  54036. */
  54037. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54038. /**
  54039. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54040. * @param data contains the texture data
  54041. * @param texture defines the BabylonJS internal texture
  54042. * @param callback defines the method to call once ready to upload
  54043. */
  54044. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54045. }
  54046. }
  54047. declare module "babylonjs/Misc/khronosTextureContainer" {
  54048. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54049. /**
  54050. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54051. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54052. */
  54053. export class KhronosTextureContainer {
  54054. /** contents of the KTX container file */
  54055. arrayBuffer: any;
  54056. private static HEADER_LEN;
  54057. private static COMPRESSED_2D;
  54058. private static COMPRESSED_3D;
  54059. private static TEX_2D;
  54060. private static TEX_3D;
  54061. /**
  54062. * Gets the openGL type
  54063. */
  54064. glType: number;
  54065. /**
  54066. * Gets the openGL type size
  54067. */
  54068. glTypeSize: number;
  54069. /**
  54070. * Gets the openGL format
  54071. */
  54072. glFormat: number;
  54073. /**
  54074. * Gets the openGL internal format
  54075. */
  54076. glInternalFormat: number;
  54077. /**
  54078. * Gets the base internal format
  54079. */
  54080. glBaseInternalFormat: number;
  54081. /**
  54082. * Gets image width in pixel
  54083. */
  54084. pixelWidth: number;
  54085. /**
  54086. * Gets image height in pixel
  54087. */
  54088. pixelHeight: number;
  54089. /**
  54090. * Gets image depth in pixels
  54091. */
  54092. pixelDepth: number;
  54093. /**
  54094. * Gets the number of array elements
  54095. */
  54096. numberOfArrayElements: number;
  54097. /**
  54098. * Gets the number of faces
  54099. */
  54100. numberOfFaces: number;
  54101. /**
  54102. * Gets the number of mipmap levels
  54103. */
  54104. numberOfMipmapLevels: number;
  54105. /**
  54106. * Gets the bytes of key value data
  54107. */
  54108. bytesOfKeyValueData: number;
  54109. /**
  54110. * Gets the load type
  54111. */
  54112. loadType: number;
  54113. /**
  54114. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54115. */
  54116. isInvalid: boolean;
  54117. /**
  54118. * Creates a new KhronosTextureContainer
  54119. * @param arrayBuffer contents of the KTX container file
  54120. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54121. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54122. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54123. */
  54124. constructor(
  54125. /** contents of the KTX container file */
  54126. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54127. /**
  54128. * Uploads KTX content to a Babylon Texture.
  54129. * It is assumed that the texture has already been created & is currently bound
  54130. * @hidden
  54131. */
  54132. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54133. private _upload2DCompressedLevels;
  54134. }
  54135. }
  54136. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54137. import { Nullable } from "babylonjs/types";
  54138. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54139. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54140. /**
  54141. * Implementation of the KTX Texture Loader.
  54142. * @hidden
  54143. */
  54144. export class _KTXTextureLoader implements IInternalTextureLoader {
  54145. /**
  54146. * Defines wether the loader supports cascade loading the different faces.
  54147. */
  54148. readonly supportCascades: boolean;
  54149. /**
  54150. * This returns if the loader support the current file information.
  54151. * @param extension defines the file extension of the file being loaded
  54152. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54153. * @param fallback defines the fallback internal texture if any
  54154. * @param isBase64 defines whether the texture is encoded as a base64
  54155. * @param isBuffer defines whether the texture data are stored as a buffer
  54156. * @returns true if the loader can load the specified file
  54157. */
  54158. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54159. /**
  54160. * Transform the url before loading if required.
  54161. * @param rootUrl the url of the texture
  54162. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54163. * @returns the transformed texture
  54164. */
  54165. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54166. /**
  54167. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54168. * @param rootUrl the url of the texture
  54169. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54170. * @returns the fallback texture
  54171. */
  54172. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54173. /**
  54174. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54175. * @param data contains the texture data
  54176. * @param texture defines the BabylonJS internal texture
  54177. * @param createPolynomials will be true if polynomials have been requested
  54178. * @param onLoad defines the callback to trigger once the texture is ready
  54179. * @param onError defines the callback to trigger in case of error
  54180. */
  54181. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54182. /**
  54183. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54184. * @param data contains the texture data
  54185. * @param texture defines the BabylonJS internal texture
  54186. * @param callback defines the method to call once ready to upload
  54187. */
  54188. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54189. }
  54190. }
  54191. declare module "babylonjs/Helpers/sceneHelpers" {
  54192. import { Nullable } from "babylonjs/types";
  54193. import { Mesh } from "babylonjs/Meshes/mesh";
  54194. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54195. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54196. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54197. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54198. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54199. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54200. import "babylonjs/Meshes/Builders/boxBuilder";
  54201. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  54202. /** @hidden */
  54203. export var _forceSceneHelpersToBundle: boolean;
  54204. module "babylonjs/scene" {
  54205. interface Scene {
  54206. /**
  54207. * Creates a default light for the scene.
  54208. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54209. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54210. */
  54211. createDefaultLight(replace?: boolean): void;
  54212. /**
  54213. * Creates a default camera for the scene.
  54214. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54215. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54216. * @param replace has default false, when true replaces the active camera in the scene
  54217. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54218. */
  54219. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54220. /**
  54221. * Creates a default camera and a default light.
  54222. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54223. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54224. * @param replace has the default false, when true replaces the active camera/light in the scene
  54225. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54226. */
  54227. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54228. /**
  54229. * Creates a new sky box
  54230. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54231. * @param environmentTexture defines the texture to use as environment texture
  54232. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54233. * @param scale defines the overall scale of the skybox
  54234. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54235. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54236. * @returns a new mesh holding the sky box
  54237. */
  54238. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54239. /**
  54240. * Creates a new environment
  54241. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54242. * @param options defines the options you can use to configure the environment
  54243. * @returns the new EnvironmentHelper
  54244. */
  54245. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54246. /**
  54247. * Creates a new VREXperienceHelper
  54248. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54249. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54250. * @returns a new VREXperienceHelper
  54251. */
  54252. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54253. /**
  54254. * Creates a new WebXRDefaultExperience
  54255. * @see http://doc.babylonjs.com/how_to/webxr
  54256. * @param options experience options
  54257. * @returns a promise for a new WebXRDefaultExperience
  54258. */
  54259. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54260. }
  54261. }
  54262. }
  54263. declare module "babylonjs/Helpers/videoDome" {
  54264. import { Scene } from "babylonjs/scene";
  54265. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54266. import { Mesh } from "babylonjs/Meshes/mesh";
  54267. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54268. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54269. import "babylonjs/Meshes/Builders/sphereBuilder";
  54270. /**
  54271. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54272. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54273. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54274. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54275. */
  54276. export class VideoDome extends TransformNode {
  54277. /**
  54278. * Define the video source as a Monoscopic panoramic 360 video.
  54279. */
  54280. static readonly MODE_MONOSCOPIC: number;
  54281. /**
  54282. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54283. */
  54284. static readonly MODE_TOPBOTTOM: number;
  54285. /**
  54286. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54287. */
  54288. static readonly MODE_SIDEBYSIDE: number;
  54289. private _halfDome;
  54290. private _useDirectMapping;
  54291. /**
  54292. * The video texture being displayed on the sphere
  54293. */
  54294. protected _videoTexture: VideoTexture;
  54295. /**
  54296. * Gets the video texture being displayed on the sphere
  54297. */
  54298. get videoTexture(): VideoTexture;
  54299. /**
  54300. * The skybox material
  54301. */
  54302. protected _material: BackgroundMaterial;
  54303. /**
  54304. * The surface used for the skybox
  54305. */
  54306. protected _mesh: Mesh;
  54307. /**
  54308. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54309. */
  54310. private _halfDomeMask;
  54311. /**
  54312. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54313. * Also see the options.resolution property.
  54314. */
  54315. get fovMultiplier(): number;
  54316. set fovMultiplier(value: number);
  54317. private _videoMode;
  54318. /**
  54319. * Gets or set the current video mode for the video. It can be:
  54320. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54321. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54322. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54323. */
  54324. get videoMode(): number;
  54325. set videoMode(value: number);
  54326. /**
  54327. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54328. *
  54329. */
  54330. get halfDome(): boolean;
  54331. /**
  54332. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54333. */
  54334. set halfDome(enabled: boolean);
  54335. /**
  54336. * Oberserver used in Stereoscopic VR Mode.
  54337. */
  54338. private _onBeforeCameraRenderObserver;
  54339. /**
  54340. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54341. * @param name Element's name, child elements will append suffixes for their own names.
  54342. * @param urlsOrVideo defines the url(s) or the video element to use
  54343. * @param options An object containing optional or exposed sub element properties
  54344. */
  54345. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54346. resolution?: number;
  54347. clickToPlay?: boolean;
  54348. autoPlay?: boolean;
  54349. loop?: boolean;
  54350. size?: number;
  54351. poster?: string;
  54352. faceForward?: boolean;
  54353. useDirectMapping?: boolean;
  54354. halfDomeMode?: boolean;
  54355. }, scene: Scene);
  54356. private _changeVideoMode;
  54357. /**
  54358. * Releases resources associated with this node.
  54359. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54360. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54361. */
  54362. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54363. }
  54364. }
  54365. declare module "babylonjs/Helpers/index" {
  54366. export * from "babylonjs/Helpers/environmentHelper";
  54367. export * from "babylonjs/Helpers/photoDome";
  54368. export * from "babylonjs/Helpers/sceneHelpers";
  54369. export * from "babylonjs/Helpers/videoDome";
  54370. }
  54371. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54372. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54373. import { IDisposable } from "babylonjs/scene";
  54374. import { Engine } from "babylonjs/Engines/engine";
  54375. /**
  54376. * This class can be used to get instrumentation data from a Babylon engine
  54377. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54378. */
  54379. export class EngineInstrumentation implements IDisposable {
  54380. /**
  54381. * Define the instrumented engine.
  54382. */
  54383. engine: Engine;
  54384. private _captureGPUFrameTime;
  54385. private _gpuFrameTimeToken;
  54386. private _gpuFrameTime;
  54387. private _captureShaderCompilationTime;
  54388. private _shaderCompilationTime;
  54389. private _onBeginFrameObserver;
  54390. private _onEndFrameObserver;
  54391. private _onBeforeShaderCompilationObserver;
  54392. private _onAfterShaderCompilationObserver;
  54393. /**
  54394. * Gets the perf counter used for GPU frame time
  54395. */
  54396. get gpuFrameTimeCounter(): PerfCounter;
  54397. /**
  54398. * Gets the GPU frame time capture status
  54399. */
  54400. get captureGPUFrameTime(): boolean;
  54401. /**
  54402. * Enable or disable the GPU frame time capture
  54403. */
  54404. set captureGPUFrameTime(value: boolean);
  54405. /**
  54406. * Gets the perf counter used for shader compilation time
  54407. */
  54408. get shaderCompilationTimeCounter(): PerfCounter;
  54409. /**
  54410. * Gets the shader compilation time capture status
  54411. */
  54412. get captureShaderCompilationTime(): boolean;
  54413. /**
  54414. * Enable or disable the shader compilation time capture
  54415. */
  54416. set captureShaderCompilationTime(value: boolean);
  54417. /**
  54418. * Instantiates a new engine instrumentation.
  54419. * This class can be used to get instrumentation data from a Babylon engine
  54420. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54421. * @param engine Defines the engine to instrument
  54422. */
  54423. constructor(
  54424. /**
  54425. * Define the instrumented engine.
  54426. */
  54427. engine: Engine);
  54428. /**
  54429. * Dispose and release associated resources.
  54430. */
  54431. dispose(): void;
  54432. }
  54433. }
  54434. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54435. import { Scene, IDisposable } from "babylonjs/scene";
  54436. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54437. /**
  54438. * This class can be used to get instrumentation data from a Babylon engine
  54439. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54440. */
  54441. export class SceneInstrumentation implements IDisposable {
  54442. /**
  54443. * Defines the scene to instrument
  54444. */
  54445. scene: Scene;
  54446. private _captureActiveMeshesEvaluationTime;
  54447. private _activeMeshesEvaluationTime;
  54448. private _captureRenderTargetsRenderTime;
  54449. private _renderTargetsRenderTime;
  54450. private _captureFrameTime;
  54451. private _frameTime;
  54452. private _captureRenderTime;
  54453. private _renderTime;
  54454. private _captureInterFrameTime;
  54455. private _interFrameTime;
  54456. private _captureParticlesRenderTime;
  54457. private _particlesRenderTime;
  54458. private _captureSpritesRenderTime;
  54459. private _spritesRenderTime;
  54460. private _capturePhysicsTime;
  54461. private _physicsTime;
  54462. private _captureAnimationsTime;
  54463. private _animationsTime;
  54464. private _captureCameraRenderTime;
  54465. private _cameraRenderTime;
  54466. private _onBeforeActiveMeshesEvaluationObserver;
  54467. private _onAfterActiveMeshesEvaluationObserver;
  54468. private _onBeforeRenderTargetsRenderObserver;
  54469. private _onAfterRenderTargetsRenderObserver;
  54470. private _onAfterRenderObserver;
  54471. private _onBeforeDrawPhaseObserver;
  54472. private _onAfterDrawPhaseObserver;
  54473. private _onBeforeAnimationsObserver;
  54474. private _onBeforeParticlesRenderingObserver;
  54475. private _onAfterParticlesRenderingObserver;
  54476. private _onBeforeSpritesRenderingObserver;
  54477. private _onAfterSpritesRenderingObserver;
  54478. private _onBeforePhysicsObserver;
  54479. private _onAfterPhysicsObserver;
  54480. private _onAfterAnimationsObserver;
  54481. private _onBeforeCameraRenderObserver;
  54482. private _onAfterCameraRenderObserver;
  54483. /**
  54484. * Gets the perf counter used for active meshes evaluation time
  54485. */
  54486. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54487. /**
  54488. * Gets the active meshes evaluation time capture status
  54489. */
  54490. get captureActiveMeshesEvaluationTime(): boolean;
  54491. /**
  54492. * Enable or disable the active meshes evaluation time capture
  54493. */
  54494. set captureActiveMeshesEvaluationTime(value: boolean);
  54495. /**
  54496. * Gets the perf counter used for render targets render time
  54497. */
  54498. get renderTargetsRenderTimeCounter(): PerfCounter;
  54499. /**
  54500. * Gets the render targets render time capture status
  54501. */
  54502. get captureRenderTargetsRenderTime(): boolean;
  54503. /**
  54504. * Enable or disable the render targets render time capture
  54505. */
  54506. set captureRenderTargetsRenderTime(value: boolean);
  54507. /**
  54508. * Gets the perf counter used for particles render time
  54509. */
  54510. get particlesRenderTimeCounter(): PerfCounter;
  54511. /**
  54512. * Gets the particles render time capture status
  54513. */
  54514. get captureParticlesRenderTime(): boolean;
  54515. /**
  54516. * Enable or disable the particles render time capture
  54517. */
  54518. set captureParticlesRenderTime(value: boolean);
  54519. /**
  54520. * Gets the perf counter used for sprites render time
  54521. */
  54522. get spritesRenderTimeCounter(): PerfCounter;
  54523. /**
  54524. * Gets the sprites render time capture status
  54525. */
  54526. get captureSpritesRenderTime(): boolean;
  54527. /**
  54528. * Enable or disable the sprites render time capture
  54529. */
  54530. set captureSpritesRenderTime(value: boolean);
  54531. /**
  54532. * Gets the perf counter used for physics time
  54533. */
  54534. get physicsTimeCounter(): PerfCounter;
  54535. /**
  54536. * Gets the physics time capture status
  54537. */
  54538. get capturePhysicsTime(): boolean;
  54539. /**
  54540. * Enable or disable the physics time capture
  54541. */
  54542. set capturePhysicsTime(value: boolean);
  54543. /**
  54544. * Gets the perf counter used for animations time
  54545. */
  54546. get animationsTimeCounter(): PerfCounter;
  54547. /**
  54548. * Gets the animations time capture status
  54549. */
  54550. get captureAnimationsTime(): boolean;
  54551. /**
  54552. * Enable or disable the animations time capture
  54553. */
  54554. set captureAnimationsTime(value: boolean);
  54555. /**
  54556. * Gets the perf counter used for frame time capture
  54557. */
  54558. get frameTimeCounter(): PerfCounter;
  54559. /**
  54560. * Gets the frame time capture status
  54561. */
  54562. get captureFrameTime(): boolean;
  54563. /**
  54564. * Enable or disable the frame time capture
  54565. */
  54566. set captureFrameTime(value: boolean);
  54567. /**
  54568. * Gets the perf counter used for inter-frames time capture
  54569. */
  54570. get interFrameTimeCounter(): PerfCounter;
  54571. /**
  54572. * Gets the inter-frames time capture status
  54573. */
  54574. get captureInterFrameTime(): boolean;
  54575. /**
  54576. * Enable or disable the inter-frames time capture
  54577. */
  54578. set captureInterFrameTime(value: boolean);
  54579. /**
  54580. * Gets the perf counter used for render time capture
  54581. */
  54582. get renderTimeCounter(): PerfCounter;
  54583. /**
  54584. * Gets the render time capture status
  54585. */
  54586. get captureRenderTime(): boolean;
  54587. /**
  54588. * Enable or disable the render time capture
  54589. */
  54590. set captureRenderTime(value: boolean);
  54591. /**
  54592. * Gets the perf counter used for camera render time capture
  54593. */
  54594. get cameraRenderTimeCounter(): PerfCounter;
  54595. /**
  54596. * Gets the camera render time capture status
  54597. */
  54598. get captureCameraRenderTime(): boolean;
  54599. /**
  54600. * Enable or disable the camera render time capture
  54601. */
  54602. set captureCameraRenderTime(value: boolean);
  54603. /**
  54604. * Gets the perf counter used for draw calls
  54605. */
  54606. get drawCallsCounter(): PerfCounter;
  54607. /**
  54608. * Instantiates a new scene instrumentation.
  54609. * This class can be used to get instrumentation data from a Babylon engine
  54610. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54611. * @param scene Defines the scene to instrument
  54612. */
  54613. constructor(
  54614. /**
  54615. * Defines the scene to instrument
  54616. */
  54617. scene: Scene);
  54618. /**
  54619. * Dispose and release associated resources.
  54620. */
  54621. dispose(): void;
  54622. }
  54623. }
  54624. declare module "babylonjs/Instrumentation/index" {
  54625. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54626. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54627. export * from "babylonjs/Instrumentation/timeToken";
  54628. }
  54629. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54630. /** @hidden */
  54631. export var glowMapGenerationPixelShader: {
  54632. name: string;
  54633. shader: string;
  54634. };
  54635. }
  54636. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54637. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54638. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54639. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54640. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54641. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54642. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54643. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54644. /** @hidden */
  54645. export var glowMapGenerationVertexShader: {
  54646. name: string;
  54647. shader: string;
  54648. };
  54649. }
  54650. declare module "babylonjs/Layers/effectLayer" {
  54651. import { Observable } from "babylonjs/Misc/observable";
  54652. import { Nullable } from "babylonjs/types";
  54653. import { Camera } from "babylonjs/Cameras/camera";
  54654. import { Scene } from "babylonjs/scene";
  54655. import { ISize } from "babylonjs/Maths/math.size";
  54656. import { Color4 } from "babylonjs/Maths/math.color";
  54657. import { Engine } from "babylonjs/Engines/engine";
  54658. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54660. import { Mesh } from "babylonjs/Meshes/mesh";
  54661. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54662. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54663. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54664. import { Effect } from "babylonjs/Materials/effect";
  54665. import { Material } from "babylonjs/Materials/material";
  54666. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54667. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54668. /**
  54669. * Effect layer options. This helps customizing the behaviour
  54670. * of the effect layer.
  54671. */
  54672. export interface IEffectLayerOptions {
  54673. /**
  54674. * Multiplication factor apply to the canvas size to compute the render target size
  54675. * used to generated the objects (the smaller the faster).
  54676. */
  54677. mainTextureRatio: number;
  54678. /**
  54679. * Enforces a fixed size texture to ensure effect stability across devices.
  54680. */
  54681. mainTextureFixedSize?: number;
  54682. /**
  54683. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54684. */
  54685. alphaBlendingMode: number;
  54686. /**
  54687. * The camera attached to the layer.
  54688. */
  54689. camera: Nullable<Camera>;
  54690. /**
  54691. * The rendering group to draw the layer in.
  54692. */
  54693. renderingGroupId: number;
  54694. }
  54695. /**
  54696. * The effect layer Helps adding post process effect blended with the main pass.
  54697. *
  54698. * This can be for instance use to generate glow or higlight effects on the scene.
  54699. *
  54700. * The effect layer class can not be used directly and is intented to inherited from to be
  54701. * customized per effects.
  54702. */
  54703. export abstract class EffectLayer {
  54704. private _vertexBuffers;
  54705. private _indexBuffer;
  54706. private _cachedDefines;
  54707. private _effectLayerMapGenerationEffect;
  54708. private _effectLayerOptions;
  54709. private _mergeEffect;
  54710. protected _scene: Scene;
  54711. protected _engine: Engine;
  54712. protected _maxSize: number;
  54713. protected _mainTextureDesiredSize: ISize;
  54714. protected _mainTexture: RenderTargetTexture;
  54715. protected _shouldRender: boolean;
  54716. protected _postProcesses: PostProcess[];
  54717. protected _textures: BaseTexture[];
  54718. protected _emissiveTextureAndColor: {
  54719. texture: Nullable<BaseTexture>;
  54720. color: Color4;
  54721. };
  54722. /**
  54723. * The name of the layer
  54724. */
  54725. name: string;
  54726. /**
  54727. * The clear color of the texture used to generate the glow map.
  54728. */
  54729. neutralColor: Color4;
  54730. /**
  54731. * Specifies wether the highlight layer is enabled or not.
  54732. */
  54733. isEnabled: boolean;
  54734. /**
  54735. * Gets the camera attached to the layer.
  54736. */
  54737. get camera(): Nullable<Camera>;
  54738. /**
  54739. * Gets the rendering group id the layer should render in.
  54740. */
  54741. get renderingGroupId(): number;
  54742. set renderingGroupId(renderingGroupId: number);
  54743. /**
  54744. * An event triggered when the effect layer has been disposed.
  54745. */
  54746. onDisposeObservable: Observable<EffectLayer>;
  54747. /**
  54748. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54749. */
  54750. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  54751. /**
  54752. * An event triggered when the generated texture is being merged in the scene.
  54753. */
  54754. onBeforeComposeObservable: Observable<EffectLayer>;
  54755. /**
  54756. * An event triggered when the mesh is rendered into the effect render target.
  54757. */
  54758. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  54759. /**
  54760. * An event triggered after the mesh has been rendered into the effect render target.
  54761. */
  54762. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  54763. /**
  54764. * An event triggered when the generated texture has been merged in the scene.
  54765. */
  54766. onAfterComposeObservable: Observable<EffectLayer>;
  54767. /**
  54768. * An event triggered when the efffect layer changes its size.
  54769. */
  54770. onSizeChangedObservable: Observable<EffectLayer>;
  54771. /** @hidden */
  54772. static _SceneComponentInitialization: (scene: Scene) => void;
  54773. /**
  54774. * Instantiates a new effect Layer and references it in the scene.
  54775. * @param name The name of the layer
  54776. * @param scene The scene to use the layer in
  54777. */
  54778. constructor(
  54779. /** The Friendly of the effect in the scene */
  54780. name: string, scene: Scene);
  54781. /**
  54782. * Get the effect name of the layer.
  54783. * @return The effect name
  54784. */
  54785. abstract getEffectName(): string;
  54786. /**
  54787. * Checks for the readiness of the element composing the layer.
  54788. * @param subMesh the mesh to check for
  54789. * @param useInstances specify wether or not to use instances to render the mesh
  54790. * @return true if ready otherwise, false
  54791. */
  54792. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54793. /**
  54794. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  54795. * @returns true if the effect requires stencil during the main canvas render pass.
  54796. */
  54797. abstract needStencil(): boolean;
  54798. /**
  54799. * Create the merge effect. This is the shader use to blit the information back
  54800. * to the main canvas at the end of the scene rendering.
  54801. * @returns The effect containing the shader used to merge the effect on the main canvas
  54802. */
  54803. protected abstract _createMergeEffect(): Effect;
  54804. /**
  54805. * Creates the render target textures and post processes used in the effect layer.
  54806. */
  54807. protected abstract _createTextureAndPostProcesses(): void;
  54808. /**
  54809. * Implementation specific of rendering the generating effect on the main canvas.
  54810. * @param effect The effect used to render through
  54811. */
  54812. protected abstract _internalRender(effect: Effect): void;
  54813. /**
  54814. * Sets the required values for both the emissive texture and and the main color.
  54815. */
  54816. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  54817. /**
  54818. * Free any resources and references associated to a mesh.
  54819. * Internal use
  54820. * @param mesh The mesh to free.
  54821. */
  54822. abstract _disposeMesh(mesh: Mesh): void;
  54823. /**
  54824. * Serializes this layer (Glow or Highlight for example)
  54825. * @returns a serialized layer object
  54826. */
  54827. abstract serialize?(): any;
  54828. /**
  54829. * Initializes the effect layer with the required options.
  54830. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  54831. */
  54832. protected _init(options: Partial<IEffectLayerOptions>): void;
  54833. /**
  54834. * Generates the index buffer of the full screen quad blending to the main canvas.
  54835. */
  54836. private _generateIndexBuffer;
  54837. /**
  54838. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  54839. */
  54840. private _generateVertexBuffer;
  54841. /**
  54842. * Sets the main texture desired size which is the closest power of two
  54843. * of the engine canvas size.
  54844. */
  54845. private _setMainTextureSize;
  54846. /**
  54847. * Creates the main texture for the effect layer.
  54848. */
  54849. protected _createMainTexture(): void;
  54850. /**
  54851. * Adds specific effects defines.
  54852. * @param defines The defines to add specifics to.
  54853. */
  54854. protected _addCustomEffectDefines(defines: string[]): void;
  54855. /**
  54856. * Checks for the readiness of the element composing the layer.
  54857. * @param subMesh the mesh to check for
  54858. * @param useInstances specify wether or not to use instances to render the mesh
  54859. * @param emissiveTexture the associated emissive texture used to generate the glow
  54860. * @return true if ready otherwise, false
  54861. */
  54862. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  54863. /**
  54864. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  54865. */
  54866. render(): void;
  54867. /**
  54868. * Determine if a given mesh will be used in the current effect.
  54869. * @param mesh mesh to test
  54870. * @returns true if the mesh will be used
  54871. */
  54872. hasMesh(mesh: AbstractMesh): boolean;
  54873. /**
  54874. * Returns true if the layer contains information to display, otherwise false.
  54875. * @returns true if the glow layer should be rendered
  54876. */
  54877. shouldRender(): boolean;
  54878. /**
  54879. * Returns true if the mesh should render, otherwise false.
  54880. * @param mesh The mesh to render
  54881. * @returns true if it should render otherwise false
  54882. */
  54883. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  54884. /**
  54885. * Returns true if the mesh can be rendered, otherwise false.
  54886. * @param mesh The mesh to render
  54887. * @param material The material used on the mesh
  54888. * @returns true if it can be rendered otherwise false
  54889. */
  54890. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  54891. /**
  54892. * Returns true if the mesh should render, otherwise false.
  54893. * @param mesh The mesh to render
  54894. * @returns true if it should render otherwise false
  54895. */
  54896. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  54897. /**
  54898. * Renders the submesh passed in parameter to the generation map.
  54899. */
  54900. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  54901. /**
  54902. * Defines wether the current material of the mesh should be use to render the effect.
  54903. * @param mesh defines the current mesh to render
  54904. */
  54905. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  54906. /**
  54907. * Rebuild the required buffers.
  54908. * @hidden Internal use only.
  54909. */
  54910. _rebuild(): void;
  54911. /**
  54912. * Dispose only the render target textures and post process.
  54913. */
  54914. private _disposeTextureAndPostProcesses;
  54915. /**
  54916. * Dispose the highlight layer and free resources.
  54917. */
  54918. dispose(): void;
  54919. /**
  54920. * Gets the class name of the effect layer
  54921. * @returns the string with the class name of the effect layer
  54922. */
  54923. getClassName(): string;
  54924. /**
  54925. * Creates an effect layer from parsed effect layer data
  54926. * @param parsedEffectLayer defines effect layer data
  54927. * @param scene defines the current scene
  54928. * @param rootUrl defines the root URL containing the effect layer information
  54929. * @returns a parsed effect Layer
  54930. */
  54931. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  54932. }
  54933. }
  54934. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  54935. import { Scene } from "babylonjs/scene";
  54936. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  54937. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  54938. import { AbstractScene } from "babylonjs/abstractScene";
  54939. module "babylonjs/abstractScene" {
  54940. interface AbstractScene {
  54941. /**
  54942. * The list of effect layers (highlights/glow) added to the scene
  54943. * @see http://doc.babylonjs.com/how_to/highlight_layer
  54944. * @see http://doc.babylonjs.com/how_to/glow_layer
  54945. */
  54946. effectLayers: Array<EffectLayer>;
  54947. /**
  54948. * Removes the given effect layer from this scene.
  54949. * @param toRemove defines the effect layer to remove
  54950. * @returns the index of the removed effect layer
  54951. */
  54952. removeEffectLayer(toRemove: EffectLayer): number;
  54953. /**
  54954. * Adds the given effect layer to this scene
  54955. * @param newEffectLayer defines the effect layer to add
  54956. */
  54957. addEffectLayer(newEffectLayer: EffectLayer): void;
  54958. }
  54959. }
  54960. /**
  54961. * Defines the layer scene component responsible to manage any effect layers
  54962. * in a given scene.
  54963. */
  54964. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  54965. /**
  54966. * The component name helpfull to identify the component in the list of scene components.
  54967. */
  54968. readonly name: string;
  54969. /**
  54970. * The scene the component belongs to.
  54971. */
  54972. scene: Scene;
  54973. private _engine;
  54974. private _renderEffects;
  54975. private _needStencil;
  54976. private _previousStencilState;
  54977. /**
  54978. * Creates a new instance of the component for the given scene
  54979. * @param scene Defines the scene to register the component in
  54980. */
  54981. constructor(scene: Scene);
  54982. /**
  54983. * Registers the component in a given scene
  54984. */
  54985. register(): void;
  54986. /**
  54987. * Rebuilds the elements related to this component in case of
  54988. * context lost for instance.
  54989. */
  54990. rebuild(): void;
  54991. /**
  54992. * Serializes the component data to the specified json object
  54993. * @param serializationObject The object to serialize to
  54994. */
  54995. serialize(serializationObject: any): void;
  54996. /**
  54997. * Adds all the elements from the container to the scene
  54998. * @param container the container holding the elements
  54999. */
  55000. addFromContainer(container: AbstractScene): void;
  55001. /**
  55002. * Removes all the elements in the container from the scene
  55003. * @param container contains the elements to remove
  55004. * @param dispose if the removed element should be disposed (default: false)
  55005. */
  55006. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55007. /**
  55008. * Disposes the component and the associated ressources.
  55009. */
  55010. dispose(): void;
  55011. private _isReadyForMesh;
  55012. private _renderMainTexture;
  55013. private _setStencil;
  55014. private _setStencilBack;
  55015. private _draw;
  55016. private _drawCamera;
  55017. private _drawRenderingGroup;
  55018. }
  55019. }
  55020. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55021. /** @hidden */
  55022. export var glowMapMergePixelShader: {
  55023. name: string;
  55024. shader: string;
  55025. };
  55026. }
  55027. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55028. /** @hidden */
  55029. export var glowMapMergeVertexShader: {
  55030. name: string;
  55031. shader: string;
  55032. };
  55033. }
  55034. declare module "babylonjs/Layers/glowLayer" {
  55035. import { Nullable } from "babylonjs/types";
  55036. import { Camera } from "babylonjs/Cameras/camera";
  55037. import { Scene } from "babylonjs/scene";
  55038. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55040. import { Mesh } from "babylonjs/Meshes/mesh";
  55041. import { Texture } from "babylonjs/Materials/Textures/texture";
  55042. import { Effect } from "babylonjs/Materials/effect";
  55043. import { Material } from "babylonjs/Materials/material";
  55044. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55045. import { Color4 } from "babylonjs/Maths/math.color";
  55046. import "babylonjs/Shaders/glowMapMerge.fragment";
  55047. import "babylonjs/Shaders/glowMapMerge.vertex";
  55048. import "babylonjs/Layers/effectLayerSceneComponent";
  55049. module "babylonjs/abstractScene" {
  55050. interface AbstractScene {
  55051. /**
  55052. * Return a the first highlight layer of the scene with a given name.
  55053. * @param name The name of the highlight layer to look for.
  55054. * @return The highlight layer if found otherwise null.
  55055. */
  55056. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55057. }
  55058. }
  55059. /**
  55060. * Glow layer options. This helps customizing the behaviour
  55061. * of the glow layer.
  55062. */
  55063. export interface IGlowLayerOptions {
  55064. /**
  55065. * Multiplication factor apply to the canvas size to compute the render target size
  55066. * used to generated the glowing objects (the smaller the faster).
  55067. */
  55068. mainTextureRatio: number;
  55069. /**
  55070. * Enforces a fixed size texture to ensure resize independant blur.
  55071. */
  55072. mainTextureFixedSize?: number;
  55073. /**
  55074. * How big is the kernel of the blur texture.
  55075. */
  55076. blurKernelSize: number;
  55077. /**
  55078. * The camera attached to the layer.
  55079. */
  55080. camera: Nullable<Camera>;
  55081. /**
  55082. * Enable MSAA by chosing the number of samples.
  55083. */
  55084. mainTextureSamples?: number;
  55085. /**
  55086. * The rendering group to draw the layer in.
  55087. */
  55088. renderingGroupId: number;
  55089. }
  55090. /**
  55091. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55092. *
  55093. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55094. *
  55095. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55096. */
  55097. export class GlowLayer extends EffectLayer {
  55098. /**
  55099. * Effect Name of the layer.
  55100. */
  55101. static readonly EffectName: string;
  55102. /**
  55103. * The default blur kernel size used for the glow.
  55104. */
  55105. static DefaultBlurKernelSize: number;
  55106. /**
  55107. * The default texture size ratio used for the glow.
  55108. */
  55109. static DefaultTextureRatio: number;
  55110. /**
  55111. * Sets the kernel size of the blur.
  55112. */
  55113. set blurKernelSize(value: number);
  55114. /**
  55115. * Gets the kernel size of the blur.
  55116. */
  55117. get blurKernelSize(): number;
  55118. /**
  55119. * Sets the glow intensity.
  55120. */
  55121. set intensity(value: number);
  55122. /**
  55123. * Gets the glow intensity.
  55124. */
  55125. get intensity(): number;
  55126. private _options;
  55127. private _intensity;
  55128. private _horizontalBlurPostprocess1;
  55129. private _verticalBlurPostprocess1;
  55130. private _horizontalBlurPostprocess2;
  55131. private _verticalBlurPostprocess2;
  55132. private _blurTexture1;
  55133. private _blurTexture2;
  55134. private _postProcesses1;
  55135. private _postProcesses2;
  55136. private _includedOnlyMeshes;
  55137. private _excludedMeshes;
  55138. private _meshesUsingTheirOwnMaterials;
  55139. /**
  55140. * Callback used to let the user override the color selection on a per mesh basis
  55141. */
  55142. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55143. /**
  55144. * Callback used to let the user override the texture selection on a per mesh basis
  55145. */
  55146. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55147. /**
  55148. * Instantiates a new glow Layer and references it to the scene.
  55149. * @param name The name of the layer
  55150. * @param scene The scene to use the layer in
  55151. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55152. */
  55153. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55154. /**
  55155. * Get the effect name of the layer.
  55156. * @return The effect name
  55157. */
  55158. getEffectName(): string;
  55159. /**
  55160. * Create the merge effect. This is the shader use to blit the information back
  55161. * to the main canvas at the end of the scene rendering.
  55162. */
  55163. protected _createMergeEffect(): Effect;
  55164. /**
  55165. * Creates the render target textures and post processes used in the glow layer.
  55166. */
  55167. protected _createTextureAndPostProcesses(): void;
  55168. /**
  55169. * Checks for the readiness of the element composing the layer.
  55170. * @param subMesh the mesh to check for
  55171. * @param useInstances specify wether or not to use instances to render the mesh
  55172. * @param emissiveTexture the associated emissive texture used to generate the glow
  55173. * @return true if ready otherwise, false
  55174. */
  55175. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55176. /**
  55177. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55178. */
  55179. needStencil(): boolean;
  55180. /**
  55181. * Returns true if the mesh can be rendered, otherwise false.
  55182. * @param mesh The mesh to render
  55183. * @param material The material used on the mesh
  55184. * @returns true if it can be rendered otherwise false
  55185. */
  55186. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55187. /**
  55188. * Implementation specific of rendering the generating effect on the main canvas.
  55189. * @param effect The effect used to render through
  55190. */
  55191. protected _internalRender(effect: Effect): void;
  55192. /**
  55193. * Sets the required values for both the emissive texture and and the main color.
  55194. */
  55195. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55196. /**
  55197. * Returns true if the mesh should render, otherwise false.
  55198. * @param mesh The mesh to render
  55199. * @returns true if it should render otherwise false
  55200. */
  55201. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55202. /**
  55203. * Adds specific effects defines.
  55204. * @param defines The defines to add specifics to.
  55205. */
  55206. protected _addCustomEffectDefines(defines: string[]): void;
  55207. /**
  55208. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55209. * @param mesh The mesh to exclude from the glow layer
  55210. */
  55211. addExcludedMesh(mesh: Mesh): void;
  55212. /**
  55213. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55214. * @param mesh The mesh to remove
  55215. */
  55216. removeExcludedMesh(mesh: Mesh): void;
  55217. /**
  55218. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55219. * @param mesh The mesh to include in the glow layer
  55220. */
  55221. addIncludedOnlyMesh(mesh: Mesh): void;
  55222. /**
  55223. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55224. * @param mesh The mesh to remove
  55225. */
  55226. removeIncludedOnlyMesh(mesh: Mesh): void;
  55227. /**
  55228. * Determine if a given mesh will be used in the glow layer
  55229. * @param mesh The mesh to test
  55230. * @returns true if the mesh will be highlighted by the current glow layer
  55231. */
  55232. hasMesh(mesh: AbstractMesh): boolean;
  55233. /**
  55234. * Defines wether the current material of the mesh should be use to render the effect.
  55235. * @param mesh defines the current mesh to render
  55236. */
  55237. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55238. /**
  55239. * Add a mesh to be rendered through its own material and not with emissive only.
  55240. * @param mesh The mesh for which we need to use its material
  55241. */
  55242. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55243. /**
  55244. * Remove a mesh from being rendered through its own material and not with emissive only.
  55245. * @param mesh The mesh for which we need to not use its material
  55246. */
  55247. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55248. /**
  55249. * Free any resources and references associated to a mesh.
  55250. * Internal use
  55251. * @param mesh The mesh to free.
  55252. * @hidden
  55253. */
  55254. _disposeMesh(mesh: Mesh): void;
  55255. /**
  55256. * Gets the class name of the effect layer
  55257. * @returns the string with the class name of the effect layer
  55258. */
  55259. getClassName(): string;
  55260. /**
  55261. * Serializes this glow layer
  55262. * @returns a serialized glow layer object
  55263. */
  55264. serialize(): any;
  55265. /**
  55266. * Creates a Glow Layer from parsed glow layer data
  55267. * @param parsedGlowLayer defines glow layer data
  55268. * @param scene defines the current scene
  55269. * @param rootUrl defines the root URL containing the glow layer information
  55270. * @returns a parsed Glow Layer
  55271. */
  55272. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55273. }
  55274. }
  55275. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55276. /** @hidden */
  55277. export var glowBlurPostProcessPixelShader: {
  55278. name: string;
  55279. shader: string;
  55280. };
  55281. }
  55282. declare module "babylonjs/Layers/highlightLayer" {
  55283. import { Observable } from "babylonjs/Misc/observable";
  55284. import { Nullable } from "babylonjs/types";
  55285. import { Camera } from "babylonjs/Cameras/camera";
  55286. import { Scene } from "babylonjs/scene";
  55287. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55289. import { Mesh } from "babylonjs/Meshes/mesh";
  55290. import { Effect } from "babylonjs/Materials/effect";
  55291. import { Material } from "babylonjs/Materials/material";
  55292. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55293. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55294. import "babylonjs/Shaders/glowMapMerge.fragment";
  55295. import "babylonjs/Shaders/glowMapMerge.vertex";
  55296. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55297. module "babylonjs/abstractScene" {
  55298. interface AbstractScene {
  55299. /**
  55300. * Return a the first highlight layer of the scene with a given name.
  55301. * @param name The name of the highlight layer to look for.
  55302. * @return The highlight layer if found otherwise null.
  55303. */
  55304. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55305. }
  55306. }
  55307. /**
  55308. * Highlight layer options. This helps customizing the behaviour
  55309. * of the highlight layer.
  55310. */
  55311. export interface IHighlightLayerOptions {
  55312. /**
  55313. * Multiplication factor apply to the canvas size to compute the render target size
  55314. * used to generated the glowing objects (the smaller the faster).
  55315. */
  55316. mainTextureRatio: number;
  55317. /**
  55318. * Enforces a fixed size texture to ensure resize independant blur.
  55319. */
  55320. mainTextureFixedSize?: number;
  55321. /**
  55322. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55323. * of the picture to blur (the smaller the faster).
  55324. */
  55325. blurTextureSizeRatio: number;
  55326. /**
  55327. * How big in texel of the blur texture is the vertical blur.
  55328. */
  55329. blurVerticalSize: number;
  55330. /**
  55331. * How big in texel of the blur texture is the horizontal blur.
  55332. */
  55333. blurHorizontalSize: number;
  55334. /**
  55335. * Alpha blending mode used to apply the blur. Default is combine.
  55336. */
  55337. alphaBlendingMode: number;
  55338. /**
  55339. * The camera attached to the layer.
  55340. */
  55341. camera: Nullable<Camera>;
  55342. /**
  55343. * Should we display highlight as a solid stroke?
  55344. */
  55345. isStroke?: boolean;
  55346. /**
  55347. * The rendering group to draw the layer in.
  55348. */
  55349. renderingGroupId: number;
  55350. }
  55351. /**
  55352. * The highlight layer Helps adding a glow effect around a mesh.
  55353. *
  55354. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55355. * glowy meshes to your scene.
  55356. *
  55357. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55358. */
  55359. export class HighlightLayer extends EffectLayer {
  55360. name: string;
  55361. /**
  55362. * Effect Name of the highlight layer.
  55363. */
  55364. static readonly EffectName: string;
  55365. /**
  55366. * The neutral color used during the preparation of the glow effect.
  55367. * This is black by default as the blend operation is a blend operation.
  55368. */
  55369. static NeutralColor: Color4;
  55370. /**
  55371. * Stencil value used for glowing meshes.
  55372. */
  55373. static GlowingMeshStencilReference: number;
  55374. /**
  55375. * Stencil value used for the other meshes in the scene.
  55376. */
  55377. static NormalMeshStencilReference: number;
  55378. /**
  55379. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55380. */
  55381. innerGlow: boolean;
  55382. /**
  55383. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55384. */
  55385. outerGlow: boolean;
  55386. /**
  55387. * Specifies the horizontal size of the blur.
  55388. */
  55389. set blurHorizontalSize(value: number);
  55390. /**
  55391. * Specifies the vertical size of the blur.
  55392. */
  55393. set blurVerticalSize(value: number);
  55394. /**
  55395. * Gets the horizontal size of the blur.
  55396. */
  55397. get blurHorizontalSize(): number;
  55398. /**
  55399. * Gets the vertical size of the blur.
  55400. */
  55401. get blurVerticalSize(): number;
  55402. /**
  55403. * An event triggered when the highlight layer is being blurred.
  55404. */
  55405. onBeforeBlurObservable: Observable<HighlightLayer>;
  55406. /**
  55407. * An event triggered when the highlight layer has been blurred.
  55408. */
  55409. onAfterBlurObservable: Observable<HighlightLayer>;
  55410. private _instanceGlowingMeshStencilReference;
  55411. private _options;
  55412. private _downSamplePostprocess;
  55413. private _horizontalBlurPostprocess;
  55414. private _verticalBlurPostprocess;
  55415. private _blurTexture;
  55416. private _meshes;
  55417. private _excludedMeshes;
  55418. /**
  55419. * Instantiates a new highlight Layer and references it to the scene..
  55420. * @param name The name of the layer
  55421. * @param scene The scene to use the layer in
  55422. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55423. */
  55424. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55425. /**
  55426. * Get the effect name of the layer.
  55427. * @return The effect name
  55428. */
  55429. getEffectName(): string;
  55430. /**
  55431. * Create the merge effect. This is the shader use to blit the information back
  55432. * to the main canvas at the end of the scene rendering.
  55433. */
  55434. protected _createMergeEffect(): Effect;
  55435. /**
  55436. * Creates the render target textures and post processes used in the highlight layer.
  55437. */
  55438. protected _createTextureAndPostProcesses(): void;
  55439. /**
  55440. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55441. */
  55442. needStencil(): boolean;
  55443. /**
  55444. * Checks for the readiness of the element composing the layer.
  55445. * @param subMesh the mesh to check for
  55446. * @param useInstances specify wether or not to use instances to render the mesh
  55447. * @param emissiveTexture the associated emissive texture used to generate the glow
  55448. * @return true if ready otherwise, false
  55449. */
  55450. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55451. /**
  55452. * Implementation specific of rendering the generating effect on the main canvas.
  55453. * @param effect The effect used to render through
  55454. */
  55455. protected _internalRender(effect: Effect): void;
  55456. /**
  55457. * Returns true if the layer contains information to display, otherwise false.
  55458. */
  55459. shouldRender(): boolean;
  55460. /**
  55461. * Returns true if the mesh should render, otherwise false.
  55462. * @param mesh The mesh to render
  55463. * @returns true if it should render otherwise false
  55464. */
  55465. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55466. /**
  55467. * Sets the required values for both the emissive texture and and the main color.
  55468. */
  55469. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55470. /**
  55471. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55472. * @param mesh The mesh to exclude from the highlight layer
  55473. */
  55474. addExcludedMesh(mesh: Mesh): void;
  55475. /**
  55476. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55477. * @param mesh The mesh to highlight
  55478. */
  55479. removeExcludedMesh(mesh: Mesh): void;
  55480. /**
  55481. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55482. * @param mesh mesh to test
  55483. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55484. */
  55485. hasMesh(mesh: AbstractMesh): boolean;
  55486. /**
  55487. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55488. * @param mesh The mesh to highlight
  55489. * @param color The color of the highlight
  55490. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55491. */
  55492. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55493. /**
  55494. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55495. * @param mesh The mesh to highlight
  55496. */
  55497. removeMesh(mesh: Mesh): void;
  55498. /**
  55499. * Force the stencil to the normal expected value for none glowing parts
  55500. */
  55501. private _defaultStencilReference;
  55502. /**
  55503. * Free any resources and references associated to a mesh.
  55504. * Internal use
  55505. * @param mesh The mesh to free.
  55506. * @hidden
  55507. */
  55508. _disposeMesh(mesh: Mesh): void;
  55509. /**
  55510. * Dispose the highlight layer and free resources.
  55511. */
  55512. dispose(): void;
  55513. /**
  55514. * Gets the class name of the effect layer
  55515. * @returns the string with the class name of the effect layer
  55516. */
  55517. getClassName(): string;
  55518. /**
  55519. * Serializes this Highlight layer
  55520. * @returns a serialized Highlight layer object
  55521. */
  55522. serialize(): any;
  55523. /**
  55524. * Creates a Highlight layer from parsed Highlight layer data
  55525. * @param parsedHightlightLayer defines the Highlight layer data
  55526. * @param scene defines the current scene
  55527. * @param rootUrl defines the root URL containing the Highlight layer information
  55528. * @returns a parsed Highlight layer
  55529. */
  55530. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55531. }
  55532. }
  55533. declare module "babylonjs/Layers/layerSceneComponent" {
  55534. import { Scene } from "babylonjs/scene";
  55535. import { ISceneComponent } from "babylonjs/sceneComponent";
  55536. import { Layer } from "babylonjs/Layers/layer";
  55537. import { AbstractScene } from "babylonjs/abstractScene";
  55538. module "babylonjs/abstractScene" {
  55539. interface AbstractScene {
  55540. /**
  55541. * The list of layers (background and foreground) of the scene
  55542. */
  55543. layers: Array<Layer>;
  55544. }
  55545. }
  55546. /**
  55547. * Defines the layer scene component responsible to manage any layers
  55548. * in a given scene.
  55549. */
  55550. export class LayerSceneComponent implements ISceneComponent {
  55551. /**
  55552. * The component name helpfull to identify the component in the list of scene components.
  55553. */
  55554. readonly name: string;
  55555. /**
  55556. * The scene the component belongs to.
  55557. */
  55558. scene: Scene;
  55559. private _engine;
  55560. /**
  55561. * Creates a new instance of the component for the given scene
  55562. * @param scene Defines the scene to register the component in
  55563. */
  55564. constructor(scene: Scene);
  55565. /**
  55566. * Registers the component in a given scene
  55567. */
  55568. register(): void;
  55569. /**
  55570. * Rebuilds the elements related to this component in case of
  55571. * context lost for instance.
  55572. */
  55573. rebuild(): void;
  55574. /**
  55575. * Disposes the component and the associated ressources.
  55576. */
  55577. dispose(): void;
  55578. private _draw;
  55579. private _drawCameraPredicate;
  55580. private _drawCameraBackground;
  55581. private _drawCameraForeground;
  55582. private _drawRenderTargetPredicate;
  55583. private _drawRenderTargetBackground;
  55584. private _drawRenderTargetForeground;
  55585. /**
  55586. * Adds all the elements from the container to the scene
  55587. * @param container the container holding the elements
  55588. */
  55589. addFromContainer(container: AbstractScene): void;
  55590. /**
  55591. * Removes all the elements in the container from the scene
  55592. * @param container contains the elements to remove
  55593. * @param dispose if the removed element should be disposed (default: false)
  55594. */
  55595. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55596. }
  55597. }
  55598. declare module "babylonjs/Shaders/layer.fragment" {
  55599. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55600. /** @hidden */
  55601. export var layerPixelShader: {
  55602. name: string;
  55603. shader: string;
  55604. };
  55605. }
  55606. declare module "babylonjs/Shaders/layer.vertex" {
  55607. /** @hidden */
  55608. export var layerVertexShader: {
  55609. name: string;
  55610. shader: string;
  55611. };
  55612. }
  55613. declare module "babylonjs/Layers/layer" {
  55614. import { Observable } from "babylonjs/Misc/observable";
  55615. import { Nullable } from "babylonjs/types";
  55616. import { Scene } from "babylonjs/scene";
  55617. import { Vector2 } from "babylonjs/Maths/math.vector";
  55618. import { Color4 } from "babylonjs/Maths/math.color";
  55619. import { Texture } from "babylonjs/Materials/Textures/texture";
  55620. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55621. import "babylonjs/Shaders/layer.fragment";
  55622. import "babylonjs/Shaders/layer.vertex";
  55623. /**
  55624. * This represents a full screen 2d layer.
  55625. * This can be useful to display a picture in the background of your scene for instance.
  55626. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55627. */
  55628. export class Layer {
  55629. /**
  55630. * Define the name of the layer.
  55631. */
  55632. name: string;
  55633. /**
  55634. * Define the texture the layer should display.
  55635. */
  55636. texture: Nullable<Texture>;
  55637. /**
  55638. * Is the layer in background or foreground.
  55639. */
  55640. isBackground: boolean;
  55641. /**
  55642. * Define the color of the layer (instead of texture).
  55643. */
  55644. color: Color4;
  55645. /**
  55646. * Define the scale of the layer in order to zoom in out of the texture.
  55647. */
  55648. scale: Vector2;
  55649. /**
  55650. * Define an offset for the layer in order to shift the texture.
  55651. */
  55652. offset: Vector2;
  55653. /**
  55654. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55655. */
  55656. alphaBlendingMode: number;
  55657. /**
  55658. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55659. * Alpha test will not mix with the background color in case of transparency.
  55660. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55661. */
  55662. alphaTest: boolean;
  55663. /**
  55664. * Define a mask to restrict the layer to only some of the scene cameras.
  55665. */
  55666. layerMask: number;
  55667. /**
  55668. * Define the list of render target the layer is visible into.
  55669. */
  55670. renderTargetTextures: RenderTargetTexture[];
  55671. /**
  55672. * Define if the layer is only used in renderTarget or if it also
  55673. * renders in the main frame buffer of the canvas.
  55674. */
  55675. renderOnlyInRenderTargetTextures: boolean;
  55676. private _scene;
  55677. private _vertexBuffers;
  55678. private _indexBuffer;
  55679. private _effect;
  55680. private _previousDefines;
  55681. /**
  55682. * An event triggered when the layer is disposed.
  55683. */
  55684. onDisposeObservable: Observable<Layer>;
  55685. private _onDisposeObserver;
  55686. /**
  55687. * Back compatibility with callback before the onDisposeObservable existed.
  55688. * The set callback will be triggered when the layer has been disposed.
  55689. */
  55690. set onDispose(callback: () => void);
  55691. /**
  55692. * An event triggered before rendering the scene
  55693. */
  55694. onBeforeRenderObservable: Observable<Layer>;
  55695. private _onBeforeRenderObserver;
  55696. /**
  55697. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55698. * The set callback will be triggered just before rendering the layer.
  55699. */
  55700. set onBeforeRender(callback: () => void);
  55701. /**
  55702. * An event triggered after rendering the scene
  55703. */
  55704. onAfterRenderObservable: Observable<Layer>;
  55705. private _onAfterRenderObserver;
  55706. /**
  55707. * Back compatibility with callback before the onAfterRenderObservable existed.
  55708. * The set callback will be triggered just after rendering the layer.
  55709. */
  55710. set onAfterRender(callback: () => void);
  55711. /**
  55712. * Instantiates a new layer.
  55713. * This represents a full screen 2d layer.
  55714. * This can be useful to display a picture in the background of your scene for instance.
  55715. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55716. * @param name Define the name of the layer in the scene
  55717. * @param imgUrl Define the url of the texture to display in the layer
  55718. * @param scene Define the scene the layer belongs to
  55719. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55720. * @param color Defines a color for the layer
  55721. */
  55722. constructor(
  55723. /**
  55724. * Define the name of the layer.
  55725. */
  55726. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55727. private _createIndexBuffer;
  55728. /** @hidden */
  55729. _rebuild(): void;
  55730. /**
  55731. * Renders the layer in the scene.
  55732. */
  55733. render(): void;
  55734. /**
  55735. * Disposes and releases the associated ressources.
  55736. */
  55737. dispose(): void;
  55738. }
  55739. }
  55740. declare module "babylonjs/Layers/index" {
  55741. export * from "babylonjs/Layers/effectLayer";
  55742. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55743. export * from "babylonjs/Layers/glowLayer";
  55744. export * from "babylonjs/Layers/highlightLayer";
  55745. export * from "babylonjs/Layers/layer";
  55746. export * from "babylonjs/Layers/layerSceneComponent";
  55747. }
  55748. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55749. /** @hidden */
  55750. export var lensFlarePixelShader: {
  55751. name: string;
  55752. shader: string;
  55753. };
  55754. }
  55755. declare module "babylonjs/Shaders/lensFlare.vertex" {
  55756. /** @hidden */
  55757. export var lensFlareVertexShader: {
  55758. name: string;
  55759. shader: string;
  55760. };
  55761. }
  55762. declare module "babylonjs/LensFlares/lensFlareSystem" {
  55763. import { Scene } from "babylonjs/scene";
  55764. import { Vector3 } from "babylonjs/Maths/math.vector";
  55765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55766. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  55767. import "babylonjs/Shaders/lensFlare.fragment";
  55768. import "babylonjs/Shaders/lensFlare.vertex";
  55769. import { Viewport } from "babylonjs/Maths/math.viewport";
  55770. /**
  55771. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55772. * It is usually composed of several `lensFlare`.
  55773. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55774. */
  55775. export class LensFlareSystem {
  55776. /**
  55777. * Define the name of the lens flare system
  55778. */
  55779. name: string;
  55780. /**
  55781. * List of lens flares used in this system.
  55782. */
  55783. lensFlares: LensFlare[];
  55784. /**
  55785. * Define a limit from the border the lens flare can be visible.
  55786. */
  55787. borderLimit: number;
  55788. /**
  55789. * Define a viewport border we do not want to see the lens flare in.
  55790. */
  55791. viewportBorder: number;
  55792. /**
  55793. * Define a predicate which could limit the list of meshes able to occlude the effect.
  55794. */
  55795. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55796. /**
  55797. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  55798. */
  55799. layerMask: number;
  55800. /**
  55801. * Define the id of the lens flare system in the scene.
  55802. * (equal to name by default)
  55803. */
  55804. id: string;
  55805. private _scene;
  55806. private _emitter;
  55807. private _vertexBuffers;
  55808. private _indexBuffer;
  55809. private _effect;
  55810. private _positionX;
  55811. private _positionY;
  55812. private _isEnabled;
  55813. /** @hidden */
  55814. static _SceneComponentInitialization: (scene: Scene) => void;
  55815. /**
  55816. * Instantiates a lens flare system.
  55817. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  55818. * It is usually composed of several `lensFlare`.
  55819. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55820. * @param name Define the name of the lens flare system in the scene
  55821. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  55822. * @param scene Define the scene the lens flare system belongs to
  55823. */
  55824. constructor(
  55825. /**
  55826. * Define the name of the lens flare system
  55827. */
  55828. name: string, emitter: any, scene: Scene);
  55829. /**
  55830. * Define if the lens flare system is enabled.
  55831. */
  55832. get isEnabled(): boolean;
  55833. set isEnabled(value: boolean);
  55834. /**
  55835. * Get the scene the effects belongs to.
  55836. * @returns the scene holding the lens flare system
  55837. */
  55838. getScene(): Scene;
  55839. /**
  55840. * Get the emitter of the lens flare system.
  55841. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55842. * @returns the emitter of the lens flare system
  55843. */
  55844. getEmitter(): any;
  55845. /**
  55846. * Set the emitter of the lens flare system.
  55847. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  55848. * @param newEmitter Define the new emitter of the system
  55849. */
  55850. setEmitter(newEmitter: any): void;
  55851. /**
  55852. * Get the lens flare system emitter position.
  55853. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  55854. * @returns the position
  55855. */
  55856. getEmitterPosition(): Vector3;
  55857. /**
  55858. * @hidden
  55859. */
  55860. computeEffectivePosition(globalViewport: Viewport): boolean;
  55861. /** @hidden */
  55862. _isVisible(): boolean;
  55863. /**
  55864. * @hidden
  55865. */
  55866. render(): boolean;
  55867. /**
  55868. * Dispose and release the lens flare with its associated resources.
  55869. */
  55870. dispose(): void;
  55871. /**
  55872. * Parse a lens flare system from a JSON repressentation
  55873. * @param parsedLensFlareSystem Define the JSON to parse
  55874. * @param scene Define the scene the parsed system should be instantiated in
  55875. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  55876. * @returns the parsed system
  55877. */
  55878. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  55879. /**
  55880. * Serialize the current Lens Flare System into a JSON representation.
  55881. * @returns the serialized JSON
  55882. */
  55883. serialize(): any;
  55884. }
  55885. }
  55886. declare module "babylonjs/LensFlares/lensFlare" {
  55887. import { Nullable } from "babylonjs/types";
  55888. import { Color3 } from "babylonjs/Maths/math.color";
  55889. import { Texture } from "babylonjs/Materials/Textures/texture";
  55890. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55891. /**
  55892. * This represents one of the lens effect in a `lensFlareSystem`.
  55893. * It controls one of the indiviual texture used in the effect.
  55894. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55895. */
  55896. export class LensFlare {
  55897. /**
  55898. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55899. */
  55900. size: number;
  55901. /**
  55902. * 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.
  55903. */
  55904. position: number;
  55905. /**
  55906. * Define the lens color.
  55907. */
  55908. color: Color3;
  55909. /**
  55910. * Define the lens texture.
  55911. */
  55912. texture: Nullable<Texture>;
  55913. /**
  55914. * Define the alpha mode to render this particular lens.
  55915. */
  55916. alphaMode: number;
  55917. private _system;
  55918. /**
  55919. * Creates a new Lens Flare.
  55920. * This represents one of the lens effect in a `lensFlareSystem`.
  55921. * It controls one of the indiviual texture used in the effect.
  55922. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55923. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  55924. * @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.
  55925. * @param color Define the lens color
  55926. * @param imgUrl Define the lens texture url
  55927. * @param system Define the `lensFlareSystem` this flare is part of
  55928. * @returns The newly created Lens Flare
  55929. */
  55930. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  55931. /**
  55932. * Instantiates a new Lens Flare.
  55933. * This represents one of the lens effect in a `lensFlareSystem`.
  55934. * It controls one of the indiviual texture used in the effect.
  55935. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55936. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  55937. * @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.
  55938. * @param color Define the lens color
  55939. * @param imgUrl Define the lens texture url
  55940. * @param system Define the `lensFlareSystem` this flare is part of
  55941. */
  55942. constructor(
  55943. /**
  55944. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  55945. */
  55946. size: number,
  55947. /**
  55948. * 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.
  55949. */
  55950. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  55951. /**
  55952. * Dispose and release the lens flare with its associated resources.
  55953. */
  55954. dispose(): void;
  55955. }
  55956. }
  55957. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  55958. import { Nullable } from "babylonjs/types";
  55959. import { Scene } from "babylonjs/scene";
  55960. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55961. import { AbstractScene } from "babylonjs/abstractScene";
  55962. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  55963. module "babylonjs/abstractScene" {
  55964. interface AbstractScene {
  55965. /**
  55966. * The list of lens flare system added to the scene
  55967. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  55968. */
  55969. lensFlareSystems: Array<LensFlareSystem>;
  55970. /**
  55971. * Removes the given lens flare system from this scene.
  55972. * @param toRemove The lens flare system to remove
  55973. * @returns The index of the removed lens flare system
  55974. */
  55975. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  55976. /**
  55977. * Adds the given lens flare system to this scene
  55978. * @param newLensFlareSystem The lens flare system to add
  55979. */
  55980. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  55981. /**
  55982. * Gets a lens flare system using its name
  55983. * @param name defines the name to look for
  55984. * @returns the lens flare system or null if not found
  55985. */
  55986. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  55987. /**
  55988. * Gets a lens flare system using its id
  55989. * @param id defines the id to look for
  55990. * @returns the lens flare system or null if not found
  55991. */
  55992. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  55993. }
  55994. }
  55995. /**
  55996. * Defines the lens flare scene component responsible to manage any lens flares
  55997. * in a given scene.
  55998. */
  55999. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56000. /**
  56001. * The component name helpfull to identify the component in the list of scene components.
  56002. */
  56003. readonly name: string;
  56004. /**
  56005. * The scene the component belongs to.
  56006. */
  56007. scene: Scene;
  56008. /**
  56009. * Creates a new instance of the component for the given scene
  56010. * @param scene Defines the scene to register the component in
  56011. */
  56012. constructor(scene: Scene);
  56013. /**
  56014. * Registers the component in a given scene
  56015. */
  56016. register(): void;
  56017. /**
  56018. * Rebuilds the elements related to this component in case of
  56019. * context lost for instance.
  56020. */
  56021. rebuild(): void;
  56022. /**
  56023. * Adds all the elements from the container to the scene
  56024. * @param container the container holding the elements
  56025. */
  56026. addFromContainer(container: AbstractScene): void;
  56027. /**
  56028. * Removes all the elements in the container from the scene
  56029. * @param container contains the elements to remove
  56030. * @param dispose if the removed element should be disposed (default: false)
  56031. */
  56032. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56033. /**
  56034. * Serializes the component data to the specified json object
  56035. * @param serializationObject The object to serialize to
  56036. */
  56037. serialize(serializationObject: any): void;
  56038. /**
  56039. * Disposes the component and the associated ressources.
  56040. */
  56041. dispose(): void;
  56042. private _draw;
  56043. }
  56044. }
  56045. declare module "babylonjs/LensFlares/index" {
  56046. export * from "babylonjs/LensFlares/lensFlare";
  56047. export * from "babylonjs/LensFlares/lensFlareSystem";
  56048. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56049. }
  56050. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56051. import { Scene } from "babylonjs/scene";
  56052. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56053. import { AbstractScene } from "babylonjs/abstractScene";
  56054. /**
  56055. * Defines the shadow generator component responsible to manage any shadow generators
  56056. * in a given scene.
  56057. */
  56058. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56059. /**
  56060. * The component name helpfull to identify the component in the list of scene components.
  56061. */
  56062. readonly name: string;
  56063. /**
  56064. * The scene the component belongs to.
  56065. */
  56066. scene: Scene;
  56067. /**
  56068. * Creates a new instance of the component for the given scene
  56069. * @param scene Defines the scene to register the component in
  56070. */
  56071. constructor(scene: Scene);
  56072. /**
  56073. * Registers the component in a given scene
  56074. */
  56075. register(): void;
  56076. /**
  56077. * Rebuilds the elements related to this component in case of
  56078. * context lost for instance.
  56079. */
  56080. rebuild(): void;
  56081. /**
  56082. * Serializes the component data to the specified json object
  56083. * @param serializationObject The object to serialize to
  56084. */
  56085. serialize(serializationObject: any): void;
  56086. /**
  56087. * Adds all the elements from the container to the scene
  56088. * @param container the container holding the elements
  56089. */
  56090. addFromContainer(container: AbstractScene): void;
  56091. /**
  56092. * Removes all the elements in the container from the scene
  56093. * @param container contains the elements to remove
  56094. * @param dispose if the removed element should be disposed (default: false)
  56095. */
  56096. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56097. /**
  56098. * Rebuilds the elements related to this component in case of
  56099. * context lost for instance.
  56100. */
  56101. dispose(): void;
  56102. private _gatherRenderTargets;
  56103. }
  56104. }
  56105. declare module "babylonjs/Lights/Shadows/index" {
  56106. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56107. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56108. }
  56109. declare module "babylonjs/Lights/pointLight" {
  56110. import { Scene } from "babylonjs/scene";
  56111. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56113. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56114. import { Effect } from "babylonjs/Materials/effect";
  56115. /**
  56116. * A point light is a light defined by an unique point in world space.
  56117. * The light is emitted in every direction from this point.
  56118. * A good example of a point light is a standard light bulb.
  56119. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56120. */
  56121. export class PointLight extends ShadowLight {
  56122. private _shadowAngle;
  56123. /**
  56124. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56125. * This specifies what angle the shadow will use to be created.
  56126. *
  56127. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56128. */
  56129. get shadowAngle(): number;
  56130. /**
  56131. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56132. * This specifies what angle the shadow will use to be created.
  56133. *
  56134. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56135. */
  56136. set shadowAngle(value: number);
  56137. /**
  56138. * Gets the direction if it has been set.
  56139. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56140. */
  56141. get direction(): Vector3;
  56142. /**
  56143. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56144. */
  56145. set direction(value: Vector3);
  56146. /**
  56147. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56148. * A PointLight emits the light in every direction.
  56149. * It can cast shadows.
  56150. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56151. * ```javascript
  56152. * var pointLight = new PointLight("pl", camera.position, scene);
  56153. * ```
  56154. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56155. * @param name The light friendly name
  56156. * @param position The position of the point light in the scene
  56157. * @param scene The scene the lights belongs to
  56158. */
  56159. constructor(name: string, position: Vector3, scene: Scene);
  56160. /**
  56161. * Returns the string "PointLight"
  56162. * @returns the class name
  56163. */
  56164. getClassName(): string;
  56165. /**
  56166. * Returns the integer 0.
  56167. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56168. */
  56169. getTypeID(): number;
  56170. /**
  56171. * Specifies wether or not the shadowmap should be a cube texture.
  56172. * @returns true if the shadowmap needs to be a cube texture.
  56173. */
  56174. needCube(): boolean;
  56175. /**
  56176. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56177. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56178. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56179. */
  56180. getShadowDirection(faceIndex?: number): Vector3;
  56181. /**
  56182. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56183. * - fov = PI / 2
  56184. * - aspect ratio : 1.0
  56185. * - z-near and far equal to the active camera minZ and maxZ.
  56186. * Returns the PointLight.
  56187. */
  56188. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56189. protected _buildUniformLayout(): void;
  56190. /**
  56191. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56192. * @param effect The effect to update
  56193. * @param lightIndex The index of the light in the effect to update
  56194. * @returns The point light
  56195. */
  56196. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56197. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56198. /**
  56199. * Prepares the list of defines specific to the light type.
  56200. * @param defines the list of defines
  56201. * @param lightIndex defines the index of the light for the effect
  56202. */
  56203. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56204. }
  56205. }
  56206. declare module "babylonjs/Lights/index" {
  56207. export * from "babylonjs/Lights/light";
  56208. export * from "babylonjs/Lights/shadowLight";
  56209. export * from "babylonjs/Lights/Shadows/index";
  56210. export * from "babylonjs/Lights/directionalLight";
  56211. export * from "babylonjs/Lights/hemisphericLight";
  56212. export * from "babylonjs/Lights/pointLight";
  56213. export * from "babylonjs/Lights/spotLight";
  56214. }
  56215. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56216. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56217. /**
  56218. * Header information of HDR texture files.
  56219. */
  56220. export interface HDRInfo {
  56221. /**
  56222. * The height of the texture in pixels.
  56223. */
  56224. height: number;
  56225. /**
  56226. * The width of the texture in pixels.
  56227. */
  56228. width: number;
  56229. /**
  56230. * The index of the beginning of the data in the binary file.
  56231. */
  56232. dataPosition: number;
  56233. }
  56234. /**
  56235. * This groups tools to convert HDR texture to native colors array.
  56236. */
  56237. export class HDRTools {
  56238. private static Ldexp;
  56239. private static Rgbe2float;
  56240. private static readStringLine;
  56241. /**
  56242. * Reads header information from an RGBE texture stored in a native array.
  56243. * More information on this format are available here:
  56244. * https://en.wikipedia.org/wiki/RGBE_image_format
  56245. *
  56246. * @param uint8array The binary file stored in native array.
  56247. * @return The header information.
  56248. */
  56249. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  56250. /**
  56251. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  56252. * This RGBE texture needs to store the information as a panorama.
  56253. *
  56254. * More information on this format are available here:
  56255. * https://en.wikipedia.org/wiki/RGBE_image_format
  56256. *
  56257. * @param buffer The binary file stored in an array buffer.
  56258. * @param size The expected size of the extracted cubemap.
  56259. * @return The Cube Map information.
  56260. */
  56261. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  56262. /**
  56263. * Returns the pixels data extracted from an RGBE texture.
  56264. * This pixels will be stored left to right up to down in the R G B order in one array.
  56265. *
  56266. * More information on this format are available here:
  56267. * https://en.wikipedia.org/wiki/RGBE_image_format
  56268. *
  56269. * @param uint8array The binary file stored in an array buffer.
  56270. * @param hdrInfo The header information of the file.
  56271. * @return The pixels data in RGB right to left up to down order.
  56272. */
  56273. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  56274. private static RGBE_ReadPixels_RLE;
  56275. }
  56276. }
  56277. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  56278. import { Nullable } from "babylonjs/types";
  56279. import { Scene } from "babylonjs/scene";
  56280. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56281. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56282. import "babylonjs/Engines/Extensions/engine.rawTexture";
  56283. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  56284. /**
  56285. * This represents a texture coming from an HDR input.
  56286. *
  56287. * The only supported format is currently panorama picture stored in RGBE format.
  56288. * Example of such files can be found on HDRLib: http://hdrlib.com/
  56289. */
  56290. export class HDRCubeTexture extends BaseTexture {
  56291. private static _facesMapping;
  56292. private _generateHarmonics;
  56293. private _noMipmap;
  56294. private _textureMatrix;
  56295. private _size;
  56296. private _onLoad;
  56297. private _onError;
  56298. /**
  56299. * The texture URL.
  56300. */
  56301. url: string;
  56302. /**
  56303. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  56304. */
  56305. coordinatesMode: number;
  56306. protected _isBlocking: boolean;
  56307. /**
  56308. * Sets wether or not the texture is blocking during loading.
  56309. */
  56310. set isBlocking(value: boolean);
  56311. /**
  56312. * Gets wether or not the texture is blocking during loading.
  56313. */
  56314. get isBlocking(): boolean;
  56315. protected _rotationY: number;
  56316. /**
  56317. * Sets texture matrix rotation angle around Y axis in radians.
  56318. */
  56319. set rotationY(value: number);
  56320. /**
  56321. * Gets texture matrix rotation angle around Y axis radians.
  56322. */
  56323. get rotationY(): number;
  56324. /**
  56325. * Gets or sets the center of the bounding box associated with the cube texture
  56326. * It must define where the camera used to render the texture was set
  56327. */
  56328. boundingBoxPosition: Vector3;
  56329. private _boundingBoxSize;
  56330. /**
  56331. * Gets or sets the size of the bounding box associated with the cube texture
  56332. * When defined, the cubemap will switch to local mode
  56333. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  56334. * @example https://www.babylonjs-playground.com/#RNASML
  56335. */
  56336. set boundingBoxSize(value: Vector3);
  56337. get boundingBoxSize(): Vector3;
  56338. /**
  56339. * Instantiates an HDRTexture from the following parameters.
  56340. *
  56341. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  56342. * @param scene The scene the texture will be used in
  56343. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56344. * @param noMipmap Forces to not generate the mipmap if true
  56345. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  56346. * @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)
  56347. * @param reserved Reserved flag for internal use.
  56348. */
  56349. 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>);
  56350. /**
  56351. * Get the current class name of the texture useful for serialization or dynamic coding.
  56352. * @returns "HDRCubeTexture"
  56353. */
  56354. getClassName(): string;
  56355. /**
  56356. * Occurs when the file is raw .hdr file.
  56357. */
  56358. private loadTexture;
  56359. clone(): HDRCubeTexture;
  56360. delayLoad(): void;
  56361. /**
  56362. * Get the texture reflection matrix used to rotate/transform the reflection.
  56363. * @returns the reflection matrix
  56364. */
  56365. getReflectionTextureMatrix(): Matrix;
  56366. /**
  56367. * Set the texture reflection matrix used to rotate/transform the reflection.
  56368. * @param value Define the reflection matrix to set
  56369. */
  56370. setReflectionTextureMatrix(value: Matrix): void;
  56371. /**
  56372. * Parses a JSON representation of an HDR Texture in order to create the texture
  56373. * @param parsedTexture Define the JSON representation
  56374. * @param scene Define the scene the texture should be created in
  56375. * @param rootUrl Define the root url in case we need to load relative dependencies
  56376. * @returns the newly created texture after parsing
  56377. */
  56378. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  56379. serialize(): any;
  56380. }
  56381. }
  56382. declare module "babylonjs/Physics/physicsEngine" {
  56383. import { Nullable } from "babylonjs/types";
  56384. import { Vector3 } from "babylonjs/Maths/math.vector";
  56385. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56386. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  56387. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  56388. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56389. /**
  56390. * Class used to control physics engine
  56391. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56392. */
  56393. export class PhysicsEngine implements IPhysicsEngine {
  56394. private _physicsPlugin;
  56395. /**
  56396. * Global value used to control the smallest number supported by the simulation
  56397. */
  56398. static Epsilon: number;
  56399. private _impostors;
  56400. private _joints;
  56401. private _subTimeStep;
  56402. /**
  56403. * Gets the gravity vector used by the simulation
  56404. */
  56405. gravity: Vector3;
  56406. /**
  56407. * Factory used to create the default physics plugin.
  56408. * @returns The default physics plugin
  56409. */
  56410. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  56411. /**
  56412. * Creates a new Physics Engine
  56413. * @param gravity defines the gravity vector used by the simulation
  56414. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  56415. */
  56416. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  56417. /**
  56418. * Sets the gravity vector used by the simulation
  56419. * @param gravity defines the gravity vector to use
  56420. */
  56421. setGravity(gravity: Vector3): void;
  56422. /**
  56423. * Set the time step of the physics engine.
  56424. * Default is 1/60.
  56425. * To slow it down, enter 1/600 for example.
  56426. * To speed it up, 1/30
  56427. * @param newTimeStep defines the new timestep to apply to this world.
  56428. */
  56429. setTimeStep(newTimeStep?: number): void;
  56430. /**
  56431. * Get the time step of the physics engine.
  56432. * @returns the current time step
  56433. */
  56434. getTimeStep(): number;
  56435. /**
  56436. * Set the sub time step of the physics engine.
  56437. * Default is 0 meaning there is no sub steps
  56438. * To increase physics resolution precision, set a small value (like 1 ms)
  56439. * @param subTimeStep defines the new sub timestep used for physics resolution.
  56440. */
  56441. setSubTimeStep(subTimeStep?: number): void;
  56442. /**
  56443. * Get the sub time step of the physics engine.
  56444. * @returns the current sub time step
  56445. */
  56446. getSubTimeStep(): number;
  56447. /**
  56448. * Release all resources
  56449. */
  56450. dispose(): void;
  56451. /**
  56452. * Gets the name of the current physics plugin
  56453. * @returns the name of the plugin
  56454. */
  56455. getPhysicsPluginName(): string;
  56456. /**
  56457. * Adding a new impostor for the impostor tracking.
  56458. * This will be done by the impostor itself.
  56459. * @param impostor the impostor to add
  56460. */
  56461. addImpostor(impostor: PhysicsImpostor): void;
  56462. /**
  56463. * Remove an impostor from the engine.
  56464. * This impostor and its mesh will not longer be updated by the physics engine.
  56465. * @param impostor the impostor to remove
  56466. */
  56467. removeImpostor(impostor: PhysicsImpostor): void;
  56468. /**
  56469. * Add a joint to the physics engine
  56470. * @param mainImpostor defines the main impostor to which the joint is added.
  56471. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  56472. * @param joint defines the joint that will connect both impostors.
  56473. */
  56474. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  56475. /**
  56476. * Removes a joint from the simulation
  56477. * @param mainImpostor defines the impostor used with the joint
  56478. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  56479. * @param joint defines the joint to remove
  56480. */
  56481. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  56482. /**
  56483. * Called by the scene. No need to call it.
  56484. * @param delta defines the timespam between frames
  56485. */
  56486. _step(delta: number): void;
  56487. /**
  56488. * Gets the current plugin used to run the simulation
  56489. * @returns current plugin
  56490. */
  56491. getPhysicsPlugin(): IPhysicsEnginePlugin;
  56492. /**
  56493. * Gets the list of physic impostors
  56494. * @returns an array of PhysicsImpostor
  56495. */
  56496. getImpostors(): Array<PhysicsImpostor>;
  56497. /**
  56498. * Gets the impostor for a physics enabled object
  56499. * @param object defines the object impersonated by the impostor
  56500. * @returns the PhysicsImpostor or null if not found
  56501. */
  56502. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  56503. /**
  56504. * Gets the impostor for a physics body object
  56505. * @param body defines physics body used by the impostor
  56506. * @returns the PhysicsImpostor or null if not found
  56507. */
  56508. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  56509. /**
  56510. * Does a raycast in the physics world
  56511. * @param from when should the ray start?
  56512. * @param to when should the ray end?
  56513. * @returns PhysicsRaycastResult
  56514. */
  56515. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56516. }
  56517. }
  56518. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  56519. import { Nullable } from "babylonjs/types";
  56520. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  56521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56522. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  56523. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56524. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  56525. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56526. /** @hidden */
  56527. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  56528. private _useDeltaForWorldStep;
  56529. world: any;
  56530. name: string;
  56531. private _physicsMaterials;
  56532. private _fixedTimeStep;
  56533. private _cannonRaycastResult;
  56534. private _raycastResult;
  56535. private _physicsBodysToRemoveAfterStep;
  56536. BJSCANNON: any;
  56537. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  56538. setGravity(gravity: Vector3): void;
  56539. setTimeStep(timeStep: number): void;
  56540. getTimeStep(): number;
  56541. executeStep(delta: number): void;
  56542. private _removeMarkedPhysicsBodiesFromWorld;
  56543. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56544. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56545. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56546. private _processChildMeshes;
  56547. removePhysicsBody(impostor: PhysicsImpostor): void;
  56548. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56549. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56550. private _addMaterial;
  56551. private _checkWithEpsilon;
  56552. private _createShape;
  56553. private _createHeightmap;
  56554. private _minus90X;
  56555. private _plus90X;
  56556. private _tmpPosition;
  56557. private _tmpDeltaPosition;
  56558. private _tmpUnityRotation;
  56559. private _updatePhysicsBodyTransformation;
  56560. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56561. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56562. isSupported(): boolean;
  56563. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56564. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56565. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56566. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56567. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56568. getBodyMass(impostor: PhysicsImpostor): number;
  56569. getBodyFriction(impostor: PhysicsImpostor): number;
  56570. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56571. getBodyRestitution(impostor: PhysicsImpostor): number;
  56572. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56573. sleepBody(impostor: PhysicsImpostor): void;
  56574. wakeUpBody(impostor: PhysicsImpostor): void;
  56575. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  56576. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  56577. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  56578. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56579. getRadius(impostor: PhysicsImpostor): number;
  56580. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56581. dispose(): void;
  56582. private _extendNamespace;
  56583. /**
  56584. * Does a raycast in the physics world
  56585. * @param from when should the ray start?
  56586. * @param to when should the ray end?
  56587. * @returns PhysicsRaycastResult
  56588. */
  56589. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56590. }
  56591. }
  56592. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  56593. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  56594. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56595. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  56596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56597. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  56598. import { Nullable } from "babylonjs/types";
  56599. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56600. /** @hidden */
  56601. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  56602. world: any;
  56603. name: string;
  56604. BJSOIMO: any;
  56605. private _raycastResult;
  56606. constructor(iterations?: number, oimoInjection?: any);
  56607. setGravity(gravity: Vector3): void;
  56608. setTimeStep(timeStep: number): void;
  56609. getTimeStep(): number;
  56610. private _tmpImpostorsArray;
  56611. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56612. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56613. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56614. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56615. private _tmpPositionVector;
  56616. removePhysicsBody(impostor: PhysicsImpostor): void;
  56617. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56618. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56619. isSupported(): boolean;
  56620. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56621. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56622. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56623. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56624. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56625. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56626. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  56627. getBodyMass(impostor: PhysicsImpostor): number;
  56628. getBodyFriction(impostor: PhysicsImpostor): number;
  56629. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  56630. getBodyRestitution(impostor: PhysicsImpostor): number;
  56631. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  56632. sleepBody(impostor: PhysicsImpostor): void;
  56633. wakeUpBody(impostor: PhysicsImpostor): void;
  56634. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  56635. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  56636. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  56637. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  56638. getRadius(impostor: PhysicsImpostor): number;
  56639. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  56640. dispose(): void;
  56641. /**
  56642. * Does a raycast in the physics world
  56643. * @param from when should the ray start?
  56644. * @param to when should the ray end?
  56645. * @returns PhysicsRaycastResult
  56646. */
  56647. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  56648. }
  56649. }
  56650. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56651. import { Nullable } from "babylonjs/types";
  56652. import { Scene } from "babylonjs/scene";
  56653. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56654. import { Color4 } from "babylonjs/Maths/math.color";
  56655. import { Mesh } from "babylonjs/Meshes/mesh";
  56656. /**
  56657. * Class containing static functions to help procedurally build meshes
  56658. */
  56659. export class RibbonBuilder {
  56660. /**
  56661. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56662. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56663. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56664. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56665. * * 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
  56666. * * 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
  56667. * * 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
  56668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56670. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56671. * * 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
  56672. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56673. * * 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
  56674. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56676. * @param name defines the name of the mesh
  56677. * @param options defines the options used to create the mesh
  56678. * @param scene defines the hosting scene
  56679. * @returns the ribbon mesh
  56680. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56681. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56682. */
  56683. static CreateRibbon(name: string, options: {
  56684. pathArray: Vector3[][];
  56685. closeArray?: boolean;
  56686. closePath?: boolean;
  56687. offset?: number;
  56688. updatable?: boolean;
  56689. sideOrientation?: number;
  56690. frontUVs?: Vector4;
  56691. backUVs?: Vector4;
  56692. instance?: Mesh;
  56693. invertUV?: boolean;
  56694. uvs?: Vector2[];
  56695. colors?: Color4[];
  56696. }, scene?: Nullable<Scene>): Mesh;
  56697. }
  56698. }
  56699. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56700. import { Nullable } from "babylonjs/types";
  56701. import { Scene } from "babylonjs/scene";
  56702. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56703. import { Mesh } from "babylonjs/Meshes/mesh";
  56704. /**
  56705. * Class containing static functions to help procedurally build meshes
  56706. */
  56707. export class ShapeBuilder {
  56708. /**
  56709. * 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.
  56710. * * 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.
  56711. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56712. * * 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.
  56713. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56714. * * 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
  56715. * * 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
  56716. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56719. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56721. * @param name defines the name of the mesh
  56722. * @param options defines the options used to create the mesh
  56723. * @param scene defines the hosting scene
  56724. * @returns the extruded shape mesh
  56725. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56726. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56727. */
  56728. static ExtrudeShape(name: string, options: {
  56729. shape: Vector3[];
  56730. path: Vector3[];
  56731. scale?: number;
  56732. rotation?: number;
  56733. cap?: number;
  56734. updatable?: boolean;
  56735. sideOrientation?: number;
  56736. frontUVs?: Vector4;
  56737. backUVs?: Vector4;
  56738. instance?: Mesh;
  56739. invertUV?: boolean;
  56740. }, scene?: Nullable<Scene>): Mesh;
  56741. /**
  56742. * Creates an custom extruded shape mesh.
  56743. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56744. * * 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.
  56745. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56746. * * 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
  56747. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56748. * * 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
  56749. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56750. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56751. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56752. * * 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
  56753. * * 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
  56754. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56757. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56759. * @param name defines the name of the mesh
  56760. * @param options defines the options used to create the mesh
  56761. * @param scene defines the hosting scene
  56762. * @returns the custom extruded shape mesh
  56763. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56764. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56765. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56766. */
  56767. static ExtrudeShapeCustom(name: string, options: {
  56768. shape: Vector3[];
  56769. path: Vector3[];
  56770. scaleFunction?: any;
  56771. rotationFunction?: any;
  56772. ribbonCloseArray?: boolean;
  56773. ribbonClosePath?: boolean;
  56774. cap?: number;
  56775. updatable?: boolean;
  56776. sideOrientation?: number;
  56777. frontUVs?: Vector4;
  56778. backUVs?: Vector4;
  56779. instance?: Mesh;
  56780. invertUV?: boolean;
  56781. }, scene?: Nullable<Scene>): Mesh;
  56782. private static _ExtrudeShapeGeneric;
  56783. }
  56784. }
  56785. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  56786. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  56787. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  56788. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56789. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  56790. import { Nullable } from "babylonjs/types";
  56791. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56792. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  56793. /**
  56794. * AmmoJS Physics plugin
  56795. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  56796. * @see https://github.com/kripken/ammo.js/
  56797. */
  56798. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  56799. private _useDeltaForWorldStep;
  56800. /**
  56801. * Reference to the Ammo library
  56802. */
  56803. bjsAMMO: any;
  56804. /**
  56805. * Created ammoJS world which physics bodies are added to
  56806. */
  56807. world: any;
  56808. /**
  56809. * Name of the plugin
  56810. */
  56811. name: string;
  56812. private _timeStep;
  56813. private _fixedTimeStep;
  56814. private _maxSteps;
  56815. private _tmpQuaternion;
  56816. private _tmpAmmoTransform;
  56817. private _tmpAmmoQuaternion;
  56818. private _tmpAmmoConcreteContactResultCallback;
  56819. private _collisionConfiguration;
  56820. private _dispatcher;
  56821. private _overlappingPairCache;
  56822. private _solver;
  56823. private _softBodySolver;
  56824. private _tmpAmmoVectorA;
  56825. private _tmpAmmoVectorB;
  56826. private _tmpAmmoVectorC;
  56827. private _tmpAmmoVectorD;
  56828. private _tmpContactCallbackResult;
  56829. private _tmpAmmoVectorRCA;
  56830. private _tmpAmmoVectorRCB;
  56831. private _raycastResult;
  56832. private static readonly DISABLE_COLLISION_FLAG;
  56833. private static readonly KINEMATIC_FLAG;
  56834. private static readonly DISABLE_DEACTIVATION_FLAG;
  56835. /**
  56836. * Initializes the ammoJS plugin
  56837. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  56838. * @param ammoInjection can be used to inject your own ammo reference
  56839. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  56840. */
  56841. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  56842. /**
  56843. * Sets the gravity of the physics world (m/(s^2))
  56844. * @param gravity Gravity to set
  56845. */
  56846. setGravity(gravity: Vector3): void;
  56847. /**
  56848. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  56849. * @param timeStep timestep to use in seconds
  56850. */
  56851. setTimeStep(timeStep: number): void;
  56852. /**
  56853. * 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)
  56854. * @param fixedTimeStep fixedTimeStep to use in seconds
  56855. */
  56856. setFixedTimeStep(fixedTimeStep: number): void;
  56857. /**
  56858. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  56859. * @param maxSteps the maximum number of steps by the physics engine per frame
  56860. */
  56861. setMaxSteps(maxSteps: number): void;
  56862. /**
  56863. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  56864. * @returns the current timestep in seconds
  56865. */
  56866. getTimeStep(): number;
  56867. /**
  56868. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  56869. */
  56870. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  56871. private _isImpostorInContact;
  56872. private _isImpostorPairInContact;
  56873. private _stepSimulation;
  56874. /**
  56875. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  56876. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  56877. * After the step the babylon meshes are set to the position of the physics imposters
  56878. * @param delta amount of time to step forward
  56879. * @param impostors array of imposters to update before/after the step
  56880. */
  56881. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  56882. /**
  56883. * Update babylon mesh to match physics world object
  56884. * @param impostor imposter to match
  56885. */
  56886. private _afterSoftStep;
  56887. /**
  56888. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56889. * @param impostor imposter to match
  56890. */
  56891. private _ropeStep;
  56892. /**
  56893. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  56894. * @param impostor imposter to match
  56895. */
  56896. private _softbodyOrClothStep;
  56897. private _tmpVector;
  56898. private _tmpMatrix;
  56899. /**
  56900. * Applies an impulse on the imposter
  56901. * @param impostor imposter to apply impulse to
  56902. * @param force amount of force to be applied to the imposter
  56903. * @param contactPoint the location to apply the impulse on the imposter
  56904. */
  56905. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56906. /**
  56907. * Applies a force on the imposter
  56908. * @param impostor imposter to apply force
  56909. * @param force amount of force to be applied to the imposter
  56910. * @param contactPoint the location to apply the force on the imposter
  56911. */
  56912. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  56913. /**
  56914. * Creates a physics body using the plugin
  56915. * @param impostor the imposter to create the physics body on
  56916. */
  56917. generatePhysicsBody(impostor: PhysicsImpostor): void;
  56918. /**
  56919. * Removes the physics body from the imposter and disposes of the body's memory
  56920. * @param impostor imposter to remove the physics body from
  56921. */
  56922. removePhysicsBody(impostor: PhysicsImpostor): void;
  56923. /**
  56924. * Generates a joint
  56925. * @param impostorJoint the imposter joint to create the joint with
  56926. */
  56927. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  56928. /**
  56929. * Removes a joint
  56930. * @param impostorJoint the imposter joint to remove the joint from
  56931. */
  56932. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  56933. private _addMeshVerts;
  56934. /**
  56935. * Initialise the soft body vertices to match its object's (mesh) vertices
  56936. * Softbody vertices (nodes) are in world space and to match this
  56937. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  56938. * @param impostor to create the softbody for
  56939. */
  56940. private _softVertexData;
  56941. /**
  56942. * Create an impostor's soft body
  56943. * @param impostor to create the softbody for
  56944. */
  56945. private _createSoftbody;
  56946. /**
  56947. * Create cloth for an impostor
  56948. * @param impostor to create the softbody for
  56949. */
  56950. private _createCloth;
  56951. /**
  56952. * Create rope for an impostor
  56953. * @param impostor to create the softbody for
  56954. */
  56955. private _createRope;
  56956. /**
  56957. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  56958. * @param impostor to create the custom physics shape for
  56959. */
  56960. private _createCustom;
  56961. private _addHullVerts;
  56962. private _createShape;
  56963. /**
  56964. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  56965. * @param impostor imposter containing the physics body and babylon object
  56966. */
  56967. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  56968. /**
  56969. * Sets the babylon object's position/rotation from the physics body's position/rotation
  56970. * @param impostor imposter containing the physics body and babylon object
  56971. * @param newPosition new position
  56972. * @param newRotation new rotation
  56973. */
  56974. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  56975. /**
  56976. * If this plugin is supported
  56977. * @returns true if its supported
  56978. */
  56979. isSupported(): boolean;
  56980. /**
  56981. * Sets the linear velocity of the physics body
  56982. * @param impostor imposter to set the velocity on
  56983. * @param velocity velocity to set
  56984. */
  56985. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56986. /**
  56987. * Sets the angular velocity of the physics body
  56988. * @param impostor imposter to set the velocity on
  56989. * @param velocity velocity to set
  56990. */
  56991. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  56992. /**
  56993. * gets the linear velocity
  56994. * @param impostor imposter to get linear velocity from
  56995. * @returns linear velocity
  56996. */
  56997. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  56998. /**
  56999. * gets the angular velocity
  57000. * @param impostor imposter to get angular velocity from
  57001. * @returns angular velocity
  57002. */
  57003. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57004. /**
  57005. * Sets the mass of physics body
  57006. * @param impostor imposter to set the mass on
  57007. * @param mass mass to set
  57008. */
  57009. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57010. /**
  57011. * Gets the mass of the physics body
  57012. * @param impostor imposter to get the mass from
  57013. * @returns mass
  57014. */
  57015. getBodyMass(impostor: PhysicsImpostor): number;
  57016. /**
  57017. * Gets friction of the impostor
  57018. * @param impostor impostor to get friction from
  57019. * @returns friction value
  57020. */
  57021. getBodyFriction(impostor: PhysicsImpostor): number;
  57022. /**
  57023. * Sets friction of the impostor
  57024. * @param impostor impostor to set friction on
  57025. * @param friction friction value
  57026. */
  57027. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57028. /**
  57029. * Gets restitution of the impostor
  57030. * @param impostor impostor to get restitution from
  57031. * @returns restitution value
  57032. */
  57033. getBodyRestitution(impostor: PhysicsImpostor): number;
  57034. /**
  57035. * Sets resitution of the impostor
  57036. * @param impostor impostor to set resitution on
  57037. * @param restitution resitution value
  57038. */
  57039. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57040. /**
  57041. * Gets pressure inside the impostor
  57042. * @param impostor impostor to get pressure from
  57043. * @returns pressure value
  57044. */
  57045. getBodyPressure(impostor: PhysicsImpostor): number;
  57046. /**
  57047. * Sets pressure inside a soft body impostor
  57048. * Cloth and rope must remain 0 pressure
  57049. * @param impostor impostor to set pressure on
  57050. * @param pressure pressure value
  57051. */
  57052. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57053. /**
  57054. * Gets stiffness of the impostor
  57055. * @param impostor impostor to get stiffness from
  57056. * @returns pressure value
  57057. */
  57058. getBodyStiffness(impostor: PhysicsImpostor): number;
  57059. /**
  57060. * Sets stiffness of the impostor
  57061. * @param impostor impostor to set stiffness on
  57062. * @param stiffness stiffness value from 0 to 1
  57063. */
  57064. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57065. /**
  57066. * Gets velocityIterations of the impostor
  57067. * @param impostor impostor to get velocity iterations from
  57068. * @returns velocityIterations value
  57069. */
  57070. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57071. /**
  57072. * Sets velocityIterations of the impostor
  57073. * @param impostor impostor to set velocity iterations on
  57074. * @param velocityIterations velocityIterations value
  57075. */
  57076. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57077. /**
  57078. * Gets positionIterations of the impostor
  57079. * @param impostor impostor to get position iterations from
  57080. * @returns positionIterations value
  57081. */
  57082. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57083. /**
  57084. * Sets positionIterations of the impostor
  57085. * @param impostor impostor to set position on
  57086. * @param positionIterations positionIterations value
  57087. */
  57088. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57089. /**
  57090. * Append an anchor to a cloth object
  57091. * @param impostor is the cloth impostor to add anchor to
  57092. * @param otherImpostor is the rigid impostor to anchor to
  57093. * @param width ratio across width from 0 to 1
  57094. * @param height ratio up height from 0 to 1
  57095. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57096. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57097. */
  57098. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57099. /**
  57100. * Append an hook to a rope object
  57101. * @param impostor is the rope impostor to add hook to
  57102. * @param otherImpostor is the rigid impostor to hook to
  57103. * @param length ratio along the rope from 0 to 1
  57104. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57105. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57106. */
  57107. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57108. /**
  57109. * Sleeps the physics body and stops it from being active
  57110. * @param impostor impostor to sleep
  57111. */
  57112. sleepBody(impostor: PhysicsImpostor): void;
  57113. /**
  57114. * Activates the physics body
  57115. * @param impostor impostor to activate
  57116. */
  57117. wakeUpBody(impostor: PhysicsImpostor): void;
  57118. /**
  57119. * Updates the distance parameters of the joint
  57120. * @param joint joint to update
  57121. * @param maxDistance maximum distance of the joint
  57122. * @param minDistance minimum distance of the joint
  57123. */
  57124. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57125. /**
  57126. * Sets a motor on the joint
  57127. * @param joint joint to set motor on
  57128. * @param speed speed of the motor
  57129. * @param maxForce maximum force of the motor
  57130. * @param motorIndex index of the motor
  57131. */
  57132. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57133. /**
  57134. * Sets the motors limit
  57135. * @param joint joint to set limit on
  57136. * @param upperLimit upper limit
  57137. * @param lowerLimit lower limit
  57138. */
  57139. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57140. /**
  57141. * Syncs the position and rotation of a mesh with the impostor
  57142. * @param mesh mesh to sync
  57143. * @param impostor impostor to update the mesh with
  57144. */
  57145. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57146. /**
  57147. * Gets the radius of the impostor
  57148. * @param impostor impostor to get radius from
  57149. * @returns the radius
  57150. */
  57151. getRadius(impostor: PhysicsImpostor): number;
  57152. /**
  57153. * Gets the box size of the impostor
  57154. * @param impostor impostor to get box size from
  57155. * @param result the resulting box size
  57156. */
  57157. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57158. /**
  57159. * Disposes of the impostor
  57160. */
  57161. dispose(): void;
  57162. /**
  57163. * Does a raycast in the physics world
  57164. * @param from when should the ray start?
  57165. * @param to when should the ray end?
  57166. * @returns PhysicsRaycastResult
  57167. */
  57168. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57169. }
  57170. }
  57171. declare module "babylonjs/Probes/reflectionProbe" {
  57172. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57173. import { Vector3 } from "babylonjs/Maths/math.vector";
  57174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57175. import { Nullable } from "babylonjs/types";
  57176. import { Scene } from "babylonjs/scene";
  57177. module "babylonjs/abstractScene" {
  57178. interface AbstractScene {
  57179. /**
  57180. * The list of reflection probes added to the scene
  57181. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57182. */
  57183. reflectionProbes: Array<ReflectionProbe>;
  57184. /**
  57185. * Removes the given reflection probe from this scene.
  57186. * @param toRemove The reflection probe to remove
  57187. * @returns The index of the removed reflection probe
  57188. */
  57189. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57190. /**
  57191. * Adds the given reflection probe to this scene.
  57192. * @param newReflectionProbe The reflection probe to add
  57193. */
  57194. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57195. }
  57196. }
  57197. /**
  57198. * Class used to generate realtime reflection / refraction cube textures
  57199. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57200. */
  57201. export class ReflectionProbe {
  57202. /** defines the name of the probe */
  57203. name: string;
  57204. private _scene;
  57205. private _renderTargetTexture;
  57206. private _projectionMatrix;
  57207. private _viewMatrix;
  57208. private _target;
  57209. private _add;
  57210. private _attachedMesh;
  57211. private _invertYAxis;
  57212. /** Gets or sets probe position (center of the cube map) */
  57213. position: Vector3;
  57214. /**
  57215. * Creates a new reflection probe
  57216. * @param name defines the name of the probe
  57217. * @param size defines the texture resolution (for each face)
  57218. * @param scene defines the hosting scene
  57219. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57220. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57221. */
  57222. constructor(
  57223. /** defines the name of the probe */
  57224. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57225. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57226. get samples(): number;
  57227. set samples(value: number);
  57228. /** Gets or sets the refresh rate to use (on every frame by default) */
  57229. get refreshRate(): number;
  57230. set refreshRate(value: number);
  57231. /**
  57232. * Gets the hosting scene
  57233. * @returns a Scene
  57234. */
  57235. getScene(): Scene;
  57236. /** Gets the internal CubeTexture used to render to */
  57237. get cubeTexture(): RenderTargetTexture;
  57238. /** Gets the list of meshes to render */
  57239. get renderList(): Nullable<AbstractMesh[]>;
  57240. /**
  57241. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  57242. * @param mesh defines the mesh to attach to
  57243. */
  57244. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57245. /**
  57246. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  57247. * @param renderingGroupId The rendering group id corresponding to its index
  57248. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57249. */
  57250. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  57251. /**
  57252. * Clean all associated resources
  57253. */
  57254. dispose(): void;
  57255. /**
  57256. * Converts the reflection probe information to a readable string for debug purpose.
  57257. * @param fullDetails Supports for multiple levels of logging within scene loading
  57258. * @returns the human readable reflection probe info
  57259. */
  57260. toString(fullDetails?: boolean): string;
  57261. /**
  57262. * Get the class name of the relfection probe.
  57263. * @returns "ReflectionProbe"
  57264. */
  57265. getClassName(): string;
  57266. /**
  57267. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  57268. * @returns The JSON representation of the texture
  57269. */
  57270. serialize(): any;
  57271. /**
  57272. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  57273. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  57274. * @param scene Define the scene the parsed reflection probe should be instantiated in
  57275. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  57276. * @returns The parsed reflection probe if successful
  57277. */
  57278. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  57279. }
  57280. }
  57281. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  57282. /** @hidden */
  57283. export var _BabylonLoaderRegistered: boolean;
  57284. /**
  57285. * Helps setting up some configuration for the babylon file loader.
  57286. */
  57287. export class BabylonFileLoaderConfiguration {
  57288. /**
  57289. * The loader does not allow injecting custom physix engine into the plugins.
  57290. * Unfortunately in ES6, we need to manually inject them into the plugin.
  57291. * So you could set this variable to your engine import to make it work.
  57292. */
  57293. static LoaderInjectedPhysicsEngine: any;
  57294. }
  57295. }
  57296. declare module "babylonjs/Loading/Plugins/index" {
  57297. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  57298. }
  57299. declare module "babylonjs/Loading/index" {
  57300. export * from "babylonjs/Loading/loadingScreen";
  57301. export * from "babylonjs/Loading/Plugins/index";
  57302. export * from "babylonjs/Loading/sceneLoader";
  57303. export * from "babylonjs/Loading/sceneLoaderFlags";
  57304. }
  57305. declare module "babylonjs/Materials/Background/index" {
  57306. export * from "babylonjs/Materials/Background/backgroundMaterial";
  57307. }
  57308. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  57309. import { Scene } from "babylonjs/scene";
  57310. import { Color3 } from "babylonjs/Maths/math.color";
  57311. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57312. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57313. /**
  57314. * The Physically based simple base material of BJS.
  57315. *
  57316. * This enables better naming and convention enforcements on top of the pbrMaterial.
  57317. * It is used as the base class for both the specGloss and metalRough conventions.
  57318. */
  57319. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  57320. /**
  57321. * Number of Simultaneous lights allowed on the material.
  57322. */
  57323. maxSimultaneousLights: number;
  57324. /**
  57325. * If sets to true, disables all the lights affecting the material.
  57326. */
  57327. disableLighting: boolean;
  57328. /**
  57329. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  57330. */
  57331. environmentTexture: BaseTexture;
  57332. /**
  57333. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57334. */
  57335. invertNormalMapX: boolean;
  57336. /**
  57337. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57338. */
  57339. invertNormalMapY: boolean;
  57340. /**
  57341. * Normal map used in the model.
  57342. */
  57343. normalTexture: BaseTexture;
  57344. /**
  57345. * Emissivie color used to self-illuminate the model.
  57346. */
  57347. emissiveColor: Color3;
  57348. /**
  57349. * Emissivie texture used to self-illuminate the model.
  57350. */
  57351. emissiveTexture: BaseTexture;
  57352. /**
  57353. * Occlusion Channel Strenght.
  57354. */
  57355. occlusionStrength: number;
  57356. /**
  57357. * Occlusion Texture of the material (adding extra occlusion effects).
  57358. */
  57359. occlusionTexture: BaseTexture;
  57360. /**
  57361. * Defines the alpha limits in alpha test mode.
  57362. */
  57363. alphaCutOff: number;
  57364. /**
  57365. * Gets the current double sided mode.
  57366. */
  57367. get doubleSided(): boolean;
  57368. /**
  57369. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57370. */
  57371. set doubleSided(value: boolean);
  57372. /**
  57373. * Stores the pre-calculated light information of a mesh in a texture.
  57374. */
  57375. lightmapTexture: BaseTexture;
  57376. /**
  57377. * If true, the light map contains occlusion information instead of lighting info.
  57378. */
  57379. useLightmapAsShadowmap: boolean;
  57380. /**
  57381. * Instantiates a new PBRMaterial instance.
  57382. *
  57383. * @param name The material name
  57384. * @param scene The scene the material will be use in.
  57385. */
  57386. constructor(name: string, scene: Scene);
  57387. getClassName(): string;
  57388. }
  57389. }
  57390. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  57391. import { Scene } from "babylonjs/scene";
  57392. import { Color3 } from "babylonjs/Maths/math.color";
  57393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57394. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  57395. /**
  57396. * The PBR material of BJS following the metal roughness convention.
  57397. *
  57398. * This fits to the PBR convention in the GLTF definition:
  57399. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  57400. */
  57401. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  57402. /**
  57403. * The base color has two different interpretations depending on the value of metalness.
  57404. * When the material is a metal, the base color is the specific measured reflectance value
  57405. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  57406. * of the material.
  57407. */
  57408. baseColor: Color3;
  57409. /**
  57410. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  57411. * well as opacity information in the alpha channel.
  57412. */
  57413. baseTexture: BaseTexture;
  57414. /**
  57415. * Specifies the metallic scalar value of the material.
  57416. * Can also be used to scale the metalness values of the metallic texture.
  57417. */
  57418. metallic: number;
  57419. /**
  57420. * Specifies the roughness scalar value of the material.
  57421. * Can also be used to scale the roughness values of the metallic texture.
  57422. */
  57423. roughness: number;
  57424. /**
  57425. * Texture containing both the metallic value in the B channel and the
  57426. * roughness value in the G channel to keep better precision.
  57427. */
  57428. metallicRoughnessTexture: BaseTexture;
  57429. /**
  57430. * Instantiates a new PBRMetalRoughnessMaterial instance.
  57431. *
  57432. * @param name The material name
  57433. * @param scene The scene the material will be use in.
  57434. */
  57435. constructor(name: string, scene: Scene);
  57436. /**
  57437. * Return the currrent class name of the material.
  57438. */
  57439. getClassName(): string;
  57440. /**
  57441. * Makes a duplicate of the current material.
  57442. * @param name - name to use for the new material.
  57443. */
  57444. clone(name: string): PBRMetallicRoughnessMaterial;
  57445. /**
  57446. * Serialize the material to a parsable JSON object.
  57447. */
  57448. serialize(): any;
  57449. /**
  57450. * Parses a JSON object correponding to the serialize function.
  57451. */
  57452. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  57453. }
  57454. }
  57455. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  57456. import { Scene } from "babylonjs/scene";
  57457. import { Color3 } from "babylonjs/Maths/math.color";
  57458. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57459. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  57460. /**
  57461. * The PBR material of BJS following the specular glossiness convention.
  57462. *
  57463. * This fits to the PBR convention in the GLTF definition:
  57464. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  57465. */
  57466. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  57467. /**
  57468. * Specifies the diffuse color of the material.
  57469. */
  57470. diffuseColor: Color3;
  57471. /**
  57472. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  57473. * channel.
  57474. */
  57475. diffuseTexture: BaseTexture;
  57476. /**
  57477. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  57478. */
  57479. specularColor: Color3;
  57480. /**
  57481. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  57482. */
  57483. glossiness: number;
  57484. /**
  57485. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  57486. */
  57487. specularGlossinessTexture: BaseTexture;
  57488. /**
  57489. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  57490. *
  57491. * @param name The material name
  57492. * @param scene The scene the material will be use in.
  57493. */
  57494. constructor(name: string, scene: Scene);
  57495. /**
  57496. * Return the currrent class name of the material.
  57497. */
  57498. getClassName(): string;
  57499. /**
  57500. * Makes a duplicate of the current material.
  57501. * @param name - name to use for the new material.
  57502. */
  57503. clone(name: string): PBRSpecularGlossinessMaterial;
  57504. /**
  57505. * Serialize the material to a parsable JSON object.
  57506. */
  57507. serialize(): any;
  57508. /**
  57509. * Parses a JSON object correponding to the serialize function.
  57510. */
  57511. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  57512. }
  57513. }
  57514. declare module "babylonjs/Materials/PBR/index" {
  57515. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  57516. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  57517. export * from "babylonjs/Materials/PBR/pbrMaterial";
  57518. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  57519. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  57520. }
  57521. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  57522. import { Nullable } from "babylonjs/types";
  57523. import { Scene } from "babylonjs/scene";
  57524. import { Matrix } from "babylonjs/Maths/math.vector";
  57525. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57526. /**
  57527. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  57528. * It can help converting any input color in a desired output one. This can then be used to create effects
  57529. * from sepia, black and white to sixties or futuristic rendering...
  57530. *
  57531. * The only supported format is currently 3dl.
  57532. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  57533. */
  57534. export class ColorGradingTexture extends BaseTexture {
  57535. /**
  57536. * The current texture matrix. (will always be identity in color grading texture)
  57537. */
  57538. private _textureMatrix;
  57539. /**
  57540. * The texture URL.
  57541. */
  57542. url: string;
  57543. /**
  57544. * Empty line regex stored for GC.
  57545. */
  57546. private static _noneEmptyLineRegex;
  57547. private _engine;
  57548. /**
  57549. * Instantiates a ColorGradingTexture from the following parameters.
  57550. *
  57551. * @param url The location of the color gradind data (currently only supporting 3dl)
  57552. * @param scene The scene the texture will be used in
  57553. */
  57554. constructor(url: string, scene: Scene);
  57555. /**
  57556. * Returns the texture matrix used in most of the material.
  57557. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  57558. */
  57559. getTextureMatrix(): Matrix;
  57560. /**
  57561. * Occurs when the file being loaded is a .3dl LUT file.
  57562. */
  57563. private load3dlTexture;
  57564. /**
  57565. * Starts the loading process of the texture.
  57566. */
  57567. private loadTexture;
  57568. /**
  57569. * Clones the color gradind texture.
  57570. */
  57571. clone(): ColorGradingTexture;
  57572. /**
  57573. * Called during delayed load for textures.
  57574. */
  57575. delayLoad(): void;
  57576. /**
  57577. * Parses a color grading texture serialized by Babylon.
  57578. * @param parsedTexture The texture information being parsedTexture
  57579. * @param scene The scene to load the texture in
  57580. * @param rootUrl The root url of the data assets to load
  57581. * @return A color gradind texture
  57582. */
  57583. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  57584. /**
  57585. * Serializes the LUT texture to json format.
  57586. */
  57587. serialize(): any;
  57588. }
  57589. }
  57590. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  57591. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57592. import { Scene } from "babylonjs/scene";
  57593. import { Nullable } from "babylonjs/types";
  57594. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57595. /**
  57596. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  57597. */
  57598. export class EquiRectangularCubeTexture extends BaseTexture {
  57599. /** The six faces of the cube. */
  57600. private static _FacesMapping;
  57601. private _noMipmap;
  57602. private _onLoad;
  57603. private _onError;
  57604. /** The size of the cubemap. */
  57605. private _size;
  57606. /** The buffer of the image. */
  57607. private _buffer;
  57608. /** The width of the input image. */
  57609. private _width;
  57610. /** The height of the input image. */
  57611. private _height;
  57612. /** The URL to the image. */
  57613. url: string;
  57614. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  57615. coordinatesMode: number;
  57616. /**
  57617. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  57618. * @param url The location of the image
  57619. * @param scene The scene the texture will be used in
  57620. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57621. * @param noMipmap Forces to not generate the mipmap if true
  57622. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  57623. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  57624. * @param onLoad — defines a callback called when texture is loaded
  57625. * @param onError — defines a callback called if there is an error
  57626. */
  57627. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  57628. /**
  57629. * Load the image data, by putting the image on a canvas and extracting its buffer.
  57630. */
  57631. private loadImage;
  57632. /**
  57633. * Convert the image buffer into a cubemap and create a CubeTexture.
  57634. */
  57635. private loadTexture;
  57636. /**
  57637. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  57638. * @param buffer The ArrayBuffer that should be converted.
  57639. * @returns The buffer as Float32Array.
  57640. */
  57641. private getFloat32ArrayFromArrayBuffer;
  57642. /**
  57643. * Get the current class name of the texture useful for serialization or dynamic coding.
  57644. * @returns "EquiRectangularCubeTexture"
  57645. */
  57646. getClassName(): string;
  57647. /**
  57648. * Create a clone of the current EquiRectangularCubeTexture and return it.
  57649. * @returns A clone of the current EquiRectangularCubeTexture.
  57650. */
  57651. clone(): EquiRectangularCubeTexture;
  57652. }
  57653. }
  57654. declare module "babylonjs/Misc/tga" {
  57655. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57656. /**
  57657. * Based on jsTGALoader - Javascript loader for TGA file
  57658. * By Vincent Thibault
  57659. * @see http://blog.robrowser.com/javascript-tga-loader.html
  57660. */
  57661. export class TGATools {
  57662. private static _TYPE_INDEXED;
  57663. private static _TYPE_RGB;
  57664. private static _TYPE_GREY;
  57665. private static _TYPE_RLE_INDEXED;
  57666. private static _TYPE_RLE_RGB;
  57667. private static _TYPE_RLE_GREY;
  57668. private static _ORIGIN_MASK;
  57669. private static _ORIGIN_SHIFT;
  57670. private static _ORIGIN_BL;
  57671. private static _ORIGIN_BR;
  57672. private static _ORIGIN_UL;
  57673. private static _ORIGIN_UR;
  57674. /**
  57675. * Gets the header of a TGA file
  57676. * @param data defines the TGA data
  57677. * @returns the header
  57678. */
  57679. static GetTGAHeader(data: Uint8Array): any;
  57680. /**
  57681. * Uploads TGA content to a Babylon Texture
  57682. * @hidden
  57683. */
  57684. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  57685. /** @hidden */
  57686. 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;
  57687. /** @hidden */
  57688. 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;
  57689. /** @hidden */
  57690. 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;
  57691. /** @hidden */
  57692. 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;
  57693. /** @hidden */
  57694. 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;
  57695. /** @hidden */
  57696. 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;
  57697. }
  57698. }
  57699. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  57700. import { Nullable } from "babylonjs/types";
  57701. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57702. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57703. /**
  57704. * Implementation of the TGA Texture Loader.
  57705. * @hidden
  57706. */
  57707. export class _TGATextureLoader implements IInternalTextureLoader {
  57708. /**
  57709. * Defines wether the loader supports cascade loading the different faces.
  57710. */
  57711. readonly supportCascades: boolean;
  57712. /**
  57713. * This returns if the loader support the current file information.
  57714. * @param extension defines the file extension of the file being loaded
  57715. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57716. * @param fallback defines the fallback internal texture if any
  57717. * @param isBase64 defines whether the texture is encoded as a base64
  57718. * @param isBuffer defines whether the texture data are stored as a buffer
  57719. * @returns true if the loader can load the specified file
  57720. */
  57721. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57722. /**
  57723. * Transform the url before loading if required.
  57724. * @param rootUrl the url of the texture
  57725. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57726. * @returns the transformed texture
  57727. */
  57728. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57729. /**
  57730. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57731. * @param rootUrl the url of the texture
  57732. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57733. * @returns the fallback texture
  57734. */
  57735. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57736. /**
  57737. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  57738. * @param data contains the texture data
  57739. * @param texture defines the BabylonJS internal texture
  57740. * @param createPolynomials will be true if polynomials have been requested
  57741. * @param onLoad defines the callback to trigger once the texture is ready
  57742. * @param onError defines the callback to trigger in case of error
  57743. */
  57744. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57745. /**
  57746. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57747. * @param data contains the texture data
  57748. * @param texture defines the BabylonJS internal texture
  57749. * @param callback defines the method to call once ready to upload
  57750. */
  57751. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57752. }
  57753. }
  57754. declare module "babylonjs/Misc/basis" {
  57755. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57756. /**
  57757. * Info about the .basis files
  57758. */
  57759. class BasisFileInfo {
  57760. /**
  57761. * If the file has alpha
  57762. */
  57763. hasAlpha: boolean;
  57764. /**
  57765. * Info about each image of the basis file
  57766. */
  57767. images: Array<{
  57768. levels: Array<{
  57769. width: number;
  57770. height: number;
  57771. transcodedPixels: ArrayBufferView;
  57772. }>;
  57773. }>;
  57774. }
  57775. /**
  57776. * Result of transcoding a basis file
  57777. */
  57778. class TranscodeResult {
  57779. /**
  57780. * Info about the .basis file
  57781. */
  57782. fileInfo: BasisFileInfo;
  57783. /**
  57784. * Format to use when loading the file
  57785. */
  57786. format: number;
  57787. }
  57788. /**
  57789. * Configuration options for the Basis transcoder
  57790. */
  57791. export class BasisTranscodeConfiguration {
  57792. /**
  57793. * Supported compression formats used to determine the supported output format of the transcoder
  57794. */
  57795. supportedCompressionFormats?: {
  57796. /**
  57797. * etc1 compression format
  57798. */
  57799. etc1?: boolean;
  57800. /**
  57801. * s3tc compression format
  57802. */
  57803. s3tc?: boolean;
  57804. /**
  57805. * pvrtc compression format
  57806. */
  57807. pvrtc?: boolean;
  57808. /**
  57809. * etc2 compression format
  57810. */
  57811. etc2?: boolean;
  57812. };
  57813. /**
  57814. * If mipmap levels should be loaded for transcoded images (Default: true)
  57815. */
  57816. loadMipmapLevels?: boolean;
  57817. /**
  57818. * Index of a single image to load (Default: all images)
  57819. */
  57820. loadSingleImage?: number;
  57821. }
  57822. /**
  57823. * Used to load .Basis files
  57824. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  57825. */
  57826. export class BasisTools {
  57827. private static _IgnoreSupportedFormats;
  57828. /**
  57829. * URL to use when loading the basis transcoder
  57830. */
  57831. static JSModuleURL: string;
  57832. /**
  57833. * URL to use when loading the wasm module for the transcoder
  57834. */
  57835. static WasmModuleURL: string;
  57836. /**
  57837. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  57838. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  57839. * @returns internal format corresponding to the Basis format
  57840. */
  57841. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  57842. private static _WorkerPromise;
  57843. private static _Worker;
  57844. private static _actionId;
  57845. private static _CreateWorkerAsync;
  57846. /**
  57847. * Transcodes a loaded image file to compressed pixel data
  57848. * @param imageData image data to transcode
  57849. * @param config configuration options for the transcoding
  57850. * @returns a promise resulting in the transcoded image
  57851. */
  57852. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  57853. /**
  57854. * Loads a texture from the transcode result
  57855. * @param texture texture load to
  57856. * @param transcodeResult the result of transcoding the basis file to load from
  57857. */
  57858. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  57859. }
  57860. }
  57861. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  57862. import { Nullable } from "babylonjs/types";
  57863. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57864. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  57865. /**
  57866. * Loader for .basis file format
  57867. */
  57868. export class _BasisTextureLoader implements IInternalTextureLoader {
  57869. /**
  57870. * Defines whether the loader supports cascade loading the different faces.
  57871. */
  57872. readonly supportCascades: boolean;
  57873. /**
  57874. * This returns if the loader support the current file information.
  57875. * @param extension defines the file extension of the file being loaded
  57876. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57877. * @param fallback defines the fallback internal texture if any
  57878. * @param isBase64 defines whether the texture is encoded as a base64
  57879. * @param isBuffer defines whether the texture data are stored as a buffer
  57880. * @returns true if the loader can load the specified file
  57881. */
  57882. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  57883. /**
  57884. * Transform the url before loading if required.
  57885. * @param rootUrl the url of the texture
  57886. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57887. * @returns the transformed texture
  57888. */
  57889. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  57890. /**
  57891. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  57892. * @param rootUrl the url of the texture
  57893. * @param textureFormatInUse defines the current compressed format in use iun the engine
  57894. * @returns the fallback texture
  57895. */
  57896. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  57897. /**
  57898. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  57899. * @param data contains the texture data
  57900. * @param texture defines the BabylonJS internal texture
  57901. * @param createPolynomials will be true if polynomials have been requested
  57902. * @param onLoad defines the callback to trigger once the texture is ready
  57903. * @param onError defines the callback to trigger in case of error
  57904. */
  57905. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57906. /**
  57907. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  57908. * @param data contains the texture data
  57909. * @param texture defines the BabylonJS internal texture
  57910. * @param callback defines the method to call once ready to upload
  57911. */
  57912. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57913. }
  57914. }
  57915. declare module "babylonjs/Materials/Textures/Loaders/index" {
  57916. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  57917. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  57918. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  57919. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  57920. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  57921. }
  57922. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  57923. import { Scene } from "babylonjs/scene";
  57924. import { Texture } from "babylonjs/Materials/Textures/texture";
  57925. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57926. /**
  57927. * 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.
  57928. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57929. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57930. */
  57931. export class CustomProceduralTexture extends ProceduralTexture {
  57932. private _animate;
  57933. private _time;
  57934. private _config;
  57935. private _texturePath;
  57936. /**
  57937. * Instantiates a new Custom Procedural Texture.
  57938. * 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.
  57939. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  57940. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  57941. * @param name Define the name of the texture
  57942. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  57943. * @param size Define the size of the texture to create
  57944. * @param scene Define the scene the texture belongs to
  57945. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  57946. * @param generateMipMaps Define if the texture should creates mip maps or not
  57947. */
  57948. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  57949. private _loadJson;
  57950. /**
  57951. * Is the texture ready to be used ? (rendered at least once)
  57952. * @returns true if ready, otherwise, false.
  57953. */
  57954. isReady(): boolean;
  57955. /**
  57956. * Render the texture to its associated render target.
  57957. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  57958. */
  57959. render(useCameraPostProcess?: boolean): void;
  57960. /**
  57961. * Update the list of dependant textures samplers in the shader.
  57962. */
  57963. updateTextures(): void;
  57964. /**
  57965. * Update the uniform values of the procedural texture in the shader.
  57966. */
  57967. updateShaderUniforms(): void;
  57968. /**
  57969. * Define if the texture animates or not.
  57970. */
  57971. get animate(): boolean;
  57972. set animate(value: boolean);
  57973. }
  57974. }
  57975. declare module "babylonjs/Shaders/noise.fragment" {
  57976. /** @hidden */
  57977. export var noisePixelShader: {
  57978. name: string;
  57979. shader: string;
  57980. };
  57981. }
  57982. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  57983. import { Nullable } from "babylonjs/types";
  57984. import { Scene } from "babylonjs/scene";
  57985. import { Texture } from "babylonjs/Materials/Textures/texture";
  57986. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  57987. import "babylonjs/Shaders/noise.fragment";
  57988. /**
  57989. * Class used to generate noise procedural textures
  57990. */
  57991. export class NoiseProceduralTexture extends ProceduralTexture {
  57992. private _time;
  57993. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  57994. brightness: number;
  57995. /** Defines the number of octaves to process */
  57996. octaves: number;
  57997. /** Defines the level of persistence (0.8 by default) */
  57998. persistence: number;
  57999. /** Gets or sets animation speed factor (default is 1) */
  58000. animationSpeedFactor: number;
  58001. /**
  58002. * Creates a new NoiseProceduralTexture
  58003. * @param name defines the name fo the texture
  58004. * @param size defines the size of the texture (default is 256)
  58005. * @param scene defines the hosting scene
  58006. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58007. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58008. */
  58009. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58010. private _updateShaderUniforms;
  58011. protected _getDefines(): string;
  58012. /** Generate the current state of the procedural texture */
  58013. render(useCameraPostProcess?: boolean): void;
  58014. /**
  58015. * Serializes this noise procedural texture
  58016. * @returns a serialized noise procedural texture object
  58017. */
  58018. serialize(): any;
  58019. /**
  58020. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58021. * @param parsedTexture defines parsed texture data
  58022. * @param scene defines the current scene
  58023. * @param rootUrl defines the root URL containing noise procedural texture information
  58024. * @returns a parsed NoiseProceduralTexture
  58025. */
  58026. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58027. }
  58028. }
  58029. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58030. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58031. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58032. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58033. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58034. }
  58035. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58036. import { Nullable } from "babylonjs/types";
  58037. import { Scene } from "babylonjs/scene";
  58038. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58039. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58040. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58041. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58042. /**
  58043. * Raw cube texture where the raw buffers are passed in
  58044. */
  58045. export class RawCubeTexture extends CubeTexture {
  58046. /**
  58047. * Creates a cube texture where the raw buffers are passed in.
  58048. * @param scene defines the scene the texture is attached to
  58049. * @param data defines the array of data to use to create each face
  58050. * @param size defines the size of the textures
  58051. * @param format defines the format of the data
  58052. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58053. * @param generateMipMaps defines if the engine should generate the mip levels
  58054. * @param invertY defines if data must be stored with Y axis inverted
  58055. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58056. * @param compression defines the compression used (null by default)
  58057. */
  58058. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58059. /**
  58060. * Updates the raw cube texture.
  58061. * @param data defines the data to store
  58062. * @param format defines the data format
  58063. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58064. * @param invertY defines if data must be stored with Y axis inverted
  58065. * @param compression defines the compression used (null by default)
  58066. * @param level defines which level of the texture to update
  58067. */
  58068. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58069. /**
  58070. * Updates a raw cube texture with RGBD encoded data.
  58071. * @param data defines the array of data [mipmap][face] to use to create each face
  58072. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58073. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58074. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58075. * @returns a promsie that resolves when the operation is complete
  58076. */
  58077. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58078. /**
  58079. * Clones the raw cube texture.
  58080. * @return a new cube texture
  58081. */
  58082. clone(): CubeTexture;
  58083. /** @hidden */
  58084. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58085. }
  58086. }
  58087. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58088. import { Scene } from "babylonjs/scene";
  58089. import { Texture } from "babylonjs/Materials/Textures/texture";
  58090. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58091. /**
  58092. * Class used to store 3D textures containing user data
  58093. */
  58094. export class RawTexture3D extends Texture {
  58095. /** Gets or sets the texture format to use */
  58096. format: number;
  58097. private _engine;
  58098. /**
  58099. * Create a new RawTexture3D
  58100. * @param data defines the data of the texture
  58101. * @param width defines the width of the texture
  58102. * @param height defines the height of the texture
  58103. * @param depth defines the depth of the texture
  58104. * @param format defines the texture format to use
  58105. * @param scene defines the hosting scene
  58106. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58107. * @param invertY defines if texture must be stored with Y axis inverted
  58108. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58109. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58110. */
  58111. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58112. /** Gets or sets the texture format to use */
  58113. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58114. /**
  58115. * Update the texture with new data
  58116. * @param data defines the data to store in the texture
  58117. */
  58118. update(data: ArrayBufferView): void;
  58119. }
  58120. }
  58121. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58122. import { Scene } from "babylonjs/scene";
  58123. import { Texture } from "babylonjs/Materials/Textures/texture";
  58124. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58125. /**
  58126. * Class used to store 2D array textures containing user data
  58127. */
  58128. export class RawTexture2DArray extends Texture {
  58129. /** Gets or sets the texture format to use */
  58130. format: number;
  58131. private _engine;
  58132. /**
  58133. * Create a new RawTexture2DArray
  58134. * @param data defines the data of the texture
  58135. * @param width defines the width of the texture
  58136. * @param height defines the height of the texture
  58137. * @param depth defines the number of layers of the texture
  58138. * @param format defines the texture format to use
  58139. * @param scene defines the hosting scene
  58140. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58141. * @param invertY defines if texture must be stored with Y axis inverted
  58142. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58143. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58144. */
  58145. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58146. /** Gets or sets the texture format to use */
  58147. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58148. /**
  58149. * Update the texture with new data
  58150. * @param data defines the data to store in the texture
  58151. */
  58152. update(data: ArrayBufferView): void;
  58153. }
  58154. }
  58155. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58156. import { Scene } from "babylonjs/scene";
  58157. import { Plane } from "babylonjs/Maths/math.plane";
  58158. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58159. /**
  58160. * Creates a refraction texture used by refraction channel of the standard material.
  58161. * It is like a mirror but to see through a material.
  58162. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58163. */
  58164. export class RefractionTexture extends RenderTargetTexture {
  58165. /**
  58166. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58167. * 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.
  58168. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58169. */
  58170. refractionPlane: Plane;
  58171. /**
  58172. * Define how deep under the surface we should see.
  58173. */
  58174. depth: number;
  58175. /**
  58176. * Creates a refraction texture used by refraction channel of the standard material.
  58177. * It is like a mirror but to see through a material.
  58178. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58179. * @param name Define the texture name
  58180. * @param size Define the size of the underlying texture
  58181. * @param scene Define the scene the refraction belongs to
  58182. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58183. */
  58184. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58185. /**
  58186. * Clone the refraction texture.
  58187. * @returns the cloned texture
  58188. */
  58189. clone(): RefractionTexture;
  58190. /**
  58191. * Serialize the texture to a JSON representation you could use in Parse later on
  58192. * @returns the serialized JSON representation
  58193. */
  58194. serialize(): any;
  58195. }
  58196. }
  58197. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58198. import { Nullable } from "babylonjs/types";
  58199. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58200. import { Matrix } from "babylonjs/Maths/math.vector";
  58201. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58202. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58203. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58204. import { Scene } from "babylonjs/scene";
  58205. /**
  58206. * Defines the options related to the creation of an HtmlElementTexture
  58207. */
  58208. export interface IHtmlElementTextureOptions {
  58209. /**
  58210. * Defines wether mip maps should be created or not.
  58211. */
  58212. generateMipMaps?: boolean;
  58213. /**
  58214. * Defines the sampling mode of the texture.
  58215. */
  58216. samplingMode?: number;
  58217. /**
  58218. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58219. */
  58220. engine: Nullable<ThinEngine>;
  58221. /**
  58222. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58223. */
  58224. scene: Nullable<Scene>;
  58225. }
  58226. /**
  58227. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58228. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58229. * is automatically managed.
  58230. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58231. * in your application.
  58232. *
  58233. * As the update is not automatic, you need to call them manually.
  58234. */
  58235. export class HtmlElementTexture extends BaseTexture {
  58236. /**
  58237. * The texture URL.
  58238. */
  58239. element: HTMLVideoElement | HTMLCanvasElement;
  58240. private static readonly DefaultOptions;
  58241. private _textureMatrix;
  58242. private _engine;
  58243. private _isVideo;
  58244. private _generateMipMaps;
  58245. private _samplingMode;
  58246. /**
  58247. * Instantiates a HtmlElementTexture from the following parameters.
  58248. *
  58249. * @param name Defines the name of the texture
  58250. * @param element Defines the video or canvas the texture is filled with
  58251. * @param options Defines the other none mandatory texture creation options
  58252. */
  58253. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58254. private _createInternalTexture;
  58255. /**
  58256. * Returns the texture matrix used in most of the material.
  58257. */
  58258. getTextureMatrix(): Matrix;
  58259. /**
  58260. * Updates the content of the texture.
  58261. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  58262. */
  58263. update(invertY?: Nullable<boolean>): void;
  58264. }
  58265. }
  58266. declare module "babylonjs/Materials/Textures/index" {
  58267. export * from "babylonjs/Materials/Textures/baseTexture";
  58268. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  58269. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  58270. export * from "babylonjs/Materials/Textures/cubeTexture";
  58271. export * from "babylonjs/Materials/Textures/dynamicTexture";
  58272. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  58273. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  58274. export * from "babylonjs/Materials/Textures/internalTexture";
  58275. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  58276. export * from "babylonjs/Materials/Textures/Loaders/index";
  58277. export * from "babylonjs/Materials/Textures/mirrorTexture";
  58278. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  58279. export * from "babylonjs/Materials/Textures/Procedurals/index";
  58280. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  58281. export * from "babylonjs/Materials/Textures/rawTexture";
  58282. export * from "babylonjs/Materials/Textures/rawTexture3D";
  58283. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  58284. export * from "babylonjs/Materials/Textures/refractionTexture";
  58285. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  58286. export * from "babylonjs/Materials/Textures/texture";
  58287. export * from "babylonjs/Materials/Textures/videoTexture";
  58288. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  58289. }
  58290. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  58291. /**
  58292. * Enum used to define the target of a block
  58293. */
  58294. export enum NodeMaterialBlockTargets {
  58295. /** Vertex shader */
  58296. Vertex = 1,
  58297. /** Fragment shader */
  58298. Fragment = 2,
  58299. /** Neutral */
  58300. Neutral = 4,
  58301. /** Vertex and Fragment */
  58302. VertexAndFragment = 3
  58303. }
  58304. }
  58305. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  58306. /**
  58307. * Defines the kind of connection point for node based material
  58308. */
  58309. export enum NodeMaterialBlockConnectionPointTypes {
  58310. /** Float */
  58311. Float = 1,
  58312. /** Int */
  58313. Int = 2,
  58314. /** Vector2 */
  58315. Vector2 = 4,
  58316. /** Vector3 */
  58317. Vector3 = 8,
  58318. /** Vector4 */
  58319. Vector4 = 16,
  58320. /** Color3 */
  58321. Color3 = 32,
  58322. /** Color4 */
  58323. Color4 = 64,
  58324. /** Matrix */
  58325. Matrix = 128,
  58326. /** Detect type based on connection */
  58327. AutoDetect = 1024,
  58328. /** Output type that will be defined by input type */
  58329. BasedOnInput = 2048
  58330. }
  58331. }
  58332. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  58333. /**
  58334. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  58335. */
  58336. export enum NodeMaterialBlockConnectionPointMode {
  58337. /** Value is an uniform */
  58338. Uniform = 0,
  58339. /** Value is a mesh attribute */
  58340. Attribute = 1,
  58341. /** Value is a varying between vertex and fragment shaders */
  58342. Varying = 2,
  58343. /** Mode is undefined */
  58344. Undefined = 3
  58345. }
  58346. }
  58347. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  58348. /**
  58349. * Enum used to define system values e.g. values automatically provided by the system
  58350. */
  58351. export enum NodeMaterialSystemValues {
  58352. /** World */
  58353. World = 1,
  58354. /** View */
  58355. View = 2,
  58356. /** Projection */
  58357. Projection = 3,
  58358. /** ViewProjection */
  58359. ViewProjection = 4,
  58360. /** WorldView */
  58361. WorldView = 5,
  58362. /** WorldViewProjection */
  58363. WorldViewProjection = 6,
  58364. /** CameraPosition */
  58365. CameraPosition = 7,
  58366. /** Fog Color */
  58367. FogColor = 8,
  58368. /** Delta time */
  58369. DeltaTime = 9
  58370. }
  58371. }
  58372. declare module "babylonjs/Materials/Node/Enums/index" {
  58373. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58374. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  58375. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  58376. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  58377. }
  58378. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  58379. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58380. /**
  58381. * Root class for all node material optimizers
  58382. */
  58383. export class NodeMaterialOptimizer {
  58384. /**
  58385. * Function used to optimize a NodeMaterial graph
  58386. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  58387. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  58388. */
  58389. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  58390. }
  58391. }
  58392. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  58393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58394. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58395. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58396. import { Scene } from "babylonjs/scene";
  58397. /**
  58398. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  58399. */
  58400. export class TransformBlock extends NodeMaterialBlock {
  58401. /**
  58402. * Defines the value to use to complement W value to transform it to a Vector4
  58403. */
  58404. complementW: number;
  58405. /**
  58406. * Defines the value to use to complement z value to transform it to a Vector4
  58407. */
  58408. complementZ: number;
  58409. /**
  58410. * Creates a new TransformBlock
  58411. * @param name defines the block name
  58412. */
  58413. constructor(name: string);
  58414. /**
  58415. * Gets the current class name
  58416. * @returns the class name
  58417. */
  58418. getClassName(): string;
  58419. /**
  58420. * Gets the vector input
  58421. */
  58422. get vector(): NodeMaterialConnectionPoint;
  58423. /**
  58424. * Gets the output component
  58425. */
  58426. get output(): NodeMaterialConnectionPoint;
  58427. /**
  58428. * Gets the matrix transform input
  58429. */
  58430. get transform(): NodeMaterialConnectionPoint;
  58431. protected _buildBlock(state: NodeMaterialBuildState): this;
  58432. serialize(): any;
  58433. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58434. protected _dumpPropertiesCode(): string;
  58435. }
  58436. }
  58437. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  58438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58441. /**
  58442. * Block used to output the vertex position
  58443. */
  58444. export class VertexOutputBlock extends NodeMaterialBlock {
  58445. /**
  58446. * Creates a new VertexOutputBlock
  58447. * @param name defines the block name
  58448. */
  58449. constructor(name: string);
  58450. /**
  58451. * Gets the current class name
  58452. * @returns the class name
  58453. */
  58454. getClassName(): string;
  58455. /**
  58456. * Gets the vector input component
  58457. */
  58458. get vector(): NodeMaterialConnectionPoint;
  58459. protected _buildBlock(state: NodeMaterialBuildState): this;
  58460. }
  58461. }
  58462. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  58463. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58464. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58465. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58466. /**
  58467. * Block used to output the final color
  58468. */
  58469. export class FragmentOutputBlock extends NodeMaterialBlock {
  58470. /**
  58471. * Create a new FragmentOutputBlock
  58472. * @param name defines the block name
  58473. */
  58474. constructor(name: string);
  58475. /**
  58476. * Gets the current class name
  58477. * @returns the class name
  58478. */
  58479. getClassName(): string;
  58480. /**
  58481. * Gets the rgba input component
  58482. */
  58483. get rgba(): NodeMaterialConnectionPoint;
  58484. /**
  58485. * Gets the rgb input component
  58486. */
  58487. get rgb(): NodeMaterialConnectionPoint;
  58488. /**
  58489. * Gets the a input component
  58490. */
  58491. get a(): NodeMaterialConnectionPoint;
  58492. protected _buildBlock(state: NodeMaterialBuildState): this;
  58493. }
  58494. }
  58495. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  58496. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58497. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58499. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58501. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58502. import { Effect } from "babylonjs/Materials/effect";
  58503. import { Mesh } from "babylonjs/Meshes/mesh";
  58504. import { Nullable } from "babylonjs/types";
  58505. import { Scene } from "babylonjs/scene";
  58506. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58507. /**
  58508. * Block used to read a reflection texture from a sampler
  58509. */
  58510. export class ReflectionTextureBlock extends NodeMaterialBlock {
  58511. private _define3DName;
  58512. private _defineCubicName;
  58513. private _defineExplicitName;
  58514. private _defineProjectionName;
  58515. private _defineLocalCubicName;
  58516. private _defineSphericalName;
  58517. private _definePlanarName;
  58518. private _defineEquirectangularName;
  58519. private _defineMirroredEquirectangularFixedName;
  58520. private _defineEquirectangularFixedName;
  58521. private _defineSkyboxName;
  58522. private _cubeSamplerName;
  58523. private _2DSamplerName;
  58524. private _positionUVWName;
  58525. private _directionWName;
  58526. private _reflectionCoordsName;
  58527. private _reflection2DCoordsName;
  58528. private _reflectionColorName;
  58529. private _reflectionMatrixName;
  58530. /**
  58531. * Gets or sets the texture associated with the node
  58532. */
  58533. texture: Nullable<BaseTexture>;
  58534. /**
  58535. * Create a new TextureBlock
  58536. * @param name defines the block name
  58537. */
  58538. constructor(name: string);
  58539. /**
  58540. * Gets the current class name
  58541. * @returns the class name
  58542. */
  58543. getClassName(): string;
  58544. /**
  58545. * Gets the world position input component
  58546. */
  58547. get position(): NodeMaterialConnectionPoint;
  58548. /**
  58549. * Gets the world position input component
  58550. */
  58551. get worldPosition(): NodeMaterialConnectionPoint;
  58552. /**
  58553. * Gets the world normal input component
  58554. */
  58555. get worldNormal(): NodeMaterialConnectionPoint;
  58556. /**
  58557. * Gets the world input component
  58558. */
  58559. get world(): NodeMaterialConnectionPoint;
  58560. /**
  58561. * Gets the camera (or eye) position component
  58562. */
  58563. get cameraPosition(): NodeMaterialConnectionPoint;
  58564. /**
  58565. * Gets the view input component
  58566. */
  58567. get view(): NodeMaterialConnectionPoint;
  58568. /**
  58569. * Gets the rgb output component
  58570. */
  58571. get rgb(): NodeMaterialConnectionPoint;
  58572. /**
  58573. * Gets the r output component
  58574. */
  58575. get r(): NodeMaterialConnectionPoint;
  58576. /**
  58577. * Gets the g output component
  58578. */
  58579. get g(): NodeMaterialConnectionPoint;
  58580. /**
  58581. * Gets the b output component
  58582. */
  58583. get b(): NodeMaterialConnectionPoint;
  58584. autoConfigure(material: NodeMaterial): void;
  58585. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58586. isReady(): boolean;
  58587. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58588. private _injectVertexCode;
  58589. private _writeOutput;
  58590. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58591. protected _dumpPropertiesCode(): string;
  58592. serialize(): any;
  58593. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58594. }
  58595. }
  58596. declare module "babylonjs/Materials/Node/nodeMaterial" {
  58597. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58598. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  58599. import { Scene } from "babylonjs/scene";
  58600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58601. import { Matrix } from "babylonjs/Maths/math.vector";
  58602. import { Mesh } from "babylonjs/Meshes/mesh";
  58603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58604. import { Observable } from "babylonjs/Misc/observable";
  58605. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58606. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  58607. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58608. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  58609. import { Nullable } from "babylonjs/types";
  58610. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  58611. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  58612. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  58613. /**
  58614. * Interface used to configure the node material editor
  58615. */
  58616. export interface INodeMaterialEditorOptions {
  58617. /** Define the URl to load node editor script */
  58618. editorURL?: string;
  58619. }
  58620. /** @hidden */
  58621. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  58622. /** BONES */
  58623. NUM_BONE_INFLUENCERS: number;
  58624. BonesPerMesh: number;
  58625. BONETEXTURE: boolean;
  58626. /** MORPH TARGETS */
  58627. MORPHTARGETS: boolean;
  58628. MORPHTARGETS_NORMAL: boolean;
  58629. MORPHTARGETS_TANGENT: boolean;
  58630. MORPHTARGETS_UV: boolean;
  58631. NUM_MORPH_INFLUENCERS: number;
  58632. /** IMAGE PROCESSING */
  58633. IMAGEPROCESSING: boolean;
  58634. VIGNETTE: boolean;
  58635. VIGNETTEBLENDMODEMULTIPLY: boolean;
  58636. VIGNETTEBLENDMODEOPAQUE: boolean;
  58637. TONEMAPPING: boolean;
  58638. TONEMAPPING_ACES: boolean;
  58639. CONTRAST: boolean;
  58640. EXPOSURE: boolean;
  58641. COLORCURVES: boolean;
  58642. COLORGRADING: boolean;
  58643. COLORGRADING3D: boolean;
  58644. SAMPLER3DGREENDEPTH: boolean;
  58645. SAMPLER3DBGRMAP: boolean;
  58646. IMAGEPROCESSINGPOSTPROCESS: boolean;
  58647. /** MISC. */
  58648. BUMPDIRECTUV: number;
  58649. constructor();
  58650. setValue(name: string, value: boolean): void;
  58651. }
  58652. /**
  58653. * Class used to configure NodeMaterial
  58654. */
  58655. export interface INodeMaterialOptions {
  58656. /**
  58657. * Defines if blocks should emit comments
  58658. */
  58659. emitComments: boolean;
  58660. }
  58661. /**
  58662. * Class used to create a node based material built by assembling shader blocks
  58663. */
  58664. export class NodeMaterial extends PushMaterial {
  58665. private static _BuildIdGenerator;
  58666. private _options;
  58667. private _vertexCompilationState;
  58668. private _fragmentCompilationState;
  58669. private _sharedData;
  58670. private _buildId;
  58671. private _buildWasSuccessful;
  58672. private _cachedWorldViewMatrix;
  58673. private _cachedWorldViewProjectionMatrix;
  58674. private _optimizers;
  58675. private _animationFrame;
  58676. /** Define the URl to load node editor script */
  58677. static EditorURL: string;
  58678. private BJSNODEMATERIALEDITOR;
  58679. /** Get the inspector from bundle or global */
  58680. private _getGlobalNodeMaterialEditor;
  58681. /**
  58682. * Gets or sets data used by visual editor
  58683. * @see https://nme.babylonjs.com
  58684. */
  58685. editorData: any;
  58686. /**
  58687. * 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)
  58688. */
  58689. ignoreAlpha: boolean;
  58690. /**
  58691. * Defines the maximum number of lights that can be used in the material
  58692. */
  58693. maxSimultaneousLights: number;
  58694. /**
  58695. * Observable raised when the material is built
  58696. */
  58697. onBuildObservable: Observable<NodeMaterial>;
  58698. /**
  58699. * Gets or sets the root nodes of the material vertex shader
  58700. */
  58701. _vertexOutputNodes: NodeMaterialBlock[];
  58702. /**
  58703. * Gets or sets the root nodes of the material fragment (pixel) shader
  58704. */
  58705. _fragmentOutputNodes: NodeMaterialBlock[];
  58706. /** Gets or sets options to control the node material overall behavior */
  58707. get options(): INodeMaterialOptions;
  58708. set options(options: INodeMaterialOptions);
  58709. /**
  58710. * Default configuration related to image processing available in the standard Material.
  58711. */
  58712. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58713. /**
  58714. * Gets the image processing configuration used either in this material.
  58715. */
  58716. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58717. /**
  58718. * Sets the Default image processing configuration used either in the this material.
  58719. *
  58720. * If sets to null, the scene one is in use.
  58721. */
  58722. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58723. /**
  58724. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  58725. */
  58726. attachedBlocks: NodeMaterialBlock[];
  58727. /**
  58728. * Create a new node based material
  58729. * @param name defines the material name
  58730. * @param scene defines the hosting scene
  58731. * @param options defines creation option
  58732. */
  58733. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  58734. /**
  58735. * Gets the current class name of the material e.g. "NodeMaterial"
  58736. * @returns the class name
  58737. */
  58738. getClassName(): string;
  58739. /**
  58740. * Keep track of the image processing observer to allow dispose and replace.
  58741. */
  58742. private _imageProcessingObserver;
  58743. /**
  58744. * Attaches a new image processing configuration to the Standard Material.
  58745. * @param configuration
  58746. */
  58747. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58748. /**
  58749. * Get a block by its name
  58750. * @param name defines the name of the block to retrieve
  58751. * @returns the required block or null if not found
  58752. */
  58753. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  58754. /**
  58755. * Get a block by its name
  58756. * @param predicate defines the predicate used to find the good candidate
  58757. * @returns the required block or null if not found
  58758. */
  58759. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  58760. /**
  58761. * Get an input block by its name
  58762. * @param predicate defines the predicate used to find the good candidate
  58763. * @returns the required input block or null if not found
  58764. */
  58765. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  58766. /**
  58767. * Gets the list of input blocks attached to this material
  58768. * @returns an array of InputBlocks
  58769. */
  58770. getInputBlocks(): InputBlock[];
  58771. /**
  58772. * Adds a new optimizer to the list of optimizers
  58773. * @param optimizer defines the optimizers to add
  58774. * @returns the current material
  58775. */
  58776. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58777. /**
  58778. * Remove an optimizer from the list of optimizers
  58779. * @param optimizer defines the optimizers to remove
  58780. * @returns the current material
  58781. */
  58782. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  58783. /**
  58784. * Add a new block to the list of output nodes
  58785. * @param node defines the node to add
  58786. * @returns the current material
  58787. */
  58788. addOutputNode(node: NodeMaterialBlock): this;
  58789. /**
  58790. * Remove a block from the list of root nodes
  58791. * @param node defines the node to remove
  58792. * @returns the current material
  58793. */
  58794. removeOutputNode(node: NodeMaterialBlock): this;
  58795. private _addVertexOutputNode;
  58796. private _removeVertexOutputNode;
  58797. private _addFragmentOutputNode;
  58798. private _removeFragmentOutputNode;
  58799. /**
  58800. * Specifies if the material will require alpha blending
  58801. * @returns a boolean specifying if alpha blending is needed
  58802. */
  58803. needAlphaBlending(): boolean;
  58804. /**
  58805. * Specifies if this material should be rendered in alpha test mode
  58806. * @returns a boolean specifying if an alpha test is needed.
  58807. */
  58808. needAlphaTesting(): boolean;
  58809. private _initializeBlock;
  58810. private _resetDualBlocks;
  58811. /**
  58812. * Remove a block from the current node material
  58813. * @param block defines the block to remove
  58814. */
  58815. removeBlock(block: NodeMaterialBlock): void;
  58816. /**
  58817. * Build the material and generates the inner effect
  58818. * @param verbose defines if the build should log activity
  58819. */
  58820. build(verbose?: boolean): void;
  58821. /**
  58822. * Runs an otpimization phase to try to improve the shader code
  58823. */
  58824. optimize(): void;
  58825. private _prepareDefinesForAttributes;
  58826. /**
  58827. * Get if the submesh is ready to be used and all its information available.
  58828. * Child classes can use it to update shaders
  58829. * @param mesh defines the mesh to check
  58830. * @param subMesh defines which submesh to check
  58831. * @param useInstances specifies that instances should be used
  58832. * @returns a boolean indicating that the submesh is ready or not
  58833. */
  58834. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58835. /**
  58836. * Get a string representing the shaders built by the current node graph
  58837. */
  58838. get compiledShaders(): string;
  58839. /**
  58840. * Binds the world matrix to the material
  58841. * @param world defines the world transformation matrix
  58842. */
  58843. bindOnlyWorldMatrix(world: Matrix): void;
  58844. /**
  58845. * Binds the submesh to this material by preparing the effect and shader to draw
  58846. * @param world defines the world transformation matrix
  58847. * @param mesh defines the mesh containing the submesh
  58848. * @param subMesh defines the submesh to bind the material to
  58849. */
  58850. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58851. /**
  58852. * Gets the active textures from the material
  58853. * @returns an array of textures
  58854. */
  58855. getActiveTextures(): BaseTexture[];
  58856. /**
  58857. * Gets the list of texture blocks
  58858. * @returns an array of texture blocks
  58859. */
  58860. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  58861. /**
  58862. * Specifies if the material uses a texture
  58863. * @param texture defines the texture to check against the material
  58864. * @returns a boolean specifying if the material uses the texture
  58865. */
  58866. hasTexture(texture: BaseTexture): boolean;
  58867. /**
  58868. * Disposes the material
  58869. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  58870. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  58871. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  58872. */
  58873. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  58874. /** Creates the node editor window. */
  58875. private _createNodeEditor;
  58876. /**
  58877. * Launch the node material editor
  58878. * @param config Define the configuration of the editor
  58879. * @return a promise fulfilled when the node editor is visible
  58880. */
  58881. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  58882. /**
  58883. * Clear the current material
  58884. */
  58885. clear(): void;
  58886. /**
  58887. * Clear the current material and set it to a default state
  58888. */
  58889. setToDefault(): void;
  58890. /**
  58891. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  58892. * @param url defines the url to load from
  58893. * @returns a promise that will fullfil when the material is fully loaded
  58894. */
  58895. loadAsync(url: string): Promise<void>;
  58896. private _gatherBlocks;
  58897. /**
  58898. * Generate a string containing the code declaration required to create an equivalent of this material
  58899. * @returns a string
  58900. */
  58901. generateCode(): string;
  58902. /**
  58903. * Serializes this material in a JSON representation
  58904. * @returns the serialized material object
  58905. */
  58906. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  58907. private _restoreConnections;
  58908. /**
  58909. * Clear the current graph and load a new one from a serialization object
  58910. * @param source defines the JSON representation of the material
  58911. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58912. */
  58913. loadFromSerialization(source: any, rootUrl?: string): void;
  58914. /**
  58915. * Creates a node material from parsed material data
  58916. * @param source defines the JSON representation of the material
  58917. * @param scene defines the hosting scene
  58918. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  58919. * @returns a new node material
  58920. */
  58921. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  58922. /**
  58923. * Creates a new node material set to default basic configuration
  58924. * @param name defines the name of the material
  58925. * @param scene defines the hosting scene
  58926. * @returns a new NodeMaterial
  58927. */
  58928. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  58929. }
  58930. }
  58931. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  58932. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58934. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  58935. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58937. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  58938. import { Effect } from "babylonjs/Materials/effect";
  58939. import { Mesh } from "babylonjs/Meshes/mesh";
  58940. import { Nullable } from "babylonjs/types";
  58941. import { Texture } from "babylonjs/Materials/Textures/texture";
  58942. import { Scene } from "babylonjs/scene";
  58943. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58944. /**
  58945. * Block used to read a texture from a sampler
  58946. */
  58947. export class TextureBlock extends NodeMaterialBlock {
  58948. private _defineName;
  58949. private _linearDefineName;
  58950. private _tempTextureRead;
  58951. private _samplerName;
  58952. private _transformedUVName;
  58953. private _textureTransformName;
  58954. private _textureInfoName;
  58955. private _mainUVName;
  58956. private _mainUVDefineName;
  58957. /**
  58958. * Gets or sets the texture associated with the node
  58959. */
  58960. texture: Nullable<Texture>;
  58961. /**
  58962. * Create a new TextureBlock
  58963. * @param name defines the block name
  58964. */
  58965. constructor(name: string);
  58966. /**
  58967. * Gets the current class name
  58968. * @returns the class name
  58969. */
  58970. getClassName(): string;
  58971. /**
  58972. * Gets the uv input component
  58973. */
  58974. get uv(): NodeMaterialConnectionPoint;
  58975. /**
  58976. * Gets the rgba output component
  58977. */
  58978. get rgba(): NodeMaterialConnectionPoint;
  58979. /**
  58980. * Gets the rgb output component
  58981. */
  58982. get rgb(): NodeMaterialConnectionPoint;
  58983. /**
  58984. * Gets the r output component
  58985. */
  58986. get r(): NodeMaterialConnectionPoint;
  58987. /**
  58988. * Gets the g output component
  58989. */
  58990. get g(): NodeMaterialConnectionPoint;
  58991. /**
  58992. * Gets the b output component
  58993. */
  58994. get b(): NodeMaterialConnectionPoint;
  58995. /**
  58996. * Gets the a output component
  58997. */
  58998. get a(): NodeMaterialConnectionPoint;
  58999. get target(): NodeMaterialBlockTargets;
  59000. autoConfigure(material: NodeMaterial): void;
  59001. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59002. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59003. private _getTextureBase;
  59004. isReady(): boolean;
  59005. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59006. private get _isMixed();
  59007. private _injectVertexCode;
  59008. private _writeTextureRead;
  59009. private _writeOutput;
  59010. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59011. protected _dumpPropertiesCode(): string;
  59012. serialize(): any;
  59013. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59014. }
  59015. }
  59016. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  59017. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59018. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59019. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59020. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59021. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59022. import { Scene } from "babylonjs/scene";
  59023. /**
  59024. * Class used to store shared data between 2 NodeMaterialBuildState
  59025. */
  59026. export class NodeMaterialBuildStateSharedData {
  59027. /**
  59028. * Gets the list of emitted varyings
  59029. */
  59030. temps: string[];
  59031. /**
  59032. * Gets the list of emitted varyings
  59033. */
  59034. varyings: string[];
  59035. /**
  59036. * Gets the varying declaration string
  59037. */
  59038. varyingDeclaration: string;
  59039. /**
  59040. * Input blocks
  59041. */
  59042. inputBlocks: InputBlock[];
  59043. /**
  59044. * Input blocks
  59045. */
  59046. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  59047. /**
  59048. * Bindable blocks (Blocks that need to set data to the effect)
  59049. */
  59050. bindableBlocks: NodeMaterialBlock[];
  59051. /**
  59052. * List of blocks that can provide a compilation fallback
  59053. */
  59054. blocksWithFallbacks: NodeMaterialBlock[];
  59055. /**
  59056. * List of blocks that can provide a define update
  59057. */
  59058. blocksWithDefines: NodeMaterialBlock[];
  59059. /**
  59060. * List of blocks that can provide a repeatable content
  59061. */
  59062. repeatableContentBlocks: NodeMaterialBlock[];
  59063. /**
  59064. * List of blocks that can provide a dynamic list of uniforms
  59065. */
  59066. dynamicUniformBlocks: NodeMaterialBlock[];
  59067. /**
  59068. * List of blocks that can block the isReady function for the material
  59069. */
  59070. blockingBlocks: NodeMaterialBlock[];
  59071. /**
  59072. * Gets the list of animated inputs
  59073. */
  59074. animatedInputs: InputBlock[];
  59075. /**
  59076. * Build Id used to avoid multiple recompilations
  59077. */
  59078. buildId: number;
  59079. /** List of emitted variables */
  59080. variableNames: {
  59081. [key: string]: number;
  59082. };
  59083. /** List of emitted defines */
  59084. defineNames: {
  59085. [key: string]: number;
  59086. };
  59087. /** Should emit comments? */
  59088. emitComments: boolean;
  59089. /** Emit build activity */
  59090. verbose: boolean;
  59091. /** Gets or sets the hosting scene */
  59092. scene: Scene;
  59093. /**
  59094. * Gets the compilation hints emitted at compilation time
  59095. */
  59096. hints: {
  59097. needWorldViewMatrix: boolean;
  59098. needWorldViewProjectionMatrix: boolean;
  59099. needAlphaBlending: boolean;
  59100. needAlphaTesting: boolean;
  59101. };
  59102. /**
  59103. * List of compilation checks
  59104. */
  59105. checks: {
  59106. emitVertex: boolean;
  59107. emitFragment: boolean;
  59108. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  59109. };
  59110. /** Creates a new shared data */
  59111. constructor();
  59112. /**
  59113. * Emits console errors and exceptions if there is a failing check
  59114. */
  59115. emitErrors(): void;
  59116. }
  59117. }
  59118. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  59119. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59120. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59121. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  59122. /**
  59123. * Class used to store node based material build state
  59124. */
  59125. export class NodeMaterialBuildState {
  59126. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  59127. supportUniformBuffers: boolean;
  59128. /**
  59129. * Gets the list of emitted attributes
  59130. */
  59131. attributes: string[];
  59132. /**
  59133. * Gets the list of emitted uniforms
  59134. */
  59135. uniforms: string[];
  59136. /**
  59137. * Gets the list of emitted constants
  59138. */
  59139. constants: string[];
  59140. /**
  59141. * Gets the list of emitted samplers
  59142. */
  59143. samplers: string[];
  59144. /**
  59145. * Gets the list of emitted functions
  59146. */
  59147. functions: {
  59148. [key: string]: string;
  59149. };
  59150. /**
  59151. * Gets the list of emitted extensions
  59152. */
  59153. extensions: {
  59154. [key: string]: string;
  59155. };
  59156. /**
  59157. * Gets the target of the compilation state
  59158. */
  59159. target: NodeMaterialBlockTargets;
  59160. /**
  59161. * Gets the list of emitted counters
  59162. */
  59163. counters: {
  59164. [key: string]: number;
  59165. };
  59166. /**
  59167. * Shared data between multiple NodeMaterialBuildState instances
  59168. */
  59169. sharedData: NodeMaterialBuildStateSharedData;
  59170. /** @hidden */
  59171. _vertexState: NodeMaterialBuildState;
  59172. /** @hidden */
  59173. _attributeDeclaration: string;
  59174. /** @hidden */
  59175. _uniformDeclaration: string;
  59176. /** @hidden */
  59177. _constantDeclaration: string;
  59178. /** @hidden */
  59179. _samplerDeclaration: string;
  59180. /** @hidden */
  59181. _varyingTransfer: string;
  59182. private _repeatableContentAnchorIndex;
  59183. /** @hidden */
  59184. _builtCompilationString: string;
  59185. /**
  59186. * Gets the emitted compilation strings
  59187. */
  59188. compilationString: string;
  59189. /**
  59190. * Finalize the compilation strings
  59191. * @param state defines the current compilation state
  59192. */
  59193. finalize(state: NodeMaterialBuildState): void;
  59194. /** @hidden */
  59195. get _repeatableContentAnchor(): string;
  59196. /** @hidden */
  59197. _getFreeVariableName(prefix: string): string;
  59198. /** @hidden */
  59199. _getFreeDefineName(prefix: string): string;
  59200. /** @hidden */
  59201. _excludeVariableName(name: string): void;
  59202. /** @hidden */
  59203. _emit2DSampler(name: string): void;
  59204. /** @hidden */
  59205. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  59206. /** @hidden */
  59207. _emitExtension(name: string, extension: string): void;
  59208. /** @hidden */
  59209. _emitFunction(name: string, code: string, comments: string): void;
  59210. /** @hidden */
  59211. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  59212. replaceStrings?: {
  59213. search: RegExp;
  59214. replace: string;
  59215. }[];
  59216. repeatKey?: string;
  59217. }): string;
  59218. /** @hidden */
  59219. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  59220. repeatKey?: string;
  59221. removeAttributes?: boolean;
  59222. removeUniforms?: boolean;
  59223. removeVaryings?: boolean;
  59224. removeIfDef?: boolean;
  59225. replaceStrings?: {
  59226. search: RegExp;
  59227. replace: string;
  59228. }[];
  59229. }, storeKey?: string): void;
  59230. /** @hidden */
  59231. _registerTempVariable(name: string): boolean;
  59232. /** @hidden */
  59233. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  59234. /** @hidden */
  59235. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  59236. /** @hidden */
  59237. _emitFloat(value: number): string;
  59238. }
  59239. }
  59240. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  59241. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59242. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59243. import { Nullable } from "babylonjs/types";
  59244. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59245. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59246. import { Effect } from "babylonjs/Materials/effect";
  59247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59248. import { Mesh } from "babylonjs/Meshes/mesh";
  59249. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59250. import { Scene } from "babylonjs/scene";
  59251. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59252. /**
  59253. * Defines a block that can be used inside a node based material
  59254. */
  59255. export class NodeMaterialBlock {
  59256. private _buildId;
  59257. private _buildTarget;
  59258. private _target;
  59259. private _isFinalMerger;
  59260. private _isInput;
  59261. protected _isUnique: boolean;
  59262. /** @hidden */
  59263. _codeVariableName: string;
  59264. /** @hidden */
  59265. _inputs: NodeMaterialConnectionPoint[];
  59266. /** @hidden */
  59267. _outputs: NodeMaterialConnectionPoint[];
  59268. /** @hidden */
  59269. _preparationId: number;
  59270. /**
  59271. * Gets or sets the name of the block
  59272. */
  59273. name: string;
  59274. /**
  59275. * Gets or sets the unique id of the node
  59276. */
  59277. uniqueId: number;
  59278. /**
  59279. * Gets or sets the comments associated with this block
  59280. */
  59281. comments: string;
  59282. /**
  59283. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  59284. */
  59285. get isUnique(): boolean;
  59286. /**
  59287. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  59288. */
  59289. get isFinalMerger(): boolean;
  59290. /**
  59291. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  59292. */
  59293. get isInput(): boolean;
  59294. /**
  59295. * Gets or sets the build Id
  59296. */
  59297. get buildId(): number;
  59298. set buildId(value: number);
  59299. /**
  59300. * Gets or sets the target of the block
  59301. */
  59302. get target(): NodeMaterialBlockTargets;
  59303. set target(value: NodeMaterialBlockTargets);
  59304. /**
  59305. * Gets the list of input points
  59306. */
  59307. get inputs(): NodeMaterialConnectionPoint[];
  59308. /** Gets the list of output points */
  59309. get outputs(): NodeMaterialConnectionPoint[];
  59310. /**
  59311. * Find an input by its name
  59312. * @param name defines the name of the input to look for
  59313. * @returns the input or null if not found
  59314. */
  59315. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59316. /**
  59317. * Find an output by its name
  59318. * @param name defines the name of the outputto look for
  59319. * @returns the output or null if not found
  59320. */
  59321. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  59322. /**
  59323. * Creates a new NodeMaterialBlock
  59324. * @param name defines the block name
  59325. * @param target defines the target of that block (Vertex by default)
  59326. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  59327. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  59328. */
  59329. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  59330. /**
  59331. * Initialize the block and prepare the context for build
  59332. * @param state defines the state that will be used for the build
  59333. */
  59334. initialize(state: NodeMaterialBuildState): void;
  59335. /**
  59336. * Bind data to effect. Will only be called for blocks with isBindable === true
  59337. * @param effect defines the effect to bind data to
  59338. * @param nodeMaterial defines the hosting NodeMaterial
  59339. * @param mesh defines the mesh that will be rendered
  59340. */
  59341. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59342. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  59343. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  59344. protected _writeFloat(value: number): string;
  59345. /**
  59346. * Gets the current class name e.g. "NodeMaterialBlock"
  59347. * @returns the class name
  59348. */
  59349. getClassName(): string;
  59350. /**
  59351. * Register a new input. Must be called inside a block constructor
  59352. * @param name defines the connection point name
  59353. * @param type defines the connection point type
  59354. * @param isOptional defines a boolean indicating that this input can be omitted
  59355. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59356. * @returns the current block
  59357. */
  59358. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  59359. /**
  59360. * Register a new output. Must be called inside a block constructor
  59361. * @param name defines the connection point name
  59362. * @param type defines the connection point type
  59363. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  59364. * @returns the current block
  59365. */
  59366. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  59367. /**
  59368. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  59369. * @param forOutput defines an optional connection point to check compatibility with
  59370. * @returns the first available input or null
  59371. */
  59372. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  59373. /**
  59374. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  59375. * @param forBlock defines an optional block to check compatibility with
  59376. * @returns the first available input or null
  59377. */
  59378. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  59379. /**
  59380. * Gets the sibling of the given output
  59381. * @param current defines the current output
  59382. * @returns the next output in the list or null
  59383. */
  59384. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  59385. /**
  59386. * Connect current block with another block
  59387. * @param other defines the block to connect with
  59388. * @param options define the various options to help pick the right connections
  59389. * @returns the current block
  59390. */
  59391. connectTo(other: NodeMaterialBlock, options?: {
  59392. input?: string;
  59393. output?: string;
  59394. outputSwizzle?: string;
  59395. }): this | undefined;
  59396. protected _buildBlock(state: NodeMaterialBuildState): void;
  59397. /**
  59398. * Add uniforms, samplers and uniform buffers at compilation time
  59399. * @param state defines the state to update
  59400. * @param nodeMaterial defines the node material requesting the update
  59401. * @param defines defines the material defines to update
  59402. * @param uniformBuffers defines the list of uniform buffer names
  59403. */
  59404. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  59405. /**
  59406. * Add potential fallbacks if shader compilation fails
  59407. * @param mesh defines the mesh to be rendered
  59408. * @param fallbacks defines the current prioritized list of fallbacks
  59409. */
  59410. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59411. /**
  59412. * Initialize defines for shader compilation
  59413. * @param mesh defines the mesh to be rendered
  59414. * @param nodeMaterial defines the node material requesting the update
  59415. * @param defines defines the material defines to update
  59416. * @param useInstances specifies that instances should be used
  59417. */
  59418. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59419. /**
  59420. * Update defines for shader compilation
  59421. * @param mesh defines the mesh to be rendered
  59422. * @param nodeMaterial defines the node material requesting the update
  59423. * @param defines defines the material defines to update
  59424. * @param useInstances specifies that instances should be used
  59425. */
  59426. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59427. /**
  59428. * Lets the block try to connect some inputs automatically
  59429. * @param material defines the hosting NodeMaterial
  59430. */
  59431. autoConfigure(material: NodeMaterial): void;
  59432. /**
  59433. * Function called when a block is declared as repeatable content generator
  59434. * @param vertexShaderState defines the current compilation state for the vertex shader
  59435. * @param fragmentShaderState defines the current compilation state for the fragment shader
  59436. * @param mesh defines the mesh to be rendered
  59437. * @param defines defines the material defines to update
  59438. */
  59439. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59440. /**
  59441. * Checks if the block is ready
  59442. * @param mesh defines the mesh to be rendered
  59443. * @param nodeMaterial defines the node material requesting the update
  59444. * @param defines defines the material defines to update
  59445. * @param useInstances specifies that instances should be used
  59446. * @returns true if the block is ready
  59447. */
  59448. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  59449. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  59450. private _processBuild;
  59451. /**
  59452. * Compile the current node and generate the shader code
  59453. * @param state defines the current compilation state (uniforms, samplers, current string)
  59454. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  59455. * @returns true if already built
  59456. */
  59457. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  59458. protected _inputRename(name: string): string;
  59459. protected _outputRename(name: string): string;
  59460. protected _dumpPropertiesCode(): string;
  59461. /** @hidden */
  59462. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  59463. /** @hidden */
  59464. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  59465. /**
  59466. * Clone the current block to a new identical block
  59467. * @param scene defines the hosting scene
  59468. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59469. * @returns a copy of the current block
  59470. */
  59471. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  59472. /**
  59473. * Serializes this block in a JSON representation
  59474. * @returns the serialized block object
  59475. */
  59476. serialize(): any;
  59477. /** @hidden */
  59478. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59479. /**
  59480. * Release resources
  59481. */
  59482. dispose(): void;
  59483. }
  59484. }
  59485. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  59486. /**
  59487. * Enum defining the type of animations supported by InputBlock
  59488. */
  59489. export enum AnimatedInputBlockTypes {
  59490. /** No animation */
  59491. None = 0,
  59492. /** Time based animation. Will only work for floats */
  59493. Time = 1
  59494. }
  59495. }
  59496. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  59497. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59498. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59499. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59500. import { Nullable } from "babylonjs/types";
  59501. import { Effect } from "babylonjs/Materials/effect";
  59502. import { Matrix } from "babylonjs/Maths/math.vector";
  59503. import { Scene } from "babylonjs/scene";
  59504. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59506. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59507. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  59508. /**
  59509. * Block used to expose an input value
  59510. */
  59511. export class InputBlock extends NodeMaterialBlock {
  59512. private _mode;
  59513. private _associatedVariableName;
  59514. private _storedValue;
  59515. private _valueCallback;
  59516. private _type;
  59517. private _animationType;
  59518. /** Gets or set a value used to limit the range of float values */
  59519. min: number;
  59520. /** Gets or set a value used to limit the range of float values */
  59521. max: number;
  59522. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  59523. matrixMode: number;
  59524. /** @hidden */
  59525. _systemValue: Nullable<NodeMaterialSystemValues>;
  59526. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  59527. visibleInInspector: boolean;
  59528. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  59529. isConstant: boolean;
  59530. /** Gets or sets the group to use to display this block in the Inspector */
  59531. groupInInspector: string;
  59532. /**
  59533. * Gets or sets the connection point type (default is float)
  59534. */
  59535. get type(): NodeMaterialBlockConnectionPointTypes;
  59536. /**
  59537. * Creates a new InputBlock
  59538. * @param name defines the block name
  59539. * @param target defines the target of that block (Vertex by default)
  59540. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  59541. */
  59542. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  59543. /**
  59544. * Gets the output component
  59545. */
  59546. get output(): NodeMaterialConnectionPoint;
  59547. /**
  59548. * Set the source of this connection point to a vertex attribute
  59549. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  59550. * @returns the current connection point
  59551. */
  59552. setAsAttribute(attributeName?: string): InputBlock;
  59553. /**
  59554. * Set the source of this connection point to a system value
  59555. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  59556. * @returns the current connection point
  59557. */
  59558. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  59559. /**
  59560. * Gets or sets the value of that point.
  59561. * Please note that this value will be ignored if valueCallback is defined
  59562. */
  59563. get value(): any;
  59564. set value(value: any);
  59565. /**
  59566. * Gets or sets a callback used to get the value of that point.
  59567. * Please note that setting this value will force the connection point to ignore the value property
  59568. */
  59569. get valueCallback(): () => any;
  59570. set valueCallback(value: () => any);
  59571. /**
  59572. * Gets or sets the associated variable name in the shader
  59573. */
  59574. get associatedVariableName(): string;
  59575. set associatedVariableName(value: string);
  59576. /** Gets or sets the type of animation applied to the input */
  59577. get animationType(): AnimatedInputBlockTypes;
  59578. set animationType(value: AnimatedInputBlockTypes);
  59579. /**
  59580. * Gets a boolean indicating that this connection point not defined yet
  59581. */
  59582. get isUndefined(): boolean;
  59583. /**
  59584. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  59585. * In this case the connection point name must be the name of the uniform to use.
  59586. * Can only be set on inputs
  59587. */
  59588. get isUniform(): boolean;
  59589. set isUniform(value: boolean);
  59590. /**
  59591. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  59592. * In this case the connection point name must be the name of the attribute to use
  59593. * Can only be set on inputs
  59594. */
  59595. get isAttribute(): boolean;
  59596. set isAttribute(value: boolean);
  59597. /**
  59598. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  59599. * Can only be set on exit points
  59600. */
  59601. get isVarying(): boolean;
  59602. set isVarying(value: boolean);
  59603. /**
  59604. * Gets a boolean indicating that the current connection point is a system value
  59605. */
  59606. get isSystemValue(): boolean;
  59607. /**
  59608. * Gets or sets the current well known value or null if not defined as a system value
  59609. */
  59610. get systemValue(): Nullable<NodeMaterialSystemValues>;
  59611. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  59612. /**
  59613. * Gets the current class name
  59614. * @returns the class name
  59615. */
  59616. getClassName(): string;
  59617. /**
  59618. * Animate the input if animationType !== None
  59619. * @param scene defines the rendering scene
  59620. */
  59621. animate(scene: Scene): void;
  59622. private _emitDefine;
  59623. initialize(state: NodeMaterialBuildState): void;
  59624. /**
  59625. * Set the input block to its default value (based on its type)
  59626. */
  59627. setDefaultValue(): void;
  59628. private _emitConstant;
  59629. private _emit;
  59630. /** @hidden */
  59631. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  59632. /** @hidden */
  59633. _transmit(effect: Effect, scene: Scene): void;
  59634. protected _buildBlock(state: NodeMaterialBuildState): void;
  59635. protected _dumpPropertiesCode(): string;
  59636. serialize(): any;
  59637. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59638. }
  59639. }
  59640. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  59641. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59642. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59643. import { Nullable } from "babylonjs/types";
  59644. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59645. import { Observable } from "babylonjs/Misc/observable";
  59646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59647. /**
  59648. * Enum used to define the compatibility state between two connection points
  59649. */
  59650. export enum NodeMaterialConnectionPointCompatibilityStates {
  59651. /** Points are compatibles */
  59652. Compatible = 0,
  59653. /** Points are incompatible because of their types */
  59654. TypeIncompatible = 1,
  59655. /** Points are incompatible because of their targets (vertex vs fragment) */
  59656. TargetIncompatible = 2
  59657. }
  59658. /**
  59659. * Defines the direction of a connection point
  59660. */
  59661. export enum NodeMaterialConnectionPointDirection {
  59662. /** Input */
  59663. Input = 0,
  59664. /** Output */
  59665. Output = 1
  59666. }
  59667. /**
  59668. * Defines a connection point for a block
  59669. */
  59670. export class NodeMaterialConnectionPoint {
  59671. /** @hidden */
  59672. _ownerBlock: NodeMaterialBlock;
  59673. /** @hidden */
  59674. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  59675. private _endpoints;
  59676. private _associatedVariableName;
  59677. private _direction;
  59678. /** @hidden */
  59679. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59680. /** @hidden */
  59681. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  59682. private _type;
  59683. /** @hidden */
  59684. _enforceAssociatedVariableName: boolean;
  59685. /** Gets the direction of the point */
  59686. get direction(): NodeMaterialConnectionPointDirection;
  59687. /**
  59688. * Gets or sets the additional types supported by this connection point
  59689. */
  59690. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59691. /**
  59692. * Gets or sets the additional types excluded by this connection point
  59693. */
  59694. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  59695. /**
  59696. * Observable triggered when this point is connected
  59697. */
  59698. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  59699. /**
  59700. * Gets or sets the associated variable name in the shader
  59701. */
  59702. get associatedVariableName(): string;
  59703. set associatedVariableName(value: string);
  59704. /**
  59705. * Gets or sets the connection point type (default is float)
  59706. */
  59707. get type(): NodeMaterialBlockConnectionPointTypes;
  59708. set type(value: NodeMaterialBlockConnectionPointTypes);
  59709. /**
  59710. * Gets or sets the connection point name
  59711. */
  59712. name: string;
  59713. /**
  59714. * Gets or sets a boolean indicating that this connection point can be omitted
  59715. */
  59716. isOptional: boolean;
  59717. /**
  59718. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  59719. */
  59720. define: string;
  59721. /** @hidden */
  59722. _prioritizeVertex: boolean;
  59723. private _target;
  59724. /** Gets or sets the target of that connection point */
  59725. get target(): NodeMaterialBlockTargets;
  59726. set target(value: NodeMaterialBlockTargets);
  59727. /**
  59728. * Gets a boolean indicating that the current point is connected
  59729. */
  59730. get isConnected(): boolean;
  59731. /**
  59732. * Gets a boolean indicating that the current point is connected to an input block
  59733. */
  59734. get isConnectedToInputBlock(): boolean;
  59735. /**
  59736. * Gets a the connected input block (if any)
  59737. */
  59738. get connectInputBlock(): Nullable<InputBlock>;
  59739. /** Get the other side of the connection (if any) */
  59740. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  59741. /** Get the block that owns this connection point */
  59742. get ownerBlock(): NodeMaterialBlock;
  59743. /** Get the block connected on the other side of this connection (if any) */
  59744. get sourceBlock(): Nullable<NodeMaterialBlock>;
  59745. /** Get the block connected on the endpoints of this connection (if any) */
  59746. get connectedBlocks(): Array<NodeMaterialBlock>;
  59747. /** Gets the list of connected endpoints */
  59748. get endpoints(): NodeMaterialConnectionPoint[];
  59749. /** Gets a boolean indicating if that output point is connected to at least one input */
  59750. get hasEndpoints(): boolean;
  59751. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  59752. get isConnectedInVertexShader(): boolean;
  59753. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  59754. get isConnectedInFragmentShader(): boolean;
  59755. /**
  59756. * Creates a new connection point
  59757. * @param name defines the connection point name
  59758. * @param ownerBlock defines the block hosting this connection point
  59759. * @param direction defines the direction of the connection point
  59760. */
  59761. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  59762. /**
  59763. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  59764. * @returns the class name
  59765. */
  59766. getClassName(): string;
  59767. /**
  59768. * Gets a boolean indicating if the current point can be connected to another point
  59769. * @param connectionPoint defines the other connection point
  59770. * @returns a boolean
  59771. */
  59772. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  59773. /**
  59774. * Gets a number indicating if the current point can be connected to another point
  59775. * @param connectionPoint defines the other connection point
  59776. * @returns a number defining the compatibility state
  59777. */
  59778. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  59779. /**
  59780. * Connect this point to another connection point
  59781. * @param connectionPoint defines the other connection point
  59782. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  59783. * @returns the current connection point
  59784. */
  59785. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  59786. /**
  59787. * Disconnect this point from one of his endpoint
  59788. * @param endpoint defines the other connection point
  59789. * @returns the current connection point
  59790. */
  59791. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  59792. /**
  59793. * Serializes this point in a JSON representation
  59794. * @returns the serialized point object
  59795. */
  59796. serialize(): any;
  59797. /**
  59798. * Release resources
  59799. */
  59800. dispose(): void;
  59801. }
  59802. }
  59803. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  59804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59805. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59807. import { Mesh } from "babylonjs/Meshes/mesh";
  59808. import { Effect } from "babylonjs/Materials/effect";
  59809. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59810. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59811. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59812. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59813. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  59814. /**
  59815. * Block used to add support for vertex skinning (bones)
  59816. */
  59817. export class BonesBlock extends NodeMaterialBlock {
  59818. /**
  59819. * Creates a new BonesBlock
  59820. * @param name defines the block name
  59821. */
  59822. constructor(name: string);
  59823. /**
  59824. * Initialize the block and prepare the context for build
  59825. * @param state defines the state that will be used for the build
  59826. */
  59827. initialize(state: NodeMaterialBuildState): void;
  59828. /**
  59829. * Gets the current class name
  59830. * @returns the class name
  59831. */
  59832. getClassName(): string;
  59833. /**
  59834. * Gets the matrix indices input component
  59835. */
  59836. get matricesIndices(): NodeMaterialConnectionPoint;
  59837. /**
  59838. * Gets the matrix weights input component
  59839. */
  59840. get matricesWeights(): NodeMaterialConnectionPoint;
  59841. /**
  59842. * Gets the extra matrix indices input component
  59843. */
  59844. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  59845. /**
  59846. * Gets the extra matrix weights input component
  59847. */
  59848. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  59849. /**
  59850. * Gets the world input component
  59851. */
  59852. get world(): NodeMaterialConnectionPoint;
  59853. /**
  59854. * Gets the output component
  59855. */
  59856. get output(): NodeMaterialConnectionPoint;
  59857. autoConfigure(material: NodeMaterial): void;
  59858. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  59859. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59860. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59861. protected _buildBlock(state: NodeMaterialBuildState): this;
  59862. }
  59863. }
  59864. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  59865. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59866. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59869. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59870. /**
  59871. * Block used to add support for instances
  59872. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  59873. */
  59874. export class InstancesBlock extends NodeMaterialBlock {
  59875. /**
  59876. * Creates a new InstancesBlock
  59877. * @param name defines the block name
  59878. */
  59879. constructor(name: string);
  59880. /**
  59881. * Gets the current class name
  59882. * @returns the class name
  59883. */
  59884. getClassName(): string;
  59885. /**
  59886. * Gets the first world row input component
  59887. */
  59888. get world0(): NodeMaterialConnectionPoint;
  59889. /**
  59890. * Gets the second world row input component
  59891. */
  59892. get world1(): NodeMaterialConnectionPoint;
  59893. /**
  59894. * Gets the third world row input component
  59895. */
  59896. get world2(): NodeMaterialConnectionPoint;
  59897. /**
  59898. * Gets the forth world row input component
  59899. */
  59900. get world3(): NodeMaterialConnectionPoint;
  59901. /**
  59902. * Gets the world input component
  59903. */
  59904. get world(): NodeMaterialConnectionPoint;
  59905. /**
  59906. * Gets the output component
  59907. */
  59908. get output(): NodeMaterialConnectionPoint;
  59909. autoConfigure(material: NodeMaterial): void;
  59910. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59911. protected _buildBlock(state: NodeMaterialBuildState): this;
  59912. }
  59913. }
  59914. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  59915. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59918. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59919. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59920. import { Effect } from "babylonjs/Materials/effect";
  59921. import { Mesh } from "babylonjs/Meshes/mesh";
  59922. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59923. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59924. /**
  59925. * Block used to add morph targets support to vertex shader
  59926. */
  59927. export class MorphTargetsBlock extends NodeMaterialBlock {
  59928. private _repeatableContentAnchor;
  59929. private _repeatebleContentGenerated;
  59930. /**
  59931. * Create a new MorphTargetsBlock
  59932. * @param name defines the block name
  59933. */
  59934. constructor(name: string);
  59935. /**
  59936. * Gets the current class name
  59937. * @returns the class name
  59938. */
  59939. getClassName(): string;
  59940. /**
  59941. * Gets the position input component
  59942. */
  59943. get position(): NodeMaterialConnectionPoint;
  59944. /**
  59945. * Gets the normal input component
  59946. */
  59947. get normal(): NodeMaterialConnectionPoint;
  59948. /**
  59949. * Gets the tangent input component
  59950. */
  59951. get tangent(): NodeMaterialConnectionPoint;
  59952. /**
  59953. * Gets the tangent input component
  59954. */
  59955. get uv(): NodeMaterialConnectionPoint;
  59956. /**
  59957. * Gets the position output component
  59958. */
  59959. get positionOutput(): NodeMaterialConnectionPoint;
  59960. /**
  59961. * Gets the normal output component
  59962. */
  59963. get normalOutput(): NodeMaterialConnectionPoint;
  59964. /**
  59965. * Gets the tangent output component
  59966. */
  59967. get tangentOutput(): NodeMaterialConnectionPoint;
  59968. /**
  59969. * Gets the tangent output component
  59970. */
  59971. get uvOutput(): NodeMaterialConnectionPoint;
  59972. initialize(state: NodeMaterialBuildState): void;
  59973. autoConfigure(material: NodeMaterial): void;
  59974. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59975. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59976. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  59977. protected _buildBlock(state: NodeMaterialBuildState): this;
  59978. }
  59979. }
  59980. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  59981. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59982. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59983. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59984. import { Nullable } from "babylonjs/types";
  59985. import { Scene } from "babylonjs/scene";
  59986. import { Effect } from "babylonjs/Materials/effect";
  59987. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59988. import { Mesh } from "babylonjs/Meshes/mesh";
  59989. import { Light } from "babylonjs/Lights/light";
  59990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59991. /**
  59992. * Block used to get data information from a light
  59993. */
  59994. export class LightInformationBlock extends NodeMaterialBlock {
  59995. private _lightDataUniformName;
  59996. private _lightColorUniformName;
  59997. private _lightTypeDefineName;
  59998. /**
  59999. * Gets or sets the light associated with this block
  60000. */
  60001. light: Nullable<Light>;
  60002. /**
  60003. * Creates a new LightInformationBlock
  60004. * @param name defines the block name
  60005. */
  60006. constructor(name: string);
  60007. /**
  60008. * Gets the current class name
  60009. * @returns the class name
  60010. */
  60011. getClassName(): string;
  60012. /**
  60013. * Gets the world position input component
  60014. */
  60015. get worldPosition(): NodeMaterialConnectionPoint;
  60016. /**
  60017. * Gets the direction output component
  60018. */
  60019. get direction(): NodeMaterialConnectionPoint;
  60020. /**
  60021. * Gets the direction output component
  60022. */
  60023. get color(): NodeMaterialConnectionPoint;
  60024. /**
  60025. * Gets the direction output component
  60026. */
  60027. get intensity(): NodeMaterialConnectionPoint;
  60028. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60029. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60030. protected _buildBlock(state: NodeMaterialBuildState): this;
  60031. serialize(): any;
  60032. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60033. }
  60034. }
  60035. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  60036. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  60037. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  60038. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  60039. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  60040. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  60041. }
  60042. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  60043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60047. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60048. import { Effect } from "babylonjs/Materials/effect";
  60049. import { Mesh } from "babylonjs/Meshes/mesh";
  60050. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60051. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60052. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60053. /**
  60054. * Block used to add image processing support to fragment shader
  60055. */
  60056. export class ImageProcessingBlock extends NodeMaterialBlock {
  60057. /**
  60058. * Create a new ImageProcessingBlock
  60059. * @param name defines the block name
  60060. */
  60061. constructor(name: string);
  60062. /**
  60063. * Gets the current class name
  60064. * @returns the class name
  60065. */
  60066. getClassName(): string;
  60067. /**
  60068. * Gets the color input component
  60069. */
  60070. get color(): NodeMaterialConnectionPoint;
  60071. /**
  60072. * Gets the output component
  60073. */
  60074. get output(): NodeMaterialConnectionPoint;
  60075. /**
  60076. * Initialize the block and prepare the context for build
  60077. * @param state defines the state that will be used for the build
  60078. */
  60079. initialize(state: NodeMaterialBuildState): void;
  60080. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  60081. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60082. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60083. protected _buildBlock(state: NodeMaterialBuildState): this;
  60084. }
  60085. }
  60086. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  60087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60090. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60091. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60092. import { Effect } from "babylonjs/Materials/effect";
  60093. import { Mesh } from "babylonjs/Meshes/mesh";
  60094. import { Scene } from "babylonjs/scene";
  60095. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  60096. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  60097. /**
  60098. * Block used to pertub normals based on a normal map
  60099. */
  60100. export class PerturbNormalBlock extends NodeMaterialBlock {
  60101. private _tangentSpaceParameterName;
  60102. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  60103. invertX: boolean;
  60104. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  60105. invertY: boolean;
  60106. /**
  60107. * Create a new PerturbNormalBlock
  60108. * @param name defines the block name
  60109. */
  60110. constructor(name: string);
  60111. /**
  60112. * Gets the current class name
  60113. * @returns the class name
  60114. */
  60115. getClassName(): string;
  60116. /**
  60117. * Gets the world position input component
  60118. */
  60119. get worldPosition(): NodeMaterialConnectionPoint;
  60120. /**
  60121. * Gets the world normal input component
  60122. */
  60123. get worldNormal(): NodeMaterialConnectionPoint;
  60124. /**
  60125. * Gets the uv input component
  60126. */
  60127. get uv(): NodeMaterialConnectionPoint;
  60128. /**
  60129. * Gets the normal map color input component
  60130. */
  60131. get normalMapColor(): NodeMaterialConnectionPoint;
  60132. /**
  60133. * Gets the strength input component
  60134. */
  60135. get strength(): NodeMaterialConnectionPoint;
  60136. /**
  60137. * Gets the output component
  60138. */
  60139. get output(): NodeMaterialConnectionPoint;
  60140. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60141. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60142. autoConfigure(material: NodeMaterial): void;
  60143. protected _buildBlock(state: NodeMaterialBuildState): this;
  60144. protected _dumpPropertiesCode(): string;
  60145. serialize(): any;
  60146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60147. }
  60148. }
  60149. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  60150. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60151. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60153. /**
  60154. * Block used to discard a pixel if a value is smaller than a cutoff
  60155. */
  60156. export class DiscardBlock extends NodeMaterialBlock {
  60157. /**
  60158. * Create a new DiscardBlock
  60159. * @param name defines the block name
  60160. */
  60161. constructor(name: string);
  60162. /**
  60163. * Gets the current class name
  60164. * @returns the class name
  60165. */
  60166. getClassName(): string;
  60167. /**
  60168. * Gets the color input component
  60169. */
  60170. get value(): NodeMaterialConnectionPoint;
  60171. /**
  60172. * Gets the cutoff input component
  60173. */
  60174. get cutoff(): NodeMaterialConnectionPoint;
  60175. protected _buildBlock(state: NodeMaterialBuildState): this;
  60176. }
  60177. }
  60178. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  60179. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60180. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60181. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60182. /**
  60183. * Block used to test if the fragment shader is front facing
  60184. */
  60185. export class FrontFacingBlock extends NodeMaterialBlock {
  60186. /**
  60187. * Creates a new FrontFacingBlock
  60188. * @param name defines the block name
  60189. */
  60190. constructor(name: string);
  60191. /**
  60192. * Gets the current class name
  60193. * @returns the class name
  60194. */
  60195. getClassName(): string;
  60196. /**
  60197. * Gets the output component
  60198. */
  60199. get output(): NodeMaterialConnectionPoint;
  60200. protected _buildBlock(state: NodeMaterialBuildState): this;
  60201. }
  60202. }
  60203. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  60204. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60205. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60206. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60207. /**
  60208. * Block used to get the derivative value on x and y of a given input
  60209. */
  60210. export class DerivativeBlock extends NodeMaterialBlock {
  60211. /**
  60212. * Create a new DerivativeBlock
  60213. * @param name defines the block name
  60214. */
  60215. constructor(name: string);
  60216. /**
  60217. * Gets the current class name
  60218. * @returns the class name
  60219. */
  60220. getClassName(): string;
  60221. /**
  60222. * Gets the input component
  60223. */
  60224. get input(): NodeMaterialConnectionPoint;
  60225. /**
  60226. * Gets the derivative output on x
  60227. */
  60228. get dx(): NodeMaterialConnectionPoint;
  60229. /**
  60230. * Gets the derivative output on y
  60231. */
  60232. get dy(): NodeMaterialConnectionPoint;
  60233. protected _buildBlock(state: NodeMaterialBuildState): this;
  60234. }
  60235. }
  60236. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  60237. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  60238. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  60239. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  60240. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  60241. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  60242. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  60243. }
  60244. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  60245. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60246. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60247. import { Mesh } from "babylonjs/Meshes/mesh";
  60248. import { Effect } from "babylonjs/Materials/effect";
  60249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60251. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60252. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60253. /**
  60254. * Block used to add support for scene fog
  60255. */
  60256. export class FogBlock extends NodeMaterialBlock {
  60257. private _fogDistanceName;
  60258. private _fogParameters;
  60259. /**
  60260. * Create a new FogBlock
  60261. * @param name defines the block name
  60262. */
  60263. constructor(name: string);
  60264. /**
  60265. * Gets the current class name
  60266. * @returns the class name
  60267. */
  60268. getClassName(): string;
  60269. /**
  60270. * Gets the world position input component
  60271. */
  60272. get worldPosition(): NodeMaterialConnectionPoint;
  60273. /**
  60274. * Gets the view input component
  60275. */
  60276. get view(): NodeMaterialConnectionPoint;
  60277. /**
  60278. * Gets the color input component
  60279. */
  60280. get input(): NodeMaterialConnectionPoint;
  60281. /**
  60282. * Gets the fog color input component
  60283. */
  60284. get fogColor(): NodeMaterialConnectionPoint;
  60285. /**
  60286. * Gets the output component
  60287. */
  60288. get output(): NodeMaterialConnectionPoint;
  60289. autoConfigure(material: NodeMaterial): void;
  60290. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60291. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60292. protected _buildBlock(state: NodeMaterialBuildState): this;
  60293. }
  60294. }
  60295. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  60296. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60297. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60298. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60300. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60301. import { Effect } from "babylonjs/Materials/effect";
  60302. import { Mesh } from "babylonjs/Meshes/mesh";
  60303. import { Light } from "babylonjs/Lights/light";
  60304. import { Nullable } from "babylonjs/types";
  60305. import { Scene } from "babylonjs/scene";
  60306. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60307. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60308. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60309. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60310. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60311. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60312. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60313. /**
  60314. * Block used to add light in the fragment shader
  60315. */
  60316. export class LightBlock extends NodeMaterialBlock {
  60317. private _lightId;
  60318. /**
  60319. * Gets or sets the light associated with this block
  60320. */
  60321. light: Nullable<Light>;
  60322. /**
  60323. * Create a new LightBlock
  60324. * @param name defines the block name
  60325. */
  60326. constructor(name: string);
  60327. /**
  60328. * Gets the current class name
  60329. * @returns the class name
  60330. */
  60331. getClassName(): string;
  60332. /**
  60333. * Gets the world position input component
  60334. */
  60335. get worldPosition(): NodeMaterialConnectionPoint;
  60336. /**
  60337. * Gets the world normal input component
  60338. */
  60339. get worldNormal(): NodeMaterialConnectionPoint;
  60340. /**
  60341. * Gets the camera (or eye) position component
  60342. */
  60343. get cameraPosition(): NodeMaterialConnectionPoint;
  60344. /**
  60345. * Gets the glossiness component
  60346. */
  60347. get glossiness(): NodeMaterialConnectionPoint;
  60348. /**
  60349. * Gets the glossinness power component
  60350. */
  60351. get glossPower(): NodeMaterialConnectionPoint;
  60352. /**
  60353. * Gets the diffuse color component
  60354. */
  60355. get diffuseColor(): NodeMaterialConnectionPoint;
  60356. /**
  60357. * Gets the specular color component
  60358. */
  60359. get specularColor(): NodeMaterialConnectionPoint;
  60360. /**
  60361. * Gets the diffuse output component
  60362. */
  60363. get diffuseOutput(): NodeMaterialConnectionPoint;
  60364. /**
  60365. * Gets the specular output component
  60366. */
  60367. get specularOutput(): NodeMaterialConnectionPoint;
  60368. /**
  60369. * Gets the shadow output component
  60370. */
  60371. get shadow(): NodeMaterialConnectionPoint;
  60372. autoConfigure(material: NodeMaterial): void;
  60373. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60374. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60375. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60376. private _injectVertexCode;
  60377. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60378. serialize(): any;
  60379. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60380. }
  60381. }
  60382. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  60383. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  60384. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  60385. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60386. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60387. }
  60388. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  60389. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60390. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60391. }
  60392. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  60393. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60394. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60395. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60396. /**
  60397. * Block used to multiply 2 values
  60398. */
  60399. export class MultiplyBlock extends NodeMaterialBlock {
  60400. /**
  60401. * Creates a new MultiplyBlock
  60402. * @param name defines the block name
  60403. */
  60404. constructor(name: string);
  60405. /**
  60406. * Gets the current class name
  60407. * @returns the class name
  60408. */
  60409. getClassName(): string;
  60410. /**
  60411. * Gets the left operand input component
  60412. */
  60413. get left(): NodeMaterialConnectionPoint;
  60414. /**
  60415. * Gets the right operand input component
  60416. */
  60417. get right(): NodeMaterialConnectionPoint;
  60418. /**
  60419. * Gets the output component
  60420. */
  60421. get output(): NodeMaterialConnectionPoint;
  60422. protected _buildBlock(state: NodeMaterialBuildState): this;
  60423. }
  60424. }
  60425. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  60426. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60427. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60428. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60429. /**
  60430. * Block used to add 2 vectors
  60431. */
  60432. export class AddBlock extends NodeMaterialBlock {
  60433. /**
  60434. * Creates a new AddBlock
  60435. * @param name defines the block name
  60436. */
  60437. constructor(name: string);
  60438. /**
  60439. * Gets the current class name
  60440. * @returns the class name
  60441. */
  60442. getClassName(): string;
  60443. /**
  60444. * Gets the left operand input component
  60445. */
  60446. get left(): NodeMaterialConnectionPoint;
  60447. /**
  60448. * Gets the right operand input component
  60449. */
  60450. get right(): NodeMaterialConnectionPoint;
  60451. /**
  60452. * Gets the output component
  60453. */
  60454. get output(): NodeMaterialConnectionPoint;
  60455. protected _buildBlock(state: NodeMaterialBuildState): this;
  60456. }
  60457. }
  60458. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  60459. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60460. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60461. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60462. /**
  60463. * Block used to scale a vector by a float
  60464. */
  60465. export class ScaleBlock extends NodeMaterialBlock {
  60466. /**
  60467. * Creates a new ScaleBlock
  60468. * @param name defines the block name
  60469. */
  60470. constructor(name: string);
  60471. /**
  60472. * Gets the current class name
  60473. * @returns the class name
  60474. */
  60475. getClassName(): string;
  60476. /**
  60477. * Gets the input component
  60478. */
  60479. get input(): NodeMaterialConnectionPoint;
  60480. /**
  60481. * Gets the factor input component
  60482. */
  60483. get factor(): NodeMaterialConnectionPoint;
  60484. /**
  60485. * Gets the output component
  60486. */
  60487. get output(): NodeMaterialConnectionPoint;
  60488. protected _buildBlock(state: NodeMaterialBuildState): this;
  60489. }
  60490. }
  60491. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  60492. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60493. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60494. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60495. import { Scene } from "babylonjs/scene";
  60496. /**
  60497. * Block used to clamp a float
  60498. */
  60499. export class ClampBlock extends NodeMaterialBlock {
  60500. /** Gets or sets the minimum range */
  60501. minimum: number;
  60502. /** Gets or sets the maximum range */
  60503. maximum: number;
  60504. /**
  60505. * Creates a new ClampBlock
  60506. * @param name defines the block name
  60507. */
  60508. constructor(name: string);
  60509. /**
  60510. * Gets the current class name
  60511. * @returns the class name
  60512. */
  60513. getClassName(): string;
  60514. /**
  60515. * Gets the value input component
  60516. */
  60517. get value(): NodeMaterialConnectionPoint;
  60518. /**
  60519. * Gets the output component
  60520. */
  60521. get output(): NodeMaterialConnectionPoint;
  60522. protected _buildBlock(state: NodeMaterialBuildState): this;
  60523. protected _dumpPropertiesCode(): string;
  60524. serialize(): any;
  60525. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60526. }
  60527. }
  60528. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  60529. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60530. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60531. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60532. /**
  60533. * Block used to apply a cross product between 2 vectors
  60534. */
  60535. export class CrossBlock extends NodeMaterialBlock {
  60536. /**
  60537. * Creates a new CrossBlock
  60538. * @param name defines the block name
  60539. */
  60540. constructor(name: string);
  60541. /**
  60542. * Gets the current class name
  60543. * @returns the class name
  60544. */
  60545. getClassName(): string;
  60546. /**
  60547. * Gets the left operand input component
  60548. */
  60549. get left(): NodeMaterialConnectionPoint;
  60550. /**
  60551. * Gets the right operand input component
  60552. */
  60553. get right(): NodeMaterialConnectionPoint;
  60554. /**
  60555. * Gets the output component
  60556. */
  60557. get output(): NodeMaterialConnectionPoint;
  60558. protected _buildBlock(state: NodeMaterialBuildState): this;
  60559. }
  60560. }
  60561. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  60562. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60563. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60564. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60565. /**
  60566. * Block used to apply a dot product between 2 vectors
  60567. */
  60568. export class DotBlock extends NodeMaterialBlock {
  60569. /**
  60570. * Creates a new DotBlock
  60571. * @param name defines the block name
  60572. */
  60573. constructor(name: string);
  60574. /**
  60575. * Gets the current class name
  60576. * @returns the class name
  60577. */
  60578. getClassName(): string;
  60579. /**
  60580. * Gets the left operand input component
  60581. */
  60582. get left(): NodeMaterialConnectionPoint;
  60583. /**
  60584. * Gets the right operand input component
  60585. */
  60586. get right(): NodeMaterialConnectionPoint;
  60587. /**
  60588. * Gets the output component
  60589. */
  60590. get output(): NodeMaterialConnectionPoint;
  60591. protected _buildBlock(state: NodeMaterialBuildState): this;
  60592. }
  60593. }
  60594. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  60595. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60596. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60597. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60598. import { Vector2 } from "babylonjs/Maths/math.vector";
  60599. import { Scene } from "babylonjs/scene";
  60600. /**
  60601. * Block used to remap a float from a range to a new one
  60602. */
  60603. export class RemapBlock extends NodeMaterialBlock {
  60604. /**
  60605. * Gets or sets the source range
  60606. */
  60607. sourceRange: Vector2;
  60608. /**
  60609. * Gets or sets the target range
  60610. */
  60611. targetRange: Vector2;
  60612. /**
  60613. * Creates a new RemapBlock
  60614. * @param name defines the block name
  60615. */
  60616. constructor(name: string);
  60617. /**
  60618. * Gets the current class name
  60619. * @returns the class name
  60620. */
  60621. getClassName(): string;
  60622. /**
  60623. * Gets the input component
  60624. */
  60625. get input(): NodeMaterialConnectionPoint;
  60626. /**
  60627. * Gets the source min input component
  60628. */
  60629. get sourceMin(): NodeMaterialConnectionPoint;
  60630. /**
  60631. * Gets the source max input component
  60632. */
  60633. get sourceMax(): NodeMaterialConnectionPoint;
  60634. /**
  60635. * Gets the target min input component
  60636. */
  60637. get targetMin(): NodeMaterialConnectionPoint;
  60638. /**
  60639. * Gets the target max input component
  60640. */
  60641. get targetMax(): NodeMaterialConnectionPoint;
  60642. /**
  60643. * Gets the output component
  60644. */
  60645. get output(): NodeMaterialConnectionPoint;
  60646. protected _buildBlock(state: NodeMaterialBuildState): this;
  60647. protected _dumpPropertiesCode(): string;
  60648. serialize(): any;
  60649. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60650. }
  60651. }
  60652. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  60653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60656. /**
  60657. * Block used to normalize a vector
  60658. */
  60659. export class NormalizeBlock extends NodeMaterialBlock {
  60660. /**
  60661. * Creates a new NormalizeBlock
  60662. * @param name defines the block name
  60663. */
  60664. constructor(name: string);
  60665. /**
  60666. * Gets the current class name
  60667. * @returns the class name
  60668. */
  60669. getClassName(): string;
  60670. /**
  60671. * Gets the input component
  60672. */
  60673. get input(): NodeMaterialConnectionPoint;
  60674. /**
  60675. * Gets the output component
  60676. */
  60677. get output(): NodeMaterialConnectionPoint;
  60678. protected _buildBlock(state: NodeMaterialBuildState): this;
  60679. }
  60680. }
  60681. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  60682. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60683. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60684. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60685. import { Scene } from "babylonjs/scene";
  60686. /**
  60687. * Operations supported by the Trigonometry block
  60688. */
  60689. export enum TrigonometryBlockOperations {
  60690. /** Cos */
  60691. Cos = 0,
  60692. /** Sin */
  60693. Sin = 1,
  60694. /** Abs */
  60695. Abs = 2,
  60696. /** Exp */
  60697. Exp = 3,
  60698. /** Exp2 */
  60699. Exp2 = 4,
  60700. /** Round */
  60701. Round = 5,
  60702. /** Floor */
  60703. Floor = 6,
  60704. /** Ceiling */
  60705. Ceiling = 7,
  60706. /** Square root */
  60707. Sqrt = 8,
  60708. /** Log */
  60709. Log = 9,
  60710. /** Tangent */
  60711. Tan = 10,
  60712. /** Arc tangent */
  60713. ArcTan = 11,
  60714. /** Arc cosinus */
  60715. ArcCos = 12,
  60716. /** Arc sinus */
  60717. ArcSin = 13,
  60718. /** Fraction */
  60719. Fract = 14,
  60720. /** Sign */
  60721. Sign = 15,
  60722. /** To radians (from degrees) */
  60723. Radians = 16,
  60724. /** To degrees (from radians) */
  60725. Degrees = 17
  60726. }
  60727. /**
  60728. * Block used to apply trigonometry operation to floats
  60729. */
  60730. export class TrigonometryBlock extends NodeMaterialBlock {
  60731. /**
  60732. * Gets or sets the operation applied by the block
  60733. */
  60734. operation: TrigonometryBlockOperations;
  60735. /**
  60736. * Creates a new TrigonometryBlock
  60737. * @param name defines the block name
  60738. */
  60739. constructor(name: string);
  60740. /**
  60741. * Gets the current class name
  60742. * @returns the class name
  60743. */
  60744. getClassName(): string;
  60745. /**
  60746. * Gets the input component
  60747. */
  60748. get input(): NodeMaterialConnectionPoint;
  60749. /**
  60750. * Gets the output component
  60751. */
  60752. get output(): NodeMaterialConnectionPoint;
  60753. protected _buildBlock(state: NodeMaterialBuildState): this;
  60754. serialize(): any;
  60755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60756. protected _dumpPropertiesCode(): string;
  60757. }
  60758. }
  60759. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  60760. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60761. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60762. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60763. /**
  60764. * Block used to create a Color3/4 out of individual inputs (one for each component)
  60765. */
  60766. export class ColorMergerBlock extends NodeMaterialBlock {
  60767. /**
  60768. * Create a new ColorMergerBlock
  60769. * @param name defines the block name
  60770. */
  60771. constructor(name: string);
  60772. /**
  60773. * Gets the current class name
  60774. * @returns the class name
  60775. */
  60776. getClassName(): string;
  60777. /**
  60778. * Gets the rgb component (input)
  60779. */
  60780. get rgbIn(): NodeMaterialConnectionPoint;
  60781. /**
  60782. * Gets the r component (input)
  60783. */
  60784. get r(): NodeMaterialConnectionPoint;
  60785. /**
  60786. * Gets the g component (input)
  60787. */
  60788. get g(): NodeMaterialConnectionPoint;
  60789. /**
  60790. * Gets the b component (input)
  60791. */
  60792. get b(): NodeMaterialConnectionPoint;
  60793. /**
  60794. * Gets the a component (input)
  60795. */
  60796. get a(): NodeMaterialConnectionPoint;
  60797. /**
  60798. * Gets the rgba component (output)
  60799. */
  60800. get rgba(): NodeMaterialConnectionPoint;
  60801. /**
  60802. * Gets the rgb component (output)
  60803. */
  60804. get rgbOut(): NodeMaterialConnectionPoint;
  60805. /**
  60806. * Gets the rgb component (output)
  60807. * @deprecated Please use rgbOut instead.
  60808. */
  60809. get rgb(): NodeMaterialConnectionPoint;
  60810. protected _buildBlock(state: NodeMaterialBuildState): this;
  60811. }
  60812. }
  60813. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  60814. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60815. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60816. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60817. /**
  60818. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  60819. */
  60820. export class VectorMergerBlock extends NodeMaterialBlock {
  60821. /**
  60822. * Create a new VectorMergerBlock
  60823. * @param name defines the block name
  60824. */
  60825. constructor(name: string);
  60826. /**
  60827. * Gets the current class name
  60828. * @returns the class name
  60829. */
  60830. getClassName(): string;
  60831. /**
  60832. * Gets the xyz component (input)
  60833. */
  60834. get xyzIn(): NodeMaterialConnectionPoint;
  60835. /**
  60836. * Gets the xy component (input)
  60837. */
  60838. get xyIn(): NodeMaterialConnectionPoint;
  60839. /**
  60840. * Gets the x component (input)
  60841. */
  60842. get x(): NodeMaterialConnectionPoint;
  60843. /**
  60844. * Gets the y component (input)
  60845. */
  60846. get y(): NodeMaterialConnectionPoint;
  60847. /**
  60848. * Gets the z component (input)
  60849. */
  60850. get z(): NodeMaterialConnectionPoint;
  60851. /**
  60852. * Gets the w component (input)
  60853. */
  60854. get w(): NodeMaterialConnectionPoint;
  60855. /**
  60856. * Gets the xyzw component (output)
  60857. */
  60858. get xyzw(): NodeMaterialConnectionPoint;
  60859. /**
  60860. * Gets the xyz component (output)
  60861. */
  60862. get xyzOut(): NodeMaterialConnectionPoint;
  60863. /**
  60864. * Gets the xy component (output)
  60865. */
  60866. get xyOut(): NodeMaterialConnectionPoint;
  60867. /**
  60868. * Gets the xy component (output)
  60869. * @deprecated Please use xyOut instead.
  60870. */
  60871. get xy(): NodeMaterialConnectionPoint;
  60872. /**
  60873. * Gets the xyz component (output)
  60874. * @deprecated Please use xyzOut instead.
  60875. */
  60876. get xyz(): NodeMaterialConnectionPoint;
  60877. protected _buildBlock(state: NodeMaterialBuildState): this;
  60878. }
  60879. }
  60880. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  60881. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60882. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60883. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60884. /**
  60885. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  60886. */
  60887. export class ColorSplitterBlock extends NodeMaterialBlock {
  60888. /**
  60889. * Create a new ColorSplitterBlock
  60890. * @param name defines the block name
  60891. */
  60892. constructor(name: string);
  60893. /**
  60894. * Gets the current class name
  60895. * @returns the class name
  60896. */
  60897. getClassName(): string;
  60898. /**
  60899. * Gets the rgba component (input)
  60900. */
  60901. get rgba(): NodeMaterialConnectionPoint;
  60902. /**
  60903. * Gets the rgb component (input)
  60904. */
  60905. get rgbIn(): NodeMaterialConnectionPoint;
  60906. /**
  60907. * Gets the rgb component (output)
  60908. */
  60909. get rgbOut(): NodeMaterialConnectionPoint;
  60910. /**
  60911. * Gets the r component (output)
  60912. */
  60913. get r(): NodeMaterialConnectionPoint;
  60914. /**
  60915. * Gets the g component (output)
  60916. */
  60917. get g(): NodeMaterialConnectionPoint;
  60918. /**
  60919. * Gets the b component (output)
  60920. */
  60921. get b(): NodeMaterialConnectionPoint;
  60922. /**
  60923. * Gets the a component (output)
  60924. */
  60925. get a(): NodeMaterialConnectionPoint;
  60926. protected _inputRename(name: string): string;
  60927. protected _outputRename(name: string): string;
  60928. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60929. }
  60930. }
  60931. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  60932. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60934. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60935. /**
  60936. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  60937. */
  60938. export class VectorSplitterBlock extends NodeMaterialBlock {
  60939. /**
  60940. * Create a new VectorSplitterBlock
  60941. * @param name defines the block name
  60942. */
  60943. constructor(name: string);
  60944. /**
  60945. * Gets the current class name
  60946. * @returns the class name
  60947. */
  60948. getClassName(): string;
  60949. /**
  60950. * Gets the xyzw component (input)
  60951. */
  60952. get xyzw(): NodeMaterialConnectionPoint;
  60953. /**
  60954. * Gets the xyz component (input)
  60955. */
  60956. get xyzIn(): NodeMaterialConnectionPoint;
  60957. /**
  60958. * Gets the xy component (input)
  60959. */
  60960. get xyIn(): NodeMaterialConnectionPoint;
  60961. /**
  60962. * Gets the xyz component (output)
  60963. */
  60964. get xyzOut(): NodeMaterialConnectionPoint;
  60965. /**
  60966. * Gets the xy component (output)
  60967. */
  60968. get xyOut(): NodeMaterialConnectionPoint;
  60969. /**
  60970. * Gets the x component (output)
  60971. */
  60972. get x(): NodeMaterialConnectionPoint;
  60973. /**
  60974. * Gets the y component (output)
  60975. */
  60976. get y(): NodeMaterialConnectionPoint;
  60977. /**
  60978. * Gets the z component (output)
  60979. */
  60980. get z(): NodeMaterialConnectionPoint;
  60981. /**
  60982. * Gets the w component (output)
  60983. */
  60984. get w(): NodeMaterialConnectionPoint;
  60985. protected _inputRename(name: string): string;
  60986. protected _outputRename(name: string): string;
  60987. protected _buildBlock(state: NodeMaterialBuildState): this;
  60988. }
  60989. }
  60990. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  60991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60994. /**
  60995. * Block used to lerp between 2 values
  60996. */
  60997. export class LerpBlock extends NodeMaterialBlock {
  60998. /**
  60999. * Creates a new LerpBlock
  61000. * @param name defines the block name
  61001. */
  61002. constructor(name: string);
  61003. /**
  61004. * Gets the current class name
  61005. * @returns the class name
  61006. */
  61007. getClassName(): string;
  61008. /**
  61009. * Gets the left operand input component
  61010. */
  61011. get left(): NodeMaterialConnectionPoint;
  61012. /**
  61013. * Gets the right operand input component
  61014. */
  61015. get right(): NodeMaterialConnectionPoint;
  61016. /**
  61017. * Gets the gradient operand input component
  61018. */
  61019. get gradient(): NodeMaterialConnectionPoint;
  61020. /**
  61021. * Gets the output component
  61022. */
  61023. get output(): NodeMaterialConnectionPoint;
  61024. protected _buildBlock(state: NodeMaterialBuildState): this;
  61025. }
  61026. }
  61027. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  61028. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61029. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61030. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61031. /**
  61032. * Block used to divide 2 vectors
  61033. */
  61034. export class DivideBlock extends NodeMaterialBlock {
  61035. /**
  61036. * Creates a new DivideBlock
  61037. * @param name defines the block name
  61038. */
  61039. constructor(name: string);
  61040. /**
  61041. * Gets the current class name
  61042. * @returns the class name
  61043. */
  61044. getClassName(): string;
  61045. /**
  61046. * Gets the left operand input component
  61047. */
  61048. get left(): NodeMaterialConnectionPoint;
  61049. /**
  61050. * Gets the right operand input component
  61051. */
  61052. get right(): NodeMaterialConnectionPoint;
  61053. /**
  61054. * Gets the output component
  61055. */
  61056. get output(): NodeMaterialConnectionPoint;
  61057. protected _buildBlock(state: NodeMaterialBuildState): this;
  61058. }
  61059. }
  61060. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  61061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61064. /**
  61065. * Block used to subtract 2 vectors
  61066. */
  61067. export class SubtractBlock extends NodeMaterialBlock {
  61068. /**
  61069. * Creates a new SubtractBlock
  61070. * @param name defines the block name
  61071. */
  61072. constructor(name: string);
  61073. /**
  61074. * Gets the current class name
  61075. * @returns the class name
  61076. */
  61077. getClassName(): string;
  61078. /**
  61079. * Gets the left operand input component
  61080. */
  61081. get left(): NodeMaterialConnectionPoint;
  61082. /**
  61083. * Gets the right operand input component
  61084. */
  61085. get right(): NodeMaterialConnectionPoint;
  61086. /**
  61087. * Gets the output component
  61088. */
  61089. get output(): NodeMaterialConnectionPoint;
  61090. protected _buildBlock(state: NodeMaterialBuildState): this;
  61091. }
  61092. }
  61093. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  61094. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61095. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61096. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61097. /**
  61098. * Block used to step a value
  61099. */
  61100. export class StepBlock extends NodeMaterialBlock {
  61101. /**
  61102. * Creates a new StepBlock
  61103. * @param name defines the block name
  61104. */
  61105. constructor(name: string);
  61106. /**
  61107. * Gets the current class name
  61108. * @returns the class name
  61109. */
  61110. getClassName(): string;
  61111. /**
  61112. * Gets the value operand input component
  61113. */
  61114. get value(): NodeMaterialConnectionPoint;
  61115. /**
  61116. * Gets the edge operand input component
  61117. */
  61118. get edge(): NodeMaterialConnectionPoint;
  61119. /**
  61120. * Gets the output component
  61121. */
  61122. get output(): NodeMaterialConnectionPoint;
  61123. protected _buildBlock(state: NodeMaterialBuildState): this;
  61124. }
  61125. }
  61126. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  61127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61130. /**
  61131. * Block used to get the opposite (1 - x) of a value
  61132. */
  61133. export class OneMinusBlock extends NodeMaterialBlock {
  61134. /**
  61135. * Creates a new OneMinusBlock
  61136. * @param name defines the block name
  61137. */
  61138. constructor(name: string);
  61139. /**
  61140. * Gets the current class name
  61141. * @returns the class name
  61142. */
  61143. getClassName(): string;
  61144. /**
  61145. * Gets the input component
  61146. */
  61147. get input(): NodeMaterialConnectionPoint;
  61148. /**
  61149. * Gets the output component
  61150. */
  61151. get output(): NodeMaterialConnectionPoint;
  61152. protected _buildBlock(state: NodeMaterialBuildState): this;
  61153. }
  61154. }
  61155. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  61156. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61157. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61158. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61159. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61160. /**
  61161. * Block used to get the view direction
  61162. */
  61163. export class ViewDirectionBlock extends NodeMaterialBlock {
  61164. /**
  61165. * Creates a new ViewDirectionBlock
  61166. * @param name defines the block name
  61167. */
  61168. constructor(name: string);
  61169. /**
  61170. * Gets the current class name
  61171. * @returns the class name
  61172. */
  61173. getClassName(): string;
  61174. /**
  61175. * Gets the world position component
  61176. */
  61177. get worldPosition(): NodeMaterialConnectionPoint;
  61178. /**
  61179. * Gets the camera position component
  61180. */
  61181. get cameraPosition(): NodeMaterialConnectionPoint;
  61182. /**
  61183. * Gets the output component
  61184. */
  61185. get output(): NodeMaterialConnectionPoint;
  61186. autoConfigure(material: NodeMaterial): void;
  61187. protected _buildBlock(state: NodeMaterialBuildState): this;
  61188. }
  61189. }
  61190. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  61191. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61192. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61193. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61194. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61195. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  61196. /**
  61197. * Block used to compute fresnel value
  61198. */
  61199. export class FresnelBlock extends NodeMaterialBlock {
  61200. /**
  61201. * Create a new FresnelBlock
  61202. * @param name defines the block name
  61203. */
  61204. constructor(name: string);
  61205. /**
  61206. * Gets the current class name
  61207. * @returns the class name
  61208. */
  61209. getClassName(): string;
  61210. /**
  61211. * Gets the world normal input component
  61212. */
  61213. get worldNormal(): NodeMaterialConnectionPoint;
  61214. /**
  61215. * Gets the view direction input component
  61216. */
  61217. get viewDirection(): NodeMaterialConnectionPoint;
  61218. /**
  61219. * Gets the bias input component
  61220. */
  61221. get bias(): NodeMaterialConnectionPoint;
  61222. /**
  61223. * Gets the camera (or eye) position component
  61224. */
  61225. get power(): NodeMaterialConnectionPoint;
  61226. /**
  61227. * Gets the fresnel output component
  61228. */
  61229. get fresnel(): NodeMaterialConnectionPoint;
  61230. autoConfigure(material: NodeMaterial): void;
  61231. protected _buildBlock(state: NodeMaterialBuildState): this;
  61232. }
  61233. }
  61234. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  61235. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61236. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61237. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61238. /**
  61239. * Block used to get the max of 2 values
  61240. */
  61241. export class MaxBlock extends NodeMaterialBlock {
  61242. /**
  61243. * Creates a new MaxBlock
  61244. * @param name defines the block name
  61245. */
  61246. constructor(name: string);
  61247. /**
  61248. * Gets the current class name
  61249. * @returns the class name
  61250. */
  61251. getClassName(): string;
  61252. /**
  61253. * Gets the left operand input component
  61254. */
  61255. get left(): NodeMaterialConnectionPoint;
  61256. /**
  61257. * Gets the right operand input component
  61258. */
  61259. get right(): NodeMaterialConnectionPoint;
  61260. /**
  61261. * Gets the output component
  61262. */
  61263. get output(): NodeMaterialConnectionPoint;
  61264. protected _buildBlock(state: NodeMaterialBuildState): this;
  61265. }
  61266. }
  61267. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  61268. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61269. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61270. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61271. /**
  61272. * Block used to get the min of 2 values
  61273. */
  61274. export class MinBlock extends NodeMaterialBlock {
  61275. /**
  61276. * Creates a new MinBlock
  61277. * @param name defines the block name
  61278. */
  61279. constructor(name: string);
  61280. /**
  61281. * Gets the current class name
  61282. * @returns the class name
  61283. */
  61284. getClassName(): string;
  61285. /**
  61286. * Gets the left operand input component
  61287. */
  61288. get left(): NodeMaterialConnectionPoint;
  61289. /**
  61290. * Gets the right operand input component
  61291. */
  61292. get right(): NodeMaterialConnectionPoint;
  61293. /**
  61294. * Gets the output component
  61295. */
  61296. get output(): NodeMaterialConnectionPoint;
  61297. protected _buildBlock(state: NodeMaterialBuildState): this;
  61298. }
  61299. }
  61300. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  61301. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61303. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61304. /**
  61305. * Block used to get the distance between 2 values
  61306. */
  61307. export class DistanceBlock extends NodeMaterialBlock {
  61308. /**
  61309. * Creates a new DistanceBlock
  61310. * @param name defines the block name
  61311. */
  61312. constructor(name: string);
  61313. /**
  61314. * Gets the current class name
  61315. * @returns the class name
  61316. */
  61317. getClassName(): string;
  61318. /**
  61319. * Gets the left operand input component
  61320. */
  61321. get left(): NodeMaterialConnectionPoint;
  61322. /**
  61323. * Gets the right operand input component
  61324. */
  61325. get right(): NodeMaterialConnectionPoint;
  61326. /**
  61327. * Gets the output component
  61328. */
  61329. get output(): NodeMaterialConnectionPoint;
  61330. protected _buildBlock(state: NodeMaterialBuildState): this;
  61331. }
  61332. }
  61333. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  61334. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61335. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61336. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61337. /**
  61338. * Block used to get the length of a vector
  61339. */
  61340. export class LengthBlock extends NodeMaterialBlock {
  61341. /**
  61342. * Creates a new LengthBlock
  61343. * @param name defines the block name
  61344. */
  61345. constructor(name: string);
  61346. /**
  61347. * Gets the current class name
  61348. * @returns the class name
  61349. */
  61350. getClassName(): string;
  61351. /**
  61352. * Gets the value input component
  61353. */
  61354. get value(): NodeMaterialConnectionPoint;
  61355. /**
  61356. * Gets the output component
  61357. */
  61358. get output(): NodeMaterialConnectionPoint;
  61359. protected _buildBlock(state: NodeMaterialBuildState): this;
  61360. }
  61361. }
  61362. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  61363. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61364. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61365. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61366. /**
  61367. * Block used to get negative version of a value (i.e. x * -1)
  61368. */
  61369. export class NegateBlock extends NodeMaterialBlock {
  61370. /**
  61371. * Creates a new NegateBlock
  61372. * @param name defines the block name
  61373. */
  61374. constructor(name: string);
  61375. /**
  61376. * Gets the current class name
  61377. * @returns the class name
  61378. */
  61379. getClassName(): string;
  61380. /**
  61381. * Gets the value input component
  61382. */
  61383. get value(): NodeMaterialConnectionPoint;
  61384. /**
  61385. * Gets the output component
  61386. */
  61387. get output(): NodeMaterialConnectionPoint;
  61388. protected _buildBlock(state: NodeMaterialBuildState): this;
  61389. }
  61390. }
  61391. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  61392. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61393. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61394. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61395. /**
  61396. * Block used to get the value of the first parameter raised to the power of the second
  61397. */
  61398. export class PowBlock extends NodeMaterialBlock {
  61399. /**
  61400. * Creates a new PowBlock
  61401. * @param name defines the block name
  61402. */
  61403. constructor(name: string);
  61404. /**
  61405. * Gets the current class name
  61406. * @returns the class name
  61407. */
  61408. getClassName(): string;
  61409. /**
  61410. * Gets the value operand input component
  61411. */
  61412. get value(): NodeMaterialConnectionPoint;
  61413. /**
  61414. * Gets the power operand input component
  61415. */
  61416. get power(): NodeMaterialConnectionPoint;
  61417. /**
  61418. * Gets the output component
  61419. */
  61420. get output(): NodeMaterialConnectionPoint;
  61421. protected _buildBlock(state: NodeMaterialBuildState): this;
  61422. }
  61423. }
  61424. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  61425. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61426. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61427. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61428. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61429. /**
  61430. * Block used to get a random number
  61431. */
  61432. export class RandomNumberBlock extends NodeMaterialBlock {
  61433. /**
  61434. * Creates a new RandomNumberBlock
  61435. * @param name defines the block name
  61436. */
  61437. constructor(name: string);
  61438. /**
  61439. * Gets the current class name
  61440. * @returns the class name
  61441. */
  61442. getClassName(): string;
  61443. /**
  61444. * Gets the seed input component
  61445. */
  61446. get seed(): NodeMaterialConnectionPoint;
  61447. /**
  61448. * Gets the output component
  61449. */
  61450. get output(): NodeMaterialConnectionPoint;
  61451. protected _buildBlock(state: NodeMaterialBuildState): this;
  61452. }
  61453. }
  61454. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  61455. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61456. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61457. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61458. /**
  61459. * Block used to compute arc tangent of 2 values
  61460. */
  61461. export class ArcTan2Block extends NodeMaterialBlock {
  61462. /**
  61463. * Creates a new ArcTan2Block
  61464. * @param name defines the block name
  61465. */
  61466. constructor(name: string);
  61467. /**
  61468. * Gets the current class name
  61469. * @returns the class name
  61470. */
  61471. getClassName(): string;
  61472. /**
  61473. * Gets the x operand input component
  61474. */
  61475. get x(): NodeMaterialConnectionPoint;
  61476. /**
  61477. * Gets the y operand input component
  61478. */
  61479. get y(): NodeMaterialConnectionPoint;
  61480. /**
  61481. * Gets the output component
  61482. */
  61483. get output(): NodeMaterialConnectionPoint;
  61484. protected _buildBlock(state: NodeMaterialBuildState): this;
  61485. }
  61486. }
  61487. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  61488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61491. /**
  61492. * Block used to smooth step a value
  61493. */
  61494. export class SmoothStepBlock extends NodeMaterialBlock {
  61495. /**
  61496. * Creates a new SmoothStepBlock
  61497. * @param name defines the block name
  61498. */
  61499. constructor(name: string);
  61500. /**
  61501. * Gets the current class name
  61502. * @returns the class name
  61503. */
  61504. getClassName(): string;
  61505. /**
  61506. * Gets the value operand input component
  61507. */
  61508. get value(): NodeMaterialConnectionPoint;
  61509. /**
  61510. * Gets the first edge operand input component
  61511. */
  61512. get edge0(): NodeMaterialConnectionPoint;
  61513. /**
  61514. * Gets the second edge operand input component
  61515. */
  61516. get edge1(): NodeMaterialConnectionPoint;
  61517. /**
  61518. * Gets the output component
  61519. */
  61520. get output(): NodeMaterialConnectionPoint;
  61521. protected _buildBlock(state: NodeMaterialBuildState): this;
  61522. }
  61523. }
  61524. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  61525. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61526. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61527. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61528. /**
  61529. * Block used to get the reciprocal (1 / x) of a value
  61530. */
  61531. export class ReciprocalBlock extends NodeMaterialBlock {
  61532. /**
  61533. * Creates a new ReciprocalBlock
  61534. * @param name defines the block name
  61535. */
  61536. constructor(name: string);
  61537. /**
  61538. * Gets the current class name
  61539. * @returns the class name
  61540. */
  61541. getClassName(): string;
  61542. /**
  61543. * Gets the input component
  61544. */
  61545. get input(): NodeMaterialConnectionPoint;
  61546. /**
  61547. * Gets the output component
  61548. */
  61549. get output(): NodeMaterialConnectionPoint;
  61550. protected _buildBlock(state: NodeMaterialBuildState): this;
  61551. }
  61552. }
  61553. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  61554. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61555. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61556. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61557. /**
  61558. * Block used to replace a color by another one
  61559. */
  61560. export class ReplaceColorBlock extends NodeMaterialBlock {
  61561. /**
  61562. * Creates a new ReplaceColorBlock
  61563. * @param name defines the block name
  61564. */
  61565. constructor(name: string);
  61566. /**
  61567. * Gets the current class name
  61568. * @returns the class name
  61569. */
  61570. getClassName(): string;
  61571. /**
  61572. * Gets the value input component
  61573. */
  61574. get value(): NodeMaterialConnectionPoint;
  61575. /**
  61576. * Gets the reference input component
  61577. */
  61578. get reference(): NodeMaterialConnectionPoint;
  61579. /**
  61580. * Gets the distance input component
  61581. */
  61582. get distance(): NodeMaterialConnectionPoint;
  61583. /**
  61584. * Gets the replacement input component
  61585. */
  61586. get replacement(): NodeMaterialConnectionPoint;
  61587. /**
  61588. * Gets the output component
  61589. */
  61590. get output(): NodeMaterialConnectionPoint;
  61591. protected _buildBlock(state: NodeMaterialBuildState): this;
  61592. }
  61593. }
  61594. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  61595. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61596. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61597. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61598. /**
  61599. * Block used to posterize a value
  61600. * @see https://en.wikipedia.org/wiki/Posterization
  61601. */
  61602. export class PosterizeBlock extends NodeMaterialBlock {
  61603. /**
  61604. * Creates a new PosterizeBlock
  61605. * @param name defines the block name
  61606. */
  61607. constructor(name: string);
  61608. /**
  61609. * Gets the current class name
  61610. * @returns the class name
  61611. */
  61612. getClassName(): string;
  61613. /**
  61614. * Gets the value input component
  61615. */
  61616. get value(): NodeMaterialConnectionPoint;
  61617. /**
  61618. * Gets the steps input component
  61619. */
  61620. get steps(): NodeMaterialConnectionPoint;
  61621. /**
  61622. * Gets the output component
  61623. */
  61624. get output(): NodeMaterialConnectionPoint;
  61625. protected _buildBlock(state: NodeMaterialBuildState): this;
  61626. }
  61627. }
  61628. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  61629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61632. import { Scene } from "babylonjs/scene";
  61633. /**
  61634. * Operations supported by the Wave block
  61635. */
  61636. export enum WaveBlockKind {
  61637. /** SawTooth */
  61638. SawTooth = 0,
  61639. /** Square */
  61640. Square = 1,
  61641. /** Triangle */
  61642. Triangle = 2
  61643. }
  61644. /**
  61645. * Block used to apply wave operation to floats
  61646. */
  61647. export class WaveBlock extends NodeMaterialBlock {
  61648. /**
  61649. * Gets or sets the kibnd of wave to be applied by the block
  61650. */
  61651. kind: WaveBlockKind;
  61652. /**
  61653. * Creates a new WaveBlock
  61654. * @param name defines the block name
  61655. */
  61656. constructor(name: string);
  61657. /**
  61658. * Gets the current class name
  61659. * @returns the class name
  61660. */
  61661. getClassName(): string;
  61662. /**
  61663. * Gets the input component
  61664. */
  61665. get input(): NodeMaterialConnectionPoint;
  61666. /**
  61667. * Gets the output component
  61668. */
  61669. get output(): NodeMaterialConnectionPoint;
  61670. protected _buildBlock(state: NodeMaterialBuildState): this;
  61671. serialize(): any;
  61672. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61673. }
  61674. }
  61675. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  61676. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61677. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61678. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61679. import { Color3 } from "babylonjs/Maths/math.color";
  61680. import { Scene } from "babylonjs/scene";
  61681. /**
  61682. * Class used to store a color step for the GradientBlock
  61683. */
  61684. export class GradientBlockColorStep {
  61685. /**
  61686. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61687. */
  61688. step: number;
  61689. /**
  61690. * Gets or sets the color associated with this step
  61691. */
  61692. color: Color3;
  61693. /**
  61694. * Creates a new GradientBlockColorStep
  61695. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  61696. * @param color defines the color associated with this step
  61697. */
  61698. constructor(
  61699. /**
  61700. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  61701. */
  61702. step: number,
  61703. /**
  61704. * Gets or sets the color associated with this step
  61705. */
  61706. color: Color3);
  61707. }
  61708. /**
  61709. * Block used to return a color from a gradient based on an input value between 0 and 1
  61710. */
  61711. export class GradientBlock extends NodeMaterialBlock {
  61712. /**
  61713. * Gets or sets the list of color steps
  61714. */
  61715. colorSteps: GradientBlockColorStep[];
  61716. /**
  61717. * Creates a new GradientBlock
  61718. * @param name defines the block name
  61719. */
  61720. constructor(name: string);
  61721. /**
  61722. * Gets the current class name
  61723. * @returns the class name
  61724. */
  61725. getClassName(): string;
  61726. /**
  61727. * Gets the gradient input component
  61728. */
  61729. get gradient(): NodeMaterialConnectionPoint;
  61730. /**
  61731. * Gets the output component
  61732. */
  61733. get output(): NodeMaterialConnectionPoint;
  61734. private _writeColorConstant;
  61735. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61736. serialize(): any;
  61737. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61738. protected _dumpPropertiesCode(): string;
  61739. }
  61740. }
  61741. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  61742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61745. /**
  61746. * Block used to normalize lerp between 2 values
  61747. */
  61748. export class NLerpBlock extends NodeMaterialBlock {
  61749. /**
  61750. * Creates a new NLerpBlock
  61751. * @param name defines the block name
  61752. */
  61753. constructor(name: string);
  61754. /**
  61755. * Gets the current class name
  61756. * @returns the class name
  61757. */
  61758. getClassName(): string;
  61759. /**
  61760. * Gets the left operand input component
  61761. */
  61762. get left(): NodeMaterialConnectionPoint;
  61763. /**
  61764. * Gets the right operand input component
  61765. */
  61766. get right(): NodeMaterialConnectionPoint;
  61767. /**
  61768. * Gets the gradient operand input component
  61769. */
  61770. get gradient(): NodeMaterialConnectionPoint;
  61771. /**
  61772. * Gets the output component
  61773. */
  61774. get output(): NodeMaterialConnectionPoint;
  61775. protected _buildBlock(state: NodeMaterialBuildState): this;
  61776. }
  61777. }
  61778. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  61779. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61780. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61782. import { Scene } from "babylonjs/scene";
  61783. /**
  61784. * block used to Generate a Worley Noise 3D Noise Pattern
  61785. */
  61786. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  61787. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61788. manhattanDistance: boolean;
  61789. /**
  61790. * Creates a new WorleyNoise3DBlock
  61791. * @param name defines the block name
  61792. */
  61793. constructor(name: string);
  61794. /**
  61795. * Gets the current class name
  61796. * @returns the class name
  61797. */
  61798. getClassName(): string;
  61799. /**
  61800. * Gets the seed input component
  61801. */
  61802. get seed(): NodeMaterialConnectionPoint;
  61803. /**
  61804. * Gets the jitter input component
  61805. */
  61806. get jitter(): NodeMaterialConnectionPoint;
  61807. /**
  61808. * Gets the output component
  61809. */
  61810. get output(): NodeMaterialConnectionPoint;
  61811. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61812. /**
  61813. * Exposes the properties to the UI?
  61814. */
  61815. protected _dumpPropertiesCode(): string;
  61816. /**
  61817. * Exposes the properties to the Seralize?
  61818. */
  61819. serialize(): any;
  61820. /**
  61821. * Exposes the properties to the deseralize?
  61822. */
  61823. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61824. }
  61825. }
  61826. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  61827. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61828. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61829. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61830. /**
  61831. * block used to Generate a Simplex Perlin 3d Noise Pattern
  61832. */
  61833. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  61834. /**
  61835. * Creates a new SimplexPerlin3DBlock
  61836. * @param name defines the block name
  61837. */
  61838. constructor(name: string);
  61839. /**
  61840. * Gets the current class name
  61841. * @returns the class name
  61842. */
  61843. getClassName(): string;
  61844. /**
  61845. * Gets the seed operand input component
  61846. */
  61847. get seed(): NodeMaterialConnectionPoint;
  61848. /**
  61849. * Gets the output component
  61850. */
  61851. get output(): NodeMaterialConnectionPoint;
  61852. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61853. }
  61854. }
  61855. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  61856. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61857. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61858. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61859. /**
  61860. * Block used to blend normals
  61861. */
  61862. export class NormalBlendBlock extends NodeMaterialBlock {
  61863. /**
  61864. * Creates a new NormalBlendBlock
  61865. * @param name defines the block name
  61866. */
  61867. constructor(name: string);
  61868. /**
  61869. * Gets the current class name
  61870. * @returns the class name
  61871. */
  61872. getClassName(): string;
  61873. /**
  61874. * Gets the first input component
  61875. */
  61876. get normalMap0(): NodeMaterialConnectionPoint;
  61877. /**
  61878. * Gets the second input component
  61879. */
  61880. get normalMap1(): NodeMaterialConnectionPoint;
  61881. /**
  61882. * Gets the output component
  61883. */
  61884. get output(): NodeMaterialConnectionPoint;
  61885. protected _buildBlock(state: NodeMaterialBuildState): this;
  61886. }
  61887. }
  61888. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  61889. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61890. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61891. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61892. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  61893. /**
  61894. * Block used to rotate a 2d vector by a given angle
  61895. */
  61896. export class Rotate2dBlock extends NodeMaterialBlock {
  61897. /**
  61898. * Creates a new Rotate2dBlock
  61899. * @param name defines the block name
  61900. */
  61901. constructor(name: string);
  61902. /**
  61903. * Gets the current class name
  61904. * @returns the class name
  61905. */
  61906. getClassName(): string;
  61907. /**
  61908. * Gets the input vector
  61909. */
  61910. get input(): NodeMaterialConnectionPoint;
  61911. /**
  61912. * Gets the input angle
  61913. */
  61914. get angle(): NodeMaterialConnectionPoint;
  61915. /**
  61916. * Gets the output component
  61917. */
  61918. get output(): NodeMaterialConnectionPoint;
  61919. autoConfigure(material: NodeMaterial): void;
  61920. protected _buildBlock(state: NodeMaterialBuildState): this;
  61921. }
  61922. }
  61923. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  61924. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61925. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61926. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61927. /**
  61928. * Block used to get the reflected vector from a direction and a normal
  61929. */
  61930. export class ReflectBlock extends NodeMaterialBlock {
  61931. /**
  61932. * Creates a new ReflectBlock
  61933. * @param name defines the block name
  61934. */
  61935. constructor(name: string);
  61936. /**
  61937. * Gets the current class name
  61938. * @returns the class name
  61939. */
  61940. getClassName(): string;
  61941. /**
  61942. * Gets the incident component
  61943. */
  61944. get incident(): NodeMaterialConnectionPoint;
  61945. /**
  61946. * Gets the normal component
  61947. */
  61948. get normal(): NodeMaterialConnectionPoint;
  61949. /**
  61950. * Gets the output component
  61951. */
  61952. get output(): NodeMaterialConnectionPoint;
  61953. protected _buildBlock(state: NodeMaterialBuildState): this;
  61954. }
  61955. }
  61956. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  61957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61960. /**
  61961. * Block used to get the refracted vector from a direction and a normal
  61962. */
  61963. export class RefractBlock extends NodeMaterialBlock {
  61964. /**
  61965. * Creates a new RefractBlock
  61966. * @param name defines the block name
  61967. */
  61968. constructor(name: string);
  61969. /**
  61970. * Gets the current class name
  61971. * @returns the class name
  61972. */
  61973. getClassName(): string;
  61974. /**
  61975. * Gets the incident component
  61976. */
  61977. get incident(): NodeMaterialConnectionPoint;
  61978. /**
  61979. * Gets the normal component
  61980. */
  61981. get normal(): NodeMaterialConnectionPoint;
  61982. /**
  61983. * Gets the index of refraction component
  61984. */
  61985. get ior(): NodeMaterialConnectionPoint;
  61986. /**
  61987. * Gets the output component
  61988. */
  61989. get output(): NodeMaterialConnectionPoint;
  61990. protected _buildBlock(state: NodeMaterialBuildState): this;
  61991. }
  61992. }
  61993. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  61994. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61995. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61997. /**
  61998. * Block used to desaturate a color
  61999. */
  62000. export class DesaturateBlock extends NodeMaterialBlock {
  62001. /**
  62002. * Creates a new DesaturateBlock
  62003. * @param name defines the block name
  62004. */
  62005. constructor(name: string);
  62006. /**
  62007. * Gets the current class name
  62008. * @returns the class name
  62009. */
  62010. getClassName(): string;
  62011. /**
  62012. * Gets the color operand input component
  62013. */
  62014. get color(): NodeMaterialConnectionPoint;
  62015. /**
  62016. * Gets the level operand input component
  62017. */
  62018. get level(): NodeMaterialConnectionPoint;
  62019. /**
  62020. * Gets the output component
  62021. */
  62022. get output(): NodeMaterialConnectionPoint;
  62023. protected _buildBlock(state: NodeMaterialBuildState): this;
  62024. }
  62025. }
  62026. declare module "babylonjs/Materials/Node/Blocks/index" {
  62027. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  62028. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  62029. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  62030. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  62031. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  62032. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  62033. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  62034. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  62035. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  62036. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  62037. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  62038. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  62039. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  62040. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  62041. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  62042. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  62043. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  62044. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  62045. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  62046. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  62047. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  62048. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  62049. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  62050. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  62051. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  62052. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  62053. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  62054. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  62055. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  62056. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  62057. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  62058. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  62059. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  62060. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  62061. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  62062. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  62063. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  62064. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  62065. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  62066. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  62067. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  62068. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  62069. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  62070. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  62071. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  62072. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  62073. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  62074. }
  62075. declare module "babylonjs/Materials/Node/Optimizers/index" {
  62076. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  62077. }
  62078. declare module "babylonjs/Materials/Node/index" {
  62079. export * from "babylonjs/Materials/Node/Enums/index";
  62080. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62081. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  62082. export * from "babylonjs/Materials/Node/nodeMaterial";
  62083. export * from "babylonjs/Materials/Node/Blocks/index";
  62084. export * from "babylonjs/Materials/Node/Optimizers/index";
  62085. }
  62086. declare module "babylonjs/Materials/effectRenderer" {
  62087. import { Nullable } from "babylonjs/types";
  62088. import { Texture } from "babylonjs/Materials/Textures/texture";
  62089. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62090. import { Viewport } from "babylonjs/Maths/math.viewport";
  62091. import { Observable } from "babylonjs/Misc/observable";
  62092. import { Effect } from "babylonjs/Materials/effect";
  62093. import "babylonjs/Engines/Extensions/engine.renderTarget";
  62094. import "babylonjs/Shaders/postprocess.vertex";
  62095. /**
  62096. * Effect Render Options
  62097. */
  62098. export interface IEffectRendererOptions {
  62099. /**
  62100. * Defines the vertices positions.
  62101. */
  62102. positions?: number[];
  62103. /**
  62104. * Defines the indices.
  62105. */
  62106. indices?: number[];
  62107. }
  62108. /**
  62109. * Helper class to render one or more effects
  62110. */
  62111. export class EffectRenderer {
  62112. private engine;
  62113. private static _DefaultOptions;
  62114. private _vertexBuffers;
  62115. private _indexBuffer;
  62116. private _ringBufferIndex;
  62117. private _ringScreenBuffer;
  62118. private _fullscreenViewport;
  62119. private _getNextFrameBuffer;
  62120. /**
  62121. * Creates an effect renderer
  62122. * @param engine the engine to use for rendering
  62123. * @param options defines the options of the effect renderer
  62124. */
  62125. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  62126. /**
  62127. * Sets the current viewport in normalized coordinates 0-1
  62128. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  62129. */
  62130. setViewport(viewport?: Viewport): void;
  62131. /**
  62132. * Binds the embedded attributes buffer to the effect.
  62133. * @param effect Defines the effect to bind the attributes for
  62134. */
  62135. bindBuffers(effect: Effect): void;
  62136. /**
  62137. * Sets the current effect wrapper to use during draw.
  62138. * The effect needs to be ready before calling this api.
  62139. * This also sets the default full screen position attribute.
  62140. * @param effectWrapper Defines the effect to draw with
  62141. */
  62142. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  62143. /**
  62144. * Draws a full screen quad.
  62145. */
  62146. draw(): void;
  62147. /**
  62148. * renders one or more effects to a specified texture
  62149. * @param effectWrappers list of effects to renderer
  62150. * @param outputTexture texture to draw to, if null it will render to the screen
  62151. */
  62152. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  62153. /**
  62154. * Disposes of the effect renderer
  62155. */
  62156. dispose(): void;
  62157. }
  62158. /**
  62159. * Options to create an EffectWrapper
  62160. */
  62161. interface EffectWrapperCreationOptions {
  62162. /**
  62163. * Engine to use to create the effect
  62164. */
  62165. engine: ThinEngine;
  62166. /**
  62167. * Fragment shader for the effect
  62168. */
  62169. fragmentShader: string;
  62170. /**
  62171. * Vertex shader for the effect
  62172. */
  62173. vertexShader?: string;
  62174. /**
  62175. * Attributes to use in the shader
  62176. */
  62177. attributeNames?: Array<string>;
  62178. /**
  62179. * Uniforms to use in the shader
  62180. */
  62181. uniformNames?: Array<string>;
  62182. /**
  62183. * Texture sampler names to use in the shader
  62184. */
  62185. samplerNames?: Array<string>;
  62186. /**
  62187. * The friendly name of the effect displayed in Spector.
  62188. */
  62189. name?: string;
  62190. }
  62191. /**
  62192. * Wraps an effect to be used for rendering
  62193. */
  62194. export class EffectWrapper {
  62195. /**
  62196. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  62197. */
  62198. onApplyObservable: Observable<{}>;
  62199. /**
  62200. * The underlying effect
  62201. */
  62202. effect: Effect;
  62203. /**
  62204. * Creates an effect to be renderer
  62205. * @param creationOptions options to create the effect
  62206. */
  62207. constructor(creationOptions: EffectWrapperCreationOptions);
  62208. /**
  62209. * Disposes of the effect wrapper
  62210. */
  62211. dispose(): void;
  62212. }
  62213. }
  62214. declare module "babylonjs/Materials/index" {
  62215. export * from "babylonjs/Materials/Background/index";
  62216. export * from "babylonjs/Materials/colorCurves";
  62217. export * from "babylonjs/Materials/iEffectFallbacks";
  62218. export * from "babylonjs/Materials/effectFallbacks";
  62219. export * from "babylonjs/Materials/effect";
  62220. export * from "babylonjs/Materials/fresnelParameters";
  62221. export * from "babylonjs/Materials/imageProcessingConfiguration";
  62222. export * from "babylonjs/Materials/material";
  62223. export * from "babylonjs/Materials/materialDefines";
  62224. export * from "babylonjs/Materials/materialHelper";
  62225. export * from "babylonjs/Materials/multiMaterial";
  62226. export * from "babylonjs/Materials/PBR/index";
  62227. export * from "babylonjs/Materials/pushMaterial";
  62228. export * from "babylonjs/Materials/shaderMaterial";
  62229. export * from "babylonjs/Materials/standardMaterial";
  62230. export * from "babylonjs/Materials/Textures/index";
  62231. export * from "babylonjs/Materials/uniformBuffer";
  62232. export * from "babylonjs/Materials/materialFlags";
  62233. export * from "babylonjs/Materials/Node/index";
  62234. export * from "babylonjs/Materials/effectRenderer";
  62235. }
  62236. declare module "babylonjs/Maths/index" {
  62237. export * from "babylonjs/Maths/math.scalar";
  62238. export * from "babylonjs/Maths/math";
  62239. export * from "babylonjs/Maths/sphericalPolynomial";
  62240. }
  62241. declare module "babylonjs/Misc/workerPool" {
  62242. import { IDisposable } from "babylonjs/scene";
  62243. /**
  62244. * Helper class to push actions to a pool of workers.
  62245. */
  62246. export class WorkerPool implements IDisposable {
  62247. private _workerInfos;
  62248. private _pendingActions;
  62249. /**
  62250. * Constructor
  62251. * @param workers Array of workers to use for actions
  62252. */
  62253. constructor(workers: Array<Worker>);
  62254. /**
  62255. * Terminates all workers and clears any pending actions.
  62256. */
  62257. dispose(): void;
  62258. /**
  62259. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62260. * pended until a worker has completed its action.
  62261. * @param action The action to perform. Call onComplete when the action is complete.
  62262. */
  62263. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62264. private _execute;
  62265. }
  62266. }
  62267. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  62268. import { IDisposable } from "babylonjs/scene";
  62269. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  62270. /**
  62271. * Configuration for Draco compression
  62272. */
  62273. export interface IDracoCompressionConfiguration {
  62274. /**
  62275. * Configuration for the decoder.
  62276. */
  62277. decoder: {
  62278. /**
  62279. * The url to the WebAssembly module.
  62280. */
  62281. wasmUrl?: string;
  62282. /**
  62283. * The url to the WebAssembly binary.
  62284. */
  62285. wasmBinaryUrl?: string;
  62286. /**
  62287. * The url to the fallback JavaScript module.
  62288. */
  62289. fallbackUrl?: string;
  62290. };
  62291. }
  62292. /**
  62293. * Draco compression (https://google.github.io/draco/)
  62294. *
  62295. * This class wraps the Draco module.
  62296. *
  62297. * **Encoder**
  62298. *
  62299. * The encoder is not currently implemented.
  62300. *
  62301. * **Decoder**
  62302. *
  62303. * 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.
  62304. *
  62305. * To update the configuration, use the following code:
  62306. * ```javascript
  62307. * DracoCompression.Configuration = {
  62308. * decoder: {
  62309. * wasmUrl: "<url to the WebAssembly library>",
  62310. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  62311. * fallbackUrl: "<url to the fallback JavaScript library>",
  62312. * }
  62313. * };
  62314. * ```
  62315. *
  62316. * 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.
  62317. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  62318. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  62319. *
  62320. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  62321. * ```javascript
  62322. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  62323. * ```
  62324. *
  62325. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  62326. */
  62327. export class DracoCompression implements IDisposable {
  62328. private _workerPoolPromise?;
  62329. private _decoderModulePromise?;
  62330. /**
  62331. * The configuration. Defaults to the following urls:
  62332. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  62333. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  62334. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  62335. */
  62336. static Configuration: IDracoCompressionConfiguration;
  62337. /**
  62338. * Returns true if the decoder configuration is available.
  62339. */
  62340. static get DecoderAvailable(): boolean;
  62341. /**
  62342. * Default number of workers to create when creating the draco compression object.
  62343. */
  62344. static DefaultNumWorkers: number;
  62345. private static GetDefaultNumWorkers;
  62346. private static _Default;
  62347. /**
  62348. * Default instance for the draco compression object.
  62349. */
  62350. static get Default(): DracoCompression;
  62351. /**
  62352. * Constructor
  62353. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62354. */
  62355. constructor(numWorkers?: number);
  62356. /**
  62357. * Stop all async operations and release resources.
  62358. */
  62359. dispose(): void;
  62360. /**
  62361. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  62362. * @returns a promise that resolves when ready
  62363. */
  62364. whenReadyAsync(): Promise<void>;
  62365. /**
  62366. * Decode Draco compressed mesh data to vertex data.
  62367. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  62368. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  62369. * @returns A promise that resolves with the decoded vertex data
  62370. */
  62371. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  62372. [kind: string]: number;
  62373. }): Promise<VertexData>;
  62374. }
  62375. }
  62376. declare module "babylonjs/Meshes/Compression/index" {
  62377. export * from "babylonjs/Meshes/Compression/dracoCompression";
  62378. }
  62379. declare module "babylonjs/Meshes/csg" {
  62380. import { Nullable } from "babylonjs/types";
  62381. import { Scene } from "babylonjs/scene";
  62382. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62383. import { Mesh } from "babylonjs/Meshes/mesh";
  62384. import { Material } from "babylonjs/Materials/material";
  62385. /**
  62386. * Class for building Constructive Solid Geometry
  62387. */
  62388. export class CSG {
  62389. private polygons;
  62390. /**
  62391. * The world matrix
  62392. */
  62393. matrix: Matrix;
  62394. /**
  62395. * Stores the position
  62396. */
  62397. position: Vector3;
  62398. /**
  62399. * Stores the rotation
  62400. */
  62401. rotation: Vector3;
  62402. /**
  62403. * Stores the rotation quaternion
  62404. */
  62405. rotationQuaternion: Nullable<Quaternion>;
  62406. /**
  62407. * Stores the scaling vector
  62408. */
  62409. scaling: Vector3;
  62410. /**
  62411. * Convert the Mesh to CSG
  62412. * @param mesh The Mesh to convert to CSG
  62413. * @returns A new CSG from the Mesh
  62414. */
  62415. static FromMesh(mesh: Mesh): CSG;
  62416. /**
  62417. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  62418. * @param polygons Polygons used to construct a CSG solid
  62419. */
  62420. private static FromPolygons;
  62421. /**
  62422. * Clones, or makes a deep copy, of the CSG
  62423. * @returns A new CSG
  62424. */
  62425. clone(): CSG;
  62426. /**
  62427. * Unions this CSG with another CSG
  62428. * @param csg The CSG to union against this CSG
  62429. * @returns The unioned CSG
  62430. */
  62431. union(csg: CSG): CSG;
  62432. /**
  62433. * Unions this CSG with another CSG in place
  62434. * @param csg The CSG to union against this CSG
  62435. */
  62436. unionInPlace(csg: CSG): void;
  62437. /**
  62438. * Subtracts this CSG with another CSG
  62439. * @param csg The CSG to subtract against this CSG
  62440. * @returns A new CSG
  62441. */
  62442. subtract(csg: CSG): CSG;
  62443. /**
  62444. * Subtracts this CSG with another CSG in place
  62445. * @param csg The CSG to subtact against this CSG
  62446. */
  62447. subtractInPlace(csg: CSG): void;
  62448. /**
  62449. * Intersect this CSG with another CSG
  62450. * @param csg The CSG to intersect against this CSG
  62451. * @returns A new CSG
  62452. */
  62453. intersect(csg: CSG): CSG;
  62454. /**
  62455. * Intersects this CSG with another CSG in place
  62456. * @param csg The CSG to intersect against this CSG
  62457. */
  62458. intersectInPlace(csg: CSG): void;
  62459. /**
  62460. * Return a new CSG solid with solid and empty space switched. This solid is
  62461. * not modified.
  62462. * @returns A new CSG solid with solid and empty space switched
  62463. */
  62464. inverse(): CSG;
  62465. /**
  62466. * Inverses the CSG in place
  62467. */
  62468. inverseInPlace(): void;
  62469. /**
  62470. * This is used to keep meshes transformations so they can be restored
  62471. * when we build back a Babylon Mesh
  62472. * NB : All CSG operations are performed in world coordinates
  62473. * @param csg The CSG to copy the transform attributes from
  62474. * @returns This CSG
  62475. */
  62476. copyTransformAttributes(csg: CSG): CSG;
  62477. /**
  62478. * Build Raw mesh from CSG
  62479. * Coordinates here are in world space
  62480. * @param name The name of the mesh geometry
  62481. * @param scene The Scene
  62482. * @param keepSubMeshes Specifies if the submeshes should be kept
  62483. * @returns A new Mesh
  62484. */
  62485. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62486. /**
  62487. * Build Mesh from CSG taking material and transforms into account
  62488. * @param name The name of the Mesh
  62489. * @param material The material of the Mesh
  62490. * @param scene The Scene
  62491. * @param keepSubMeshes Specifies if submeshes should be kept
  62492. * @returns The new Mesh
  62493. */
  62494. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  62495. }
  62496. }
  62497. declare module "babylonjs/Meshes/trailMesh" {
  62498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62499. import { Mesh } from "babylonjs/Meshes/mesh";
  62500. import { Scene } from "babylonjs/scene";
  62501. /**
  62502. * Class used to create a trail following a mesh
  62503. */
  62504. export class TrailMesh extends Mesh {
  62505. private _generator;
  62506. private _autoStart;
  62507. private _running;
  62508. private _diameter;
  62509. private _length;
  62510. private _sectionPolygonPointsCount;
  62511. private _sectionVectors;
  62512. private _sectionNormalVectors;
  62513. private _beforeRenderObserver;
  62514. /**
  62515. * @constructor
  62516. * @param name The value used by scene.getMeshByName() to do a lookup.
  62517. * @param generator The mesh to generate a trail.
  62518. * @param scene The scene to add this mesh to.
  62519. * @param diameter Diameter of trailing mesh. Default is 1.
  62520. * @param length Length of trailing mesh. Default is 60.
  62521. * @param autoStart Automatically start trailing mesh. Default true.
  62522. */
  62523. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  62524. /**
  62525. * "TrailMesh"
  62526. * @returns "TrailMesh"
  62527. */
  62528. getClassName(): string;
  62529. private _createMesh;
  62530. /**
  62531. * Start trailing mesh.
  62532. */
  62533. start(): void;
  62534. /**
  62535. * Stop trailing mesh.
  62536. */
  62537. stop(): void;
  62538. /**
  62539. * Update trailing mesh geometry.
  62540. */
  62541. update(): void;
  62542. /**
  62543. * Returns a new TrailMesh object.
  62544. * @param name is a string, the name given to the new mesh
  62545. * @param newGenerator use new generator object for cloned trail mesh
  62546. * @returns a new mesh
  62547. */
  62548. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  62549. /**
  62550. * Serializes this trail mesh
  62551. * @param serializationObject object to write serialization to
  62552. */
  62553. serialize(serializationObject: any): void;
  62554. /**
  62555. * Parses a serialized trail mesh
  62556. * @param parsedMesh the serialized mesh
  62557. * @param scene the scene to create the trail mesh in
  62558. * @returns the created trail mesh
  62559. */
  62560. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  62561. }
  62562. }
  62563. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  62564. import { Nullable } from "babylonjs/types";
  62565. import { Scene } from "babylonjs/scene";
  62566. import { Vector4 } from "babylonjs/Maths/math.vector";
  62567. import { Color4 } from "babylonjs/Maths/math.color";
  62568. import { Mesh } from "babylonjs/Meshes/mesh";
  62569. /**
  62570. * Class containing static functions to help procedurally build meshes
  62571. */
  62572. export class TiledBoxBuilder {
  62573. /**
  62574. * Creates a box mesh
  62575. * 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)
  62576. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62577. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62578. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62579. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62580. * @param name defines the name of the mesh
  62581. * @param options defines the options used to create the mesh
  62582. * @param scene defines the hosting scene
  62583. * @returns the box mesh
  62584. */
  62585. static CreateTiledBox(name: string, options: {
  62586. pattern?: number;
  62587. width?: number;
  62588. height?: number;
  62589. depth?: number;
  62590. tileSize?: number;
  62591. tileWidth?: number;
  62592. tileHeight?: number;
  62593. alignHorizontal?: number;
  62594. alignVertical?: number;
  62595. faceUV?: Vector4[];
  62596. faceColors?: Color4[];
  62597. sideOrientation?: number;
  62598. updatable?: boolean;
  62599. }, scene?: Nullable<Scene>): Mesh;
  62600. }
  62601. }
  62602. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  62603. import { Vector4 } from "babylonjs/Maths/math.vector";
  62604. import { Mesh } from "babylonjs/Meshes/mesh";
  62605. /**
  62606. * Class containing static functions to help procedurally build meshes
  62607. */
  62608. export class TorusKnotBuilder {
  62609. /**
  62610. * Creates a torus knot mesh
  62611. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  62612. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  62613. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  62614. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  62615. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62616. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62618. * @param name defines the name of the mesh
  62619. * @param options defines the options used to create the mesh
  62620. * @param scene defines the hosting scene
  62621. * @returns the torus knot mesh
  62622. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  62623. */
  62624. static CreateTorusKnot(name: string, options: {
  62625. radius?: number;
  62626. tube?: number;
  62627. radialSegments?: number;
  62628. tubularSegments?: number;
  62629. p?: number;
  62630. q?: number;
  62631. updatable?: boolean;
  62632. sideOrientation?: number;
  62633. frontUVs?: Vector4;
  62634. backUVs?: Vector4;
  62635. }, scene: any): Mesh;
  62636. }
  62637. }
  62638. declare module "babylonjs/Meshes/polygonMesh" {
  62639. import { Scene } from "babylonjs/scene";
  62640. import { Vector2 } from "babylonjs/Maths/math.vector";
  62641. import { Mesh } from "babylonjs/Meshes/mesh";
  62642. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  62643. import { Path2 } from "babylonjs/Maths/math.path";
  62644. /**
  62645. * Polygon
  62646. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  62647. */
  62648. export class Polygon {
  62649. /**
  62650. * Creates a rectangle
  62651. * @param xmin bottom X coord
  62652. * @param ymin bottom Y coord
  62653. * @param xmax top X coord
  62654. * @param ymax top Y coord
  62655. * @returns points that make the resulting rectation
  62656. */
  62657. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  62658. /**
  62659. * Creates a circle
  62660. * @param radius radius of circle
  62661. * @param cx scale in x
  62662. * @param cy scale in y
  62663. * @param numberOfSides number of sides that make up the circle
  62664. * @returns points that make the resulting circle
  62665. */
  62666. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  62667. /**
  62668. * Creates a polygon from input string
  62669. * @param input Input polygon data
  62670. * @returns the parsed points
  62671. */
  62672. static Parse(input: string): Vector2[];
  62673. /**
  62674. * Starts building a polygon from x and y coordinates
  62675. * @param x x coordinate
  62676. * @param y y coordinate
  62677. * @returns the started path2
  62678. */
  62679. static StartingAt(x: number, y: number): Path2;
  62680. }
  62681. /**
  62682. * Builds a polygon
  62683. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  62684. */
  62685. export class PolygonMeshBuilder {
  62686. private _points;
  62687. private _outlinepoints;
  62688. private _holes;
  62689. private _name;
  62690. private _scene;
  62691. private _epoints;
  62692. private _eholes;
  62693. private _addToepoint;
  62694. /**
  62695. * Babylon reference to the earcut plugin.
  62696. */
  62697. bjsEarcut: any;
  62698. /**
  62699. * Creates a PolygonMeshBuilder
  62700. * @param name name of the builder
  62701. * @param contours Path of the polygon
  62702. * @param scene scene to add to when creating the mesh
  62703. * @param earcutInjection can be used to inject your own earcut reference
  62704. */
  62705. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  62706. /**
  62707. * Adds a whole within the polygon
  62708. * @param hole Array of points defining the hole
  62709. * @returns this
  62710. */
  62711. addHole(hole: Vector2[]): PolygonMeshBuilder;
  62712. /**
  62713. * Creates the polygon
  62714. * @param updatable If the mesh should be updatable
  62715. * @param depth The depth of the mesh created
  62716. * @returns the created mesh
  62717. */
  62718. build(updatable?: boolean, depth?: number): Mesh;
  62719. /**
  62720. * Creates the polygon
  62721. * @param depth The depth of the mesh created
  62722. * @returns the created VertexData
  62723. */
  62724. buildVertexData(depth?: number): VertexData;
  62725. /**
  62726. * Adds a side to the polygon
  62727. * @param positions points that make the polygon
  62728. * @param normals normals of the polygon
  62729. * @param uvs uvs of the polygon
  62730. * @param indices indices of the polygon
  62731. * @param bounds bounds of the polygon
  62732. * @param points points of the polygon
  62733. * @param depth depth of the polygon
  62734. * @param flip flip of the polygon
  62735. */
  62736. private addSide;
  62737. }
  62738. }
  62739. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  62740. import { Scene } from "babylonjs/scene";
  62741. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62742. import { Color4 } from "babylonjs/Maths/math.color";
  62743. import { Mesh } from "babylonjs/Meshes/mesh";
  62744. import { Nullable } from "babylonjs/types";
  62745. /**
  62746. * Class containing static functions to help procedurally build meshes
  62747. */
  62748. export class PolygonBuilder {
  62749. /**
  62750. * Creates a polygon mesh
  62751. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  62752. * * 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
  62753. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62754. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  62756. * * Remember you can only change the shape positions, not their number when updating a polygon
  62757. * @param name defines the name of the mesh
  62758. * @param options defines the options used to create the mesh
  62759. * @param scene defines the hosting scene
  62760. * @param earcutInjection can be used to inject your own earcut reference
  62761. * @returns the polygon mesh
  62762. */
  62763. static CreatePolygon(name: string, options: {
  62764. shape: Vector3[];
  62765. holes?: Vector3[][];
  62766. depth?: number;
  62767. faceUV?: Vector4[];
  62768. faceColors?: Color4[];
  62769. updatable?: boolean;
  62770. sideOrientation?: number;
  62771. frontUVs?: Vector4;
  62772. backUVs?: Vector4;
  62773. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62774. /**
  62775. * Creates an extruded polygon mesh, with depth in the Y direction.
  62776. * * 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)
  62777. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  62778. * @param name defines the name of the mesh
  62779. * @param options defines the options used to create the mesh
  62780. * @param scene defines the hosting scene
  62781. * @param earcutInjection can be used to inject your own earcut reference
  62782. * @returns the polygon mesh
  62783. */
  62784. static ExtrudePolygon(name: string, options: {
  62785. shape: Vector3[];
  62786. holes?: Vector3[][];
  62787. depth?: number;
  62788. faceUV?: Vector4[];
  62789. faceColors?: Color4[];
  62790. updatable?: boolean;
  62791. sideOrientation?: number;
  62792. frontUVs?: Vector4;
  62793. backUVs?: Vector4;
  62794. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  62795. }
  62796. }
  62797. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  62798. import { Scene } from "babylonjs/scene";
  62799. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62800. import { Mesh } from "babylonjs/Meshes/mesh";
  62801. import { Nullable } from "babylonjs/types";
  62802. /**
  62803. * Class containing static functions to help procedurally build meshes
  62804. */
  62805. export class LatheBuilder {
  62806. /**
  62807. * Creates lathe mesh.
  62808. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  62809. * * 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
  62810. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  62811. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  62812. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  62813. * * 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
  62814. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  62815. * * 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
  62816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62818. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62819. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62820. * @param name defines the name of the mesh
  62821. * @param options defines the options used to create the mesh
  62822. * @param scene defines the hosting scene
  62823. * @returns the lathe mesh
  62824. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  62825. */
  62826. static CreateLathe(name: string, options: {
  62827. shape: Vector3[];
  62828. radius?: number;
  62829. tessellation?: number;
  62830. clip?: number;
  62831. arc?: number;
  62832. closed?: boolean;
  62833. updatable?: boolean;
  62834. sideOrientation?: number;
  62835. frontUVs?: Vector4;
  62836. backUVs?: Vector4;
  62837. cap?: number;
  62838. invertUV?: boolean;
  62839. }, scene?: Nullable<Scene>): Mesh;
  62840. }
  62841. }
  62842. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  62843. import { Nullable } from "babylonjs/types";
  62844. import { Scene } from "babylonjs/scene";
  62845. import { Vector4 } from "babylonjs/Maths/math.vector";
  62846. import { Mesh } from "babylonjs/Meshes/mesh";
  62847. /**
  62848. * Class containing static functions to help procedurally build meshes
  62849. */
  62850. export class TiledPlaneBuilder {
  62851. /**
  62852. * Creates a tiled plane mesh
  62853. * * The parameter `pattern` will, depending on value, do nothing or
  62854. * * * flip (reflect about central vertical) alternate tiles across and up
  62855. * * * flip every tile on alternate rows
  62856. * * * rotate (180 degs) alternate tiles across and up
  62857. * * * rotate every tile on alternate rows
  62858. * * * flip and rotate alternate tiles across and up
  62859. * * * flip and rotate every tile on alternate rows
  62860. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  62861. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  62862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62863. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  62864. * * 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)
  62865. * * 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)
  62866. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  62867. * @param name defines the name of the mesh
  62868. * @param options defines the options used to create the mesh
  62869. * @param scene defines the hosting scene
  62870. * @returns the box mesh
  62871. */
  62872. static CreateTiledPlane(name: string, options: {
  62873. pattern?: number;
  62874. tileSize?: number;
  62875. tileWidth?: number;
  62876. tileHeight?: number;
  62877. size?: number;
  62878. width?: number;
  62879. height?: number;
  62880. alignHorizontal?: number;
  62881. alignVertical?: number;
  62882. sideOrientation?: number;
  62883. frontUVs?: Vector4;
  62884. backUVs?: Vector4;
  62885. updatable?: boolean;
  62886. }, scene?: Nullable<Scene>): Mesh;
  62887. }
  62888. }
  62889. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  62890. import { Nullable } from "babylonjs/types";
  62891. import { Scene } from "babylonjs/scene";
  62892. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62893. import { Mesh } from "babylonjs/Meshes/mesh";
  62894. /**
  62895. * Class containing static functions to help procedurally build meshes
  62896. */
  62897. export class TubeBuilder {
  62898. /**
  62899. * Creates a tube mesh.
  62900. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62901. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  62902. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  62903. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  62904. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  62905. * * 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)
  62906. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  62907. * * 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
  62908. * * 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
  62909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62910. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62911. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62913. * @param name defines the name of the mesh
  62914. * @param options defines the options used to create the mesh
  62915. * @param scene defines the hosting scene
  62916. * @returns the tube mesh
  62917. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62918. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  62919. */
  62920. static CreateTube(name: string, options: {
  62921. path: Vector3[];
  62922. radius?: number;
  62923. tessellation?: number;
  62924. radiusFunction?: {
  62925. (i: number, distance: number): number;
  62926. };
  62927. cap?: number;
  62928. arc?: number;
  62929. updatable?: boolean;
  62930. sideOrientation?: number;
  62931. frontUVs?: Vector4;
  62932. backUVs?: Vector4;
  62933. instance?: Mesh;
  62934. invertUV?: boolean;
  62935. }, scene?: Nullable<Scene>): Mesh;
  62936. }
  62937. }
  62938. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  62939. import { Scene } from "babylonjs/scene";
  62940. import { Vector4 } from "babylonjs/Maths/math.vector";
  62941. import { Mesh } from "babylonjs/Meshes/mesh";
  62942. import { Nullable } from "babylonjs/types";
  62943. /**
  62944. * Class containing static functions to help procedurally build meshes
  62945. */
  62946. export class IcoSphereBuilder {
  62947. /**
  62948. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  62949. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  62950. * * 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`)
  62951. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  62952. * * 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
  62953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62956. * @param name defines the name of the mesh
  62957. * @param options defines the options used to create the mesh
  62958. * @param scene defines the hosting scene
  62959. * @returns the icosahedron mesh
  62960. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  62961. */
  62962. static CreateIcoSphere(name: string, options: {
  62963. radius?: number;
  62964. radiusX?: number;
  62965. radiusY?: number;
  62966. radiusZ?: number;
  62967. flat?: boolean;
  62968. subdivisions?: number;
  62969. sideOrientation?: number;
  62970. frontUVs?: Vector4;
  62971. backUVs?: Vector4;
  62972. updatable?: boolean;
  62973. }, scene?: Nullable<Scene>): Mesh;
  62974. }
  62975. }
  62976. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  62977. import { Vector3 } from "babylonjs/Maths/math.vector";
  62978. import { Mesh } from "babylonjs/Meshes/mesh";
  62979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62980. /**
  62981. * Class containing static functions to help procedurally build meshes
  62982. */
  62983. export class DecalBuilder {
  62984. /**
  62985. * Creates a decal mesh.
  62986. * 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
  62987. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  62988. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  62989. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  62990. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  62991. * @param name defines the name of the mesh
  62992. * @param sourceMesh defines the mesh where the decal must be applied
  62993. * @param options defines the options used to create the mesh
  62994. * @param scene defines the hosting scene
  62995. * @returns the decal mesh
  62996. * @see https://doc.babylonjs.com/how_to/decals
  62997. */
  62998. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  62999. position?: Vector3;
  63000. normal?: Vector3;
  63001. size?: Vector3;
  63002. angle?: number;
  63003. }): Mesh;
  63004. }
  63005. }
  63006. declare module "babylonjs/Meshes/meshBuilder" {
  63007. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  63008. import { Nullable } from "babylonjs/types";
  63009. import { Scene } from "babylonjs/scene";
  63010. import { Mesh } from "babylonjs/Meshes/mesh";
  63011. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  63012. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  63013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63014. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63015. import { Plane } from "babylonjs/Maths/math.plane";
  63016. /**
  63017. * Class containing static functions to help procedurally build meshes
  63018. */
  63019. export class MeshBuilder {
  63020. /**
  63021. * Creates a box mesh
  63022. * * The parameter `size` sets the size (float) of each box side (default 1)
  63023. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63024. * * 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)
  63025. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63029. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63030. * @param name defines the name of the mesh
  63031. * @param options defines the options used to create the mesh
  63032. * @param scene defines the hosting scene
  63033. * @returns the box mesh
  63034. */
  63035. static CreateBox(name: string, options: {
  63036. size?: number;
  63037. width?: number;
  63038. height?: number;
  63039. depth?: number;
  63040. faceUV?: Vector4[];
  63041. faceColors?: Color4[];
  63042. sideOrientation?: number;
  63043. frontUVs?: Vector4;
  63044. backUVs?: Vector4;
  63045. updatable?: boolean;
  63046. }, scene?: Nullable<Scene>): Mesh;
  63047. /**
  63048. * Creates a tiled box mesh
  63049. * * faceTiles sets the pattern, tile size and number of tiles for a face
  63050. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63051. * @param name defines the name of the mesh
  63052. * @param options defines the options used to create the mesh
  63053. * @param scene defines the hosting scene
  63054. * @returns the tiled box mesh
  63055. */
  63056. static CreateTiledBox(name: string, options: {
  63057. pattern?: number;
  63058. size?: number;
  63059. width?: number;
  63060. height?: number;
  63061. depth: number;
  63062. tileSize?: number;
  63063. tileWidth?: number;
  63064. tileHeight?: number;
  63065. faceUV?: Vector4[];
  63066. faceColors?: Color4[];
  63067. alignHorizontal?: number;
  63068. alignVertical?: number;
  63069. sideOrientation?: number;
  63070. updatable?: boolean;
  63071. }, scene?: Nullable<Scene>): Mesh;
  63072. /**
  63073. * Creates a sphere mesh
  63074. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  63075. * * 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`)
  63076. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  63077. * * 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
  63078. * * 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)
  63079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63082. * @param name defines the name of the mesh
  63083. * @param options defines the options used to create the mesh
  63084. * @param scene defines the hosting scene
  63085. * @returns the sphere mesh
  63086. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  63087. */
  63088. static CreateSphere(name: string, options: {
  63089. segments?: number;
  63090. diameter?: number;
  63091. diameterX?: number;
  63092. diameterY?: number;
  63093. diameterZ?: number;
  63094. arc?: number;
  63095. slice?: number;
  63096. sideOrientation?: number;
  63097. frontUVs?: Vector4;
  63098. backUVs?: Vector4;
  63099. updatable?: boolean;
  63100. }, scene?: Nullable<Scene>): Mesh;
  63101. /**
  63102. * Creates a plane polygonal mesh. By default, this is a disc
  63103. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  63104. * * 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
  63105. * * 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
  63106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63108. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63109. * @param name defines the name of the mesh
  63110. * @param options defines the options used to create the mesh
  63111. * @param scene defines the hosting scene
  63112. * @returns the plane polygonal mesh
  63113. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  63114. */
  63115. static CreateDisc(name: string, options: {
  63116. radius?: number;
  63117. tessellation?: number;
  63118. arc?: number;
  63119. updatable?: boolean;
  63120. sideOrientation?: number;
  63121. frontUVs?: Vector4;
  63122. backUVs?: Vector4;
  63123. }, scene?: Nullable<Scene>): Mesh;
  63124. /**
  63125. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63126. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63127. * * 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`)
  63128. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63129. * * 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
  63130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63133. * @param name defines the name of the mesh
  63134. * @param options defines the options used to create the mesh
  63135. * @param scene defines the hosting scene
  63136. * @returns the icosahedron mesh
  63137. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63138. */
  63139. static CreateIcoSphere(name: string, options: {
  63140. radius?: number;
  63141. radiusX?: number;
  63142. radiusY?: number;
  63143. radiusZ?: number;
  63144. flat?: boolean;
  63145. subdivisions?: number;
  63146. sideOrientation?: number;
  63147. frontUVs?: Vector4;
  63148. backUVs?: Vector4;
  63149. updatable?: boolean;
  63150. }, scene?: Nullable<Scene>): Mesh;
  63151. /**
  63152. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63153. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  63154. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  63155. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  63156. * * 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
  63157. * * 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
  63158. * * 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
  63159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63160. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63161. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63162. * * 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
  63163. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  63164. * * 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
  63165. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  63166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63167. * @param name defines the name of the mesh
  63168. * @param options defines the options used to create the mesh
  63169. * @param scene defines the hosting scene
  63170. * @returns the ribbon mesh
  63171. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  63172. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63173. */
  63174. static CreateRibbon(name: string, options: {
  63175. pathArray: Vector3[][];
  63176. closeArray?: boolean;
  63177. closePath?: boolean;
  63178. offset?: number;
  63179. updatable?: boolean;
  63180. sideOrientation?: number;
  63181. frontUVs?: Vector4;
  63182. backUVs?: Vector4;
  63183. instance?: Mesh;
  63184. invertUV?: boolean;
  63185. uvs?: Vector2[];
  63186. colors?: Color4[];
  63187. }, scene?: Nullable<Scene>): Mesh;
  63188. /**
  63189. * Creates a cylinder or a cone mesh
  63190. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  63191. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  63192. * * 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.
  63193. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  63194. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  63195. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  63196. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  63197. * * 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).
  63198. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  63199. * * 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).
  63200. * * 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
  63201. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  63202. * * 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
  63203. * * 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.
  63204. * * If `enclose` is false, a ring surface is one element.
  63205. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  63206. * * 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
  63207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63210. * @param name defines the name of the mesh
  63211. * @param options defines the options used to create the mesh
  63212. * @param scene defines the hosting scene
  63213. * @returns the cylinder mesh
  63214. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  63215. */
  63216. static CreateCylinder(name: string, options: {
  63217. height?: number;
  63218. diameterTop?: number;
  63219. diameterBottom?: number;
  63220. diameter?: number;
  63221. tessellation?: number;
  63222. subdivisions?: number;
  63223. arc?: number;
  63224. faceColors?: Color4[];
  63225. faceUV?: Vector4[];
  63226. updatable?: boolean;
  63227. hasRings?: boolean;
  63228. enclose?: boolean;
  63229. cap?: number;
  63230. sideOrientation?: number;
  63231. frontUVs?: Vector4;
  63232. backUVs?: Vector4;
  63233. }, scene?: Nullable<Scene>): Mesh;
  63234. /**
  63235. * Creates a torus mesh
  63236. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  63237. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  63238. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  63239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63242. * @param name defines the name of the mesh
  63243. * @param options defines the options used to create the mesh
  63244. * @param scene defines the hosting scene
  63245. * @returns the torus mesh
  63246. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  63247. */
  63248. static CreateTorus(name: string, options: {
  63249. diameter?: number;
  63250. thickness?: number;
  63251. tessellation?: number;
  63252. updatable?: boolean;
  63253. sideOrientation?: number;
  63254. frontUVs?: Vector4;
  63255. backUVs?: Vector4;
  63256. }, scene?: Nullable<Scene>): Mesh;
  63257. /**
  63258. * Creates a torus knot mesh
  63259. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63260. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63261. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63262. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63266. * @param name defines the name of the mesh
  63267. * @param options defines the options used to create the mesh
  63268. * @param scene defines the hosting scene
  63269. * @returns the torus knot mesh
  63270. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63271. */
  63272. static CreateTorusKnot(name: string, options: {
  63273. radius?: number;
  63274. tube?: number;
  63275. radialSegments?: number;
  63276. tubularSegments?: number;
  63277. p?: number;
  63278. q?: number;
  63279. updatable?: boolean;
  63280. sideOrientation?: number;
  63281. frontUVs?: Vector4;
  63282. backUVs?: Vector4;
  63283. }, scene?: Nullable<Scene>): Mesh;
  63284. /**
  63285. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  63286. * * 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
  63287. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  63288. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  63289. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  63290. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  63291. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  63292. * * 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
  63293. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  63294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  63296. * @param name defines the name of the new line system
  63297. * @param options defines the options used to create the line system
  63298. * @param scene defines the hosting scene
  63299. * @returns a new line system mesh
  63300. */
  63301. static CreateLineSystem(name: string, options: {
  63302. lines: Vector3[][];
  63303. updatable?: boolean;
  63304. instance?: Nullable<LinesMesh>;
  63305. colors?: Nullable<Color4[][]>;
  63306. useVertexAlpha?: boolean;
  63307. }, scene: Nullable<Scene>): LinesMesh;
  63308. /**
  63309. * Creates a line mesh
  63310. * 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
  63311. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63312. * * The parameter `points` is an array successive Vector3
  63313. * * 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
  63314. * * The optional parameter `colors` is an array of successive Color4, one per line point
  63315. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  63316. * * When updating an instance, remember that only point positions can change, not the number of points
  63317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  63319. * @param name defines the name of the new line system
  63320. * @param options defines the options used to create the line system
  63321. * @param scene defines the hosting scene
  63322. * @returns a new line mesh
  63323. */
  63324. static CreateLines(name: string, options: {
  63325. points: Vector3[];
  63326. updatable?: boolean;
  63327. instance?: Nullable<LinesMesh>;
  63328. colors?: Color4[];
  63329. useVertexAlpha?: boolean;
  63330. }, scene?: Nullable<Scene>): LinesMesh;
  63331. /**
  63332. * Creates a dashed line mesh
  63333. * * 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
  63334. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  63335. * * The parameter `points` is an array successive Vector3
  63336. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  63337. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  63338. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  63339. * * 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
  63340. * * When updating an instance, remember that only point positions can change, not the number of points
  63341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63342. * @param name defines the name of the mesh
  63343. * @param options defines the options used to create the mesh
  63344. * @param scene defines the hosting scene
  63345. * @returns the dashed line mesh
  63346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  63347. */
  63348. static CreateDashedLines(name: string, options: {
  63349. points: Vector3[];
  63350. dashSize?: number;
  63351. gapSize?: number;
  63352. dashNb?: number;
  63353. updatable?: boolean;
  63354. instance?: LinesMesh;
  63355. }, scene?: Nullable<Scene>): LinesMesh;
  63356. /**
  63357. * 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.
  63358. * * 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.
  63359. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63360. * * 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.
  63361. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  63362. * * 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
  63363. * * 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
  63364. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  63365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63366. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63367. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  63368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63369. * @param name defines the name of the mesh
  63370. * @param options defines the options used to create the mesh
  63371. * @param scene defines the hosting scene
  63372. * @returns the extruded shape mesh
  63373. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63375. */
  63376. static ExtrudeShape(name: string, options: {
  63377. shape: Vector3[];
  63378. path: Vector3[];
  63379. scale?: number;
  63380. rotation?: number;
  63381. cap?: number;
  63382. updatable?: boolean;
  63383. sideOrientation?: number;
  63384. frontUVs?: Vector4;
  63385. backUVs?: Vector4;
  63386. instance?: Mesh;
  63387. invertUV?: boolean;
  63388. }, scene?: Nullable<Scene>): Mesh;
  63389. /**
  63390. * Creates an custom extruded shape mesh.
  63391. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  63392. * * 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.
  63393. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  63394. * * 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
  63395. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  63396. * * 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
  63397. * * It must returns a float value that will be the scale value applied to the shape on each path point
  63398. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  63399. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  63400. * * 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
  63401. * * 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
  63402. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  63403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63405. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63407. * @param name defines the name of the mesh
  63408. * @param options defines the options used to create the mesh
  63409. * @param scene defines the hosting scene
  63410. * @returns the custom extruded shape mesh
  63411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  63412. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63413. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  63414. */
  63415. static ExtrudeShapeCustom(name: string, options: {
  63416. shape: Vector3[];
  63417. path: Vector3[];
  63418. scaleFunction?: any;
  63419. rotationFunction?: any;
  63420. ribbonCloseArray?: boolean;
  63421. ribbonClosePath?: boolean;
  63422. cap?: number;
  63423. updatable?: boolean;
  63424. sideOrientation?: number;
  63425. frontUVs?: Vector4;
  63426. backUVs?: Vector4;
  63427. instance?: Mesh;
  63428. invertUV?: boolean;
  63429. }, scene?: Nullable<Scene>): Mesh;
  63430. /**
  63431. * Creates lathe mesh.
  63432. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63433. * * 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
  63434. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63435. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63436. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63437. * * 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
  63438. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63439. * * 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
  63440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63442. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63444. * @param name defines the name of the mesh
  63445. * @param options defines the options used to create the mesh
  63446. * @param scene defines the hosting scene
  63447. * @returns the lathe mesh
  63448. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63449. */
  63450. static CreateLathe(name: string, options: {
  63451. shape: Vector3[];
  63452. radius?: number;
  63453. tessellation?: number;
  63454. clip?: number;
  63455. arc?: number;
  63456. closed?: boolean;
  63457. updatable?: boolean;
  63458. sideOrientation?: number;
  63459. frontUVs?: Vector4;
  63460. backUVs?: Vector4;
  63461. cap?: number;
  63462. invertUV?: boolean;
  63463. }, scene?: Nullable<Scene>): Mesh;
  63464. /**
  63465. * Creates a tiled plane mesh
  63466. * * You can set a limited pattern arrangement with the tiles
  63467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63470. * @param name defines the name of the mesh
  63471. * @param options defines the options used to create the mesh
  63472. * @param scene defines the hosting scene
  63473. * @returns the plane mesh
  63474. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63475. */
  63476. static CreateTiledPlane(name: string, options: {
  63477. pattern?: number;
  63478. tileSize?: number;
  63479. tileWidth?: number;
  63480. tileHeight?: number;
  63481. size?: number;
  63482. width?: number;
  63483. height?: number;
  63484. alignHorizontal?: number;
  63485. alignVertical?: number;
  63486. sideOrientation?: number;
  63487. frontUVs?: Vector4;
  63488. backUVs?: Vector4;
  63489. updatable?: boolean;
  63490. }, scene?: Nullable<Scene>): Mesh;
  63491. /**
  63492. * Creates a plane mesh
  63493. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  63494. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  63495. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  63496. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63497. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63499. * @param name defines the name of the mesh
  63500. * @param options defines the options used to create the mesh
  63501. * @param scene defines the hosting scene
  63502. * @returns the plane mesh
  63503. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  63504. */
  63505. static CreatePlane(name: string, options: {
  63506. size?: number;
  63507. width?: number;
  63508. height?: number;
  63509. sideOrientation?: number;
  63510. frontUVs?: Vector4;
  63511. backUVs?: Vector4;
  63512. updatable?: boolean;
  63513. sourcePlane?: Plane;
  63514. }, scene?: Nullable<Scene>): Mesh;
  63515. /**
  63516. * Creates a ground mesh
  63517. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  63518. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  63519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63520. * @param name defines the name of the mesh
  63521. * @param options defines the options used to create the mesh
  63522. * @param scene defines the hosting scene
  63523. * @returns the ground mesh
  63524. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  63525. */
  63526. static CreateGround(name: string, options: {
  63527. width?: number;
  63528. height?: number;
  63529. subdivisions?: number;
  63530. subdivisionsX?: number;
  63531. subdivisionsY?: number;
  63532. updatable?: boolean;
  63533. }, scene?: Nullable<Scene>): Mesh;
  63534. /**
  63535. * Creates a tiled ground mesh
  63536. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  63537. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  63538. * * 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
  63539. * * 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
  63540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63541. * @param name defines the name of the mesh
  63542. * @param options defines the options used to create the mesh
  63543. * @param scene defines the hosting scene
  63544. * @returns the tiled ground mesh
  63545. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  63546. */
  63547. static CreateTiledGround(name: string, options: {
  63548. xmin: number;
  63549. zmin: number;
  63550. xmax: number;
  63551. zmax: number;
  63552. subdivisions?: {
  63553. w: number;
  63554. h: number;
  63555. };
  63556. precision?: {
  63557. w: number;
  63558. h: number;
  63559. };
  63560. updatable?: boolean;
  63561. }, scene?: Nullable<Scene>): Mesh;
  63562. /**
  63563. * Creates a ground mesh from a height map
  63564. * * The parameter `url` sets the URL of the height map image resource.
  63565. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  63566. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  63567. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  63568. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  63569. * * 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.
  63570. * * 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).
  63571. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  63572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63573. * @param name defines the name of the mesh
  63574. * @param url defines the url to the height map
  63575. * @param options defines the options used to create the mesh
  63576. * @param scene defines the hosting scene
  63577. * @returns the ground mesh
  63578. * @see https://doc.babylonjs.com/babylon101/height_map
  63579. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  63580. */
  63581. static CreateGroundFromHeightMap(name: string, url: string, options: {
  63582. width?: number;
  63583. height?: number;
  63584. subdivisions?: number;
  63585. minHeight?: number;
  63586. maxHeight?: number;
  63587. colorFilter?: Color3;
  63588. alphaFilter?: number;
  63589. updatable?: boolean;
  63590. onReady?: (mesh: GroundMesh) => void;
  63591. }, scene?: Nullable<Scene>): GroundMesh;
  63592. /**
  63593. * Creates a polygon mesh
  63594. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63595. * * 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
  63596. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63598. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63599. * * Remember you can only change the shape positions, not their number when updating a polygon
  63600. * @param name defines the name of the mesh
  63601. * @param options defines the options used to create the mesh
  63602. * @param scene defines the hosting scene
  63603. * @param earcutInjection can be used to inject your own earcut reference
  63604. * @returns the polygon mesh
  63605. */
  63606. static CreatePolygon(name: string, options: {
  63607. shape: Vector3[];
  63608. holes?: Vector3[][];
  63609. depth?: number;
  63610. faceUV?: Vector4[];
  63611. faceColors?: Color4[];
  63612. updatable?: boolean;
  63613. sideOrientation?: number;
  63614. frontUVs?: Vector4;
  63615. backUVs?: Vector4;
  63616. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63617. /**
  63618. * Creates an extruded polygon mesh, with depth in the Y direction.
  63619. * * 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)
  63620. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63621. * @param name defines the name of the mesh
  63622. * @param options defines the options used to create the mesh
  63623. * @param scene defines the hosting scene
  63624. * @param earcutInjection can be used to inject your own earcut reference
  63625. * @returns the polygon mesh
  63626. */
  63627. static ExtrudePolygon(name: string, options: {
  63628. shape: Vector3[];
  63629. holes?: Vector3[][];
  63630. depth?: number;
  63631. faceUV?: Vector4[];
  63632. faceColors?: Color4[];
  63633. updatable?: boolean;
  63634. sideOrientation?: number;
  63635. frontUVs?: Vector4;
  63636. backUVs?: Vector4;
  63637. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63638. /**
  63639. * Creates a tube mesh.
  63640. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63641. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63642. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63643. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63644. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63645. * * 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)
  63646. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63647. * * 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
  63648. * * 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
  63649. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63650. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63651. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63653. * @param name defines the name of the mesh
  63654. * @param options defines the options used to create the mesh
  63655. * @param scene defines the hosting scene
  63656. * @returns the tube mesh
  63657. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63658. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63659. */
  63660. static CreateTube(name: string, options: {
  63661. path: Vector3[];
  63662. radius?: number;
  63663. tessellation?: number;
  63664. radiusFunction?: {
  63665. (i: number, distance: number): number;
  63666. };
  63667. cap?: number;
  63668. arc?: number;
  63669. updatable?: boolean;
  63670. sideOrientation?: number;
  63671. frontUVs?: Vector4;
  63672. backUVs?: Vector4;
  63673. instance?: Mesh;
  63674. invertUV?: boolean;
  63675. }, scene?: Nullable<Scene>): Mesh;
  63676. /**
  63677. * Creates a polyhedron mesh
  63678. * * 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
  63679. * * The parameter `size` (positive float, default 1) sets the polygon size
  63680. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  63681. * * 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`
  63682. * * 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
  63683. * * 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)`)
  63684. * * 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
  63685. * * 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
  63686. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63687. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63688. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63689. * @param name defines the name of the mesh
  63690. * @param options defines the options used to create the mesh
  63691. * @param scene defines the hosting scene
  63692. * @returns the polyhedron mesh
  63693. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  63694. */
  63695. static CreatePolyhedron(name: string, options: {
  63696. type?: number;
  63697. size?: number;
  63698. sizeX?: number;
  63699. sizeY?: number;
  63700. sizeZ?: number;
  63701. custom?: any;
  63702. faceUV?: Vector4[];
  63703. faceColors?: Color4[];
  63704. flat?: boolean;
  63705. updatable?: boolean;
  63706. sideOrientation?: number;
  63707. frontUVs?: Vector4;
  63708. backUVs?: Vector4;
  63709. }, scene?: Nullable<Scene>): Mesh;
  63710. /**
  63711. * Creates a decal mesh.
  63712. * 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
  63713. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63714. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63715. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63716. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63717. * @param name defines the name of the mesh
  63718. * @param sourceMesh defines the mesh where the decal must be applied
  63719. * @param options defines the options used to create the mesh
  63720. * @param scene defines the hosting scene
  63721. * @returns the decal mesh
  63722. * @see https://doc.babylonjs.com/how_to/decals
  63723. */
  63724. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63725. position?: Vector3;
  63726. normal?: Vector3;
  63727. size?: Vector3;
  63728. angle?: number;
  63729. }): Mesh;
  63730. }
  63731. }
  63732. declare module "babylonjs/Meshes/meshSimplification" {
  63733. import { Mesh } from "babylonjs/Meshes/mesh";
  63734. /**
  63735. * A simplifier interface for future simplification implementations
  63736. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63737. */
  63738. export interface ISimplifier {
  63739. /**
  63740. * Simplification of a given mesh according to the given settings.
  63741. * Since this requires computation, it is assumed that the function runs async.
  63742. * @param settings The settings of the simplification, including quality and distance
  63743. * @param successCallback A callback that will be called after the mesh was simplified.
  63744. * @param errorCallback in case of an error, this callback will be called. optional.
  63745. */
  63746. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  63747. }
  63748. /**
  63749. * Expected simplification settings.
  63750. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  63751. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63752. */
  63753. export interface ISimplificationSettings {
  63754. /**
  63755. * Gets or sets the expected quality
  63756. */
  63757. quality: number;
  63758. /**
  63759. * Gets or sets the distance when this optimized version should be used
  63760. */
  63761. distance: number;
  63762. /**
  63763. * Gets an already optimized mesh
  63764. */
  63765. optimizeMesh?: boolean;
  63766. }
  63767. /**
  63768. * Class used to specify simplification options
  63769. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63770. */
  63771. export class SimplificationSettings implements ISimplificationSettings {
  63772. /** expected quality */
  63773. quality: number;
  63774. /** distance when this optimized version should be used */
  63775. distance: number;
  63776. /** already optimized mesh */
  63777. optimizeMesh?: boolean | undefined;
  63778. /**
  63779. * Creates a SimplificationSettings
  63780. * @param quality expected quality
  63781. * @param distance distance when this optimized version should be used
  63782. * @param optimizeMesh already optimized mesh
  63783. */
  63784. constructor(
  63785. /** expected quality */
  63786. quality: number,
  63787. /** distance when this optimized version should be used */
  63788. distance: number,
  63789. /** already optimized mesh */
  63790. optimizeMesh?: boolean | undefined);
  63791. }
  63792. /**
  63793. * Interface used to define a simplification task
  63794. */
  63795. export interface ISimplificationTask {
  63796. /**
  63797. * Array of settings
  63798. */
  63799. settings: Array<ISimplificationSettings>;
  63800. /**
  63801. * Simplification type
  63802. */
  63803. simplificationType: SimplificationType;
  63804. /**
  63805. * Mesh to simplify
  63806. */
  63807. mesh: Mesh;
  63808. /**
  63809. * Callback called on success
  63810. */
  63811. successCallback?: () => void;
  63812. /**
  63813. * Defines if parallel processing can be used
  63814. */
  63815. parallelProcessing: boolean;
  63816. }
  63817. /**
  63818. * Queue used to order the simplification tasks
  63819. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63820. */
  63821. export class SimplificationQueue {
  63822. private _simplificationArray;
  63823. /**
  63824. * Gets a boolean indicating that the process is still running
  63825. */
  63826. running: boolean;
  63827. /**
  63828. * Creates a new queue
  63829. */
  63830. constructor();
  63831. /**
  63832. * Adds a new simplification task
  63833. * @param task defines a task to add
  63834. */
  63835. addTask(task: ISimplificationTask): void;
  63836. /**
  63837. * Execute next task
  63838. */
  63839. executeNext(): void;
  63840. /**
  63841. * Execute a simplification task
  63842. * @param task defines the task to run
  63843. */
  63844. runSimplification(task: ISimplificationTask): void;
  63845. private getSimplifier;
  63846. }
  63847. /**
  63848. * The implemented types of simplification
  63849. * At the moment only Quadratic Error Decimation is implemented
  63850. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63851. */
  63852. export enum SimplificationType {
  63853. /** Quadratic error decimation */
  63854. QUADRATIC = 0
  63855. }
  63856. }
  63857. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  63858. import { Scene } from "babylonjs/scene";
  63859. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  63860. import { ISceneComponent } from "babylonjs/sceneComponent";
  63861. module "babylonjs/scene" {
  63862. interface Scene {
  63863. /** @hidden (Backing field) */
  63864. _simplificationQueue: SimplificationQueue;
  63865. /**
  63866. * Gets or sets the simplification queue attached to the scene
  63867. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  63868. */
  63869. simplificationQueue: SimplificationQueue;
  63870. }
  63871. }
  63872. module "babylonjs/Meshes/mesh" {
  63873. interface Mesh {
  63874. /**
  63875. * Simplify the mesh according to the given array of settings.
  63876. * Function will return immediately and will simplify async
  63877. * @param settings a collection of simplification settings
  63878. * @param parallelProcessing should all levels calculate parallel or one after the other
  63879. * @param simplificationType the type of simplification to run
  63880. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  63881. * @returns the current mesh
  63882. */
  63883. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  63884. }
  63885. }
  63886. /**
  63887. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  63888. * created in a scene
  63889. */
  63890. export class SimplicationQueueSceneComponent implements ISceneComponent {
  63891. /**
  63892. * The component name helpfull to identify the component in the list of scene components.
  63893. */
  63894. readonly name: string;
  63895. /**
  63896. * The scene the component belongs to.
  63897. */
  63898. scene: Scene;
  63899. /**
  63900. * Creates a new instance of the component for the given scene
  63901. * @param scene Defines the scene to register the component in
  63902. */
  63903. constructor(scene: Scene);
  63904. /**
  63905. * Registers the component in a given scene
  63906. */
  63907. register(): void;
  63908. /**
  63909. * Rebuilds the elements related to this component in case of
  63910. * context lost for instance.
  63911. */
  63912. rebuild(): void;
  63913. /**
  63914. * Disposes the component and the associated ressources
  63915. */
  63916. dispose(): void;
  63917. private _beforeCameraUpdate;
  63918. }
  63919. }
  63920. declare module "babylonjs/Meshes/Builders/index" {
  63921. export * from "babylonjs/Meshes/Builders/boxBuilder";
  63922. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  63923. export * from "babylonjs/Meshes/Builders/discBuilder";
  63924. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  63925. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  63926. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  63927. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  63928. export * from "babylonjs/Meshes/Builders/torusBuilder";
  63929. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  63930. export * from "babylonjs/Meshes/Builders/linesBuilder";
  63931. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  63932. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  63933. export * from "babylonjs/Meshes/Builders/latheBuilder";
  63934. export * from "babylonjs/Meshes/Builders/planeBuilder";
  63935. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  63936. export * from "babylonjs/Meshes/Builders/groundBuilder";
  63937. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  63938. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  63939. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  63940. export * from "babylonjs/Meshes/Builders/decalBuilder";
  63941. }
  63942. declare module "babylonjs/Meshes/index" {
  63943. export * from "babylonjs/Meshes/abstractMesh";
  63944. export * from "babylonjs/Meshes/buffer";
  63945. export * from "babylonjs/Meshes/Compression/index";
  63946. export * from "babylonjs/Meshes/csg";
  63947. export * from "babylonjs/Meshes/geometry";
  63948. export * from "babylonjs/Meshes/groundMesh";
  63949. export * from "babylonjs/Meshes/trailMesh";
  63950. export * from "babylonjs/Meshes/instancedMesh";
  63951. export * from "babylonjs/Meshes/linesMesh";
  63952. export * from "babylonjs/Meshes/mesh";
  63953. export * from "babylonjs/Meshes/mesh.vertexData";
  63954. export * from "babylonjs/Meshes/meshBuilder";
  63955. export * from "babylonjs/Meshes/meshSimplification";
  63956. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  63957. export * from "babylonjs/Meshes/polygonMesh";
  63958. export * from "babylonjs/Meshes/subMesh";
  63959. export * from "babylonjs/Meshes/meshLODLevel";
  63960. export * from "babylonjs/Meshes/transformNode";
  63961. export * from "babylonjs/Meshes/Builders/index";
  63962. export * from "babylonjs/Meshes/dataBuffer";
  63963. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  63964. }
  63965. declare module "babylonjs/Morph/index" {
  63966. export * from "babylonjs/Morph/morphTarget";
  63967. export * from "babylonjs/Morph/morphTargetManager";
  63968. }
  63969. declare module "babylonjs/Navigation/INavigationEngine" {
  63970. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63971. import { Vector3 } from "babylonjs/Maths/math";
  63972. import { Mesh } from "babylonjs/Meshes/mesh";
  63973. import { Scene } from "babylonjs/scene";
  63974. /**
  63975. * Navigation plugin interface to add navigation constrained by a navigation mesh
  63976. */
  63977. export interface INavigationEnginePlugin {
  63978. /**
  63979. * plugin name
  63980. */
  63981. name: string;
  63982. /**
  63983. * Creates a navigation mesh
  63984. * @param meshes array of all the geometry used to compute the navigatio mesh
  63985. * @param parameters bunch of parameters used to filter geometry
  63986. */
  63987. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  63988. /**
  63989. * Create a navigation mesh debug mesh
  63990. * @param scene is where the mesh will be added
  63991. * @returns debug display mesh
  63992. */
  63993. createDebugNavMesh(scene: Scene): Mesh;
  63994. /**
  63995. * Get a navigation mesh constrained position, closest to the parameter position
  63996. * @param position world position
  63997. * @returns the closest point to position constrained by the navigation mesh
  63998. */
  63999. getClosestPoint(position: Vector3): Vector3;
  64000. /**
  64001. * Get a navigation mesh constrained position, within a particular radius
  64002. * @param position world position
  64003. * @param maxRadius the maximum distance to the constrained world position
  64004. * @returns the closest point to position constrained by the navigation mesh
  64005. */
  64006. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64007. /**
  64008. * Compute the final position from a segment made of destination-position
  64009. * @param position world position
  64010. * @param destination world position
  64011. * @returns the resulting point along the navmesh
  64012. */
  64013. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64014. /**
  64015. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64016. * @param start world position
  64017. * @param end world position
  64018. * @returns array containing world position composing the path
  64019. */
  64020. computePath(start: Vector3, end: Vector3): Vector3[];
  64021. /**
  64022. * If this plugin is supported
  64023. * @returns true if plugin is supported
  64024. */
  64025. isSupported(): boolean;
  64026. /**
  64027. * Create a new Crowd so you can add agents
  64028. * @param maxAgents the maximum agent count in the crowd
  64029. * @param maxAgentRadius the maximum radius an agent can have
  64030. * @param scene to attach the crowd to
  64031. * @returns the crowd you can add agents to
  64032. */
  64033. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64034. /**
  64035. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64036. * The queries will try to find a solution within those bounds
  64037. * default is (1,1,1)
  64038. * @param extent x,y,z value that define the extent around the queries point of reference
  64039. */
  64040. setDefaultQueryExtent(extent: Vector3): void;
  64041. /**
  64042. * Get the Bounding box extent specified by setDefaultQueryExtent
  64043. * @returns the box extent values
  64044. */
  64045. getDefaultQueryExtent(): Vector3;
  64046. /**
  64047. * Release all resources
  64048. */
  64049. dispose(): void;
  64050. }
  64051. /**
  64052. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  64053. */
  64054. export interface ICrowd {
  64055. /**
  64056. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64057. * You can attach anything to that node. The node position is updated in the scene update tick.
  64058. * @param pos world position that will be constrained by the navigation mesh
  64059. * @param parameters agent parameters
  64060. * @param transform hooked to the agent that will be update by the scene
  64061. * @returns agent index
  64062. */
  64063. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64064. /**
  64065. * Returns the agent position in world space
  64066. * @param index agent index returned by addAgent
  64067. * @returns world space position
  64068. */
  64069. getAgentPosition(index: number): Vector3;
  64070. /**
  64071. * Gets the agent velocity in world space
  64072. * @param index agent index returned by addAgent
  64073. * @returns world space velocity
  64074. */
  64075. getAgentVelocity(index: number): Vector3;
  64076. /**
  64077. * remove a particular agent previously created
  64078. * @param index agent index returned by addAgent
  64079. */
  64080. removeAgent(index: number): void;
  64081. /**
  64082. * get the list of all agents attached to this crowd
  64083. * @returns list of agent indices
  64084. */
  64085. getAgents(): number[];
  64086. /**
  64087. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64088. * @param deltaTime in seconds
  64089. */
  64090. update(deltaTime: number): void;
  64091. /**
  64092. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64093. * @param index agent index returned by addAgent
  64094. * @param destination targeted world position
  64095. */
  64096. agentGoto(index: number, destination: Vector3): void;
  64097. /**
  64098. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64099. * The queries will try to find a solution within those bounds
  64100. * default is (1,1,1)
  64101. * @param extent x,y,z value that define the extent around the queries point of reference
  64102. */
  64103. setDefaultQueryExtent(extent: Vector3): void;
  64104. /**
  64105. * Get the Bounding box extent specified by setDefaultQueryExtent
  64106. * @returns the box extent values
  64107. */
  64108. getDefaultQueryExtent(): Vector3;
  64109. /**
  64110. * Release all resources
  64111. */
  64112. dispose(): void;
  64113. }
  64114. /**
  64115. * Configures an agent
  64116. */
  64117. export interface IAgentParameters {
  64118. /**
  64119. * Agent radius. [Limit: >= 0]
  64120. */
  64121. radius: number;
  64122. /**
  64123. * Agent height. [Limit: > 0]
  64124. */
  64125. height: number;
  64126. /**
  64127. * Maximum allowed acceleration. [Limit: >= 0]
  64128. */
  64129. maxAcceleration: number;
  64130. /**
  64131. * Maximum allowed speed. [Limit: >= 0]
  64132. */
  64133. maxSpeed: number;
  64134. /**
  64135. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  64136. */
  64137. collisionQueryRange: number;
  64138. /**
  64139. * The path visibility optimization range. [Limit: > 0]
  64140. */
  64141. pathOptimizationRange: number;
  64142. /**
  64143. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  64144. */
  64145. separationWeight: number;
  64146. }
  64147. /**
  64148. * Configures the navigation mesh creation
  64149. */
  64150. export interface INavMeshParameters {
  64151. /**
  64152. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  64153. */
  64154. cs: number;
  64155. /**
  64156. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  64157. */
  64158. ch: number;
  64159. /**
  64160. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  64161. */
  64162. walkableSlopeAngle: number;
  64163. /**
  64164. * Minimum floor to 'ceiling' height that will still allow the floor area to
  64165. * be considered walkable. [Limit: >= 3] [Units: vx]
  64166. */
  64167. walkableHeight: number;
  64168. /**
  64169. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  64170. */
  64171. walkableClimb: number;
  64172. /**
  64173. * The distance to erode/shrink the walkable area of the heightfield away from
  64174. * obstructions. [Limit: >=0] [Units: vx]
  64175. */
  64176. walkableRadius: number;
  64177. /**
  64178. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  64179. */
  64180. maxEdgeLen: number;
  64181. /**
  64182. * The maximum distance a simplfied contour's border edges should deviate
  64183. * the original raw contour. [Limit: >=0] [Units: vx]
  64184. */
  64185. maxSimplificationError: number;
  64186. /**
  64187. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  64188. */
  64189. minRegionArea: number;
  64190. /**
  64191. * Any regions with a span count smaller than this value will, if possible,
  64192. * be merged with larger regions. [Limit: >=0] [Units: vx]
  64193. */
  64194. mergeRegionArea: number;
  64195. /**
  64196. * The maximum number of vertices allowed for polygons generated during the
  64197. * contour to polygon conversion process. [Limit: >= 3]
  64198. */
  64199. maxVertsPerPoly: number;
  64200. /**
  64201. * Sets the sampling distance to use when generating the detail mesh.
  64202. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  64203. */
  64204. detailSampleDist: number;
  64205. /**
  64206. * The maximum distance the detail mesh surface should deviate from heightfield
  64207. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  64208. */
  64209. detailSampleMaxError: number;
  64210. }
  64211. }
  64212. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  64213. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  64214. import { Mesh } from "babylonjs/Meshes/mesh";
  64215. import { Scene } from "babylonjs/scene";
  64216. import { Vector3 } from "babylonjs/Maths/math";
  64217. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64218. /**
  64219. * RecastJS navigation plugin
  64220. */
  64221. export class RecastJSPlugin implements INavigationEnginePlugin {
  64222. /**
  64223. * Reference to the Recast library
  64224. */
  64225. bjsRECAST: any;
  64226. /**
  64227. * plugin name
  64228. */
  64229. name: string;
  64230. /**
  64231. * the first navmesh created. We might extend this to support multiple navmeshes
  64232. */
  64233. navMesh: any;
  64234. /**
  64235. * Initializes the recastJS plugin
  64236. * @param recastInjection can be used to inject your own recast reference
  64237. */
  64238. constructor(recastInjection?: any);
  64239. /**
  64240. * Creates a navigation mesh
  64241. * @param meshes array of all the geometry used to compute the navigatio mesh
  64242. * @param parameters bunch of parameters used to filter geometry
  64243. */
  64244. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64245. /**
  64246. * Create a navigation mesh debug mesh
  64247. * @param scene is where the mesh will be added
  64248. * @returns debug display mesh
  64249. */
  64250. createDebugNavMesh(scene: Scene): Mesh;
  64251. /**
  64252. * Get a navigation mesh constrained position, closest to the parameter position
  64253. * @param position world position
  64254. * @returns the closest point to position constrained by the navigation mesh
  64255. */
  64256. getClosestPoint(position: Vector3): Vector3;
  64257. /**
  64258. * Get a navigation mesh constrained position, within a particular radius
  64259. * @param position world position
  64260. * @param maxRadius the maximum distance to the constrained world position
  64261. * @returns the closest point to position constrained by the navigation mesh
  64262. */
  64263. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64264. /**
  64265. * Compute the final position from a segment made of destination-position
  64266. * @param position world position
  64267. * @param destination world position
  64268. * @returns the resulting point along the navmesh
  64269. */
  64270. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64271. /**
  64272. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64273. * @param start world position
  64274. * @param end world position
  64275. * @returns array containing world position composing the path
  64276. */
  64277. computePath(start: Vector3, end: Vector3): Vector3[];
  64278. /**
  64279. * Create a new Crowd so you can add agents
  64280. * @param maxAgents the maximum agent count in the crowd
  64281. * @param maxAgentRadius the maximum radius an agent can have
  64282. * @param scene to attach the crowd to
  64283. * @returns the crowd you can add agents to
  64284. */
  64285. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  64286. /**
  64287. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64288. * The queries will try to find a solution within those bounds
  64289. * default is (1,1,1)
  64290. * @param extent x,y,z value that define the extent around the queries point of reference
  64291. */
  64292. setDefaultQueryExtent(extent: Vector3): void;
  64293. /**
  64294. * Get the Bounding box extent specified by setDefaultQueryExtent
  64295. * @returns the box extent values
  64296. */
  64297. getDefaultQueryExtent(): Vector3;
  64298. /**
  64299. * Disposes
  64300. */
  64301. dispose(): void;
  64302. /**
  64303. * If this plugin is supported
  64304. * @returns true if plugin is supported
  64305. */
  64306. isSupported(): boolean;
  64307. }
  64308. /**
  64309. * Recast detour crowd implementation
  64310. */
  64311. export class RecastJSCrowd implements ICrowd {
  64312. /**
  64313. * Recast/detour plugin
  64314. */
  64315. bjsRECASTPlugin: RecastJSPlugin;
  64316. /**
  64317. * Link to the detour crowd
  64318. */
  64319. recastCrowd: any;
  64320. /**
  64321. * One transform per agent
  64322. */
  64323. transforms: TransformNode[];
  64324. /**
  64325. * All agents created
  64326. */
  64327. agents: number[];
  64328. /**
  64329. * Link to the scene is kept to unregister the crowd from the scene
  64330. */
  64331. private _scene;
  64332. /**
  64333. * Observer for crowd updates
  64334. */
  64335. private _onBeforeAnimationsObserver;
  64336. /**
  64337. * Constructor
  64338. * @param plugin recastJS plugin
  64339. * @param maxAgents the maximum agent count in the crowd
  64340. * @param maxAgentRadius the maximum radius an agent can have
  64341. * @param scene to attach the crowd to
  64342. * @returns the crowd you can add agents to
  64343. */
  64344. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  64345. /**
  64346. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  64347. * You can attach anything to that node. The node position is updated in the scene update tick.
  64348. * @param pos world position that will be constrained by the navigation mesh
  64349. * @param parameters agent parameters
  64350. * @param transform hooked to the agent that will be update by the scene
  64351. * @returns agent index
  64352. */
  64353. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  64354. /**
  64355. * Returns the agent position in world space
  64356. * @param index agent index returned by addAgent
  64357. * @returns world space position
  64358. */
  64359. getAgentPosition(index: number): Vector3;
  64360. /**
  64361. * Returns the agent velocity in world space
  64362. * @param index agent index returned by addAgent
  64363. * @returns world space velocity
  64364. */
  64365. getAgentVelocity(index: number): Vector3;
  64366. /**
  64367. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  64368. * @param index agent index returned by addAgent
  64369. * @param destination targeted world position
  64370. */
  64371. agentGoto(index: number, destination: Vector3): void;
  64372. /**
  64373. * remove a particular agent previously created
  64374. * @param index agent index returned by addAgent
  64375. */
  64376. removeAgent(index: number): void;
  64377. /**
  64378. * get the list of all agents attached to this crowd
  64379. * @returns list of agent indices
  64380. */
  64381. getAgents(): number[];
  64382. /**
  64383. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  64384. * @param deltaTime in seconds
  64385. */
  64386. update(deltaTime: number): void;
  64387. /**
  64388. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  64389. * The queries will try to find a solution within those bounds
  64390. * default is (1,1,1)
  64391. * @param extent x,y,z value that define the extent around the queries point of reference
  64392. */
  64393. setDefaultQueryExtent(extent: Vector3): void;
  64394. /**
  64395. * Get the Bounding box extent specified by setDefaultQueryExtent
  64396. * @returns the box extent values
  64397. */
  64398. getDefaultQueryExtent(): Vector3;
  64399. /**
  64400. * Release all resources
  64401. */
  64402. dispose(): void;
  64403. }
  64404. }
  64405. declare module "babylonjs/Navigation/Plugins/index" {
  64406. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  64407. }
  64408. declare module "babylonjs/Navigation/index" {
  64409. export * from "babylonjs/Navigation/INavigationEngine";
  64410. export * from "babylonjs/Navigation/Plugins/index";
  64411. }
  64412. declare module "babylonjs/Offline/database" {
  64413. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  64414. /**
  64415. * Class used to enable access to IndexedDB
  64416. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  64417. */
  64418. export class Database implements IOfflineProvider {
  64419. private _callbackManifestChecked;
  64420. private _currentSceneUrl;
  64421. private _db;
  64422. private _enableSceneOffline;
  64423. private _enableTexturesOffline;
  64424. private _manifestVersionFound;
  64425. private _mustUpdateRessources;
  64426. private _hasReachedQuota;
  64427. private _isSupported;
  64428. private _idbFactory;
  64429. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  64430. private static IsUASupportingBlobStorage;
  64431. /**
  64432. * Gets a boolean indicating if Database storate is enabled (off by default)
  64433. */
  64434. static IDBStorageEnabled: boolean;
  64435. /**
  64436. * Gets a boolean indicating if scene must be saved in the database
  64437. */
  64438. get enableSceneOffline(): boolean;
  64439. /**
  64440. * Gets a boolean indicating if textures must be saved in the database
  64441. */
  64442. get enableTexturesOffline(): boolean;
  64443. /**
  64444. * Creates a new Database
  64445. * @param urlToScene defines the url to load the scene
  64446. * @param callbackManifestChecked defines the callback to use when manifest is checked
  64447. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  64448. */
  64449. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  64450. private static _ParseURL;
  64451. private static _ReturnFullUrlLocation;
  64452. private _checkManifestFile;
  64453. /**
  64454. * Open the database and make it available
  64455. * @param successCallback defines the callback to call on success
  64456. * @param errorCallback defines the callback to call on error
  64457. */
  64458. open(successCallback: () => void, errorCallback: () => void): void;
  64459. /**
  64460. * Loads an image from the database
  64461. * @param url defines the url to load from
  64462. * @param image defines the target DOM image
  64463. */
  64464. loadImage(url: string, image: HTMLImageElement): void;
  64465. private _loadImageFromDBAsync;
  64466. private _saveImageIntoDBAsync;
  64467. private _checkVersionFromDB;
  64468. private _loadVersionFromDBAsync;
  64469. private _saveVersionIntoDBAsync;
  64470. /**
  64471. * Loads a file from database
  64472. * @param url defines the URL to load from
  64473. * @param sceneLoaded defines a callback to call on success
  64474. * @param progressCallBack defines a callback to call when progress changed
  64475. * @param errorCallback defines a callback to call on error
  64476. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  64477. */
  64478. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  64479. private _loadFileAsync;
  64480. private _saveFileAsync;
  64481. /**
  64482. * Validates if xhr data is correct
  64483. * @param xhr defines the request to validate
  64484. * @param dataType defines the expected data type
  64485. * @returns true if data is correct
  64486. */
  64487. private static _ValidateXHRData;
  64488. }
  64489. }
  64490. declare module "babylonjs/Offline/index" {
  64491. export * from "babylonjs/Offline/database";
  64492. export * from "babylonjs/Offline/IOfflineProvider";
  64493. }
  64494. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  64495. /** @hidden */
  64496. export var gpuUpdateParticlesPixelShader: {
  64497. name: string;
  64498. shader: string;
  64499. };
  64500. }
  64501. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  64502. /** @hidden */
  64503. export var gpuUpdateParticlesVertexShader: {
  64504. name: string;
  64505. shader: string;
  64506. };
  64507. }
  64508. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  64509. /** @hidden */
  64510. export var clipPlaneFragmentDeclaration2: {
  64511. name: string;
  64512. shader: string;
  64513. };
  64514. }
  64515. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  64516. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  64517. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64518. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64519. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64520. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  64521. /** @hidden */
  64522. export var gpuRenderParticlesPixelShader: {
  64523. name: string;
  64524. shader: string;
  64525. };
  64526. }
  64527. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  64528. /** @hidden */
  64529. export var clipPlaneVertexDeclaration2: {
  64530. name: string;
  64531. shader: string;
  64532. };
  64533. }
  64534. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  64535. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  64536. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  64537. /** @hidden */
  64538. export var gpuRenderParticlesVertexShader: {
  64539. name: string;
  64540. shader: string;
  64541. };
  64542. }
  64543. declare module "babylonjs/Particles/gpuParticleSystem" {
  64544. import { Nullable } from "babylonjs/types";
  64545. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  64546. import { Observable } from "babylonjs/Misc/observable";
  64547. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64548. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64549. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  64550. import { Scene, IDisposable } from "babylonjs/scene";
  64551. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  64552. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64553. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  64554. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  64555. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  64556. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  64557. /**
  64558. * This represents a GPU particle system in Babylon
  64559. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  64560. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  64561. */
  64562. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  64563. /**
  64564. * The layer mask we are rendering the particles through.
  64565. */
  64566. layerMask: number;
  64567. private _capacity;
  64568. private _activeCount;
  64569. private _currentActiveCount;
  64570. private _accumulatedCount;
  64571. private _renderEffect;
  64572. private _updateEffect;
  64573. private _buffer0;
  64574. private _buffer1;
  64575. private _spriteBuffer;
  64576. private _updateVAO;
  64577. private _renderVAO;
  64578. private _targetIndex;
  64579. private _sourceBuffer;
  64580. private _targetBuffer;
  64581. private _engine;
  64582. private _currentRenderId;
  64583. private _started;
  64584. private _stopped;
  64585. private _timeDelta;
  64586. private _randomTexture;
  64587. private _randomTexture2;
  64588. private _attributesStrideSize;
  64589. private _updateEffectOptions;
  64590. private _randomTextureSize;
  64591. private _actualFrame;
  64592. private readonly _rawTextureWidth;
  64593. /**
  64594. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  64595. */
  64596. static get IsSupported(): boolean;
  64597. /**
  64598. * An event triggered when the system is disposed.
  64599. */
  64600. onDisposeObservable: Observable<GPUParticleSystem>;
  64601. /**
  64602. * Gets the maximum number of particles active at the same time.
  64603. * @returns The max number of active particles.
  64604. */
  64605. getCapacity(): number;
  64606. /**
  64607. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  64608. * to override the particles.
  64609. */
  64610. forceDepthWrite: boolean;
  64611. /**
  64612. * Gets or set the number of active particles
  64613. */
  64614. get activeParticleCount(): number;
  64615. set activeParticleCount(value: number);
  64616. private _preWarmDone;
  64617. /**
  64618. * Is this system ready to be used/rendered
  64619. * @return true if the system is ready
  64620. */
  64621. isReady(): boolean;
  64622. /**
  64623. * Gets if the system has been started. (Note: this will still be true after stop is called)
  64624. * @returns True if it has been started, otherwise false.
  64625. */
  64626. isStarted(): boolean;
  64627. /**
  64628. * Starts the particle system and begins to emit
  64629. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  64630. */
  64631. start(delay?: number): void;
  64632. /**
  64633. * Stops the particle system.
  64634. */
  64635. stop(): void;
  64636. /**
  64637. * Remove all active particles
  64638. */
  64639. reset(): void;
  64640. /**
  64641. * Returns the string "GPUParticleSystem"
  64642. * @returns a string containing the class name
  64643. */
  64644. getClassName(): string;
  64645. private _colorGradientsTexture;
  64646. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  64647. /**
  64648. * Adds a new color gradient
  64649. * @param gradient defines the gradient to use (between 0 and 1)
  64650. * @param color1 defines the color to affect to the specified gradient
  64651. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  64652. * @returns the current particle system
  64653. */
  64654. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  64655. /**
  64656. * Remove a specific color gradient
  64657. * @param gradient defines the gradient to remove
  64658. * @returns the current particle system
  64659. */
  64660. removeColorGradient(gradient: number): GPUParticleSystem;
  64661. private _angularSpeedGradientsTexture;
  64662. private _sizeGradientsTexture;
  64663. private _velocityGradientsTexture;
  64664. private _limitVelocityGradientsTexture;
  64665. private _dragGradientsTexture;
  64666. private _addFactorGradient;
  64667. /**
  64668. * Adds a new size gradient
  64669. * @param gradient defines the gradient to use (between 0 and 1)
  64670. * @param factor defines the size factor to affect to the specified gradient
  64671. * @returns the current particle system
  64672. */
  64673. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  64674. /**
  64675. * Remove a specific size gradient
  64676. * @param gradient defines the gradient to remove
  64677. * @returns the current particle system
  64678. */
  64679. removeSizeGradient(gradient: number): GPUParticleSystem;
  64680. /**
  64681. * Adds a new angular speed gradient
  64682. * @param gradient defines the gradient to use (between 0 and 1)
  64683. * @param factor defines the angular speed to affect to the specified gradient
  64684. * @returns the current particle system
  64685. */
  64686. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  64687. /**
  64688. * Remove a specific angular speed gradient
  64689. * @param gradient defines the gradient to remove
  64690. * @returns the current particle system
  64691. */
  64692. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  64693. /**
  64694. * Adds a new velocity gradient
  64695. * @param gradient defines the gradient to use (between 0 and 1)
  64696. * @param factor defines the velocity to affect to the specified gradient
  64697. * @returns the current particle system
  64698. */
  64699. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64700. /**
  64701. * Remove a specific velocity gradient
  64702. * @param gradient defines the gradient to remove
  64703. * @returns the current particle system
  64704. */
  64705. removeVelocityGradient(gradient: number): GPUParticleSystem;
  64706. /**
  64707. * Adds a new limit velocity gradient
  64708. * @param gradient defines the gradient to use (between 0 and 1)
  64709. * @param factor defines the limit velocity value to affect to the specified gradient
  64710. * @returns the current particle system
  64711. */
  64712. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  64713. /**
  64714. * Remove a specific limit velocity gradient
  64715. * @param gradient defines the gradient to remove
  64716. * @returns the current particle system
  64717. */
  64718. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  64719. /**
  64720. * Adds a new drag gradient
  64721. * @param gradient defines the gradient to use (between 0 and 1)
  64722. * @param factor defines the drag value to affect to the specified gradient
  64723. * @returns the current particle system
  64724. */
  64725. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  64726. /**
  64727. * Remove a specific drag gradient
  64728. * @param gradient defines the gradient to remove
  64729. * @returns the current particle system
  64730. */
  64731. removeDragGradient(gradient: number): GPUParticleSystem;
  64732. /**
  64733. * Not supported by GPUParticleSystem
  64734. * @param gradient defines the gradient to use (between 0 and 1)
  64735. * @param factor defines the emit rate value to affect to the specified gradient
  64736. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64737. * @returns the current particle system
  64738. */
  64739. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64740. /**
  64741. * Not supported by GPUParticleSystem
  64742. * @param gradient defines the gradient to remove
  64743. * @returns the current particle system
  64744. */
  64745. removeEmitRateGradient(gradient: number): IParticleSystem;
  64746. /**
  64747. * Not supported by GPUParticleSystem
  64748. * @param gradient defines the gradient to use (between 0 and 1)
  64749. * @param factor defines the start size value to affect to the specified gradient
  64750. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64751. * @returns the current particle system
  64752. */
  64753. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64754. /**
  64755. * Not supported by GPUParticleSystem
  64756. * @param gradient defines the gradient to remove
  64757. * @returns the current particle system
  64758. */
  64759. removeStartSizeGradient(gradient: number): IParticleSystem;
  64760. /**
  64761. * Not supported by GPUParticleSystem
  64762. * @param gradient defines the gradient to use (between 0 and 1)
  64763. * @param min defines the color remap minimal range
  64764. * @param max defines the color remap maximal range
  64765. * @returns the current particle system
  64766. */
  64767. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64768. /**
  64769. * Not supported by GPUParticleSystem
  64770. * @param gradient defines the gradient to remove
  64771. * @returns the current particle system
  64772. */
  64773. removeColorRemapGradient(): IParticleSystem;
  64774. /**
  64775. * Not supported by GPUParticleSystem
  64776. * @param gradient defines the gradient to use (between 0 and 1)
  64777. * @param min defines the alpha remap minimal range
  64778. * @param max defines the alpha remap maximal range
  64779. * @returns the current particle system
  64780. */
  64781. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  64782. /**
  64783. * Not supported by GPUParticleSystem
  64784. * @param gradient defines the gradient to remove
  64785. * @returns the current particle system
  64786. */
  64787. removeAlphaRemapGradient(): IParticleSystem;
  64788. /**
  64789. * Not supported by GPUParticleSystem
  64790. * @param gradient defines the gradient to use (between 0 and 1)
  64791. * @param color defines the color to affect to the specified gradient
  64792. * @returns the current particle system
  64793. */
  64794. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  64795. /**
  64796. * Not supported by GPUParticleSystem
  64797. * @param gradient defines the gradient to remove
  64798. * @returns the current particle system
  64799. */
  64800. removeRampGradient(): IParticleSystem;
  64801. /**
  64802. * Not supported by GPUParticleSystem
  64803. * @returns the list of ramp gradients
  64804. */
  64805. getRampGradients(): Nullable<Array<Color3Gradient>>;
  64806. /**
  64807. * Not supported by GPUParticleSystem
  64808. * Gets or sets a boolean indicating that ramp gradients must be used
  64809. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  64810. */
  64811. get useRampGradients(): boolean;
  64812. set useRampGradients(value: boolean);
  64813. /**
  64814. * Not supported by GPUParticleSystem
  64815. * @param gradient defines the gradient to use (between 0 and 1)
  64816. * @param factor defines the life time factor to affect to the specified gradient
  64817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  64818. * @returns the current particle system
  64819. */
  64820. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  64821. /**
  64822. * Not supported by GPUParticleSystem
  64823. * @param gradient defines the gradient to remove
  64824. * @returns the current particle system
  64825. */
  64826. removeLifeTimeGradient(gradient: number): IParticleSystem;
  64827. /**
  64828. * Instantiates a GPU particle system.
  64829. * 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.
  64830. * @param name The name of the particle system
  64831. * @param options The options used to create the system
  64832. * @param scene The scene the particle system belongs to
  64833. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  64834. */
  64835. constructor(name: string, options: Partial<{
  64836. capacity: number;
  64837. randomTextureSize: number;
  64838. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  64839. protected _reset(): void;
  64840. private _createUpdateVAO;
  64841. private _createRenderVAO;
  64842. private _initialize;
  64843. /** @hidden */
  64844. _recreateUpdateEffect(): void;
  64845. /** @hidden */
  64846. _recreateRenderEffect(): void;
  64847. /**
  64848. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  64849. * @param preWarm defines if we are in the pre-warmimg phase
  64850. */
  64851. animate(preWarm?: boolean): void;
  64852. private _createFactorGradientTexture;
  64853. private _createSizeGradientTexture;
  64854. private _createAngularSpeedGradientTexture;
  64855. private _createVelocityGradientTexture;
  64856. private _createLimitVelocityGradientTexture;
  64857. private _createDragGradientTexture;
  64858. private _createColorGradientTexture;
  64859. /**
  64860. * Renders the particle system in its current state
  64861. * @param preWarm defines if the system should only update the particles but not render them
  64862. * @returns the current number of particles
  64863. */
  64864. render(preWarm?: boolean): number;
  64865. /**
  64866. * Rebuilds the particle system
  64867. */
  64868. rebuild(): void;
  64869. private _releaseBuffers;
  64870. private _releaseVAOs;
  64871. /**
  64872. * Disposes the particle system and free the associated resources
  64873. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  64874. */
  64875. dispose(disposeTexture?: boolean): void;
  64876. /**
  64877. * Clones the particle system.
  64878. * @param name The name of the cloned object
  64879. * @param newEmitter The new emitter to use
  64880. * @returns the cloned particle system
  64881. */
  64882. clone(name: string, newEmitter: any): GPUParticleSystem;
  64883. /**
  64884. * Serializes the particle system to a JSON object.
  64885. * @returns the JSON object
  64886. */
  64887. serialize(): any;
  64888. /**
  64889. * Parses a JSON object to create a GPU particle system.
  64890. * @param parsedParticleSystem The JSON object to parse
  64891. * @param scene The scene to create the particle system in
  64892. * @param rootUrl The root url to use to load external dependencies like texture
  64893. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  64894. * @returns the parsed GPU particle system
  64895. */
  64896. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  64897. }
  64898. }
  64899. declare module "babylonjs/Particles/particleSystemSet" {
  64900. import { Nullable } from "babylonjs/types";
  64901. import { Color3 } from "babylonjs/Maths/math.color";
  64902. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64904. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64905. import { Scene, IDisposable } from "babylonjs/scene";
  64906. /**
  64907. * Represents a set of particle systems working together to create a specific effect
  64908. */
  64909. export class ParticleSystemSet implements IDisposable {
  64910. /**
  64911. * Gets or sets base Assets URL
  64912. */
  64913. static BaseAssetsUrl: string;
  64914. private _emitterCreationOptions;
  64915. private _emitterNode;
  64916. /**
  64917. * Gets the particle system list
  64918. */
  64919. systems: IParticleSystem[];
  64920. /**
  64921. * Gets the emitter node used with this set
  64922. */
  64923. get emitterNode(): Nullable<TransformNode>;
  64924. /**
  64925. * Creates a new emitter mesh as a sphere
  64926. * @param options defines the options used to create the sphere
  64927. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  64928. * @param scene defines the hosting scene
  64929. */
  64930. setEmitterAsSphere(options: {
  64931. diameter: number;
  64932. segments: number;
  64933. color: Color3;
  64934. }, renderingGroupId: number, scene: Scene): void;
  64935. /**
  64936. * Starts all particle systems of the set
  64937. * @param emitter defines an optional mesh to use as emitter for the particle systems
  64938. */
  64939. start(emitter?: AbstractMesh): void;
  64940. /**
  64941. * Release all associated resources
  64942. */
  64943. dispose(): void;
  64944. /**
  64945. * Serialize the set into a JSON compatible object
  64946. * @returns a JSON compatible representation of the set
  64947. */
  64948. serialize(): any;
  64949. /**
  64950. * Parse a new ParticleSystemSet from a serialized source
  64951. * @param data defines a JSON compatible representation of the set
  64952. * @param scene defines the hosting scene
  64953. * @param gpu defines if we want GPU particles or CPU particles
  64954. * @returns a new ParticleSystemSet
  64955. */
  64956. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  64957. }
  64958. }
  64959. declare module "babylonjs/Particles/particleHelper" {
  64960. import { Nullable } from "babylonjs/types";
  64961. import { Scene } from "babylonjs/scene";
  64962. import { Vector3 } from "babylonjs/Maths/math.vector";
  64963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64964. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64965. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  64966. /**
  64967. * This class is made for on one-liner static method to help creating particle system set.
  64968. */
  64969. export class ParticleHelper {
  64970. /**
  64971. * Gets or sets base Assets URL
  64972. */
  64973. static BaseAssetsUrl: string;
  64974. /**
  64975. * Create a default particle system that you can tweak
  64976. * @param emitter defines the emitter to use
  64977. * @param capacity defines the system capacity (default is 500 particles)
  64978. * @param scene defines the hosting scene
  64979. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  64980. * @returns the new Particle system
  64981. */
  64982. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  64983. /**
  64984. * This is the main static method (one-liner) of this helper to create different particle systems
  64985. * @param type This string represents the type to the particle system to create
  64986. * @param scene The scene where the particle system should live
  64987. * @param gpu If the system will use gpu
  64988. * @returns the ParticleSystemSet created
  64989. */
  64990. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  64991. /**
  64992. * Static function used to export a particle system to a ParticleSystemSet variable.
  64993. * Please note that the emitter shape is not exported
  64994. * @param systems defines the particle systems to export
  64995. * @returns the created particle system set
  64996. */
  64997. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  64998. }
  64999. }
  65000. declare module "babylonjs/Particles/particleSystemComponent" {
  65001. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65002. import { Effect } from "babylonjs/Materials/effect";
  65003. import "babylonjs/Shaders/particles.vertex";
  65004. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65005. module "babylonjs/Engines/engine" {
  65006. interface Engine {
  65007. /**
  65008. * Create an effect to use with particle systems.
  65009. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  65010. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  65011. * @param uniformsNames defines a list of attribute names
  65012. * @param samplers defines an array of string used to represent textures
  65013. * @param defines defines the string containing the defines to use to compile the shaders
  65014. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  65015. * @param onCompiled defines a function to call when the effect creation is successful
  65016. * @param onError defines a function to call when the effect creation has failed
  65017. * @returns the new Effect
  65018. */
  65019. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  65020. }
  65021. }
  65022. module "babylonjs/Meshes/mesh" {
  65023. interface Mesh {
  65024. /**
  65025. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  65026. * @returns an array of IParticleSystem
  65027. */
  65028. getEmittedParticleSystems(): IParticleSystem[];
  65029. /**
  65030. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  65031. * @returns an array of IParticleSystem
  65032. */
  65033. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  65034. }
  65035. }
  65036. /**
  65037. * @hidden
  65038. */
  65039. export var _IDoNeedToBeInTheBuild: number;
  65040. }
  65041. declare module "babylonjs/Particles/pointsCloudSystem" {
  65042. import { Color4 } from "babylonjs/Maths/math";
  65043. import { Mesh } from "babylonjs/Meshes/mesh";
  65044. import { Scene, IDisposable } from "babylonjs/scene";
  65045. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  65046. /** Defines the 4 color options */
  65047. export enum PointColor {
  65048. /** color value */
  65049. Color = 2,
  65050. /** uv value */
  65051. UV = 1,
  65052. /** random value */
  65053. Random = 0,
  65054. /** stated value */
  65055. Stated = 3
  65056. }
  65057. /**
  65058. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  65059. * 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.
  65060. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  65061. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  65062. *
  65063. * Full documentation here : TO BE ENTERED
  65064. */
  65065. export class PointsCloudSystem implements IDisposable {
  65066. /**
  65067. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  65068. * Example : var p = SPS.particles[i];
  65069. */
  65070. particles: CloudPoint[];
  65071. /**
  65072. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  65073. */
  65074. nbParticles: number;
  65075. /**
  65076. * This a counter for your own usage. It's not set by any SPS functions.
  65077. */
  65078. counter: number;
  65079. /**
  65080. * The PCS name. This name is also given to the underlying mesh.
  65081. */
  65082. name: string;
  65083. /**
  65084. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  65085. */
  65086. mesh: Mesh;
  65087. /**
  65088. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  65089. * Please read :
  65090. */
  65091. vars: any;
  65092. /**
  65093. * @hidden
  65094. */
  65095. _size: number;
  65096. private _scene;
  65097. private _promises;
  65098. private _positions;
  65099. private _indices;
  65100. private _normals;
  65101. private _colors;
  65102. private _uvs;
  65103. private _indices32;
  65104. private _positions32;
  65105. private _colors32;
  65106. private _uvs32;
  65107. private _updatable;
  65108. private _isVisibilityBoxLocked;
  65109. private _alwaysVisible;
  65110. private _groups;
  65111. private _groupCounter;
  65112. private _computeParticleColor;
  65113. private _computeParticleTexture;
  65114. private _computeParticleRotation;
  65115. private _computeBoundingBox;
  65116. private _isReady;
  65117. /**
  65118. * Creates a PCS (Points Cloud System) object
  65119. * @param name (String) is the PCS name, this will be the underlying mesh name
  65120. * @param pointSize (number) is the size for each point
  65121. * @param scene (Scene) is the scene in which the PCS is added
  65122. * @param options defines the options of the PCS e.g.
  65123. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  65124. */
  65125. constructor(name: string, pointSize: number, scene: Scene, options?: {
  65126. updatable?: boolean;
  65127. });
  65128. /**
  65129. * Builds the PCS underlying mesh. Returns a standard Mesh.
  65130. * If no points were added to the PCS, the returned mesh is just a single point.
  65131. * @returns a promise for the created mesh
  65132. */
  65133. buildMeshAsync(): Promise<Mesh>;
  65134. /**
  65135. * @hidden
  65136. */
  65137. private _buildMesh;
  65138. private _addParticle;
  65139. private _randomUnitVector;
  65140. private _getColorIndicesForCoord;
  65141. private _setPointsColorOrUV;
  65142. private _colorFromTexture;
  65143. private _calculateDensity;
  65144. /**
  65145. * Adds points to the PCS in random positions within a unit sphere
  65146. * @param nb (positive integer) the number of particles to be created from this model
  65147. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  65148. * @returns the number of groups in the system
  65149. */
  65150. addPoints(nb: number, pointFunction?: any): number;
  65151. /**
  65152. * Adds points to the PCS from the surface of the model shape
  65153. * @param mesh is any Mesh object that will be used as a surface model for the points
  65154. * @param nb (positive integer) the number of particles to be created from this model
  65155. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65156. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65157. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65158. * @returns the number of groups in the system
  65159. */
  65160. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65161. /**
  65162. * Adds points to the PCS inside the model shape
  65163. * @param mesh is any Mesh object that will be used as a surface model for the points
  65164. * @param nb (positive integer) the number of particles to be created from this model
  65165. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  65166. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  65167. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  65168. * @returns the number of groups in the system
  65169. */
  65170. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  65171. /**
  65172. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  65173. * This method calls `updateParticle()` for each particle of the SPS.
  65174. * For an animated SPS, it is usually called within the render loop.
  65175. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  65176. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  65177. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  65178. * @returns the PCS.
  65179. */
  65180. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  65181. /**
  65182. * Disposes the PCS.
  65183. */
  65184. dispose(): void;
  65185. /**
  65186. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  65187. * doc :
  65188. * @returns the PCS.
  65189. */
  65190. refreshVisibleSize(): PointsCloudSystem;
  65191. /**
  65192. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  65193. * @param size the size (float) of the visibility box
  65194. * note : this doesn't lock the PCS mesh bounding box.
  65195. * doc :
  65196. */
  65197. setVisibilityBox(size: number): void;
  65198. /**
  65199. * Gets whether the PCS is always visible or not
  65200. * doc :
  65201. */
  65202. get isAlwaysVisible(): boolean;
  65203. /**
  65204. * Sets the PCS as always visible or not
  65205. * doc :
  65206. */
  65207. set isAlwaysVisible(val: boolean);
  65208. /**
  65209. * Tells to `setParticles()` to compute the particle rotations or not
  65210. * Default value : false. The PCS is faster when it's set to false
  65211. * Note : particle rotations are only applied to parent particles
  65212. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  65213. */
  65214. set computeParticleRotation(val: boolean);
  65215. /**
  65216. * Tells to `setParticles()` to compute the particle colors or not.
  65217. * Default value : true. The PCS is faster when it's set to false.
  65218. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65219. */
  65220. set computeParticleColor(val: boolean);
  65221. set computeParticleTexture(val: boolean);
  65222. /**
  65223. * Gets if `setParticles()` computes the particle colors or not.
  65224. * Default value : false. The PCS is faster when it's set to false.
  65225. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  65226. */
  65227. get computeParticleColor(): boolean;
  65228. /**
  65229. * Gets if `setParticles()` computes the particle textures or not.
  65230. * Default value : false. The PCS is faster when it's set to false.
  65231. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  65232. */
  65233. get computeParticleTexture(): boolean;
  65234. /**
  65235. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  65236. */
  65237. set computeBoundingBox(val: boolean);
  65238. /**
  65239. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  65240. */
  65241. get computeBoundingBox(): boolean;
  65242. /**
  65243. * This function does nothing. It may be overwritten to set all the particle first values.
  65244. * The PCS doesn't call this function, you may have to call it by your own.
  65245. * doc :
  65246. */
  65247. initParticles(): void;
  65248. /**
  65249. * This function does nothing. It may be overwritten to recycle a particle
  65250. * The PCS doesn't call this function, you can to call it
  65251. * doc :
  65252. * @param particle The particle to recycle
  65253. * @returns the recycled particle
  65254. */
  65255. recycleParticle(particle: CloudPoint): CloudPoint;
  65256. /**
  65257. * Updates a particle : this function should be overwritten by the user.
  65258. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  65259. * doc :
  65260. * @example : just set a particle position or velocity and recycle conditions
  65261. * @param particle The particle to update
  65262. * @returns the updated particle
  65263. */
  65264. updateParticle(particle: CloudPoint): CloudPoint;
  65265. /**
  65266. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  65267. * This does nothing and may be overwritten by the user.
  65268. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65269. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65270. * @param update the boolean update value actually passed to setParticles()
  65271. */
  65272. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65273. /**
  65274. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  65275. * This will be passed three parameters.
  65276. * This does nothing and may be overwritten by the user.
  65277. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  65278. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  65279. * @param update the boolean update value actually passed to setParticles()
  65280. */
  65281. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  65282. }
  65283. }
  65284. declare module "babylonjs/Particles/cloudPoint" {
  65285. import { Nullable } from "babylonjs/types";
  65286. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  65287. import { Mesh } from "babylonjs/Meshes/mesh";
  65288. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  65289. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  65290. /**
  65291. * Represents one particle of a points cloud system.
  65292. */
  65293. export class CloudPoint {
  65294. /**
  65295. * particle global index
  65296. */
  65297. idx: number;
  65298. /**
  65299. * The color of the particle
  65300. */
  65301. color: Nullable<Color4>;
  65302. /**
  65303. * The world space position of the particle.
  65304. */
  65305. position: Vector3;
  65306. /**
  65307. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  65308. */
  65309. rotation: Vector3;
  65310. /**
  65311. * The world space rotation quaternion of the particle.
  65312. */
  65313. rotationQuaternion: Nullable<Quaternion>;
  65314. /**
  65315. * The uv of the particle.
  65316. */
  65317. uv: Nullable<Vector2>;
  65318. /**
  65319. * The current speed of the particle.
  65320. */
  65321. velocity: Vector3;
  65322. /**
  65323. * The pivot point in the particle local space.
  65324. */
  65325. pivot: Vector3;
  65326. /**
  65327. * Must the particle be translated from its pivot point in its local space ?
  65328. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  65329. * Default : false
  65330. */
  65331. translateFromPivot: boolean;
  65332. /**
  65333. * Index of this particle in the global "positions" array (Internal use)
  65334. * @hidden
  65335. */
  65336. _pos: number;
  65337. /**
  65338. * @hidden Index of this particle in the global "indices" array (Internal use)
  65339. */
  65340. _ind: number;
  65341. /**
  65342. * Group this particle belongs to
  65343. */
  65344. _group: PointsGroup;
  65345. /**
  65346. * Group id of this particle
  65347. */
  65348. groupId: number;
  65349. /**
  65350. * Index of the particle in its group id (Internal use)
  65351. */
  65352. idxInGroup: number;
  65353. /**
  65354. * @hidden Particle BoundingInfo object (Internal use)
  65355. */
  65356. _boundingInfo: BoundingInfo;
  65357. /**
  65358. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  65359. */
  65360. _pcs: PointsCloudSystem;
  65361. /**
  65362. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  65363. */
  65364. _stillInvisible: boolean;
  65365. /**
  65366. * @hidden Last computed particle rotation matrix
  65367. */
  65368. _rotationMatrix: number[];
  65369. /**
  65370. * Parent particle Id, if any.
  65371. * Default null.
  65372. */
  65373. parentId: Nullable<number>;
  65374. /**
  65375. * @hidden Internal global position in the PCS.
  65376. */
  65377. _globalPosition: Vector3;
  65378. /**
  65379. * Creates a Point Cloud object.
  65380. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  65381. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  65382. * @param group (PointsGroup) is the group the particle belongs to
  65383. * @param groupId (integer) is the group identifier in the PCS.
  65384. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  65385. * @param pcs defines the PCS it is associated to
  65386. */
  65387. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  65388. /**
  65389. * get point size
  65390. */
  65391. get size(): Vector3;
  65392. /**
  65393. * Set point size
  65394. */
  65395. set size(scale: Vector3);
  65396. /**
  65397. * Legacy support, changed quaternion to rotationQuaternion
  65398. */
  65399. get quaternion(): Nullable<Quaternion>;
  65400. /**
  65401. * Legacy support, changed quaternion to rotationQuaternion
  65402. */
  65403. set quaternion(q: Nullable<Quaternion>);
  65404. /**
  65405. * Returns a boolean. True if the particle intersects a mesh, else false
  65406. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  65407. * @param target is the object (point or mesh) what the intersection is computed against
  65408. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  65409. * @returns true if it intersects
  65410. */
  65411. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  65412. /**
  65413. * get the rotation matrix of the particle
  65414. * @hidden
  65415. */
  65416. getRotationMatrix(m: Matrix): void;
  65417. }
  65418. /**
  65419. * Represents a group of points in a points cloud system
  65420. * * PCS internal tool, don't use it manually.
  65421. */
  65422. export class PointsGroup {
  65423. /**
  65424. * The group id
  65425. * @hidden
  65426. */
  65427. groupID: number;
  65428. /**
  65429. * image data for group (internal use)
  65430. * @hidden
  65431. */
  65432. _groupImageData: Nullable<ArrayBufferView>;
  65433. /**
  65434. * Image Width (internal use)
  65435. * @hidden
  65436. */
  65437. _groupImgWidth: number;
  65438. /**
  65439. * Image Height (internal use)
  65440. * @hidden
  65441. */
  65442. _groupImgHeight: number;
  65443. /**
  65444. * Custom position function (internal use)
  65445. * @hidden
  65446. */
  65447. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  65448. /**
  65449. * density per facet for surface points
  65450. * @hidden
  65451. */
  65452. _groupDensity: number[];
  65453. /**
  65454. * Only when points are colored by texture carries pointer to texture list array
  65455. * @hidden
  65456. */
  65457. _textureNb: number;
  65458. /**
  65459. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  65460. * PCS internal tool, don't use it manually.
  65461. * @hidden
  65462. */
  65463. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  65464. }
  65465. }
  65466. declare module "babylonjs/Particles/index" {
  65467. export * from "babylonjs/Particles/baseParticleSystem";
  65468. export * from "babylonjs/Particles/EmitterTypes/index";
  65469. export * from "babylonjs/Particles/gpuParticleSystem";
  65470. export * from "babylonjs/Particles/IParticleSystem";
  65471. export * from "babylonjs/Particles/particle";
  65472. export * from "babylonjs/Particles/particleHelper";
  65473. export * from "babylonjs/Particles/particleSystem";
  65474. export * from "babylonjs/Particles/particleSystemComponent";
  65475. export * from "babylonjs/Particles/particleSystemSet";
  65476. export * from "babylonjs/Particles/solidParticle";
  65477. export * from "babylonjs/Particles/solidParticleSystem";
  65478. export * from "babylonjs/Particles/cloudPoint";
  65479. export * from "babylonjs/Particles/pointsCloudSystem";
  65480. export * from "babylonjs/Particles/subEmitter";
  65481. }
  65482. declare module "babylonjs/Physics/physicsEngineComponent" {
  65483. import { Nullable } from "babylonjs/types";
  65484. import { Observable, Observer } from "babylonjs/Misc/observable";
  65485. import { Vector3 } from "babylonjs/Maths/math.vector";
  65486. import { Mesh } from "babylonjs/Meshes/mesh";
  65487. import { ISceneComponent } from "babylonjs/sceneComponent";
  65488. import { Scene } from "babylonjs/scene";
  65489. import { Node } from "babylonjs/node";
  65490. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  65491. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65492. module "babylonjs/scene" {
  65493. interface Scene {
  65494. /** @hidden (Backing field) */
  65495. _physicsEngine: Nullable<IPhysicsEngine>;
  65496. /** @hidden */
  65497. _physicsTimeAccumulator: number;
  65498. /**
  65499. * Gets the current physics engine
  65500. * @returns a IPhysicsEngine or null if none attached
  65501. */
  65502. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  65503. /**
  65504. * Enables physics to the current scene
  65505. * @param gravity defines the scene's gravity for the physics engine
  65506. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  65507. * @return a boolean indicating if the physics engine was initialized
  65508. */
  65509. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  65510. /**
  65511. * Disables and disposes the physics engine associated with the scene
  65512. */
  65513. disablePhysicsEngine(): void;
  65514. /**
  65515. * Gets a boolean indicating if there is an active physics engine
  65516. * @returns a boolean indicating if there is an active physics engine
  65517. */
  65518. isPhysicsEnabled(): boolean;
  65519. /**
  65520. * Deletes a physics compound impostor
  65521. * @param compound defines the compound to delete
  65522. */
  65523. deleteCompoundImpostor(compound: any): void;
  65524. /**
  65525. * An event triggered when physic simulation is about to be run
  65526. */
  65527. onBeforePhysicsObservable: Observable<Scene>;
  65528. /**
  65529. * An event triggered when physic simulation has been done
  65530. */
  65531. onAfterPhysicsObservable: Observable<Scene>;
  65532. }
  65533. }
  65534. module "babylonjs/Meshes/abstractMesh" {
  65535. interface AbstractMesh {
  65536. /** @hidden */
  65537. _physicsImpostor: Nullable<PhysicsImpostor>;
  65538. /**
  65539. * Gets or sets impostor used for physic simulation
  65540. * @see http://doc.babylonjs.com/features/physics_engine
  65541. */
  65542. physicsImpostor: Nullable<PhysicsImpostor>;
  65543. /**
  65544. * Gets the current physics impostor
  65545. * @see http://doc.babylonjs.com/features/physics_engine
  65546. * @returns a physics impostor or null
  65547. */
  65548. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  65549. /** Apply a physic impulse to the mesh
  65550. * @param force defines the force to apply
  65551. * @param contactPoint defines where to apply the force
  65552. * @returns the current mesh
  65553. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  65554. */
  65555. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  65556. /**
  65557. * Creates a physic joint between two meshes
  65558. * @param otherMesh defines the other mesh to use
  65559. * @param pivot1 defines the pivot to use on this mesh
  65560. * @param pivot2 defines the pivot to use on the other mesh
  65561. * @param options defines additional options (can be plugin dependent)
  65562. * @returns the current mesh
  65563. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  65564. */
  65565. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  65566. /** @hidden */
  65567. _disposePhysicsObserver: Nullable<Observer<Node>>;
  65568. }
  65569. }
  65570. /**
  65571. * Defines the physics engine scene component responsible to manage a physics engine
  65572. */
  65573. export class PhysicsEngineSceneComponent implements ISceneComponent {
  65574. /**
  65575. * The component name helpful to identify the component in the list of scene components.
  65576. */
  65577. readonly name: string;
  65578. /**
  65579. * The scene the component belongs to.
  65580. */
  65581. scene: Scene;
  65582. /**
  65583. * Creates a new instance of the component for the given scene
  65584. * @param scene Defines the scene to register the component in
  65585. */
  65586. constructor(scene: Scene);
  65587. /**
  65588. * Registers the component in a given scene
  65589. */
  65590. register(): void;
  65591. /**
  65592. * Rebuilds the elements related to this component in case of
  65593. * context lost for instance.
  65594. */
  65595. rebuild(): void;
  65596. /**
  65597. * Disposes the component and the associated ressources
  65598. */
  65599. dispose(): void;
  65600. }
  65601. }
  65602. declare module "babylonjs/Physics/physicsHelper" {
  65603. import { Nullable } from "babylonjs/types";
  65604. import { Vector3 } from "babylonjs/Maths/math.vector";
  65605. import { Mesh } from "babylonjs/Meshes/mesh";
  65606. import { Scene } from "babylonjs/scene";
  65607. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  65608. /**
  65609. * A helper for physics simulations
  65610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65611. */
  65612. export class PhysicsHelper {
  65613. private _scene;
  65614. private _physicsEngine;
  65615. /**
  65616. * Initializes the Physics helper
  65617. * @param scene Babylon.js scene
  65618. */
  65619. constructor(scene: Scene);
  65620. /**
  65621. * Applies a radial explosion impulse
  65622. * @param origin the origin of the explosion
  65623. * @param radiusOrEventOptions the radius or the options of radial explosion
  65624. * @param strength the explosion strength
  65625. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65626. * @returns A physics radial explosion event, or null
  65627. */
  65628. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65629. /**
  65630. * Applies a radial explosion force
  65631. * @param origin the origin of the explosion
  65632. * @param radiusOrEventOptions the radius or the options of radial explosion
  65633. * @param strength the explosion strength
  65634. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65635. * @returns A physics radial explosion event, or null
  65636. */
  65637. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  65638. /**
  65639. * Creates a gravitational field
  65640. * @param origin the origin of the explosion
  65641. * @param radiusOrEventOptions the radius or the options of radial explosion
  65642. * @param strength the explosion strength
  65643. * @param falloff possible options: Constant & Linear. Defaults to Constant
  65644. * @returns A physics gravitational field event, or null
  65645. */
  65646. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  65647. /**
  65648. * Creates a physics updraft event
  65649. * @param origin the origin of the updraft
  65650. * @param radiusOrEventOptions the radius or the options of the updraft
  65651. * @param strength the strength of the updraft
  65652. * @param height the height of the updraft
  65653. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  65654. * @returns A physics updraft event, or null
  65655. */
  65656. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  65657. /**
  65658. * Creates a physics vortex event
  65659. * @param origin the of the vortex
  65660. * @param radiusOrEventOptions the radius or the options of the vortex
  65661. * @param strength the strength of the vortex
  65662. * @param height the height of the vortex
  65663. * @returns a Physics vortex event, or null
  65664. * A physics vortex event or null
  65665. */
  65666. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  65667. }
  65668. /**
  65669. * Represents a physics radial explosion event
  65670. */
  65671. class PhysicsRadialExplosionEvent {
  65672. private _scene;
  65673. private _options;
  65674. private _sphere;
  65675. private _dataFetched;
  65676. /**
  65677. * Initializes a radial explosioin event
  65678. * @param _scene BabylonJS scene
  65679. * @param _options The options for the vortex event
  65680. */
  65681. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  65682. /**
  65683. * Returns the data related to the radial explosion event (sphere).
  65684. * @returns The radial explosion event data
  65685. */
  65686. getData(): PhysicsRadialExplosionEventData;
  65687. /**
  65688. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  65689. * @param impostor A physics imposter
  65690. * @param origin the origin of the explosion
  65691. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  65692. */
  65693. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  65694. /**
  65695. * Triggers affecterd impostors callbacks
  65696. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  65697. */
  65698. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  65699. /**
  65700. * Disposes the sphere.
  65701. * @param force Specifies if the sphere should be disposed by force
  65702. */
  65703. dispose(force?: boolean): void;
  65704. /*** Helpers ***/
  65705. private _prepareSphere;
  65706. private _intersectsWithSphere;
  65707. }
  65708. /**
  65709. * Represents a gravitational field event
  65710. */
  65711. class PhysicsGravitationalFieldEvent {
  65712. private _physicsHelper;
  65713. private _scene;
  65714. private _origin;
  65715. private _options;
  65716. private _tickCallback;
  65717. private _sphere;
  65718. private _dataFetched;
  65719. /**
  65720. * Initializes the physics gravitational field event
  65721. * @param _physicsHelper A physics helper
  65722. * @param _scene BabylonJS scene
  65723. * @param _origin The origin position of the gravitational field event
  65724. * @param _options The options for the vortex event
  65725. */
  65726. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  65727. /**
  65728. * Returns the data related to the gravitational field event (sphere).
  65729. * @returns A gravitational field event
  65730. */
  65731. getData(): PhysicsGravitationalFieldEventData;
  65732. /**
  65733. * Enables the gravitational field.
  65734. */
  65735. enable(): void;
  65736. /**
  65737. * Disables the gravitational field.
  65738. */
  65739. disable(): void;
  65740. /**
  65741. * Disposes the sphere.
  65742. * @param force The force to dispose from the gravitational field event
  65743. */
  65744. dispose(force?: boolean): void;
  65745. private _tick;
  65746. }
  65747. /**
  65748. * Represents a physics updraft event
  65749. */
  65750. class PhysicsUpdraftEvent {
  65751. private _scene;
  65752. private _origin;
  65753. private _options;
  65754. private _physicsEngine;
  65755. private _originTop;
  65756. private _originDirection;
  65757. private _tickCallback;
  65758. private _cylinder;
  65759. private _cylinderPosition;
  65760. private _dataFetched;
  65761. /**
  65762. * Initializes the physics updraft event
  65763. * @param _scene BabylonJS scene
  65764. * @param _origin The origin position of the updraft
  65765. * @param _options The options for the updraft event
  65766. */
  65767. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  65768. /**
  65769. * Returns the data related to the updraft event (cylinder).
  65770. * @returns A physics updraft event
  65771. */
  65772. getData(): PhysicsUpdraftEventData;
  65773. /**
  65774. * Enables the updraft.
  65775. */
  65776. enable(): void;
  65777. /**
  65778. * Disables the updraft.
  65779. */
  65780. disable(): void;
  65781. /**
  65782. * Disposes the cylinder.
  65783. * @param force Specifies if the updraft should be disposed by force
  65784. */
  65785. dispose(force?: boolean): void;
  65786. private getImpostorHitData;
  65787. private _tick;
  65788. /*** Helpers ***/
  65789. private _prepareCylinder;
  65790. private _intersectsWithCylinder;
  65791. }
  65792. /**
  65793. * Represents a physics vortex event
  65794. */
  65795. class PhysicsVortexEvent {
  65796. private _scene;
  65797. private _origin;
  65798. private _options;
  65799. private _physicsEngine;
  65800. private _originTop;
  65801. private _tickCallback;
  65802. private _cylinder;
  65803. private _cylinderPosition;
  65804. private _dataFetched;
  65805. /**
  65806. * Initializes the physics vortex event
  65807. * @param _scene The BabylonJS scene
  65808. * @param _origin The origin position of the vortex
  65809. * @param _options The options for the vortex event
  65810. */
  65811. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  65812. /**
  65813. * Returns the data related to the vortex event (cylinder).
  65814. * @returns The physics vortex event data
  65815. */
  65816. getData(): PhysicsVortexEventData;
  65817. /**
  65818. * Enables the vortex.
  65819. */
  65820. enable(): void;
  65821. /**
  65822. * Disables the cortex.
  65823. */
  65824. disable(): void;
  65825. /**
  65826. * Disposes the sphere.
  65827. * @param force
  65828. */
  65829. dispose(force?: boolean): void;
  65830. private getImpostorHitData;
  65831. private _tick;
  65832. /*** Helpers ***/
  65833. private _prepareCylinder;
  65834. private _intersectsWithCylinder;
  65835. }
  65836. /**
  65837. * Options fot the radial explosion event
  65838. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65839. */
  65840. export class PhysicsRadialExplosionEventOptions {
  65841. /**
  65842. * The radius of the sphere for the radial explosion.
  65843. */
  65844. radius: number;
  65845. /**
  65846. * The strenth of the explosion.
  65847. */
  65848. strength: number;
  65849. /**
  65850. * The strenght of the force in correspondence to the distance of the affected object
  65851. */
  65852. falloff: PhysicsRadialImpulseFalloff;
  65853. /**
  65854. * Sphere options for the radial explosion.
  65855. */
  65856. sphere: {
  65857. segments: number;
  65858. diameter: number;
  65859. };
  65860. /**
  65861. * Sphere options for the radial explosion.
  65862. */
  65863. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  65864. }
  65865. /**
  65866. * Options fot the updraft event
  65867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65868. */
  65869. export class PhysicsUpdraftEventOptions {
  65870. /**
  65871. * The radius of the cylinder for the vortex
  65872. */
  65873. radius: number;
  65874. /**
  65875. * The strenth of the updraft.
  65876. */
  65877. strength: number;
  65878. /**
  65879. * The height of the cylinder for the updraft.
  65880. */
  65881. height: number;
  65882. /**
  65883. * The mode for the the updraft.
  65884. */
  65885. updraftMode: PhysicsUpdraftMode;
  65886. }
  65887. /**
  65888. * Options fot the vortex event
  65889. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65890. */
  65891. export class PhysicsVortexEventOptions {
  65892. /**
  65893. * The radius of the cylinder for the vortex
  65894. */
  65895. radius: number;
  65896. /**
  65897. * The strenth of the vortex.
  65898. */
  65899. strength: number;
  65900. /**
  65901. * The height of the cylinder for the vortex.
  65902. */
  65903. height: number;
  65904. /**
  65905. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  65906. */
  65907. centripetalForceThreshold: number;
  65908. /**
  65909. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  65910. */
  65911. centripetalForceMultiplier: number;
  65912. /**
  65913. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  65914. */
  65915. centrifugalForceMultiplier: number;
  65916. /**
  65917. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  65918. */
  65919. updraftForceMultiplier: number;
  65920. }
  65921. /**
  65922. * The strenght of the force in correspondence to the distance of the affected object
  65923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65924. */
  65925. export enum PhysicsRadialImpulseFalloff {
  65926. /** Defines that impulse is constant in strength across it's whole radius */
  65927. Constant = 0,
  65928. /** Defines that impulse gets weaker if it's further from the origin */
  65929. Linear = 1
  65930. }
  65931. /**
  65932. * The strength of the force in correspondence to the distance of the affected object
  65933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65934. */
  65935. export enum PhysicsUpdraftMode {
  65936. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  65937. Center = 0,
  65938. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  65939. Perpendicular = 1
  65940. }
  65941. /**
  65942. * Interface for a physics hit data
  65943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65944. */
  65945. export interface PhysicsHitData {
  65946. /**
  65947. * The force applied at the contact point
  65948. */
  65949. force: Vector3;
  65950. /**
  65951. * The contact point
  65952. */
  65953. contactPoint: Vector3;
  65954. /**
  65955. * The distance from the origin to the contact point
  65956. */
  65957. distanceFromOrigin: number;
  65958. }
  65959. /**
  65960. * Interface for radial explosion event data
  65961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65962. */
  65963. export interface PhysicsRadialExplosionEventData {
  65964. /**
  65965. * A sphere used for the radial explosion event
  65966. */
  65967. sphere: Mesh;
  65968. }
  65969. /**
  65970. * Interface for gravitational field event data
  65971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65972. */
  65973. export interface PhysicsGravitationalFieldEventData {
  65974. /**
  65975. * A sphere mesh used for the gravitational field event
  65976. */
  65977. sphere: Mesh;
  65978. }
  65979. /**
  65980. * Interface for updraft event data
  65981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65982. */
  65983. export interface PhysicsUpdraftEventData {
  65984. /**
  65985. * A cylinder used for the updraft event
  65986. */
  65987. cylinder: Mesh;
  65988. }
  65989. /**
  65990. * Interface for vortex event data
  65991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  65992. */
  65993. export interface PhysicsVortexEventData {
  65994. /**
  65995. * A cylinder used for the vortex event
  65996. */
  65997. cylinder: Mesh;
  65998. }
  65999. /**
  66000. * Interface for an affected physics impostor
  66001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66002. */
  66003. export interface PhysicsAffectedImpostorWithData {
  66004. /**
  66005. * The impostor affected by the effect
  66006. */
  66007. impostor: PhysicsImpostor;
  66008. /**
  66009. * The data about the hit/horce from the explosion
  66010. */
  66011. hitData: PhysicsHitData;
  66012. }
  66013. }
  66014. declare module "babylonjs/Physics/Plugins/index" {
  66015. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  66016. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  66017. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  66018. }
  66019. declare module "babylonjs/Physics/index" {
  66020. export * from "babylonjs/Physics/IPhysicsEngine";
  66021. export * from "babylonjs/Physics/physicsEngine";
  66022. export * from "babylonjs/Physics/physicsEngineComponent";
  66023. export * from "babylonjs/Physics/physicsHelper";
  66024. export * from "babylonjs/Physics/physicsImpostor";
  66025. export * from "babylonjs/Physics/physicsJoint";
  66026. export * from "babylonjs/Physics/Plugins/index";
  66027. }
  66028. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  66029. /** @hidden */
  66030. export var blackAndWhitePixelShader: {
  66031. name: string;
  66032. shader: string;
  66033. };
  66034. }
  66035. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  66036. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66037. import { Camera } from "babylonjs/Cameras/camera";
  66038. import { Engine } from "babylonjs/Engines/engine";
  66039. import "babylonjs/Shaders/blackAndWhite.fragment";
  66040. /**
  66041. * Post process used to render in black and white
  66042. */
  66043. export class BlackAndWhitePostProcess extends PostProcess {
  66044. /**
  66045. * Linear about to convert he result to black and white (default: 1)
  66046. */
  66047. degree: number;
  66048. /**
  66049. * Creates a black and white post process
  66050. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  66051. * @param name The name of the effect.
  66052. * @param options The required width/height ratio to downsize to before computing the render pass.
  66053. * @param camera The camera to apply the render pass to.
  66054. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66055. * @param engine The engine which the post process will be applied. (default: current engine)
  66056. * @param reusable If the post process can be reused on the same frame. (default: false)
  66057. */
  66058. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66059. }
  66060. }
  66061. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  66062. import { Nullable } from "babylonjs/types";
  66063. import { Camera } from "babylonjs/Cameras/camera";
  66064. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66065. import { Engine } from "babylonjs/Engines/engine";
  66066. /**
  66067. * This represents a set of one or more post processes in Babylon.
  66068. * A post process can be used to apply a shader to a texture after it is rendered.
  66069. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  66070. */
  66071. export class PostProcessRenderEffect {
  66072. private _postProcesses;
  66073. private _getPostProcesses;
  66074. private _singleInstance;
  66075. private _cameras;
  66076. private _indicesForCamera;
  66077. /**
  66078. * Name of the effect
  66079. * @hidden
  66080. */
  66081. _name: string;
  66082. /**
  66083. * Instantiates a post process render effect.
  66084. * A post process can be used to apply a shader to a texture after it is rendered.
  66085. * @param engine The engine the effect is tied to
  66086. * @param name The name of the effect
  66087. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  66088. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  66089. */
  66090. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  66091. /**
  66092. * Checks if all the post processes in the effect are supported.
  66093. */
  66094. get isSupported(): boolean;
  66095. /**
  66096. * Updates the current state of the effect
  66097. * @hidden
  66098. */
  66099. _update(): void;
  66100. /**
  66101. * Attaches the effect on cameras
  66102. * @param cameras The camera to attach to.
  66103. * @hidden
  66104. */
  66105. _attachCameras(cameras: Camera): void;
  66106. /**
  66107. * Attaches the effect on cameras
  66108. * @param cameras The camera to attach to.
  66109. * @hidden
  66110. */
  66111. _attachCameras(cameras: Camera[]): void;
  66112. /**
  66113. * Detaches the effect on cameras
  66114. * @param cameras The camera to detatch from.
  66115. * @hidden
  66116. */
  66117. _detachCameras(cameras: Camera): void;
  66118. /**
  66119. * Detatches the effect on cameras
  66120. * @param cameras The camera to detatch from.
  66121. * @hidden
  66122. */
  66123. _detachCameras(cameras: Camera[]): void;
  66124. /**
  66125. * Enables the effect on given cameras
  66126. * @param cameras The camera to enable.
  66127. * @hidden
  66128. */
  66129. _enable(cameras: Camera): void;
  66130. /**
  66131. * Enables the effect on given cameras
  66132. * @param cameras The camera to enable.
  66133. * @hidden
  66134. */
  66135. _enable(cameras: Nullable<Camera[]>): void;
  66136. /**
  66137. * Disables the effect on the given cameras
  66138. * @param cameras The camera to disable.
  66139. * @hidden
  66140. */
  66141. _disable(cameras: Camera): void;
  66142. /**
  66143. * Disables the effect on the given cameras
  66144. * @param cameras The camera to disable.
  66145. * @hidden
  66146. */
  66147. _disable(cameras: Nullable<Camera[]>): void;
  66148. /**
  66149. * Gets a list of the post processes contained in the effect.
  66150. * @param camera The camera to get the post processes on.
  66151. * @returns The list of the post processes in the effect.
  66152. */
  66153. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  66154. }
  66155. }
  66156. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  66157. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66158. /** @hidden */
  66159. export var extractHighlightsPixelShader: {
  66160. name: string;
  66161. shader: string;
  66162. };
  66163. }
  66164. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  66165. import { Nullable } from "babylonjs/types";
  66166. import { Camera } from "babylonjs/Cameras/camera";
  66167. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66168. import { Engine } from "babylonjs/Engines/engine";
  66169. import "babylonjs/Shaders/extractHighlights.fragment";
  66170. /**
  66171. * 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.
  66172. */
  66173. export class ExtractHighlightsPostProcess extends PostProcess {
  66174. /**
  66175. * The luminance threshold, pixels below this value will be set to black.
  66176. */
  66177. threshold: number;
  66178. /** @hidden */
  66179. _exposure: number;
  66180. /**
  66181. * Post process which has the input texture to be used when performing highlight extraction
  66182. * @hidden
  66183. */
  66184. _inputPostProcess: Nullable<PostProcess>;
  66185. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66186. }
  66187. }
  66188. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  66189. /** @hidden */
  66190. export var bloomMergePixelShader: {
  66191. name: string;
  66192. shader: string;
  66193. };
  66194. }
  66195. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  66196. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66197. import { Nullable } from "babylonjs/types";
  66198. import { Engine } from "babylonjs/Engines/engine";
  66199. import { Camera } from "babylonjs/Cameras/camera";
  66200. import "babylonjs/Shaders/bloomMerge.fragment";
  66201. /**
  66202. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66203. */
  66204. export class BloomMergePostProcess extends PostProcess {
  66205. /** Weight of the bloom to be added to the original input. */
  66206. weight: number;
  66207. /**
  66208. * Creates a new instance of @see BloomMergePostProcess
  66209. * @param name The name of the effect.
  66210. * @param originalFromInput Post process which's input will be used for the merge.
  66211. * @param blurred Blurred highlights post process which's output will be used.
  66212. * @param weight Weight of the bloom to be added to the original input.
  66213. * @param options The required width/height ratio to downsize to before computing the render pass.
  66214. * @param camera The camera to apply the render pass to.
  66215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66216. * @param engine The engine which the post process will be applied. (default: current engine)
  66217. * @param reusable If the post process can be reused on the same frame. (default: false)
  66218. * @param textureType Type of textures used when performing the post process. (default: 0)
  66219. * @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)
  66220. */
  66221. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  66222. /** Weight of the bloom to be added to the original input. */
  66223. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66224. }
  66225. }
  66226. declare module "babylonjs/PostProcesses/bloomEffect" {
  66227. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66228. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66229. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  66230. import { Camera } from "babylonjs/Cameras/camera";
  66231. import { Scene } from "babylonjs/scene";
  66232. /**
  66233. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  66234. */
  66235. export class BloomEffect extends PostProcessRenderEffect {
  66236. private bloomScale;
  66237. /**
  66238. * @hidden Internal
  66239. */
  66240. _effects: Array<PostProcess>;
  66241. /**
  66242. * @hidden Internal
  66243. */
  66244. _downscale: ExtractHighlightsPostProcess;
  66245. private _blurX;
  66246. private _blurY;
  66247. private _merge;
  66248. /**
  66249. * The luminance threshold to find bright areas of the image to bloom.
  66250. */
  66251. get threshold(): number;
  66252. set threshold(value: number);
  66253. /**
  66254. * The strength of the bloom.
  66255. */
  66256. get weight(): number;
  66257. set weight(value: number);
  66258. /**
  66259. * Specifies the size of the bloom blur kernel, relative to the final output size
  66260. */
  66261. get kernel(): number;
  66262. set kernel(value: number);
  66263. /**
  66264. * Creates a new instance of @see BloomEffect
  66265. * @param scene The scene the effect belongs to.
  66266. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  66267. * @param bloomKernel The size of the kernel to be used when applying the blur.
  66268. * @param bloomWeight The the strength of bloom.
  66269. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66270. * @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)
  66271. */
  66272. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  66273. /**
  66274. * Disposes each of the internal effects for a given camera.
  66275. * @param camera The camera to dispose the effect on.
  66276. */
  66277. disposeEffects(camera: Camera): void;
  66278. /**
  66279. * @hidden Internal
  66280. */
  66281. _updateEffects(): void;
  66282. /**
  66283. * Internal
  66284. * @returns if all the contained post processes are ready.
  66285. * @hidden
  66286. */
  66287. _isReady(): boolean;
  66288. }
  66289. }
  66290. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  66291. /** @hidden */
  66292. export var chromaticAberrationPixelShader: {
  66293. name: string;
  66294. shader: string;
  66295. };
  66296. }
  66297. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  66298. import { Vector2 } from "babylonjs/Maths/math.vector";
  66299. import { Nullable } from "babylonjs/types";
  66300. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66301. import { Camera } from "babylonjs/Cameras/camera";
  66302. import { Engine } from "babylonjs/Engines/engine";
  66303. import "babylonjs/Shaders/chromaticAberration.fragment";
  66304. /**
  66305. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  66306. */
  66307. export class ChromaticAberrationPostProcess extends PostProcess {
  66308. /**
  66309. * The amount of seperation of rgb channels (default: 30)
  66310. */
  66311. aberrationAmount: number;
  66312. /**
  66313. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  66314. */
  66315. radialIntensity: number;
  66316. /**
  66317. * 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))
  66318. */
  66319. direction: Vector2;
  66320. /**
  66321. * 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))
  66322. */
  66323. centerPosition: Vector2;
  66324. /**
  66325. * Creates a new instance ChromaticAberrationPostProcess
  66326. * @param name The name of the effect.
  66327. * @param screenWidth The width of the screen to apply the effect on.
  66328. * @param screenHeight The height of the screen to apply the effect on.
  66329. * @param options The required width/height ratio to downsize to before computing the render pass.
  66330. * @param camera The camera to apply the render pass to.
  66331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66332. * @param engine The engine which the post process will be applied. (default: current engine)
  66333. * @param reusable If the post process can be reused on the same frame. (default: false)
  66334. * @param textureType Type of textures used when performing the post process. (default: 0)
  66335. * @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)
  66336. */
  66337. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66338. }
  66339. }
  66340. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  66341. /** @hidden */
  66342. export var circleOfConfusionPixelShader: {
  66343. name: string;
  66344. shader: string;
  66345. };
  66346. }
  66347. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  66348. import { Nullable } from "babylonjs/types";
  66349. import { Engine } from "babylonjs/Engines/engine";
  66350. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66351. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66352. import { Camera } from "babylonjs/Cameras/camera";
  66353. import "babylonjs/Shaders/circleOfConfusion.fragment";
  66354. /**
  66355. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  66356. */
  66357. export class CircleOfConfusionPostProcess extends PostProcess {
  66358. /**
  66359. * 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.
  66360. */
  66361. lensSize: number;
  66362. /**
  66363. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66364. */
  66365. fStop: number;
  66366. /**
  66367. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66368. */
  66369. focusDistance: number;
  66370. /**
  66371. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  66372. */
  66373. focalLength: number;
  66374. private _depthTexture;
  66375. /**
  66376. * Creates a new instance CircleOfConfusionPostProcess
  66377. * @param name The name of the effect.
  66378. * @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.
  66379. * @param options The required width/height ratio to downsize to before computing the render pass.
  66380. * @param camera The camera to apply the render pass to.
  66381. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66382. * @param engine The engine which the post process will be applied. (default: current engine)
  66383. * @param reusable If the post process can be reused on the same frame. (default: false)
  66384. * @param textureType Type of textures used when performing the post process. (default: 0)
  66385. * @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)
  66386. */
  66387. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66388. /**
  66389. * 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.
  66390. */
  66391. set depthTexture(value: RenderTargetTexture);
  66392. }
  66393. }
  66394. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  66395. /** @hidden */
  66396. export var colorCorrectionPixelShader: {
  66397. name: string;
  66398. shader: string;
  66399. };
  66400. }
  66401. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  66402. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66403. import { Engine } from "babylonjs/Engines/engine";
  66404. import { Camera } from "babylonjs/Cameras/camera";
  66405. import "babylonjs/Shaders/colorCorrection.fragment";
  66406. /**
  66407. *
  66408. * This post-process allows the modification of rendered colors by using
  66409. * a 'look-up table' (LUT). This effect is also called Color Grading.
  66410. *
  66411. * The object needs to be provided an url to a texture containing the color
  66412. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  66413. * Use an image editing software to tweak the LUT to match your needs.
  66414. *
  66415. * For an example of a color LUT, see here:
  66416. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  66417. * For explanations on color grading, see here:
  66418. * @see http://udn.epicgames.com/Three/ColorGrading.html
  66419. *
  66420. */
  66421. export class ColorCorrectionPostProcess extends PostProcess {
  66422. private _colorTableTexture;
  66423. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66424. }
  66425. }
  66426. declare module "babylonjs/Shaders/convolution.fragment" {
  66427. /** @hidden */
  66428. export var convolutionPixelShader: {
  66429. name: string;
  66430. shader: string;
  66431. };
  66432. }
  66433. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  66434. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66435. import { Nullable } from "babylonjs/types";
  66436. import { Camera } from "babylonjs/Cameras/camera";
  66437. import { Engine } from "babylonjs/Engines/engine";
  66438. import "babylonjs/Shaders/convolution.fragment";
  66439. /**
  66440. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  66441. * input texture to perform effects such as edge detection or sharpening
  66442. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  66443. */
  66444. export class ConvolutionPostProcess extends PostProcess {
  66445. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66446. kernel: number[];
  66447. /**
  66448. * Creates a new instance ConvolutionPostProcess
  66449. * @param name The name of the effect.
  66450. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  66451. * @param options The required width/height ratio to downsize to before computing the render pass.
  66452. * @param camera The camera to apply the render pass to.
  66453. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66454. * @param engine The engine which the post process will be applied. (default: current engine)
  66455. * @param reusable If the post process can be reused on the same frame. (default: false)
  66456. * @param textureType Type of textures used when performing the post process. (default: 0)
  66457. */
  66458. constructor(name: string,
  66459. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  66460. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66461. /**
  66462. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66463. */
  66464. static EdgeDetect0Kernel: number[];
  66465. /**
  66466. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66467. */
  66468. static EdgeDetect1Kernel: number[];
  66469. /**
  66470. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66471. */
  66472. static EdgeDetect2Kernel: number[];
  66473. /**
  66474. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66475. */
  66476. static SharpenKernel: number[];
  66477. /**
  66478. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66479. */
  66480. static EmbossKernel: number[];
  66481. /**
  66482. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  66483. */
  66484. static GaussianKernel: number[];
  66485. }
  66486. }
  66487. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  66488. import { Nullable } from "babylonjs/types";
  66489. import { Vector2 } from "babylonjs/Maths/math.vector";
  66490. import { Camera } from "babylonjs/Cameras/camera";
  66491. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66492. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  66493. import { Engine } from "babylonjs/Engines/engine";
  66494. import { Scene } from "babylonjs/scene";
  66495. /**
  66496. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  66497. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  66498. * based on samples that have a large difference in distance than the center pixel.
  66499. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  66500. */
  66501. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  66502. direction: Vector2;
  66503. /**
  66504. * Creates a new instance CircleOfConfusionPostProcess
  66505. * @param name The name of the effect.
  66506. * @param scene The scene the effect belongs to.
  66507. * @param direction The direction the blur should be applied.
  66508. * @param kernel The size of the kernel used to blur.
  66509. * @param options The required width/height ratio to downsize to before computing the render pass.
  66510. * @param camera The camera to apply the render pass to.
  66511. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  66512. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  66513. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66514. * @param engine The engine which the post process will be applied. (default: current engine)
  66515. * @param reusable If the post process can be reused on the same frame. (default: false)
  66516. * @param textureType Type of textures used when performing the post process. (default: 0)
  66517. * @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)
  66518. */
  66519. 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);
  66520. }
  66521. }
  66522. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  66523. /** @hidden */
  66524. export var depthOfFieldMergePixelShader: {
  66525. name: string;
  66526. shader: string;
  66527. };
  66528. }
  66529. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  66530. import { Nullable } from "babylonjs/types";
  66531. import { Camera } from "babylonjs/Cameras/camera";
  66532. import { Effect } from "babylonjs/Materials/effect";
  66533. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66534. import { Engine } from "babylonjs/Engines/engine";
  66535. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  66536. /**
  66537. * Options to be set when merging outputs from the default pipeline.
  66538. */
  66539. export class DepthOfFieldMergePostProcessOptions {
  66540. /**
  66541. * The original image to merge on top of
  66542. */
  66543. originalFromInput: PostProcess;
  66544. /**
  66545. * Parameters to perform the merge of the depth of field effect
  66546. */
  66547. depthOfField?: {
  66548. circleOfConfusion: PostProcess;
  66549. blurSteps: Array<PostProcess>;
  66550. };
  66551. /**
  66552. * Parameters to perform the merge of bloom effect
  66553. */
  66554. bloom?: {
  66555. blurred: PostProcess;
  66556. weight: number;
  66557. };
  66558. }
  66559. /**
  66560. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  66561. */
  66562. export class DepthOfFieldMergePostProcess extends PostProcess {
  66563. private blurSteps;
  66564. /**
  66565. * Creates a new instance of DepthOfFieldMergePostProcess
  66566. * @param name The name of the effect.
  66567. * @param originalFromInput Post process which's input will be used for the merge.
  66568. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  66569. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  66570. * @param options The required width/height ratio to downsize to before computing the render pass.
  66571. * @param camera The camera to apply the render pass to.
  66572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66573. * @param engine The engine which the post process will be applied. (default: current engine)
  66574. * @param reusable If the post process can be reused on the same frame. (default: false)
  66575. * @param textureType Type of textures used when performing the post process. (default: 0)
  66576. * @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)
  66577. */
  66578. 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);
  66579. /**
  66580. * Updates the effect with the current post process compile time values and recompiles the shader.
  66581. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  66582. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  66583. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  66584. * @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
  66585. * @param onCompiled Called when the shader has been compiled.
  66586. * @param onError Called if there is an error when compiling a shader.
  66587. */
  66588. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  66589. }
  66590. }
  66591. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  66592. import { Nullable } from "babylonjs/types";
  66593. import { Camera } from "babylonjs/Cameras/camera";
  66594. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66595. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  66596. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  66597. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  66598. import { Scene } from "babylonjs/scene";
  66599. /**
  66600. * Specifies the level of max blur that should be applied when using the depth of field effect
  66601. */
  66602. export enum DepthOfFieldEffectBlurLevel {
  66603. /**
  66604. * Subtle blur
  66605. */
  66606. Low = 0,
  66607. /**
  66608. * Medium blur
  66609. */
  66610. Medium = 1,
  66611. /**
  66612. * Large blur
  66613. */
  66614. High = 2
  66615. }
  66616. /**
  66617. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  66618. */
  66619. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  66620. private _circleOfConfusion;
  66621. /**
  66622. * @hidden Internal, blurs from high to low
  66623. */
  66624. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  66625. private _depthOfFieldBlurY;
  66626. private _dofMerge;
  66627. /**
  66628. * @hidden Internal post processes in depth of field effect
  66629. */
  66630. _effects: Array<PostProcess>;
  66631. /**
  66632. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  66633. */
  66634. set focalLength(value: number);
  66635. get focalLength(): number;
  66636. /**
  66637. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  66638. */
  66639. set fStop(value: number);
  66640. get fStop(): number;
  66641. /**
  66642. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  66643. */
  66644. set focusDistance(value: number);
  66645. get focusDistance(): number;
  66646. /**
  66647. * 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.
  66648. */
  66649. set lensSize(value: number);
  66650. get lensSize(): number;
  66651. /**
  66652. * Creates a new instance DepthOfFieldEffect
  66653. * @param scene The scene the effect belongs to.
  66654. * @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.
  66655. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  66656. * @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)
  66657. */
  66658. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  66659. /**
  66660. * Get the current class name of the current effet
  66661. * @returns "DepthOfFieldEffect"
  66662. */
  66663. getClassName(): string;
  66664. /**
  66665. * 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.
  66666. */
  66667. set depthTexture(value: RenderTargetTexture);
  66668. /**
  66669. * Disposes each of the internal effects for a given camera.
  66670. * @param camera The camera to dispose the effect on.
  66671. */
  66672. disposeEffects(camera: Camera): void;
  66673. /**
  66674. * @hidden Internal
  66675. */
  66676. _updateEffects(): void;
  66677. /**
  66678. * Internal
  66679. * @returns if all the contained post processes are ready.
  66680. * @hidden
  66681. */
  66682. _isReady(): boolean;
  66683. }
  66684. }
  66685. declare module "babylonjs/Shaders/displayPass.fragment" {
  66686. /** @hidden */
  66687. export var displayPassPixelShader: {
  66688. name: string;
  66689. shader: string;
  66690. };
  66691. }
  66692. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  66693. import { Nullable } from "babylonjs/types";
  66694. import { Camera } from "babylonjs/Cameras/camera";
  66695. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66696. import { Engine } from "babylonjs/Engines/engine";
  66697. import "babylonjs/Shaders/displayPass.fragment";
  66698. /**
  66699. * DisplayPassPostProcess which produces an output the same as it's input
  66700. */
  66701. export class DisplayPassPostProcess extends PostProcess {
  66702. /**
  66703. * Creates the DisplayPassPostProcess
  66704. * @param name The name of the effect.
  66705. * @param options The required width/height ratio to downsize to before computing the render pass.
  66706. * @param camera The camera to apply the render pass to.
  66707. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66708. * @param engine The engine which the post process will be applied. (default: current engine)
  66709. * @param reusable If the post process can be reused on the same frame. (default: false)
  66710. */
  66711. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66712. }
  66713. }
  66714. declare module "babylonjs/Shaders/filter.fragment" {
  66715. /** @hidden */
  66716. export var filterPixelShader: {
  66717. name: string;
  66718. shader: string;
  66719. };
  66720. }
  66721. declare module "babylonjs/PostProcesses/filterPostProcess" {
  66722. import { Nullable } from "babylonjs/types";
  66723. import { Matrix } from "babylonjs/Maths/math.vector";
  66724. import { Camera } from "babylonjs/Cameras/camera";
  66725. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66726. import { Engine } from "babylonjs/Engines/engine";
  66727. import "babylonjs/Shaders/filter.fragment";
  66728. /**
  66729. * Applies a kernel filter to the image
  66730. */
  66731. export class FilterPostProcess extends PostProcess {
  66732. /** The matrix to be applied to the image */
  66733. kernelMatrix: Matrix;
  66734. /**
  66735. *
  66736. * @param name The name of the effect.
  66737. * @param kernelMatrix The matrix to be applied to the image
  66738. * @param options The required width/height ratio to downsize to before computing the render pass.
  66739. * @param camera The camera to apply the render pass to.
  66740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66741. * @param engine The engine which the post process will be applied. (default: current engine)
  66742. * @param reusable If the post process can be reused on the same frame. (default: false)
  66743. */
  66744. constructor(name: string,
  66745. /** The matrix to be applied to the image */
  66746. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  66747. }
  66748. }
  66749. declare module "babylonjs/Shaders/fxaa.fragment" {
  66750. /** @hidden */
  66751. export var fxaaPixelShader: {
  66752. name: string;
  66753. shader: string;
  66754. };
  66755. }
  66756. declare module "babylonjs/Shaders/fxaa.vertex" {
  66757. /** @hidden */
  66758. export var fxaaVertexShader: {
  66759. name: string;
  66760. shader: string;
  66761. };
  66762. }
  66763. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  66764. import { Nullable } from "babylonjs/types";
  66765. import { Camera } from "babylonjs/Cameras/camera";
  66766. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66767. import { Engine } from "babylonjs/Engines/engine";
  66768. import "babylonjs/Shaders/fxaa.fragment";
  66769. import "babylonjs/Shaders/fxaa.vertex";
  66770. /**
  66771. * Fxaa post process
  66772. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  66773. */
  66774. export class FxaaPostProcess extends PostProcess {
  66775. /** @hidden */
  66776. texelWidth: number;
  66777. /** @hidden */
  66778. texelHeight: number;
  66779. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66780. private _getDefines;
  66781. }
  66782. }
  66783. declare module "babylonjs/Shaders/grain.fragment" {
  66784. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66785. /** @hidden */
  66786. export var grainPixelShader: {
  66787. name: string;
  66788. shader: string;
  66789. };
  66790. }
  66791. declare module "babylonjs/PostProcesses/grainPostProcess" {
  66792. import { Nullable } from "babylonjs/types";
  66793. import { Camera } from "babylonjs/Cameras/camera";
  66794. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66795. import { Engine } from "babylonjs/Engines/engine";
  66796. import "babylonjs/Shaders/grain.fragment";
  66797. /**
  66798. * The GrainPostProcess adds noise to the image at mid luminance levels
  66799. */
  66800. export class GrainPostProcess extends PostProcess {
  66801. /**
  66802. * The intensity of the grain added (default: 30)
  66803. */
  66804. intensity: number;
  66805. /**
  66806. * If the grain should be randomized on every frame
  66807. */
  66808. animated: boolean;
  66809. /**
  66810. * Creates a new instance of @see GrainPostProcess
  66811. * @param name The name of the effect.
  66812. * @param options The required width/height ratio to downsize to before computing the render pass.
  66813. * @param camera The camera to apply the render pass to.
  66814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66815. * @param engine The engine which the post process will be applied. (default: current engine)
  66816. * @param reusable If the post process can be reused on the same frame. (default: false)
  66817. * @param textureType Type of textures used when performing the post process. (default: 0)
  66818. * @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)
  66819. */
  66820. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  66821. }
  66822. }
  66823. declare module "babylonjs/Shaders/highlights.fragment" {
  66824. /** @hidden */
  66825. export var highlightsPixelShader: {
  66826. name: string;
  66827. shader: string;
  66828. };
  66829. }
  66830. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  66831. import { Nullable } from "babylonjs/types";
  66832. import { Camera } from "babylonjs/Cameras/camera";
  66833. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  66834. import { Engine } from "babylonjs/Engines/engine";
  66835. import "babylonjs/Shaders/highlights.fragment";
  66836. /**
  66837. * Extracts highlights from the image
  66838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66839. */
  66840. export class HighlightsPostProcess extends PostProcess {
  66841. /**
  66842. * Extracts highlights from the image
  66843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  66844. * @param name The name of the effect.
  66845. * @param options The required width/height ratio to downsize to before computing the render pass.
  66846. * @param camera The camera to apply the render pass to.
  66847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  66848. * @param engine The engine which the post process will be applied. (default: current engine)
  66849. * @param reusable If the post process can be reused on the same frame. (default: false)
  66850. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  66851. */
  66852. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  66853. }
  66854. }
  66855. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  66856. /** @hidden */
  66857. export var mrtFragmentDeclaration: {
  66858. name: string;
  66859. shader: string;
  66860. };
  66861. }
  66862. declare module "babylonjs/Shaders/geometry.fragment" {
  66863. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  66864. /** @hidden */
  66865. export var geometryPixelShader: {
  66866. name: string;
  66867. shader: string;
  66868. };
  66869. }
  66870. declare module "babylonjs/Shaders/geometry.vertex" {
  66871. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66872. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66873. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66874. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  66875. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  66876. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  66877. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66878. /** @hidden */
  66879. export var geometryVertexShader: {
  66880. name: string;
  66881. shader: string;
  66882. };
  66883. }
  66884. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  66885. import { Matrix } from "babylonjs/Maths/math.vector";
  66886. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66887. import { Mesh } from "babylonjs/Meshes/mesh";
  66888. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  66889. import { Effect } from "babylonjs/Materials/effect";
  66890. import { Scene } from "babylonjs/scene";
  66891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66892. import "babylonjs/Shaders/geometry.fragment";
  66893. import "babylonjs/Shaders/geometry.vertex";
  66894. /** @hidden */
  66895. interface ISavedTransformationMatrix {
  66896. world: Matrix;
  66897. viewProjection: Matrix;
  66898. }
  66899. /**
  66900. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  66901. */
  66902. export class GeometryBufferRenderer {
  66903. /**
  66904. * Constant used to retrieve the position texture index in the G-Buffer textures array
  66905. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  66906. */
  66907. static readonly POSITION_TEXTURE_TYPE: number;
  66908. /**
  66909. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  66910. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  66911. */
  66912. static readonly VELOCITY_TEXTURE_TYPE: number;
  66913. /**
  66914. * Dictionary used to store the previous transformation matrices of each rendered mesh
  66915. * in order to compute objects velocities when enableVelocity is set to "true"
  66916. * @hidden
  66917. */
  66918. _previousTransformationMatrices: {
  66919. [index: number]: ISavedTransformationMatrix;
  66920. };
  66921. /**
  66922. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  66923. * in order to compute objects velocities when enableVelocity is set to "true"
  66924. * @hidden
  66925. */
  66926. _previousBonesTransformationMatrices: {
  66927. [index: number]: Float32Array;
  66928. };
  66929. /**
  66930. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  66931. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  66932. */
  66933. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  66934. private _scene;
  66935. private _multiRenderTarget;
  66936. private _ratio;
  66937. private _enablePosition;
  66938. private _enableVelocity;
  66939. private _positionIndex;
  66940. private _velocityIndex;
  66941. protected _effect: Effect;
  66942. protected _cachedDefines: string;
  66943. /**
  66944. * Set the render list (meshes to be rendered) used in the G buffer.
  66945. */
  66946. set renderList(meshes: Mesh[]);
  66947. /**
  66948. * Gets wether or not G buffer are supported by the running hardware.
  66949. * This requires draw buffer supports
  66950. */
  66951. get isSupported(): boolean;
  66952. /**
  66953. * Returns the index of the given texture type in the G-Buffer textures array
  66954. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  66955. * @returns the index of the given texture type in the G-Buffer textures array
  66956. */
  66957. getTextureIndex(textureType: number): number;
  66958. /**
  66959. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  66960. */
  66961. get enablePosition(): boolean;
  66962. /**
  66963. * Sets whether or not objects positions are enabled for the G buffer.
  66964. */
  66965. set enablePosition(enable: boolean);
  66966. /**
  66967. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  66968. */
  66969. get enableVelocity(): boolean;
  66970. /**
  66971. * Sets wether or not objects velocities are enabled for the G buffer.
  66972. */
  66973. set enableVelocity(enable: boolean);
  66974. /**
  66975. * Gets the scene associated with the buffer.
  66976. */
  66977. get scene(): Scene;
  66978. /**
  66979. * Gets the ratio used by the buffer during its creation.
  66980. * How big is the buffer related to the main canvas.
  66981. */
  66982. get ratio(): number;
  66983. /** @hidden */
  66984. static _SceneComponentInitialization: (scene: Scene) => void;
  66985. /**
  66986. * Creates a new G Buffer for the scene
  66987. * @param scene The scene the buffer belongs to
  66988. * @param ratio How big is the buffer related to the main canvas.
  66989. */
  66990. constructor(scene: Scene, ratio?: number);
  66991. /**
  66992. * Checks wether everything is ready to render a submesh to the G buffer.
  66993. * @param subMesh the submesh to check readiness for
  66994. * @param useInstances is the mesh drawn using instance or not
  66995. * @returns true if ready otherwise false
  66996. */
  66997. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66998. /**
  66999. * Gets the current underlying G Buffer.
  67000. * @returns the buffer
  67001. */
  67002. getGBuffer(): MultiRenderTarget;
  67003. /**
  67004. * Gets the number of samples used to render the buffer (anti aliasing).
  67005. */
  67006. get samples(): number;
  67007. /**
  67008. * Sets the number of samples used to render the buffer (anti aliasing).
  67009. */
  67010. set samples(value: number);
  67011. /**
  67012. * Disposes the renderer and frees up associated resources.
  67013. */
  67014. dispose(): void;
  67015. protected _createRenderTargets(): void;
  67016. private _copyBonesTransformationMatrices;
  67017. }
  67018. }
  67019. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  67020. import { Nullable } from "babylonjs/types";
  67021. import { Scene } from "babylonjs/scene";
  67022. import { ISceneComponent } from "babylonjs/sceneComponent";
  67023. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  67024. module "babylonjs/scene" {
  67025. interface Scene {
  67026. /** @hidden (Backing field) */
  67027. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67028. /**
  67029. * Gets or Sets the current geometry buffer associated to the scene.
  67030. */
  67031. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  67032. /**
  67033. * Enables a GeometryBufferRender and associates it with the scene
  67034. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  67035. * @returns the GeometryBufferRenderer
  67036. */
  67037. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  67038. /**
  67039. * Disables the GeometryBufferRender associated with the scene
  67040. */
  67041. disableGeometryBufferRenderer(): void;
  67042. }
  67043. }
  67044. /**
  67045. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  67046. * in several rendering techniques.
  67047. */
  67048. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  67049. /**
  67050. * The component name helpful to identify the component in the list of scene components.
  67051. */
  67052. readonly name: string;
  67053. /**
  67054. * The scene the component belongs to.
  67055. */
  67056. scene: Scene;
  67057. /**
  67058. * Creates a new instance of the component for the given scene
  67059. * @param scene Defines the scene to register the component in
  67060. */
  67061. constructor(scene: Scene);
  67062. /**
  67063. * Registers the component in a given scene
  67064. */
  67065. register(): void;
  67066. /**
  67067. * Rebuilds the elements related to this component in case of
  67068. * context lost for instance.
  67069. */
  67070. rebuild(): void;
  67071. /**
  67072. * Disposes the component and the associated ressources
  67073. */
  67074. dispose(): void;
  67075. private _gatherRenderTargets;
  67076. }
  67077. }
  67078. declare module "babylonjs/Shaders/motionBlur.fragment" {
  67079. /** @hidden */
  67080. export var motionBlurPixelShader: {
  67081. name: string;
  67082. shader: string;
  67083. };
  67084. }
  67085. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  67086. import { Nullable } from "babylonjs/types";
  67087. import { Camera } from "babylonjs/Cameras/camera";
  67088. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67089. import { Scene } from "babylonjs/scene";
  67090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67091. import "babylonjs/Animations/animatable";
  67092. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  67093. import "babylonjs/Shaders/motionBlur.fragment";
  67094. import { Engine } from "babylonjs/Engines/engine";
  67095. /**
  67096. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  67097. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  67098. * As an example, all you have to do is to create the post-process:
  67099. * var mb = new BABYLON.MotionBlurPostProcess(
  67100. * 'mb', // The name of the effect.
  67101. * scene, // The scene containing the objects to blur according to their velocity.
  67102. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  67103. * camera // The camera to apply the render pass to.
  67104. * );
  67105. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  67106. */
  67107. export class MotionBlurPostProcess extends PostProcess {
  67108. /**
  67109. * Defines how much the image is blurred by the movement. Default value is equal to 1
  67110. */
  67111. motionStrength: number;
  67112. /**
  67113. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  67114. */
  67115. get motionBlurSamples(): number;
  67116. /**
  67117. * Sets the number of iterations to be used for motion blur quality
  67118. */
  67119. set motionBlurSamples(samples: number);
  67120. private _motionBlurSamples;
  67121. private _geometryBufferRenderer;
  67122. /**
  67123. * Creates a new instance MotionBlurPostProcess
  67124. * @param name The name of the effect.
  67125. * @param scene The scene containing the objects to blur according to their velocity.
  67126. * @param options The required width/height ratio to downsize to before computing the render pass.
  67127. * @param camera The camera to apply the render pass to.
  67128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67129. * @param engine The engine which the post process will be applied. (default: current engine)
  67130. * @param reusable If the post process can be reused on the same frame. (default: false)
  67131. * @param textureType Type of textures used when performing the post process. (default: 0)
  67132. * @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)
  67133. */
  67134. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67135. /**
  67136. * Excludes the given skinned mesh from computing bones velocities.
  67137. * 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.
  67138. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  67139. */
  67140. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67141. /**
  67142. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  67143. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  67144. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  67145. */
  67146. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  67147. /**
  67148. * Disposes the post process.
  67149. * @param camera The camera to dispose the post process on.
  67150. */
  67151. dispose(camera?: Camera): void;
  67152. }
  67153. }
  67154. declare module "babylonjs/Shaders/refraction.fragment" {
  67155. /** @hidden */
  67156. export var refractionPixelShader: {
  67157. name: string;
  67158. shader: string;
  67159. };
  67160. }
  67161. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  67162. import { Color3 } from "babylonjs/Maths/math.color";
  67163. import { Camera } from "babylonjs/Cameras/camera";
  67164. import { Texture } from "babylonjs/Materials/Textures/texture";
  67165. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67166. import { Engine } from "babylonjs/Engines/engine";
  67167. import "babylonjs/Shaders/refraction.fragment";
  67168. /**
  67169. * Post process which applies a refractin texture
  67170. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67171. */
  67172. export class RefractionPostProcess extends PostProcess {
  67173. /** the base color of the refraction (used to taint the rendering) */
  67174. color: Color3;
  67175. /** simulated refraction depth */
  67176. depth: number;
  67177. /** the coefficient of the base color (0 to remove base color tainting) */
  67178. colorLevel: number;
  67179. private _refTexture;
  67180. private _ownRefractionTexture;
  67181. /**
  67182. * Gets or sets the refraction texture
  67183. * Please note that you are responsible for disposing the texture if you set it manually
  67184. */
  67185. get refractionTexture(): Texture;
  67186. set refractionTexture(value: Texture);
  67187. /**
  67188. * Initializes the RefractionPostProcess
  67189. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  67190. * @param name The name of the effect.
  67191. * @param refractionTextureUrl Url of the refraction texture to use
  67192. * @param color the base color of the refraction (used to taint the rendering)
  67193. * @param depth simulated refraction depth
  67194. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  67195. * @param camera The camera to apply the render pass to.
  67196. * @param options The required width/height ratio to downsize to before computing the render pass.
  67197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67198. * @param engine The engine which the post process will be applied. (default: current engine)
  67199. * @param reusable If the post process can be reused on the same frame. (default: false)
  67200. */
  67201. constructor(name: string, refractionTextureUrl: string,
  67202. /** the base color of the refraction (used to taint the rendering) */
  67203. color: Color3,
  67204. /** simulated refraction depth */
  67205. depth: number,
  67206. /** the coefficient of the base color (0 to remove base color tainting) */
  67207. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67208. /**
  67209. * Disposes of the post process
  67210. * @param camera Camera to dispose post process on
  67211. */
  67212. dispose(camera: Camera): void;
  67213. }
  67214. }
  67215. declare module "babylonjs/Shaders/sharpen.fragment" {
  67216. /** @hidden */
  67217. export var sharpenPixelShader: {
  67218. name: string;
  67219. shader: string;
  67220. };
  67221. }
  67222. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  67223. import { Nullable } from "babylonjs/types";
  67224. import { Camera } from "babylonjs/Cameras/camera";
  67225. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67226. import "babylonjs/Shaders/sharpen.fragment";
  67227. import { Engine } from "babylonjs/Engines/engine";
  67228. /**
  67229. * The SharpenPostProcess applies a sharpen kernel to every pixel
  67230. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67231. */
  67232. export class SharpenPostProcess extends PostProcess {
  67233. /**
  67234. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  67235. */
  67236. colorAmount: number;
  67237. /**
  67238. * How much sharpness should be applied (default: 0.3)
  67239. */
  67240. edgeAmount: number;
  67241. /**
  67242. * Creates a new instance ConvolutionPostProcess
  67243. * @param name The name of the effect.
  67244. * @param options The required width/height ratio to downsize to before computing the render pass.
  67245. * @param camera The camera to apply the render pass to.
  67246. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67247. * @param engine The engine which the post process will be applied. (default: current engine)
  67248. * @param reusable If the post process can be reused on the same frame. (default: false)
  67249. * @param textureType Type of textures used when performing the post process. (default: 0)
  67250. * @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)
  67251. */
  67252. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67253. }
  67254. }
  67255. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  67256. import { Nullable } from "babylonjs/types";
  67257. import { Camera } from "babylonjs/Cameras/camera";
  67258. import { Engine } from "babylonjs/Engines/engine";
  67259. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67260. import { IInspectable } from "babylonjs/Misc/iInspectable";
  67261. /**
  67262. * PostProcessRenderPipeline
  67263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67264. */
  67265. export class PostProcessRenderPipeline {
  67266. private engine;
  67267. private _renderEffects;
  67268. private _renderEffectsForIsolatedPass;
  67269. /**
  67270. * List of inspectable custom properties (used by the Inspector)
  67271. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67272. */
  67273. inspectableCustomProperties: IInspectable[];
  67274. /**
  67275. * @hidden
  67276. */
  67277. protected _cameras: Camera[];
  67278. /** @hidden */
  67279. _name: string;
  67280. /**
  67281. * Gets pipeline name
  67282. */
  67283. get name(): string;
  67284. /** Gets the list of attached cameras */
  67285. get cameras(): Camera[];
  67286. /**
  67287. * Initializes a PostProcessRenderPipeline
  67288. * @param engine engine to add the pipeline to
  67289. * @param name name of the pipeline
  67290. */
  67291. constructor(engine: Engine, name: string);
  67292. /**
  67293. * Gets the class name
  67294. * @returns "PostProcessRenderPipeline"
  67295. */
  67296. getClassName(): string;
  67297. /**
  67298. * If all the render effects in the pipeline are supported
  67299. */
  67300. get isSupported(): boolean;
  67301. /**
  67302. * Adds an effect to the pipeline
  67303. * @param renderEffect the effect to add
  67304. */
  67305. addEffect(renderEffect: PostProcessRenderEffect): void;
  67306. /** @hidden */
  67307. _rebuild(): void;
  67308. /** @hidden */
  67309. _enableEffect(renderEffectName: string, cameras: Camera): void;
  67310. /** @hidden */
  67311. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  67312. /** @hidden */
  67313. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67314. /** @hidden */
  67315. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  67316. /** @hidden */
  67317. _attachCameras(cameras: Camera, unique: boolean): void;
  67318. /** @hidden */
  67319. _attachCameras(cameras: Camera[], unique: boolean): void;
  67320. /** @hidden */
  67321. _detachCameras(cameras: Camera): void;
  67322. /** @hidden */
  67323. _detachCameras(cameras: Nullable<Camera[]>): void;
  67324. /** @hidden */
  67325. _update(): void;
  67326. /** @hidden */
  67327. _reset(): void;
  67328. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  67329. /**
  67330. * Disposes of the pipeline
  67331. */
  67332. dispose(): void;
  67333. }
  67334. }
  67335. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  67336. import { Camera } from "babylonjs/Cameras/camera";
  67337. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67338. /**
  67339. * PostProcessRenderPipelineManager class
  67340. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67341. */
  67342. export class PostProcessRenderPipelineManager {
  67343. private _renderPipelines;
  67344. /**
  67345. * Initializes a PostProcessRenderPipelineManager
  67346. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67347. */
  67348. constructor();
  67349. /**
  67350. * Gets the list of supported render pipelines
  67351. */
  67352. get supportedPipelines(): PostProcessRenderPipeline[];
  67353. /**
  67354. * Adds a pipeline to the manager
  67355. * @param renderPipeline The pipeline to add
  67356. */
  67357. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  67358. /**
  67359. * Attaches a camera to the pipeline
  67360. * @param renderPipelineName The name of the pipeline to attach to
  67361. * @param cameras the camera to attach
  67362. * @param unique if the camera can be attached multiple times to the pipeline
  67363. */
  67364. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  67365. /**
  67366. * Detaches a camera from the pipeline
  67367. * @param renderPipelineName The name of the pipeline to detach from
  67368. * @param cameras the camera to detach
  67369. */
  67370. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  67371. /**
  67372. * Enables an effect by name on a pipeline
  67373. * @param renderPipelineName the name of the pipeline to enable the effect in
  67374. * @param renderEffectName the name of the effect to enable
  67375. * @param cameras the cameras that the effect should be enabled on
  67376. */
  67377. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67378. /**
  67379. * Disables an effect by name on a pipeline
  67380. * @param renderPipelineName the name of the pipeline to disable the effect in
  67381. * @param renderEffectName the name of the effect to disable
  67382. * @param cameras the cameras that the effect should be disabled on
  67383. */
  67384. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  67385. /**
  67386. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  67387. */
  67388. update(): void;
  67389. /** @hidden */
  67390. _rebuild(): void;
  67391. /**
  67392. * Disposes of the manager and pipelines
  67393. */
  67394. dispose(): void;
  67395. }
  67396. }
  67397. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  67398. import { ISceneComponent } from "babylonjs/sceneComponent";
  67399. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  67400. import { Scene } from "babylonjs/scene";
  67401. module "babylonjs/scene" {
  67402. interface Scene {
  67403. /** @hidden (Backing field) */
  67404. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67405. /**
  67406. * Gets the postprocess render pipeline manager
  67407. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67408. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67409. */
  67410. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  67411. }
  67412. }
  67413. /**
  67414. * Defines the Render Pipeline scene component responsible to rendering pipelines
  67415. */
  67416. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  67417. /**
  67418. * The component name helpfull to identify the component in the list of scene components.
  67419. */
  67420. readonly name: string;
  67421. /**
  67422. * The scene the component belongs to.
  67423. */
  67424. scene: Scene;
  67425. /**
  67426. * Creates a new instance of the component for the given scene
  67427. * @param scene Defines the scene to register the component in
  67428. */
  67429. constructor(scene: Scene);
  67430. /**
  67431. * Registers the component in a given scene
  67432. */
  67433. register(): void;
  67434. /**
  67435. * Rebuilds the elements related to this component in case of
  67436. * context lost for instance.
  67437. */
  67438. rebuild(): void;
  67439. /**
  67440. * Disposes the component and the associated ressources
  67441. */
  67442. dispose(): void;
  67443. private _gatherRenderTargets;
  67444. }
  67445. }
  67446. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  67447. import { Nullable } from "babylonjs/types";
  67448. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  67449. import { Camera } from "babylonjs/Cameras/camera";
  67450. import { IDisposable } from "babylonjs/scene";
  67451. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  67452. import { Scene } from "babylonjs/scene";
  67453. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  67454. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  67455. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  67456. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  67457. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  67458. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67459. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  67460. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67461. import { Animation } from "babylonjs/Animations/animation";
  67462. /**
  67463. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  67464. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  67465. */
  67466. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  67467. private _scene;
  67468. private _camerasToBeAttached;
  67469. /**
  67470. * ID of the sharpen post process,
  67471. */
  67472. private readonly SharpenPostProcessId;
  67473. /**
  67474. * @ignore
  67475. * ID of the image processing post process;
  67476. */
  67477. readonly ImageProcessingPostProcessId: string;
  67478. /**
  67479. * @ignore
  67480. * ID of the Fast Approximate Anti-Aliasing post process;
  67481. */
  67482. readonly FxaaPostProcessId: string;
  67483. /**
  67484. * ID of the chromatic aberration post process,
  67485. */
  67486. private readonly ChromaticAberrationPostProcessId;
  67487. /**
  67488. * ID of the grain post process
  67489. */
  67490. private readonly GrainPostProcessId;
  67491. /**
  67492. * Sharpen post process which will apply a sharpen convolution to enhance edges
  67493. */
  67494. sharpen: SharpenPostProcess;
  67495. private _sharpenEffect;
  67496. private bloom;
  67497. /**
  67498. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  67499. */
  67500. depthOfField: DepthOfFieldEffect;
  67501. /**
  67502. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  67503. */
  67504. fxaa: FxaaPostProcess;
  67505. /**
  67506. * Image post processing pass used to perform operations such as tone mapping or color grading.
  67507. */
  67508. imageProcessing: ImageProcessingPostProcess;
  67509. /**
  67510. * Chromatic aberration post process which will shift rgb colors in the image
  67511. */
  67512. chromaticAberration: ChromaticAberrationPostProcess;
  67513. private _chromaticAberrationEffect;
  67514. /**
  67515. * Grain post process which add noise to the image
  67516. */
  67517. grain: GrainPostProcess;
  67518. private _grainEffect;
  67519. /**
  67520. * Glow post process which adds a glow to emissive areas of the image
  67521. */
  67522. private _glowLayer;
  67523. /**
  67524. * Animations which can be used to tweak settings over a period of time
  67525. */
  67526. animations: Animation[];
  67527. private _imageProcessingConfigurationObserver;
  67528. private _sharpenEnabled;
  67529. private _bloomEnabled;
  67530. private _depthOfFieldEnabled;
  67531. private _depthOfFieldBlurLevel;
  67532. private _fxaaEnabled;
  67533. private _imageProcessingEnabled;
  67534. private _defaultPipelineTextureType;
  67535. private _bloomScale;
  67536. private _chromaticAberrationEnabled;
  67537. private _grainEnabled;
  67538. private _buildAllowed;
  67539. /**
  67540. * Gets active scene
  67541. */
  67542. get scene(): Scene;
  67543. /**
  67544. * Enable or disable the sharpen process from the pipeline
  67545. */
  67546. set sharpenEnabled(enabled: boolean);
  67547. get sharpenEnabled(): boolean;
  67548. private _resizeObserver;
  67549. private _hardwareScaleLevel;
  67550. private _bloomKernel;
  67551. /**
  67552. * Specifies the size of the bloom blur kernel, relative to the final output size
  67553. */
  67554. get bloomKernel(): number;
  67555. set bloomKernel(value: number);
  67556. /**
  67557. * Specifies the weight of the bloom in the final rendering
  67558. */
  67559. private _bloomWeight;
  67560. /**
  67561. * Specifies the luma threshold for the area that will be blurred by the bloom
  67562. */
  67563. private _bloomThreshold;
  67564. private _hdr;
  67565. /**
  67566. * The strength of the bloom.
  67567. */
  67568. set bloomWeight(value: number);
  67569. get bloomWeight(): number;
  67570. /**
  67571. * The strength of the bloom.
  67572. */
  67573. set bloomThreshold(value: number);
  67574. get bloomThreshold(): number;
  67575. /**
  67576. * The scale of the bloom, lower value will provide better performance.
  67577. */
  67578. set bloomScale(value: number);
  67579. get bloomScale(): number;
  67580. /**
  67581. * Enable or disable the bloom from the pipeline
  67582. */
  67583. set bloomEnabled(enabled: boolean);
  67584. get bloomEnabled(): boolean;
  67585. private _rebuildBloom;
  67586. /**
  67587. * If the depth of field is enabled.
  67588. */
  67589. get depthOfFieldEnabled(): boolean;
  67590. set depthOfFieldEnabled(enabled: boolean);
  67591. /**
  67592. * Blur level of the depth of field effect. (Higher blur will effect performance)
  67593. */
  67594. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  67595. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  67596. /**
  67597. * If the anti aliasing is enabled.
  67598. */
  67599. set fxaaEnabled(enabled: boolean);
  67600. get fxaaEnabled(): boolean;
  67601. private _samples;
  67602. /**
  67603. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  67604. */
  67605. set samples(sampleCount: number);
  67606. get samples(): number;
  67607. /**
  67608. * If image processing is enabled.
  67609. */
  67610. set imageProcessingEnabled(enabled: boolean);
  67611. get imageProcessingEnabled(): boolean;
  67612. /**
  67613. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  67614. */
  67615. set glowLayerEnabled(enabled: boolean);
  67616. get glowLayerEnabled(): boolean;
  67617. /**
  67618. * Gets the glow layer (or null if not defined)
  67619. */
  67620. get glowLayer(): Nullable<GlowLayer>;
  67621. /**
  67622. * Enable or disable the chromaticAberration process from the pipeline
  67623. */
  67624. set chromaticAberrationEnabled(enabled: boolean);
  67625. get chromaticAberrationEnabled(): boolean;
  67626. /**
  67627. * Enable or disable the grain process from the pipeline
  67628. */
  67629. set grainEnabled(enabled: boolean);
  67630. get grainEnabled(): boolean;
  67631. /**
  67632. * @constructor
  67633. * @param name - The rendering pipeline name (default: "")
  67634. * @param hdr - If high dynamic range textures should be used (default: true)
  67635. * @param scene - The scene linked to this pipeline (default: the last created scene)
  67636. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  67637. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  67638. */
  67639. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  67640. /**
  67641. * Get the class name
  67642. * @returns "DefaultRenderingPipeline"
  67643. */
  67644. getClassName(): string;
  67645. /**
  67646. * Force the compilation of the entire pipeline.
  67647. */
  67648. prepare(): void;
  67649. private _hasCleared;
  67650. private _prevPostProcess;
  67651. private _prevPrevPostProcess;
  67652. private _setAutoClearAndTextureSharing;
  67653. private _depthOfFieldSceneObserver;
  67654. private _buildPipeline;
  67655. private _disposePostProcesses;
  67656. /**
  67657. * Adds a camera to the pipeline
  67658. * @param camera the camera to be added
  67659. */
  67660. addCamera(camera: Camera): void;
  67661. /**
  67662. * Removes a camera from the pipeline
  67663. * @param camera the camera to remove
  67664. */
  67665. removeCamera(camera: Camera): void;
  67666. /**
  67667. * Dispose of the pipeline and stop all post processes
  67668. */
  67669. dispose(): void;
  67670. /**
  67671. * Serialize the rendering pipeline (Used when exporting)
  67672. * @returns the serialized object
  67673. */
  67674. serialize(): any;
  67675. /**
  67676. * Parse the serialized pipeline
  67677. * @param source Source pipeline.
  67678. * @param scene The scene to load the pipeline to.
  67679. * @param rootUrl The URL of the serialized pipeline.
  67680. * @returns An instantiated pipeline from the serialized object.
  67681. */
  67682. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  67683. }
  67684. }
  67685. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  67686. /** @hidden */
  67687. export var lensHighlightsPixelShader: {
  67688. name: string;
  67689. shader: string;
  67690. };
  67691. }
  67692. declare module "babylonjs/Shaders/depthOfField.fragment" {
  67693. /** @hidden */
  67694. export var depthOfFieldPixelShader: {
  67695. name: string;
  67696. shader: string;
  67697. };
  67698. }
  67699. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  67700. import { Camera } from "babylonjs/Cameras/camera";
  67701. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67702. import { Scene } from "babylonjs/scene";
  67703. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67704. import "babylonjs/Shaders/chromaticAberration.fragment";
  67705. import "babylonjs/Shaders/lensHighlights.fragment";
  67706. import "babylonjs/Shaders/depthOfField.fragment";
  67707. /**
  67708. * BABYLON.JS Chromatic Aberration GLSL Shader
  67709. * Author: Olivier Guyot
  67710. * Separates very slightly R, G and B colors on the edges of the screen
  67711. * Inspired by Francois Tarlier & Martins Upitis
  67712. */
  67713. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  67714. /**
  67715. * @ignore
  67716. * The chromatic aberration PostProcess id in the pipeline
  67717. */
  67718. LensChromaticAberrationEffect: string;
  67719. /**
  67720. * @ignore
  67721. * The highlights enhancing PostProcess id in the pipeline
  67722. */
  67723. HighlightsEnhancingEffect: string;
  67724. /**
  67725. * @ignore
  67726. * The depth-of-field PostProcess id in the pipeline
  67727. */
  67728. LensDepthOfFieldEffect: string;
  67729. private _scene;
  67730. private _depthTexture;
  67731. private _grainTexture;
  67732. private _chromaticAberrationPostProcess;
  67733. private _highlightsPostProcess;
  67734. private _depthOfFieldPostProcess;
  67735. private _edgeBlur;
  67736. private _grainAmount;
  67737. private _chromaticAberration;
  67738. private _distortion;
  67739. private _highlightsGain;
  67740. private _highlightsThreshold;
  67741. private _dofDistance;
  67742. private _dofAperture;
  67743. private _dofDarken;
  67744. private _dofPentagon;
  67745. private _blurNoise;
  67746. /**
  67747. * @constructor
  67748. *
  67749. * Effect parameters are as follow:
  67750. * {
  67751. * chromatic_aberration: number; // from 0 to x (1 for realism)
  67752. * edge_blur: number; // from 0 to x (1 for realism)
  67753. * distortion: number; // from 0 to x (1 for realism)
  67754. * grain_amount: number; // from 0 to 1
  67755. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  67756. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  67757. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  67758. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  67759. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  67760. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  67761. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  67762. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  67763. * }
  67764. * Note: if an effect parameter is unset, effect is disabled
  67765. *
  67766. * @param name The rendering pipeline name
  67767. * @param parameters - An object containing all parameters (see above)
  67768. * @param scene The scene linked to this pipeline
  67769. * @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)
  67770. * @param cameras The array of cameras that the rendering pipeline will be attached to
  67771. */
  67772. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  67773. /**
  67774. * Get the class name
  67775. * @returns "LensRenderingPipeline"
  67776. */
  67777. getClassName(): string;
  67778. /**
  67779. * Gets associated scene
  67780. */
  67781. get scene(): Scene;
  67782. /**
  67783. * Gets or sets the edge blur
  67784. */
  67785. get edgeBlur(): number;
  67786. set edgeBlur(value: number);
  67787. /**
  67788. * Gets or sets the grain amount
  67789. */
  67790. get grainAmount(): number;
  67791. set grainAmount(value: number);
  67792. /**
  67793. * Gets or sets the chromatic aberration amount
  67794. */
  67795. get chromaticAberration(): number;
  67796. set chromaticAberration(value: number);
  67797. /**
  67798. * Gets or sets the depth of field aperture
  67799. */
  67800. get dofAperture(): number;
  67801. set dofAperture(value: number);
  67802. /**
  67803. * Gets or sets the edge distortion
  67804. */
  67805. get edgeDistortion(): number;
  67806. set edgeDistortion(value: number);
  67807. /**
  67808. * Gets or sets the depth of field distortion
  67809. */
  67810. get dofDistortion(): number;
  67811. set dofDistortion(value: number);
  67812. /**
  67813. * Gets or sets the darken out of focus amount
  67814. */
  67815. get darkenOutOfFocus(): number;
  67816. set darkenOutOfFocus(value: number);
  67817. /**
  67818. * Gets or sets a boolean indicating if blur noise is enabled
  67819. */
  67820. get blurNoise(): boolean;
  67821. set blurNoise(value: boolean);
  67822. /**
  67823. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  67824. */
  67825. get pentagonBokeh(): boolean;
  67826. set pentagonBokeh(value: boolean);
  67827. /**
  67828. * Gets or sets the highlight grain amount
  67829. */
  67830. get highlightsGain(): number;
  67831. set highlightsGain(value: number);
  67832. /**
  67833. * Gets or sets the highlight threshold
  67834. */
  67835. get highlightsThreshold(): number;
  67836. set highlightsThreshold(value: number);
  67837. /**
  67838. * Sets the amount of blur at the edges
  67839. * @param amount blur amount
  67840. */
  67841. setEdgeBlur(amount: number): void;
  67842. /**
  67843. * Sets edge blur to 0
  67844. */
  67845. disableEdgeBlur(): void;
  67846. /**
  67847. * Sets the amout of grain
  67848. * @param amount Amount of grain
  67849. */
  67850. setGrainAmount(amount: number): void;
  67851. /**
  67852. * Set grain amount to 0
  67853. */
  67854. disableGrain(): void;
  67855. /**
  67856. * Sets the chromatic aberration amount
  67857. * @param amount amount of chromatic aberration
  67858. */
  67859. setChromaticAberration(amount: number): void;
  67860. /**
  67861. * Sets chromatic aberration amount to 0
  67862. */
  67863. disableChromaticAberration(): void;
  67864. /**
  67865. * Sets the EdgeDistortion amount
  67866. * @param amount amount of EdgeDistortion
  67867. */
  67868. setEdgeDistortion(amount: number): void;
  67869. /**
  67870. * Sets edge distortion to 0
  67871. */
  67872. disableEdgeDistortion(): void;
  67873. /**
  67874. * Sets the FocusDistance amount
  67875. * @param amount amount of FocusDistance
  67876. */
  67877. setFocusDistance(amount: number): void;
  67878. /**
  67879. * Disables depth of field
  67880. */
  67881. disableDepthOfField(): void;
  67882. /**
  67883. * Sets the Aperture amount
  67884. * @param amount amount of Aperture
  67885. */
  67886. setAperture(amount: number): void;
  67887. /**
  67888. * Sets the DarkenOutOfFocus amount
  67889. * @param amount amount of DarkenOutOfFocus
  67890. */
  67891. setDarkenOutOfFocus(amount: number): void;
  67892. private _pentagonBokehIsEnabled;
  67893. /**
  67894. * Creates a pentagon bokeh effect
  67895. */
  67896. enablePentagonBokeh(): void;
  67897. /**
  67898. * Disables the pentagon bokeh effect
  67899. */
  67900. disablePentagonBokeh(): void;
  67901. /**
  67902. * Enables noise blur
  67903. */
  67904. enableNoiseBlur(): void;
  67905. /**
  67906. * Disables noise blur
  67907. */
  67908. disableNoiseBlur(): void;
  67909. /**
  67910. * Sets the HighlightsGain amount
  67911. * @param amount amount of HighlightsGain
  67912. */
  67913. setHighlightsGain(amount: number): void;
  67914. /**
  67915. * Sets the HighlightsThreshold amount
  67916. * @param amount amount of HighlightsThreshold
  67917. */
  67918. setHighlightsThreshold(amount: number): void;
  67919. /**
  67920. * Disables highlights
  67921. */
  67922. disableHighlights(): void;
  67923. /**
  67924. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  67925. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  67926. */
  67927. dispose(disableDepthRender?: boolean): void;
  67928. private _createChromaticAberrationPostProcess;
  67929. private _createHighlightsPostProcess;
  67930. private _createDepthOfFieldPostProcess;
  67931. private _createGrainTexture;
  67932. }
  67933. }
  67934. declare module "babylonjs/Shaders/ssao2.fragment" {
  67935. /** @hidden */
  67936. export var ssao2PixelShader: {
  67937. name: string;
  67938. shader: string;
  67939. };
  67940. }
  67941. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  67942. /** @hidden */
  67943. export var ssaoCombinePixelShader: {
  67944. name: string;
  67945. shader: string;
  67946. };
  67947. }
  67948. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  67949. import { Camera } from "babylonjs/Cameras/camera";
  67950. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  67951. import { Scene } from "babylonjs/scene";
  67952. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  67953. import "babylonjs/Shaders/ssao2.fragment";
  67954. import "babylonjs/Shaders/ssaoCombine.fragment";
  67955. /**
  67956. * Render pipeline to produce ssao effect
  67957. */
  67958. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  67959. /**
  67960. * @ignore
  67961. * The PassPostProcess id in the pipeline that contains the original scene color
  67962. */
  67963. SSAOOriginalSceneColorEffect: string;
  67964. /**
  67965. * @ignore
  67966. * The SSAO PostProcess id in the pipeline
  67967. */
  67968. SSAORenderEffect: string;
  67969. /**
  67970. * @ignore
  67971. * The horizontal blur PostProcess id in the pipeline
  67972. */
  67973. SSAOBlurHRenderEffect: string;
  67974. /**
  67975. * @ignore
  67976. * The vertical blur PostProcess id in the pipeline
  67977. */
  67978. SSAOBlurVRenderEffect: string;
  67979. /**
  67980. * @ignore
  67981. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  67982. */
  67983. SSAOCombineRenderEffect: string;
  67984. /**
  67985. * The output strength of the SSAO post-process. Default value is 1.0.
  67986. */
  67987. totalStrength: number;
  67988. /**
  67989. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  67990. */
  67991. maxZ: number;
  67992. /**
  67993. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  67994. */
  67995. minZAspect: number;
  67996. private _samples;
  67997. /**
  67998. * Number of samples used for the SSAO calculations. Default value is 8
  67999. */
  68000. set samples(n: number);
  68001. get samples(): number;
  68002. private _textureSamples;
  68003. /**
  68004. * Number of samples to use for antialiasing
  68005. */
  68006. set textureSamples(n: number);
  68007. get textureSamples(): number;
  68008. /**
  68009. * Ratio object used for SSAO ratio and blur ratio
  68010. */
  68011. private _ratio;
  68012. /**
  68013. * Dynamically generated sphere sampler.
  68014. */
  68015. private _sampleSphere;
  68016. /**
  68017. * Blur filter offsets
  68018. */
  68019. private _samplerOffsets;
  68020. private _expensiveBlur;
  68021. /**
  68022. * If bilateral blur should be used
  68023. */
  68024. set expensiveBlur(b: boolean);
  68025. get expensiveBlur(): boolean;
  68026. /**
  68027. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  68028. */
  68029. radius: number;
  68030. /**
  68031. * The base color of the SSAO post-process
  68032. * The final result is "base + ssao" between [0, 1]
  68033. */
  68034. base: number;
  68035. /**
  68036. * Support test.
  68037. */
  68038. static get IsSupported(): boolean;
  68039. private _scene;
  68040. private _depthTexture;
  68041. private _normalTexture;
  68042. private _randomTexture;
  68043. private _originalColorPostProcess;
  68044. private _ssaoPostProcess;
  68045. private _blurHPostProcess;
  68046. private _blurVPostProcess;
  68047. private _ssaoCombinePostProcess;
  68048. /**
  68049. * Gets active scene
  68050. */
  68051. get scene(): Scene;
  68052. /**
  68053. * @constructor
  68054. * @param name The rendering pipeline name
  68055. * @param scene The scene linked to this pipeline
  68056. * @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 }
  68057. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68058. */
  68059. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68060. /**
  68061. * Get the class name
  68062. * @returns "SSAO2RenderingPipeline"
  68063. */
  68064. getClassName(): string;
  68065. /**
  68066. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68067. */
  68068. dispose(disableGeometryBufferRenderer?: boolean): void;
  68069. private _createBlurPostProcess;
  68070. /** @hidden */
  68071. _rebuild(): void;
  68072. private _bits;
  68073. private _radicalInverse_VdC;
  68074. private _hammersley;
  68075. private _hemisphereSample_uniform;
  68076. private _generateHemisphere;
  68077. private _createSSAOPostProcess;
  68078. private _createSSAOCombinePostProcess;
  68079. private _createRandomTexture;
  68080. /**
  68081. * Serialize the rendering pipeline (Used when exporting)
  68082. * @returns the serialized object
  68083. */
  68084. serialize(): any;
  68085. /**
  68086. * Parse the serialized pipeline
  68087. * @param source Source pipeline.
  68088. * @param scene The scene to load the pipeline to.
  68089. * @param rootUrl The URL of the serialized pipeline.
  68090. * @returns An instantiated pipeline from the serialized object.
  68091. */
  68092. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  68093. }
  68094. }
  68095. declare module "babylonjs/Shaders/ssao.fragment" {
  68096. /** @hidden */
  68097. export var ssaoPixelShader: {
  68098. name: string;
  68099. shader: string;
  68100. };
  68101. }
  68102. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  68103. import { Camera } from "babylonjs/Cameras/camera";
  68104. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68105. import { Scene } from "babylonjs/scene";
  68106. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68107. import "babylonjs/Shaders/ssao.fragment";
  68108. import "babylonjs/Shaders/ssaoCombine.fragment";
  68109. /**
  68110. * Render pipeline to produce ssao effect
  68111. */
  68112. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  68113. /**
  68114. * @ignore
  68115. * The PassPostProcess id in the pipeline that contains the original scene color
  68116. */
  68117. SSAOOriginalSceneColorEffect: string;
  68118. /**
  68119. * @ignore
  68120. * The SSAO PostProcess id in the pipeline
  68121. */
  68122. SSAORenderEffect: string;
  68123. /**
  68124. * @ignore
  68125. * The horizontal blur PostProcess id in the pipeline
  68126. */
  68127. SSAOBlurHRenderEffect: string;
  68128. /**
  68129. * @ignore
  68130. * The vertical blur PostProcess id in the pipeline
  68131. */
  68132. SSAOBlurVRenderEffect: string;
  68133. /**
  68134. * @ignore
  68135. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  68136. */
  68137. SSAOCombineRenderEffect: string;
  68138. /**
  68139. * The output strength of the SSAO post-process. Default value is 1.0.
  68140. */
  68141. totalStrength: number;
  68142. /**
  68143. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  68144. */
  68145. radius: number;
  68146. /**
  68147. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  68148. * Must not be equal to fallOff and superior to fallOff.
  68149. * Default value is 0.0075
  68150. */
  68151. area: number;
  68152. /**
  68153. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  68154. * Must not be equal to area and inferior to area.
  68155. * Default value is 0.000001
  68156. */
  68157. fallOff: number;
  68158. /**
  68159. * The base color of the SSAO post-process
  68160. * The final result is "base + ssao" between [0, 1]
  68161. */
  68162. base: number;
  68163. private _scene;
  68164. private _depthTexture;
  68165. private _randomTexture;
  68166. private _originalColorPostProcess;
  68167. private _ssaoPostProcess;
  68168. private _blurHPostProcess;
  68169. private _blurVPostProcess;
  68170. private _ssaoCombinePostProcess;
  68171. private _firstUpdate;
  68172. /**
  68173. * Gets active scene
  68174. */
  68175. get scene(): Scene;
  68176. /**
  68177. * @constructor
  68178. * @param name - The rendering pipeline name
  68179. * @param scene - The scene linked to this pipeline
  68180. * @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 }
  68181. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  68182. */
  68183. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  68184. /**
  68185. * Get the class name
  68186. * @returns "SSAORenderingPipeline"
  68187. */
  68188. getClassName(): string;
  68189. /**
  68190. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  68191. */
  68192. dispose(disableDepthRender?: boolean): void;
  68193. private _createBlurPostProcess;
  68194. /** @hidden */
  68195. _rebuild(): void;
  68196. private _createSSAOPostProcess;
  68197. private _createSSAOCombinePostProcess;
  68198. private _createRandomTexture;
  68199. }
  68200. }
  68201. declare module "babylonjs/Shaders/standard.fragment" {
  68202. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68203. /** @hidden */
  68204. export var standardPixelShader: {
  68205. name: string;
  68206. shader: string;
  68207. };
  68208. }
  68209. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  68210. import { Nullable } from "babylonjs/types";
  68211. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68212. import { Camera } from "babylonjs/Cameras/camera";
  68213. import { Texture } from "babylonjs/Materials/Textures/texture";
  68214. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68215. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68216. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  68217. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68218. import { IDisposable } from "babylonjs/scene";
  68219. import { SpotLight } from "babylonjs/Lights/spotLight";
  68220. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  68221. import { Scene } from "babylonjs/scene";
  68222. import { Animation } from "babylonjs/Animations/animation";
  68223. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68224. import "babylonjs/Shaders/standard.fragment";
  68225. /**
  68226. * Standard rendering pipeline
  68227. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68228. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  68229. */
  68230. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68231. /**
  68232. * Public members
  68233. */
  68234. /**
  68235. * Post-process which contains the original scene color before the pipeline applies all the effects
  68236. */
  68237. originalPostProcess: Nullable<PostProcess>;
  68238. /**
  68239. * Post-process used to down scale an image x4
  68240. */
  68241. downSampleX4PostProcess: Nullable<PostProcess>;
  68242. /**
  68243. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  68244. */
  68245. brightPassPostProcess: Nullable<PostProcess>;
  68246. /**
  68247. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  68248. */
  68249. blurHPostProcesses: PostProcess[];
  68250. /**
  68251. * Post-process array storing all the vertical blur post-processes used by the pipeline
  68252. */
  68253. blurVPostProcesses: PostProcess[];
  68254. /**
  68255. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  68256. */
  68257. textureAdderPostProcess: Nullable<PostProcess>;
  68258. /**
  68259. * Post-process used to create volumetric lighting effect
  68260. */
  68261. volumetricLightPostProcess: Nullable<PostProcess>;
  68262. /**
  68263. * Post-process used to smooth the previous volumetric light post-process on the X axis
  68264. */
  68265. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  68266. /**
  68267. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  68268. */
  68269. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  68270. /**
  68271. * Post-process used to merge the volumetric light effect and the real scene color
  68272. */
  68273. volumetricLightMergePostProces: Nullable<PostProcess>;
  68274. /**
  68275. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  68276. */
  68277. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  68278. /**
  68279. * Base post-process used to calculate the average luminance of the final image for HDR
  68280. */
  68281. luminancePostProcess: Nullable<PostProcess>;
  68282. /**
  68283. * Post-processes used to create down sample post-processes in order to get
  68284. * the average luminance of the final image for HDR
  68285. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  68286. */
  68287. luminanceDownSamplePostProcesses: PostProcess[];
  68288. /**
  68289. * Post-process used to create a HDR effect (light adaptation)
  68290. */
  68291. hdrPostProcess: Nullable<PostProcess>;
  68292. /**
  68293. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  68294. */
  68295. textureAdderFinalPostProcess: Nullable<PostProcess>;
  68296. /**
  68297. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  68298. */
  68299. lensFlareFinalPostProcess: Nullable<PostProcess>;
  68300. /**
  68301. * Post-process used to merge the final HDR post-process and the real scene color
  68302. */
  68303. hdrFinalPostProcess: Nullable<PostProcess>;
  68304. /**
  68305. * Post-process used to create a lens flare effect
  68306. */
  68307. lensFlarePostProcess: Nullable<PostProcess>;
  68308. /**
  68309. * Post-process that merges the result of the lens flare post-process and the real scene color
  68310. */
  68311. lensFlareComposePostProcess: Nullable<PostProcess>;
  68312. /**
  68313. * Post-process used to create a motion blur effect
  68314. */
  68315. motionBlurPostProcess: Nullable<PostProcess>;
  68316. /**
  68317. * Post-process used to create a depth of field effect
  68318. */
  68319. depthOfFieldPostProcess: Nullable<PostProcess>;
  68320. /**
  68321. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68322. */
  68323. fxaaPostProcess: Nullable<FxaaPostProcess>;
  68324. /**
  68325. * Represents the brightness threshold in order to configure the illuminated surfaces
  68326. */
  68327. brightThreshold: number;
  68328. /**
  68329. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  68330. */
  68331. blurWidth: number;
  68332. /**
  68333. * Sets if the blur for highlighted surfaces must be only horizontal
  68334. */
  68335. horizontalBlur: boolean;
  68336. /**
  68337. * Gets the overall exposure used by the pipeline
  68338. */
  68339. get exposure(): number;
  68340. /**
  68341. * Sets the overall exposure used by the pipeline
  68342. */
  68343. set exposure(value: number);
  68344. /**
  68345. * Texture used typically to simulate "dirty" on camera lens
  68346. */
  68347. lensTexture: Nullable<Texture>;
  68348. /**
  68349. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  68350. */
  68351. volumetricLightCoefficient: number;
  68352. /**
  68353. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  68354. */
  68355. volumetricLightPower: number;
  68356. /**
  68357. * Used the set the blur intensity to smooth the volumetric lights
  68358. */
  68359. volumetricLightBlurScale: number;
  68360. /**
  68361. * Light (spot or directional) used to generate the volumetric lights rays
  68362. * The source light must have a shadow generate so the pipeline can get its
  68363. * depth map
  68364. */
  68365. sourceLight: Nullable<SpotLight | DirectionalLight>;
  68366. /**
  68367. * For eye adaptation, represents the minimum luminance the eye can see
  68368. */
  68369. hdrMinimumLuminance: number;
  68370. /**
  68371. * For eye adaptation, represents the decrease luminance speed
  68372. */
  68373. hdrDecreaseRate: number;
  68374. /**
  68375. * For eye adaptation, represents the increase luminance speed
  68376. */
  68377. hdrIncreaseRate: number;
  68378. /**
  68379. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68380. */
  68381. get hdrAutoExposure(): boolean;
  68382. /**
  68383. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  68384. */
  68385. set hdrAutoExposure(value: boolean);
  68386. /**
  68387. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  68388. */
  68389. lensColorTexture: Nullable<Texture>;
  68390. /**
  68391. * The overall strengh for the lens flare effect
  68392. */
  68393. lensFlareStrength: number;
  68394. /**
  68395. * Dispersion coefficient for lens flare ghosts
  68396. */
  68397. lensFlareGhostDispersal: number;
  68398. /**
  68399. * Main lens flare halo width
  68400. */
  68401. lensFlareHaloWidth: number;
  68402. /**
  68403. * Based on the lens distortion effect, defines how much the lens flare result
  68404. * is distorted
  68405. */
  68406. lensFlareDistortionStrength: number;
  68407. /**
  68408. * Configures the blur intensity used for for lens flare (halo)
  68409. */
  68410. lensFlareBlurWidth: number;
  68411. /**
  68412. * Lens star texture must be used to simulate rays on the flares and is available
  68413. * in the documentation
  68414. */
  68415. lensStarTexture: Nullable<Texture>;
  68416. /**
  68417. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  68418. * flare effect by taking account of the dirt texture
  68419. */
  68420. lensFlareDirtTexture: Nullable<Texture>;
  68421. /**
  68422. * Represents the focal length for the depth of field effect
  68423. */
  68424. depthOfFieldDistance: number;
  68425. /**
  68426. * Represents the blur intensity for the blurred part of the depth of field effect
  68427. */
  68428. depthOfFieldBlurWidth: number;
  68429. /**
  68430. * Gets how much the image is blurred by the movement while using the motion blur post-process
  68431. */
  68432. get motionStrength(): number;
  68433. /**
  68434. * Sets how much the image is blurred by the movement while using the motion blur post-process
  68435. */
  68436. set motionStrength(strength: number);
  68437. /**
  68438. * Gets wether or not the motion blur post-process is object based or screen based.
  68439. */
  68440. get objectBasedMotionBlur(): boolean;
  68441. /**
  68442. * Sets wether or not the motion blur post-process should be object based or screen based
  68443. */
  68444. set objectBasedMotionBlur(value: boolean);
  68445. /**
  68446. * List of animations for the pipeline (IAnimatable implementation)
  68447. */
  68448. animations: Animation[];
  68449. /**
  68450. * Private members
  68451. */
  68452. private _scene;
  68453. private _currentDepthOfFieldSource;
  68454. private _basePostProcess;
  68455. private _fixedExposure;
  68456. private _currentExposure;
  68457. private _hdrAutoExposure;
  68458. private _hdrCurrentLuminance;
  68459. private _motionStrength;
  68460. private _isObjectBasedMotionBlur;
  68461. private _floatTextureType;
  68462. private _camerasToBeAttached;
  68463. private _ratio;
  68464. private _bloomEnabled;
  68465. private _depthOfFieldEnabled;
  68466. private _vlsEnabled;
  68467. private _lensFlareEnabled;
  68468. private _hdrEnabled;
  68469. private _motionBlurEnabled;
  68470. private _fxaaEnabled;
  68471. private _motionBlurSamples;
  68472. private _volumetricLightStepsCount;
  68473. private _samples;
  68474. /**
  68475. * @ignore
  68476. * Specifies if the bloom pipeline is enabled
  68477. */
  68478. get BloomEnabled(): boolean;
  68479. set BloomEnabled(enabled: boolean);
  68480. /**
  68481. * @ignore
  68482. * Specifies if the depth of field pipeline is enabed
  68483. */
  68484. get DepthOfFieldEnabled(): boolean;
  68485. set DepthOfFieldEnabled(enabled: boolean);
  68486. /**
  68487. * @ignore
  68488. * Specifies if the lens flare pipeline is enabed
  68489. */
  68490. get LensFlareEnabled(): boolean;
  68491. set LensFlareEnabled(enabled: boolean);
  68492. /**
  68493. * @ignore
  68494. * Specifies if the HDR pipeline is enabled
  68495. */
  68496. get HDREnabled(): boolean;
  68497. set HDREnabled(enabled: boolean);
  68498. /**
  68499. * @ignore
  68500. * Specifies if the volumetric lights scattering effect is enabled
  68501. */
  68502. get VLSEnabled(): boolean;
  68503. set VLSEnabled(enabled: boolean);
  68504. /**
  68505. * @ignore
  68506. * Specifies if the motion blur effect is enabled
  68507. */
  68508. get MotionBlurEnabled(): boolean;
  68509. set MotionBlurEnabled(enabled: boolean);
  68510. /**
  68511. * Specifies if anti-aliasing is enabled
  68512. */
  68513. get fxaaEnabled(): boolean;
  68514. set fxaaEnabled(enabled: boolean);
  68515. /**
  68516. * Specifies the number of steps used to calculate the volumetric lights
  68517. * Typically in interval [50, 200]
  68518. */
  68519. get volumetricLightStepsCount(): number;
  68520. set volumetricLightStepsCount(count: number);
  68521. /**
  68522. * Specifies the number of samples used for the motion blur effect
  68523. * Typically in interval [16, 64]
  68524. */
  68525. get motionBlurSamples(): number;
  68526. set motionBlurSamples(samples: number);
  68527. /**
  68528. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68529. */
  68530. get samples(): number;
  68531. set samples(sampleCount: number);
  68532. /**
  68533. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  68534. * @constructor
  68535. * @param name The rendering pipeline name
  68536. * @param scene The scene linked to this pipeline
  68537. * @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)
  68538. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  68539. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68540. */
  68541. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  68542. private _buildPipeline;
  68543. private _createDownSampleX4PostProcess;
  68544. private _createBrightPassPostProcess;
  68545. private _createBlurPostProcesses;
  68546. private _createTextureAdderPostProcess;
  68547. private _createVolumetricLightPostProcess;
  68548. private _createLuminancePostProcesses;
  68549. private _createHdrPostProcess;
  68550. private _createLensFlarePostProcess;
  68551. private _createDepthOfFieldPostProcess;
  68552. private _createMotionBlurPostProcess;
  68553. private _getDepthTexture;
  68554. private _disposePostProcesses;
  68555. /**
  68556. * Dispose of the pipeline and stop all post processes
  68557. */
  68558. dispose(): void;
  68559. /**
  68560. * Serialize the rendering pipeline (Used when exporting)
  68561. * @returns the serialized object
  68562. */
  68563. serialize(): any;
  68564. /**
  68565. * Parse the serialized pipeline
  68566. * @param source Source pipeline.
  68567. * @param scene The scene to load the pipeline to.
  68568. * @param rootUrl The URL of the serialized pipeline.
  68569. * @returns An instantiated pipeline from the serialized object.
  68570. */
  68571. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  68572. /**
  68573. * Luminance steps
  68574. */
  68575. static LuminanceSteps: number;
  68576. }
  68577. }
  68578. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  68579. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  68580. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  68581. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  68582. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  68583. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  68584. }
  68585. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  68586. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  68587. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68588. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68589. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68590. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68591. }
  68592. declare module "babylonjs/Shaders/tonemap.fragment" {
  68593. /** @hidden */
  68594. export var tonemapPixelShader: {
  68595. name: string;
  68596. shader: string;
  68597. };
  68598. }
  68599. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  68600. import { Camera } from "babylonjs/Cameras/camera";
  68601. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68602. import "babylonjs/Shaders/tonemap.fragment";
  68603. import { Engine } from "babylonjs/Engines/engine";
  68604. /** Defines operator used for tonemapping */
  68605. export enum TonemappingOperator {
  68606. /** Hable */
  68607. Hable = 0,
  68608. /** Reinhard */
  68609. Reinhard = 1,
  68610. /** HejiDawson */
  68611. HejiDawson = 2,
  68612. /** Photographic */
  68613. Photographic = 3
  68614. }
  68615. /**
  68616. * Defines a post process to apply tone mapping
  68617. */
  68618. export class TonemapPostProcess extends PostProcess {
  68619. private _operator;
  68620. /** Defines the required exposure adjustement */
  68621. exposureAdjustment: number;
  68622. /**
  68623. * Creates a new TonemapPostProcess
  68624. * @param name defines the name of the postprocess
  68625. * @param _operator defines the operator to use
  68626. * @param exposureAdjustment defines the required exposure adjustement
  68627. * @param camera defines the camera to use (can be null)
  68628. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  68629. * @param engine defines the hosting engine (can be ignore if camera is set)
  68630. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  68631. */
  68632. constructor(name: string, _operator: TonemappingOperator,
  68633. /** Defines the required exposure adjustement */
  68634. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  68635. }
  68636. }
  68637. declare module "babylonjs/Shaders/depth.vertex" {
  68638. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68639. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68640. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68641. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68642. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68643. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68644. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68645. /** @hidden */
  68646. export var depthVertexShader: {
  68647. name: string;
  68648. shader: string;
  68649. };
  68650. }
  68651. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  68652. /** @hidden */
  68653. export var volumetricLightScatteringPixelShader: {
  68654. name: string;
  68655. shader: string;
  68656. };
  68657. }
  68658. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  68659. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68660. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68661. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68662. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68663. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68664. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68665. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68666. /** @hidden */
  68667. export var volumetricLightScatteringPassVertexShader: {
  68668. name: string;
  68669. shader: string;
  68670. };
  68671. }
  68672. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  68673. /** @hidden */
  68674. export var volumetricLightScatteringPassPixelShader: {
  68675. name: string;
  68676. shader: string;
  68677. };
  68678. }
  68679. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  68680. import { Vector3 } from "babylonjs/Maths/math.vector";
  68681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68682. import { Mesh } from "babylonjs/Meshes/mesh";
  68683. import { Camera } from "babylonjs/Cameras/camera";
  68684. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68685. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68686. import { Scene } from "babylonjs/scene";
  68687. import "babylonjs/Meshes/Builders/planeBuilder";
  68688. import "babylonjs/Shaders/depth.vertex";
  68689. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  68690. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  68691. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  68692. import { Engine } from "babylonjs/Engines/engine";
  68693. /**
  68694. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  68695. */
  68696. export class VolumetricLightScatteringPostProcess extends PostProcess {
  68697. private _volumetricLightScatteringPass;
  68698. private _volumetricLightScatteringRTT;
  68699. private _viewPort;
  68700. private _screenCoordinates;
  68701. private _cachedDefines;
  68702. /**
  68703. * If not undefined, the mesh position is computed from the attached node position
  68704. */
  68705. attachedNode: {
  68706. position: Vector3;
  68707. };
  68708. /**
  68709. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  68710. */
  68711. customMeshPosition: Vector3;
  68712. /**
  68713. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  68714. */
  68715. useCustomMeshPosition: boolean;
  68716. /**
  68717. * If the post-process should inverse the light scattering direction
  68718. */
  68719. invert: boolean;
  68720. /**
  68721. * The internal mesh used by the post-process
  68722. */
  68723. mesh: Mesh;
  68724. /**
  68725. * @hidden
  68726. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  68727. */
  68728. get useDiffuseColor(): boolean;
  68729. set useDiffuseColor(useDiffuseColor: boolean);
  68730. /**
  68731. * Array containing the excluded meshes not rendered in the internal pass
  68732. */
  68733. excludedMeshes: AbstractMesh[];
  68734. /**
  68735. * Controls the overall intensity of the post-process
  68736. */
  68737. exposure: number;
  68738. /**
  68739. * Dissipates each sample's contribution in range [0, 1]
  68740. */
  68741. decay: number;
  68742. /**
  68743. * Controls the overall intensity of each sample
  68744. */
  68745. weight: number;
  68746. /**
  68747. * Controls the density of each sample
  68748. */
  68749. density: number;
  68750. /**
  68751. * @constructor
  68752. * @param name The post-process name
  68753. * @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)
  68754. * @param camera The camera that the post-process will be attached to
  68755. * @param mesh The mesh used to create the light scattering
  68756. * @param samples The post-process quality, default 100
  68757. * @param samplingModeThe post-process filtering mode
  68758. * @param engine The babylon engine
  68759. * @param reusable If the post-process is reusable
  68760. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  68761. */
  68762. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  68763. /**
  68764. * Returns the string "VolumetricLightScatteringPostProcess"
  68765. * @returns "VolumetricLightScatteringPostProcess"
  68766. */
  68767. getClassName(): string;
  68768. private _isReady;
  68769. /**
  68770. * Sets the new light position for light scattering effect
  68771. * @param position The new custom light position
  68772. */
  68773. setCustomMeshPosition(position: Vector3): void;
  68774. /**
  68775. * Returns the light position for light scattering effect
  68776. * @return Vector3 The custom light position
  68777. */
  68778. getCustomMeshPosition(): Vector3;
  68779. /**
  68780. * Disposes the internal assets and detaches the post-process from the camera
  68781. */
  68782. dispose(camera: Camera): void;
  68783. /**
  68784. * Returns the render target texture used by the post-process
  68785. * @return the render target texture used by the post-process
  68786. */
  68787. getPass(): RenderTargetTexture;
  68788. private _meshExcluded;
  68789. private _createPass;
  68790. private _updateMeshScreenCoordinates;
  68791. /**
  68792. * Creates a default mesh for the Volumeric Light Scattering post-process
  68793. * @param name The mesh name
  68794. * @param scene The scene where to create the mesh
  68795. * @return the default mesh
  68796. */
  68797. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  68798. }
  68799. }
  68800. declare module "babylonjs/PostProcesses/index" {
  68801. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  68802. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  68803. export * from "babylonjs/PostProcesses/bloomEffect";
  68804. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  68805. export * from "babylonjs/PostProcesses/blurPostProcess";
  68806. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68807. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  68808. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  68809. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  68810. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68811. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  68812. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  68813. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  68814. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68815. export * from "babylonjs/PostProcesses/filterPostProcess";
  68816. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  68817. export * from "babylonjs/PostProcesses/grainPostProcess";
  68818. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  68819. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68820. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  68821. export * from "babylonjs/PostProcesses/passPostProcess";
  68822. export * from "babylonjs/PostProcesses/postProcess";
  68823. export * from "babylonjs/PostProcesses/postProcessManager";
  68824. export * from "babylonjs/PostProcesses/refractionPostProcess";
  68825. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  68826. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  68827. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  68828. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  68829. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  68830. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  68831. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  68832. }
  68833. declare module "babylonjs/Probes/index" {
  68834. export * from "babylonjs/Probes/reflectionProbe";
  68835. }
  68836. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  68837. import { Scene } from "babylonjs/scene";
  68838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68839. import { SmartArray } from "babylonjs/Misc/smartArray";
  68840. import { ISceneComponent } from "babylonjs/sceneComponent";
  68841. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  68842. import "babylonjs/Meshes/Builders/boxBuilder";
  68843. import "babylonjs/Shaders/color.fragment";
  68844. import "babylonjs/Shaders/color.vertex";
  68845. import { Color3 } from "babylonjs/Maths/math.color";
  68846. module "babylonjs/scene" {
  68847. interface Scene {
  68848. /** @hidden (Backing field) */
  68849. _boundingBoxRenderer: BoundingBoxRenderer;
  68850. /** @hidden (Backing field) */
  68851. _forceShowBoundingBoxes: boolean;
  68852. /**
  68853. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  68854. */
  68855. forceShowBoundingBoxes: boolean;
  68856. /**
  68857. * Gets the bounding box renderer associated with the scene
  68858. * @returns a BoundingBoxRenderer
  68859. */
  68860. getBoundingBoxRenderer(): BoundingBoxRenderer;
  68861. }
  68862. }
  68863. module "babylonjs/Meshes/abstractMesh" {
  68864. interface AbstractMesh {
  68865. /** @hidden (Backing field) */
  68866. _showBoundingBox: boolean;
  68867. /**
  68868. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  68869. */
  68870. showBoundingBox: boolean;
  68871. }
  68872. }
  68873. /**
  68874. * Component responsible of rendering the bounding box of the meshes in a scene.
  68875. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  68876. */
  68877. export class BoundingBoxRenderer implements ISceneComponent {
  68878. /**
  68879. * The component name helpfull to identify the component in the list of scene components.
  68880. */
  68881. readonly name: string;
  68882. /**
  68883. * The scene the component belongs to.
  68884. */
  68885. scene: Scene;
  68886. /**
  68887. * Color of the bounding box lines placed in front of an object
  68888. */
  68889. frontColor: Color3;
  68890. /**
  68891. * Color of the bounding box lines placed behind an object
  68892. */
  68893. backColor: Color3;
  68894. /**
  68895. * Defines if the renderer should show the back lines or not
  68896. */
  68897. showBackLines: boolean;
  68898. /**
  68899. * @hidden
  68900. */
  68901. renderList: SmartArray<BoundingBox>;
  68902. private _colorShader;
  68903. private _vertexBuffers;
  68904. private _indexBuffer;
  68905. private _fillIndexBuffer;
  68906. private _fillIndexData;
  68907. /**
  68908. * Instantiates a new bounding box renderer in a scene.
  68909. * @param scene the scene the renderer renders in
  68910. */
  68911. constructor(scene: Scene);
  68912. /**
  68913. * Registers the component in a given scene
  68914. */
  68915. register(): void;
  68916. private _evaluateSubMesh;
  68917. private _activeMesh;
  68918. private _prepareRessources;
  68919. private _createIndexBuffer;
  68920. /**
  68921. * Rebuilds the elements related to this component in case of
  68922. * context lost for instance.
  68923. */
  68924. rebuild(): void;
  68925. /**
  68926. * @hidden
  68927. */
  68928. reset(): void;
  68929. /**
  68930. * Render the bounding boxes of a specific rendering group
  68931. * @param renderingGroupId defines the rendering group to render
  68932. */
  68933. render(renderingGroupId: number): void;
  68934. /**
  68935. * In case of occlusion queries, we can render the occlusion bounding box through this method
  68936. * @param mesh Define the mesh to render the occlusion bounding box for
  68937. */
  68938. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  68939. /**
  68940. * Dispose and release the resources attached to this renderer.
  68941. */
  68942. dispose(): void;
  68943. }
  68944. }
  68945. declare module "babylonjs/Shaders/depth.fragment" {
  68946. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  68947. /** @hidden */
  68948. export var depthPixelShader: {
  68949. name: string;
  68950. shader: string;
  68951. };
  68952. }
  68953. declare module "babylonjs/Rendering/depthRenderer" {
  68954. import { Nullable } from "babylonjs/types";
  68955. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68956. import { Scene } from "babylonjs/scene";
  68957. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68958. import { Camera } from "babylonjs/Cameras/camera";
  68959. import "babylonjs/Shaders/depth.fragment";
  68960. import "babylonjs/Shaders/depth.vertex";
  68961. /**
  68962. * This represents a depth renderer in Babylon.
  68963. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  68964. */
  68965. export class DepthRenderer {
  68966. private _scene;
  68967. private _depthMap;
  68968. private _effect;
  68969. private readonly _storeNonLinearDepth;
  68970. private readonly _clearColor;
  68971. /** Get if the depth renderer is using packed depth or not */
  68972. readonly isPacked: boolean;
  68973. private _cachedDefines;
  68974. private _camera;
  68975. /**
  68976. * Specifiess that the depth renderer will only be used within
  68977. * the camera it is created for.
  68978. * This can help forcing its rendering during the camera processing.
  68979. */
  68980. useOnlyInActiveCamera: boolean;
  68981. /** @hidden */
  68982. static _SceneComponentInitialization: (scene: Scene) => void;
  68983. /**
  68984. * Instantiates a depth renderer
  68985. * @param scene The scene the renderer belongs to
  68986. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  68987. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  68988. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  68989. */
  68990. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  68991. /**
  68992. * Creates the depth rendering effect and checks if the effect is ready.
  68993. * @param subMesh The submesh to be used to render the depth map of
  68994. * @param useInstances If multiple world instances should be used
  68995. * @returns if the depth renderer is ready to render the depth map
  68996. */
  68997. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68998. /**
  68999. * Gets the texture which the depth map will be written to.
  69000. * @returns The depth map texture
  69001. */
  69002. getDepthMap(): RenderTargetTexture;
  69003. /**
  69004. * Disposes of the depth renderer.
  69005. */
  69006. dispose(): void;
  69007. }
  69008. }
  69009. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  69010. import { Nullable } from "babylonjs/types";
  69011. import { Scene } from "babylonjs/scene";
  69012. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  69013. import { Camera } from "babylonjs/Cameras/camera";
  69014. import { ISceneComponent } from "babylonjs/sceneComponent";
  69015. module "babylonjs/scene" {
  69016. interface Scene {
  69017. /** @hidden (Backing field) */
  69018. _depthRenderer: {
  69019. [id: string]: DepthRenderer;
  69020. };
  69021. /**
  69022. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  69023. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  69024. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  69025. * @returns the created depth renderer
  69026. */
  69027. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  69028. /**
  69029. * Disables a depth renderer for a given camera
  69030. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  69031. */
  69032. disableDepthRenderer(camera?: Nullable<Camera>): void;
  69033. }
  69034. }
  69035. /**
  69036. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  69037. * in several rendering techniques.
  69038. */
  69039. export class DepthRendererSceneComponent implements ISceneComponent {
  69040. /**
  69041. * The component name helpfull to identify the component in the list of scene components.
  69042. */
  69043. readonly name: string;
  69044. /**
  69045. * The scene the component belongs to.
  69046. */
  69047. scene: Scene;
  69048. /**
  69049. * Creates a new instance of the component for the given scene
  69050. * @param scene Defines the scene to register the component in
  69051. */
  69052. constructor(scene: Scene);
  69053. /**
  69054. * Registers the component in a given scene
  69055. */
  69056. register(): void;
  69057. /**
  69058. * Rebuilds the elements related to this component in case of
  69059. * context lost for instance.
  69060. */
  69061. rebuild(): void;
  69062. /**
  69063. * Disposes the component and the associated ressources
  69064. */
  69065. dispose(): void;
  69066. private _gatherRenderTargets;
  69067. private _gatherActiveCameraRenderTargets;
  69068. }
  69069. }
  69070. declare module "babylonjs/Shaders/outline.fragment" {
  69071. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  69072. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  69073. /** @hidden */
  69074. export var outlinePixelShader: {
  69075. name: string;
  69076. shader: string;
  69077. };
  69078. }
  69079. declare module "babylonjs/Shaders/outline.vertex" {
  69080. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69081. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69082. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69083. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69084. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  69085. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69086. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69087. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69088. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  69089. /** @hidden */
  69090. export var outlineVertexShader: {
  69091. name: string;
  69092. shader: string;
  69093. };
  69094. }
  69095. declare module "babylonjs/Rendering/outlineRenderer" {
  69096. import { SubMesh } from "babylonjs/Meshes/subMesh";
  69097. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  69098. import { Scene } from "babylonjs/scene";
  69099. import { ISceneComponent } from "babylonjs/sceneComponent";
  69100. import "babylonjs/Shaders/outline.fragment";
  69101. import "babylonjs/Shaders/outline.vertex";
  69102. module "babylonjs/scene" {
  69103. interface Scene {
  69104. /** @hidden */
  69105. _outlineRenderer: OutlineRenderer;
  69106. /**
  69107. * Gets the outline renderer associated with the scene
  69108. * @returns a OutlineRenderer
  69109. */
  69110. getOutlineRenderer(): OutlineRenderer;
  69111. }
  69112. }
  69113. module "babylonjs/Meshes/abstractMesh" {
  69114. interface AbstractMesh {
  69115. /** @hidden (Backing field) */
  69116. _renderOutline: boolean;
  69117. /**
  69118. * Gets or sets a boolean indicating if the outline must be rendered as well
  69119. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  69120. */
  69121. renderOutline: boolean;
  69122. /** @hidden (Backing field) */
  69123. _renderOverlay: boolean;
  69124. /**
  69125. * Gets or sets a boolean indicating if the overlay must be rendered as well
  69126. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  69127. */
  69128. renderOverlay: boolean;
  69129. }
  69130. }
  69131. /**
  69132. * This class is responsible to draw bothe outline/overlay of meshes.
  69133. * It should not be used directly but through the available method on mesh.
  69134. */
  69135. export class OutlineRenderer implements ISceneComponent {
  69136. /**
  69137. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  69138. */
  69139. private static _StencilReference;
  69140. /**
  69141. * The name of the component. Each component must have a unique name.
  69142. */
  69143. name: string;
  69144. /**
  69145. * The scene the component belongs to.
  69146. */
  69147. scene: Scene;
  69148. /**
  69149. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  69150. */
  69151. zOffset: number;
  69152. private _engine;
  69153. private _effect;
  69154. private _cachedDefines;
  69155. private _savedDepthWrite;
  69156. /**
  69157. * Instantiates a new outline renderer. (There could be only one per scene).
  69158. * @param scene Defines the scene it belongs to
  69159. */
  69160. constructor(scene: Scene);
  69161. /**
  69162. * Register the component to one instance of a scene.
  69163. */
  69164. register(): void;
  69165. /**
  69166. * Rebuilds the elements related to this component in case of
  69167. * context lost for instance.
  69168. */
  69169. rebuild(): void;
  69170. /**
  69171. * Disposes the component and the associated ressources.
  69172. */
  69173. dispose(): void;
  69174. /**
  69175. * Renders the outline in the canvas.
  69176. * @param subMesh Defines the sumesh to render
  69177. * @param batch Defines the batch of meshes in case of instances
  69178. * @param useOverlay Defines if the rendering is for the overlay or the outline
  69179. */
  69180. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  69181. /**
  69182. * Returns whether or not the outline renderer is ready for a given submesh.
  69183. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  69184. * @param subMesh Defines the submesh to check readyness for
  69185. * @param useInstances Defines wheter wee are trying to render instances or not
  69186. * @returns true if ready otherwise false
  69187. */
  69188. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69189. private _beforeRenderingMesh;
  69190. private _afterRenderingMesh;
  69191. }
  69192. }
  69193. declare module "babylonjs/Rendering/index" {
  69194. export * from "babylonjs/Rendering/boundingBoxRenderer";
  69195. export * from "babylonjs/Rendering/depthRenderer";
  69196. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  69197. export * from "babylonjs/Rendering/edgesRenderer";
  69198. export * from "babylonjs/Rendering/geometryBufferRenderer";
  69199. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  69200. export * from "babylonjs/Rendering/outlineRenderer";
  69201. export * from "babylonjs/Rendering/renderingGroup";
  69202. export * from "babylonjs/Rendering/renderingManager";
  69203. export * from "babylonjs/Rendering/utilityLayerRenderer";
  69204. }
  69205. declare module "babylonjs/Sprites/ISprites" {
  69206. /**
  69207. * Defines the basic options interface of a Sprite Frame Source Size.
  69208. */
  69209. export interface ISpriteJSONSpriteSourceSize {
  69210. /**
  69211. * number of the original width of the Frame
  69212. */
  69213. w: number;
  69214. /**
  69215. * number of the original height of the Frame
  69216. */
  69217. h: number;
  69218. }
  69219. /**
  69220. * Defines the basic options interface of a Sprite Frame Data.
  69221. */
  69222. export interface ISpriteJSONSpriteFrameData {
  69223. /**
  69224. * number of the x offset of the Frame
  69225. */
  69226. x: number;
  69227. /**
  69228. * number of the y offset of the Frame
  69229. */
  69230. y: number;
  69231. /**
  69232. * number of the width of the Frame
  69233. */
  69234. w: number;
  69235. /**
  69236. * number of the height of the Frame
  69237. */
  69238. h: number;
  69239. }
  69240. /**
  69241. * Defines the basic options interface of a JSON Sprite.
  69242. */
  69243. export interface ISpriteJSONSprite {
  69244. /**
  69245. * string name of the Frame
  69246. */
  69247. filename: string;
  69248. /**
  69249. * ISpriteJSONSpriteFrame basic object of the frame data
  69250. */
  69251. frame: ISpriteJSONSpriteFrameData;
  69252. /**
  69253. * boolean to flag is the frame was rotated.
  69254. */
  69255. rotated: boolean;
  69256. /**
  69257. * boolean to flag is the frame was trimmed.
  69258. */
  69259. trimmed: boolean;
  69260. /**
  69261. * ISpriteJSONSpriteFrame basic object of the source data
  69262. */
  69263. spriteSourceSize: ISpriteJSONSpriteFrameData;
  69264. /**
  69265. * ISpriteJSONSpriteFrame basic object of the source data
  69266. */
  69267. sourceSize: ISpriteJSONSpriteSourceSize;
  69268. }
  69269. /**
  69270. * Defines the basic options interface of a JSON atlas.
  69271. */
  69272. export interface ISpriteJSONAtlas {
  69273. /**
  69274. * Array of objects that contain the frame data.
  69275. */
  69276. frames: Array<ISpriteJSONSprite>;
  69277. /**
  69278. * object basic object containing the sprite meta data.
  69279. */
  69280. meta?: object;
  69281. }
  69282. }
  69283. declare module "babylonjs/Shaders/spriteMap.fragment" {
  69284. /** @hidden */
  69285. export var spriteMapPixelShader: {
  69286. name: string;
  69287. shader: string;
  69288. };
  69289. }
  69290. declare module "babylonjs/Shaders/spriteMap.vertex" {
  69291. /** @hidden */
  69292. export var spriteMapVertexShader: {
  69293. name: string;
  69294. shader: string;
  69295. };
  69296. }
  69297. declare module "babylonjs/Sprites/spriteMap" {
  69298. import { IDisposable, Scene } from "babylonjs/scene";
  69299. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  69300. import { Texture } from "babylonjs/Materials/Textures/texture";
  69301. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69302. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  69303. import "babylonjs/Meshes/Builders/planeBuilder";
  69304. import "babylonjs/Shaders/spriteMap.fragment";
  69305. import "babylonjs/Shaders/spriteMap.vertex";
  69306. /**
  69307. * Defines the basic options interface of a SpriteMap
  69308. */
  69309. export interface ISpriteMapOptions {
  69310. /**
  69311. * Vector2 of the number of cells in the grid.
  69312. */
  69313. stageSize?: Vector2;
  69314. /**
  69315. * Vector2 of the size of the output plane in World Units.
  69316. */
  69317. outputSize?: Vector2;
  69318. /**
  69319. * Vector3 of the position of the output plane in World Units.
  69320. */
  69321. outputPosition?: Vector3;
  69322. /**
  69323. * Vector3 of the rotation of the output plane.
  69324. */
  69325. outputRotation?: Vector3;
  69326. /**
  69327. * number of layers that the system will reserve in resources.
  69328. */
  69329. layerCount?: number;
  69330. /**
  69331. * number of max animation frames a single cell will reserve in resources.
  69332. */
  69333. maxAnimationFrames?: number;
  69334. /**
  69335. * number cell index of the base tile when the system compiles.
  69336. */
  69337. baseTile?: number;
  69338. /**
  69339. * boolean flip the sprite after its been repositioned by the framing data.
  69340. */
  69341. flipU?: boolean;
  69342. /**
  69343. * Vector3 scalar of the global RGB values of the SpriteMap.
  69344. */
  69345. colorMultiply?: Vector3;
  69346. }
  69347. /**
  69348. * Defines the IDisposable interface in order to be cleanable from resources.
  69349. */
  69350. export interface ISpriteMap extends IDisposable {
  69351. /**
  69352. * String name of the SpriteMap.
  69353. */
  69354. name: string;
  69355. /**
  69356. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  69357. */
  69358. atlasJSON: ISpriteJSONAtlas;
  69359. /**
  69360. * Texture of the SpriteMap.
  69361. */
  69362. spriteSheet: Texture;
  69363. /**
  69364. * The parameters to initialize the SpriteMap with.
  69365. */
  69366. options: ISpriteMapOptions;
  69367. }
  69368. /**
  69369. * Class used to manage a grid restricted sprite deployment on an Output plane.
  69370. */
  69371. export class SpriteMap implements ISpriteMap {
  69372. /** The Name of the spriteMap */
  69373. name: string;
  69374. /** The JSON file with the frame and meta data */
  69375. atlasJSON: ISpriteJSONAtlas;
  69376. /** The systems Sprite Sheet Texture */
  69377. spriteSheet: Texture;
  69378. /** Arguments passed with the Constructor */
  69379. options: ISpriteMapOptions;
  69380. /** Public Sprite Storage array, parsed from atlasJSON */
  69381. sprites: Array<ISpriteJSONSprite>;
  69382. /** Returns the Number of Sprites in the System */
  69383. get spriteCount(): number;
  69384. /** Returns the Position of Output Plane*/
  69385. get position(): Vector3;
  69386. /** Returns the Position of Output Plane*/
  69387. set position(v: Vector3);
  69388. /** Returns the Rotation of Output Plane*/
  69389. get rotation(): Vector3;
  69390. /** Returns the Rotation of Output Plane*/
  69391. set rotation(v: Vector3);
  69392. /** Sets the AnimationMap*/
  69393. get animationMap(): RawTexture;
  69394. /** Sets the AnimationMap*/
  69395. set animationMap(v: RawTexture);
  69396. /** Scene that the SpriteMap was created in */
  69397. private _scene;
  69398. /** Texture Buffer of Float32 that holds tile frame data*/
  69399. private _frameMap;
  69400. /** Texture Buffers of Float32 that holds tileMap data*/
  69401. private _tileMaps;
  69402. /** Texture Buffer of Float32 that holds Animation Data*/
  69403. private _animationMap;
  69404. /** Custom ShaderMaterial Central to the System*/
  69405. private _material;
  69406. /** Custom ShaderMaterial Central to the System*/
  69407. private _output;
  69408. /** Systems Time Ticker*/
  69409. private _time;
  69410. /**
  69411. * Creates a new SpriteMap
  69412. * @param name defines the SpriteMaps Name
  69413. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  69414. * @param spriteSheet is the Texture that the Sprites are on.
  69415. * @param options a basic deployment configuration
  69416. * @param scene The Scene that the map is deployed on
  69417. */
  69418. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  69419. /**
  69420. * Returns tileID location
  69421. * @returns Vector2 the cell position ID
  69422. */
  69423. getTileID(): Vector2;
  69424. /**
  69425. * Gets the UV location of the mouse over the SpriteMap.
  69426. * @returns Vector2 the UV position of the mouse interaction
  69427. */
  69428. getMousePosition(): Vector2;
  69429. /**
  69430. * Creates the "frame" texture Buffer
  69431. * -------------------------------------
  69432. * Structure of frames
  69433. * "filename": "Falling-Water-2.png",
  69434. * "frame": {"x":69,"y":103,"w":24,"h":32},
  69435. * "rotated": true,
  69436. * "trimmed": true,
  69437. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  69438. * "sourceSize": {"w":32,"h":32}
  69439. * @returns RawTexture of the frameMap
  69440. */
  69441. private _createFrameBuffer;
  69442. /**
  69443. * Creates the tileMap texture Buffer
  69444. * @param buffer normally and array of numbers, or a false to generate from scratch
  69445. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  69446. * @returns RawTexture of the tileMap
  69447. */
  69448. private _createTileBuffer;
  69449. /**
  69450. * Modifies the data of the tileMaps
  69451. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  69452. * @param pos is the iVector2 Coordinates of the Tile
  69453. * @param tile The SpriteIndex of the new Tile
  69454. */
  69455. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  69456. /**
  69457. * Creates the animationMap texture Buffer
  69458. * @param buffer normally and array of numbers, or a false to generate from scratch
  69459. * @returns RawTexture of the animationMap
  69460. */
  69461. private _createTileAnimationBuffer;
  69462. /**
  69463. * Modifies the data of the animationMap
  69464. * @param cellID is the Index of the Sprite
  69465. * @param _frame is the target Animation frame
  69466. * @param toCell is the Target Index of the next frame of the animation
  69467. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  69468. * @param speed is a global scalar of the time variable on the map.
  69469. */
  69470. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  69471. /**
  69472. * Exports the .tilemaps file
  69473. */
  69474. saveTileMaps(): void;
  69475. /**
  69476. * Imports the .tilemaps file
  69477. * @param url of the .tilemaps file
  69478. */
  69479. loadTileMaps(url: string): void;
  69480. /**
  69481. * Release associated resources
  69482. */
  69483. dispose(): void;
  69484. }
  69485. }
  69486. declare module "babylonjs/Sprites/spritePackedManager" {
  69487. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  69488. import { Scene } from "babylonjs/scene";
  69489. /**
  69490. * Class used to manage multiple sprites of different sizes on the same spritesheet
  69491. * @see http://doc.babylonjs.com/babylon101/sprites
  69492. */
  69493. export class SpritePackedManager extends SpriteManager {
  69494. /** defines the packed manager's name */
  69495. name: string;
  69496. /**
  69497. * Creates a new sprite manager from a packed sprite sheet
  69498. * @param name defines the manager's name
  69499. * @param imgUrl defines the sprite sheet url
  69500. * @param capacity defines the maximum allowed number of sprites
  69501. * @param scene defines the hosting scene
  69502. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  69503. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  69504. * @param samplingMode defines the smapling mode to use with spritesheet
  69505. * @param fromPacked set to true; do not alter
  69506. */
  69507. constructor(
  69508. /** defines the packed manager's name */
  69509. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  69510. }
  69511. }
  69512. declare module "babylonjs/Sprites/index" {
  69513. export * from "babylonjs/Sprites/sprite";
  69514. export * from "babylonjs/Sprites/ISprites";
  69515. export * from "babylonjs/Sprites/spriteManager";
  69516. export * from "babylonjs/Sprites/spriteMap";
  69517. export * from "babylonjs/Sprites/spritePackedManager";
  69518. export * from "babylonjs/Sprites/spriteSceneComponent";
  69519. }
  69520. declare module "babylonjs/States/index" {
  69521. export * from "babylonjs/States/alphaCullingState";
  69522. export * from "babylonjs/States/depthCullingState";
  69523. export * from "babylonjs/States/stencilState";
  69524. }
  69525. declare module "babylonjs/Misc/assetsManager" {
  69526. import { Scene } from "babylonjs/scene";
  69527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69528. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69529. import { Skeleton } from "babylonjs/Bones/skeleton";
  69530. import { Observable } from "babylonjs/Misc/observable";
  69531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  69532. import { Texture } from "babylonjs/Materials/Textures/texture";
  69533. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  69534. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  69535. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  69536. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  69537. /**
  69538. * Defines the list of states available for a task inside a AssetsManager
  69539. */
  69540. export enum AssetTaskState {
  69541. /**
  69542. * Initialization
  69543. */
  69544. INIT = 0,
  69545. /**
  69546. * Running
  69547. */
  69548. RUNNING = 1,
  69549. /**
  69550. * Done
  69551. */
  69552. DONE = 2,
  69553. /**
  69554. * Error
  69555. */
  69556. ERROR = 3
  69557. }
  69558. /**
  69559. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  69560. */
  69561. export abstract class AbstractAssetTask {
  69562. /**
  69563. * Task name
  69564. */ name: string;
  69565. /**
  69566. * Callback called when the task is successful
  69567. */
  69568. onSuccess: (task: any) => void;
  69569. /**
  69570. * Callback called when the task is not successful
  69571. */
  69572. onError: (task: any, message?: string, exception?: any) => void;
  69573. /**
  69574. * Creates a new AssetsManager
  69575. * @param name defines the name of the task
  69576. */
  69577. constructor(
  69578. /**
  69579. * Task name
  69580. */ name: string);
  69581. private _isCompleted;
  69582. private _taskState;
  69583. private _errorObject;
  69584. /**
  69585. * Get if the task is completed
  69586. */
  69587. get isCompleted(): boolean;
  69588. /**
  69589. * Gets the current state of the task
  69590. */
  69591. get taskState(): AssetTaskState;
  69592. /**
  69593. * Gets the current error object (if task is in error)
  69594. */
  69595. get errorObject(): {
  69596. message?: string;
  69597. exception?: any;
  69598. };
  69599. /**
  69600. * Internal only
  69601. * @hidden
  69602. */
  69603. _setErrorObject(message?: string, exception?: any): void;
  69604. /**
  69605. * Execute the current task
  69606. * @param scene defines the scene where you want your assets to be loaded
  69607. * @param onSuccess is a callback called when the task is successfully executed
  69608. * @param onError is a callback called if an error occurs
  69609. */
  69610. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69611. /**
  69612. * Execute the current task
  69613. * @param scene defines the scene where you want your assets to be loaded
  69614. * @param onSuccess is a callback called when the task is successfully executed
  69615. * @param onError is a callback called if an error occurs
  69616. */
  69617. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69618. /**
  69619. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  69620. * This can be used with failed tasks that have the reason for failure fixed.
  69621. */
  69622. reset(): void;
  69623. private onErrorCallback;
  69624. private onDoneCallback;
  69625. }
  69626. /**
  69627. * Define the interface used by progress events raised during assets loading
  69628. */
  69629. export interface IAssetsProgressEvent {
  69630. /**
  69631. * Defines the number of remaining tasks to process
  69632. */
  69633. remainingCount: number;
  69634. /**
  69635. * Defines the total number of tasks
  69636. */
  69637. totalCount: number;
  69638. /**
  69639. * Defines the task that was just processed
  69640. */
  69641. task: AbstractAssetTask;
  69642. }
  69643. /**
  69644. * Class used to share progress information about assets loading
  69645. */
  69646. export class AssetsProgressEvent implements IAssetsProgressEvent {
  69647. /**
  69648. * Defines the number of remaining tasks to process
  69649. */
  69650. remainingCount: number;
  69651. /**
  69652. * Defines the total number of tasks
  69653. */
  69654. totalCount: number;
  69655. /**
  69656. * Defines the task that was just processed
  69657. */
  69658. task: AbstractAssetTask;
  69659. /**
  69660. * Creates a AssetsProgressEvent
  69661. * @param remainingCount defines the number of remaining tasks to process
  69662. * @param totalCount defines the total number of tasks
  69663. * @param task defines the task that was just processed
  69664. */
  69665. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  69666. }
  69667. /**
  69668. * Define a task used by AssetsManager to load meshes
  69669. */
  69670. export class MeshAssetTask extends AbstractAssetTask {
  69671. /**
  69672. * Defines the name of the task
  69673. */
  69674. name: string;
  69675. /**
  69676. * Defines the list of mesh's names you want to load
  69677. */
  69678. meshesNames: any;
  69679. /**
  69680. * Defines the root url to use as a base to load your meshes and associated resources
  69681. */
  69682. rootUrl: string;
  69683. /**
  69684. * Defines the filename of the scene to load from
  69685. */
  69686. sceneFilename: string;
  69687. /**
  69688. * Gets the list of loaded meshes
  69689. */
  69690. loadedMeshes: Array<AbstractMesh>;
  69691. /**
  69692. * Gets the list of loaded particle systems
  69693. */
  69694. loadedParticleSystems: Array<IParticleSystem>;
  69695. /**
  69696. * Gets the list of loaded skeletons
  69697. */
  69698. loadedSkeletons: Array<Skeleton>;
  69699. /**
  69700. * Gets the list of loaded animation groups
  69701. */
  69702. loadedAnimationGroups: Array<AnimationGroup>;
  69703. /**
  69704. * Callback called when the task is successful
  69705. */
  69706. onSuccess: (task: MeshAssetTask) => void;
  69707. /**
  69708. * Callback called when the task is successful
  69709. */
  69710. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  69711. /**
  69712. * Creates a new MeshAssetTask
  69713. * @param name defines the name of the task
  69714. * @param meshesNames defines the list of mesh's names you want to load
  69715. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  69716. * @param sceneFilename defines the filename of the scene to load from
  69717. */
  69718. constructor(
  69719. /**
  69720. * Defines the name of the task
  69721. */
  69722. name: string,
  69723. /**
  69724. * Defines the list of mesh's names you want to load
  69725. */
  69726. meshesNames: any,
  69727. /**
  69728. * Defines the root url to use as a base to load your meshes and associated resources
  69729. */
  69730. rootUrl: string,
  69731. /**
  69732. * Defines the filename of the scene to load from
  69733. */
  69734. sceneFilename: string);
  69735. /**
  69736. * Execute the current task
  69737. * @param scene defines the scene where you want your assets to be loaded
  69738. * @param onSuccess is a callback called when the task is successfully executed
  69739. * @param onError is a callback called if an error occurs
  69740. */
  69741. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69742. }
  69743. /**
  69744. * Define a task used by AssetsManager to load text content
  69745. */
  69746. export class TextFileAssetTask extends AbstractAssetTask {
  69747. /**
  69748. * Defines the name of the task
  69749. */
  69750. name: string;
  69751. /**
  69752. * Defines the location of the file to load
  69753. */
  69754. url: string;
  69755. /**
  69756. * Gets the loaded text string
  69757. */
  69758. text: string;
  69759. /**
  69760. * Callback called when the task is successful
  69761. */
  69762. onSuccess: (task: TextFileAssetTask) => void;
  69763. /**
  69764. * Callback called when the task is successful
  69765. */
  69766. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  69767. /**
  69768. * Creates a new TextFileAssetTask object
  69769. * @param name defines the name of the task
  69770. * @param url defines the location of the file to load
  69771. */
  69772. constructor(
  69773. /**
  69774. * Defines the name of the task
  69775. */
  69776. name: string,
  69777. /**
  69778. * Defines the location of the file to load
  69779. */
  69780. url: string);
  69781. /**
  69782. * Execute the current task
  69783. * @param scene defines the scene where you want your assets to be loaded
  69784. * @param onSuccess is a callback called when the task is successfully executed
  69785. * @param onError is a callback called if an error occurs
  69786. */
  69787. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69788. }
  69789. /**
  69790. * Define a task used by AssetsManager to load binary data
  69791. */
  69792. export class BinaryFileAssetTask extends AbstractAssetTask {
  69793. /**
  69794. * Defines the name of the task
  69795. */
  69796. name: string;
  69797. /**
  69798. * Defines the location of the file to load
  69799. */
  69800. url: string;
  69801. /**
  69802. * Gets the lodaded data (as an array buffer)
  69803. */
  69804. data: ArrayBuffer;
  69805. /**
  69806. * Callback called when the task is successful
  69807. */
  69808. onSuccess: (task: BinaryFileAssetTask) => void;
  69809. /**
  69810. * Callback called when the task is successful
  69811. */
  69812. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  69813. /**
  69814. * Creates a new BinaryFileAssetTask object
  69815. * @param name defines the name of the new task
  69816. * @param url defines the location of the file to load
  69817. */
  69818. constructor(
  69819. /**
  69820. * Defines the name of the task
  69821. */
  69822. name: string,
  69823. /**
  69824. * Defines the location of the file to load
  69825. */
  69826. url: string);
  69827. /**
  69828. * Execute the current task
  69829. * @param scene defines the scene where you want your assets to be loaded
  69830. * @param onSuccess is a callback called when the task is successfully executed
  69831. * @param onError is a callback called if an error occurs
  69832. */
  69833. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69834. }
  69835. /**
  69836. * Define a task used by AssetsManager to load images
  69837. */
  69838. export class ImageAssetTask extends AbstractAssetTask {
  69839. /**
  69840. * Defines the name of the task
  69841. */
  69842. name: string;
  69843. /**
  69844. * Defines the location of the image to load
  69845. */
  69846. url: string;
  69847. /**
  69848. * Gets the loaded images
  69849. */
  69850. image: HTMLImageElement;
  69851. /**
  69852. * Callback called when the task is successful
  69853. */
  69854. onSuccess: (task: ImageAssetTask) => void;
  69855. /**
  69856. * Callback called when the task is successful
  69857. */
  69858. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  69859. /**
  69860. * Creates a new ImageAssetTask
  69861. * @param name defines the name of the task
  69862. * @param url defines the location of the image to load
  69863. */
  69864. constructor(
  69865. /**
  69866. * Defines the name of the task
  69867. */
  69868. name: string,
  69869. /**
  69870. * Defines the location of the image to load
  69871. */
  69872. url: string);
  69873. /**
  69874. * Execute the current task
  69875. * @param scene defines the scene where you want your assets to be loaded
  69876. * @param onSuccess is a callback called when the task is successfully executed
  69877. * @param onError is a callback called if an error occurs
  69878. */
  69879. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69880. }
  69881. /**
  69882. * Defines the interface used by texture loading tasks
  69883. */
  69884. export interface ITextureAssetTask<TEX extends BaseTexture> {
  69885. /**
  69886. * Gets the loaded texture
  69887. */
  69888. texture: TEX;
  69889. }
  69890. /**
  69891. * Define a task used by AssetsManager to load 2D textures
  69892. */
  69893. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  69894. /**
  69895. * Defines the name of the task
  69896. */
  69897. name: string;
  69898. /**
  69899. * Defines the location of the file to load
  69900. */
  69901. url: string;
  69902. /**
  69903. * Defines if mipmap should not be generated (default is false)
  69904. */
  69905. noMipmap?: boolean | undefined;
  69906. /**
  69907. * Defines if texture must be inverted on Y axis (default is false)
  69908. */
  69909. invertY?: boolean | undefined;
  69910. /**
  69911. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69912. */
  69913. samplingMode: number;
  69914. /**
  69915. * Gets the loaded texture
  69916. */
  69917. texture: Texture;
  69918. /**
  69919. * Callback called when the task is successful
  69920. */
  69921. onSuccess: (task: TextureAssetTask) => void;
  69922. /**
  69923. * Callback called when the task is successful
  69924. */
  69925. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  69926. /**
  69927. * Creates a new TextureAssetTask object
  69928. * @param name defines the name of the task
  69929. * @param url defines the location of the file to load
  69930. * @param noMipmap defines if mipmap should not be generated (default is false)
  69931. * @param invertY defines if texture must be inverted on Y axis (default is false)
  69932. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69933. */
  69934. constructor(
  69935. /**
  69936. * Defines the name of the task
  69937. */
  69938. name: string,
  69939. /**
  69940. * Defines the location of the file to load
  69941. */
  69942. url: string,
  69943. /**
  69944. * Defines if mipmap should not be generated (default is false)
  69945. */
  69946. noMipmap?: boolean | undefined,
  69947. /**
  69948. * Defines if texture must be inverted on Y axis (default is false)
  69949. */
  69950. invertY?: boolean | undefined,
  69951. /**
  69952. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  69953. */
  69954. samplingMode?: number);
  69955. /**
  69956. * Execute the current task
  69957. * @param scene defines the scene where you want your assets to be loaded
  69958. * @param onSuccess is a callback called when the task is successfully executed
  69959. * @param onError is a callback called if an error occurs
  69960. */
  69961. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  69962. }
  69963. /**
  69964. * Define a task used by AssetsManager to load cube textures
  69965. */
  69966. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  69967. /**
  69968. * Defines the name of the task
  69969. */
  69970. name: string;
  69971. /**
  69972. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  69973. */
  69974. url: string;
  69975. /**
  69976. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  69977. */
  69978. extensions?: string[] | undefined;
  69979. /**
  69980. * Defines if mipmaps should not be generated (default is false)
  69981. */
  69982. noMipmap?: boolean | undefined;
  69983. /**
  69984. * Defines the explicit list of files (undefined by default)
  69985. */
  69986. files?: string[] | undefined;
  69987. /**
  69988. * Gets the loaded texture
  69989. */
  69990. texture: CubeTexture;
  69991. /**
  69992. * Callback called when the task is successful
  69993. */
  69994. onSuccess: (task: CubeTextureAssetTask) => void;
  69995. /**
  69996. * Callback called when the task is successful
  69997. */
  69998. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  69999. /**
  70000. * Creates a new CubeTextureAssetTask
  70001. * @param name defines the name of the task
  70002. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70003. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70004. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70005. * @param files defines the explicit list of files (undefined by default)
  70006. */
  70007. constructor(
  70008. /**
  70009. * Defines the name of the task
  70010. */
  70011. name: string,
  70012. /**
  70013. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  70014. */
  70015. url: string,
  70016. /**
  70017. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  70018. */
  70019. extensions?: string[] | undefined,
  70020. /**
  70021. * Defines if mipmaps should not be generated (default is false)
  70022. */
  70023. noMipmap?: boolean | undefined,
  70024. /**
  70025. * Defines the explicit list of files (undefined by default)
  70026. */
  70027. files?: string[] | undefined);
  70028. /**
  70029. * Execute the current task
  70030. * @param scene defines the scene where you want your assets to be loaded
  70031. * @param onSuccess is a callback called when the task is successfully executed
  70032. * @param onError is a callback called if an error occurs
  70033. */
  70034. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70035. }
  70036. /**
  70037. * Define a task used by AssetsManager to load HDR cube textures
  70038. */
  70039. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  70040. /**
  70041. * Defines the name of the task
  70042. */
  70043. name: string;
  70044. /**
  70045. * Defines the location of the file to load
  70046. */
  70047. url: string;
  70048. /**
  70049. * Defines the desired size (the more it increases the longer the generation will be)
  70050. */
  70051. size: number;
  70052. /**
  70053. * Defines if mipmaps should not be generated (default is false)
  70054. */
  70055. noMipmap: boolean;
  70056. /**
  70057. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70058. */
  70059. generateHarmonics: boolean;
  70060. /**
  70061. * 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)
  70062. */
  70063. gammaSpace: boolean;
  70064. /**
  70065. * Internal Use Only
  70066. */
  70067. reserved: boolean;
  70068. /**
  70069. * Gets the loaded texture
  70070. */
  70071. texture: HDRCubeTexture;
  70072. /**
  70073. * Callback called when the task is successful
  70074. */
  70075. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  70076. /**
  70077. * Callback called when the task is successful
  70078. */
  70079. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  70080. /**
  70081. * Creates a new HDRCubeTextureAssetTask object
  70082. * @param name defines the name of the task
  70083. * @param url defines the location of the file to load
  70084. * @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.
  70085. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70086. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70087. * @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)
  70088. * @param reserved Internal use only
  70089. */
  70090. constructor(
  70091. /**
  70092. * Defines the name of the task
  70093. */
  70094. name: string,
  70095. /**
  70096. * Defines the location of the file to load
  70097. */
  70098. url: string,
  70099. /**
  70100. * Defines the desired size (the more it increases the longer the generation will be)
  70101. */
  70102. size: number,
  70103. /**
  70104. * Defines if mipmaps should not be generated (default is false)
  70105. */
  70106. noMipmap?: boolean,
  70107. /**
  70108. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  70109. */
  70110. generateHarmonics?: boolean,
  70111. /**
  70112. * 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)
  70113. */
  70114. gammaSpace?: boolean,
  70115. /**
  70116. * Internal Use Only
  70117. */
  70118. reserved?: boolean);
  70119. /**
  70120. * Execute the current task
  70121. * @param scene defines the scene where you want your assets to be loaded
  70122. * @param onSuccess is a callback called when the task is successfully executed
  70123. * @param onError is a callback called if an error occurs
  70124. */
  70125. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70126. }
  70127. /**
  70128. * Define a task used by AssetsManager to load Equirectangular cube textures
  70129. */
  70130. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  70131. /**
  70132. * Defines the name of the task
  70133. */
  70134. name: string;
  70135. /**
  70136. * Defines the location of the file to load
  70137. */
  70138. url: string;
  70139. /**
  70140. * Defines the desired size (the more it increases the longer the generation will be)
  70141. */
  70142. size: number;
  70143. /**
  70144. * Defines if mipmaps should not be generated (default is false)
  70145. */
  70146. noMipmap: boolean;
  70147. /**
  70148. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70149. * but the standard material would require them in Gamma space) (default is true)
  70150. */
  70151. gammaSpace: boolean;
  70152. /**
  70153. * Gets the loaded texture
  70154. */
  70155. texture: EquiRectangularCubeTexture;
  70156. /**
  70157. * Callback called when the task is successful
  70158. */
  70159. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  70160. /**
  70161. * Callback called when the task is successful
  70162. */
  70163. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  70164. /**
  70165. * Creates a new EquiRectangularCubeTextureAssetTask object
  70166. * @param name defines the name of the task
  70167. * @param url defines the location of the file to load
  70168. * @param size defines the desired size (the more it increases the longer the generation will be)
  70169. * If the size is omitted this implies you are using a preprocessed cubemap.
  70170. * @param noMipmap defines if mipmaps should not be generated (default is false)
  70171. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  70172. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  70173. * (default is true)
  70174. */
  70175. constructor(
  70176. /**
  70177. * Defines the name of the task
  70178. */
  70179. name: string,
  70180. /**
  70181. * Defines the location of the file to load
  70182. */
  70183. url: string,
  70184. /**
  70185. * Defines the desired size (the more it increases the longer the generation will be)
  70186. */
  70187. size: number,
  70188. /**
  70189. * Defines if mipmaps should not be generated (default is false)
  70190. */
  70191. noMipmap?: boolean,
  70192. /**
  70193. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  70194. * but the standard material would require them in Gamma space) (default is true)
  70195. */
  70196. gammaSpace?: boolean);
  70197. /**
  70198. * Execute the current task
  70199. * @param scene defines the scene where you want your assets to be loaded
  70200. * @param onSuccess is a callback called when the task is successfully executed
  70201. * @param onError is a callback called if an error occurs
  70202. */
  70203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70204. }
  70205. /**
  70206. * This class can be used to easily import assets into a scene
  70207. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  70208. */
  70209. export class AssetsManager {
  70210. private _scene;
  70211. private _isLoading;
  70212. protected _tasks: AbstractAssetTask[];
  70213. protected _waitingTasksCount: number;
  70214. protected _totalTasksCount: number;
  70215. /**
  70216. * Callback called when all tasks are processed
  70217. */
  70218. onFinish: (tasks: AbstractAssetTask[]) => void;
  70219. /**
  70220. * Callback called when a task is successful
  70221. */
  70222. onTaskSuccess: (task: AbstractAssetTask) => void;
  70223. /**
  70224. * Callback called when a task had an error
  70225. */
  70226. onTaskError: (task: AbstractAssetTask) => void;
  70227. /**
  70228. * Callback called when a task is done (whatever the result is)
  70229. */
  70230. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  70231. /**
  70232. * Observable called when all tasks are processed
  70233. */
  70234. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  70235. /**
  70236. * Observable called when a task had an error
  70237. */
  70238. onTaskErrorObservable: Observable<AbstractAssetTask>;
  70239. /**
  70240. * Observable called when all tasks were executed
  70241. */
  70242. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  70243. /**
  70244. * Observable called when a task is done (whatever the result is)
  70245. */
  70246. onProgressObservable: Observable<IAssetsProgressEvent>;
  70247. /**
  70248. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  70249. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  70250. */
  70251. useDefaultLoadingScreen: boolean;
  70252. /**
  70253. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  70254. * when all assets have been downloaded.
  70255. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  70256. */
  70257. autoHideLoadingUI: boolean;
  70258. /**
  70259. * Creates a new AssetsManager
  70260. * @param scene defines the scene to work on
  70261. */
  70262. constructor(scene: Scene);
  70263. /**
  70264. * Add a MeshAssetTask to the list of active tasks
  70265. * @param taskName defines the name of the new task
  70266. * @param meshesNames defines the name of meshes to load
  70267. * @param rootUrl defines the root url to use to locate files
  70268. * @param sceneFilename defines the filename of the scene file
  70269. * @returns a new MeshAssetTask object
  70270. */
  70271. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  70272. /**
  70273. * Add a TextFileAssetTask to the list of active tasks
  70274. * @param taskName defines the name of the new task
  70275. * @param url defines the url of the file to load
  70276. * @returns a new TextFileAssetTask object
  70277. */
  70278. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  70279. /**
  70280. * Add a BinaryFileAssetTask to the list of active tasks
  70281. * @param taskName defines the name of the new task
  70282. * @param url defines the url of the file to load
  70283. * @returns a new BinaryFileAssetTask object
  70284. */
  70285. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  70286. /**
  70287. * Add a ImageAssetTask to the list of active tasks
  70288. * @param taskName defines the name of the new task
  70289. * @param url defines the url of the file to load
  70290. * @returns a new ImageAssetTask object
  70291. */
  70292. addImageTask(taskName: string, url: string): ImageAssetTask;
  70293. /**
  70294. * Add a TextureAssetTask to the list of active tasks
  70295. * @param taskName defines the name of the new task
  70296. * @param url defines the url of the file to load
  70297. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70298. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  70299. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  70300. * @returns a new TextureAssetTask object
  70301. */
  70302. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  70303. /**
  70304. * Add a CubeTextureAssetTask to the list of active tasks
  70305. * @param taskName defines the name of the new task
  70306. * @param url defines the url of the file to load
  70307. * @param extensions defines the extension to use to load the cube map (can be null)
  70308. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70309. * @param files defines the list of files to load (can be null)
  70310. * @returns a new CubeTextureAssetTask object
  70311. */
  70312. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  70313. /**
  70314. *
  70315. * Add a HDRCubeTextureAssetTask to the list of active tasks
  70316. * @param taskName defines the name of the new task
  70317. * @param url defines the url of the file to load
  70318. * @param size defines the size you want for the cubemap (can be null)
  70319. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70320. * @param generateHarmonics defines if you want to automatically generate (true by default)
  70321. * @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)
  70322. * @param reserved Internal use only
  70323. * @returns a new HDRCubeTextureAssetTask object
  70324. */
  70325. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  70326. /**
  70327. *
  70328. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  70329. * @param taskName defines the name of the new task
  70330. * @param url defines the url of the file to load
  70331. * @param size defines the size you want for the cubemap (can be null)
  70332. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  70333. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  70334. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  70335. * @returns a new EquiRectangularCubeTextureAssetTask object
  70336. */
  70337. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  70338. /**
  70339. * Remove a task from the assets manager.
  70340. * @param task the task to remove
  70341. */
  70342. removeTask(task: AbstractAssetTask): void;
  70343. private _decreaseWaitingTasksCount;
  70344. private _runTask;
  70345. /**
  70346. * Reset the AssetsManager and remove all tasks
  70347. * @return the current instance of the AssetsManager
  70348. */
  70349. reset(): AssetsManager;
  70350. /**
  70351. * Start the loading process
  70352. * @return the current instance of the AssetsManager
  70353. */
  70354. load(): AssetsManager;
  70355. /**
  70356. * Start the loading process as an async operation
  70357. * @return a promise returning the list of failed tasks
  70358. */
  70359. loadAsync(): Promise<void>;
  70360. }
  70361. }
  70362. declare module "babylonjs/Misc/deferred" {
  70363. /**
  70364. * Wrapper class for promise with external resolve and reject.
  70365. */
  70366. export class Deferred<T> {
  70367. /**
  70368. * The promise associated with this deferred object.
  70369. */
  70370. readonly promise: Promise<T>;
  70371. private _resolve;
  70372. private _reject;
  70373. /**
  70374. * The resolve method of the promise associated with this deferred object.
  70375. */
  70376. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  70377. /**
  70378. * The reject method of the promise associated with this deferred object.
  70379. */
  70380. get reject(): (reason?: any) => void;
  70381. /**
  70382. * Constructor for this deferred object.
  70383. */
  70384. constructor();
  70385. }
  70386. }
  70387. declare module "babylonjs/Misc/meshExploder" {
  70388. import { Mesh } from "babylonjs/Meshes/mesh";
  70389. /**
  70390. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  70391. */
  70392. export class MeshExploder {
  70393. private _centerMesh;
  70394. private _meshes;
  70395. private _meshesOrigins;
  70396. private _toCenterVectors;
  70397. private _scaledDirection;
  70398. private _newPosition;
  70399. private _centerPosition;
  70400. /**
  70401. * Explodes meshes from a center mesh.
  70402. * @param meshes The meshes to explode.
  70403. * @param centerMesh The mesh to be center of explosion.
  70404. */
  70405. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  70406. private _setCenterMesh;
  70407. /**
  70408. * Get class name
  70409. * @returns "MeshExploder"
  70410. */
  70411. getClassName(): string;
  70412. /**
  70413. * "Exploded meshes"
  70414. * @returns Array of meshes with the centerMesh at index 0.
  70415. */
  70416. getMeshes(): Array<Mesh>;
  70417. /**
  70418. * Explodes meshes giving a specific direction
  70419. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  70420. */
  70421. explode(direction?: number): void;
  70422. }
  70423. }
  70424. declare module "babylonjs/Misc/filesInput" {
  70425. import { Engine } from "babylonjs/Engines/engine";
  70426. import { Scene } from "babylonjs/scene";
  70427. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  70428. /**
  70429. * Class used to help managing file picking and drag'n'drop
  70430. */
  70431. export class FilesInput {
  70432. /**
  70433. * List of files ready to be loaded
  70434. */
  70435. static get FilesToLoad(): {
  70436. [key: string]: File;
  70437. };
  70438. /**
  70439. * Callback called when a file is processed
  70440. */
  70441. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  70442. private _engine;
  70443. private _currentScene;
  70444. private _sceneLoadedCallback;
  70445. private _progressCallback;
  70446. private _additionalRenderLoopLogicCallback;
  70447. private _textureLoadingCallback;
  70448. private _startingProcessingFilesCallback;
  70449. private _onReloadCallback;
  70450. private _errorCallback;
  70451. private _elementToMonitor;
  70452. private _sceneFileToLoad;
  70453. private _filesToLoad;
  70454. /**
  70455. * Creates a new FilesInput
  70456. * @param engine defines the rendering engine
  70457. * @param scene defines the hosting scene
  70458. * @param sceneLoadedCallback callback called when scene is loaded
  70459. * @param progressCallback callback called to track progress
  70460. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  70461. * @param textureLoadingCallback callback called when a texture is loading
  70462. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  70463. * @param onReloadCallback callback called when a reload is requested
  70464. * @param errorCallback callback call if an error occurs
  70465. */
  70466. 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);
  70467. private _dragEnterHandler;
  70468. private _dragOverHandler;
  70469. private _dropHandler;
  70470. /**
  70471. * Calls this function to listen to drag'n'drop events on a specific DOM element
  70472. * @param elementToMonitor defines the DOM element to track
  70473. */
  70474. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  70475. /**
  70476. * Release all associated resources
  70477. */
  70478. dispose(): void;
  70479. private renderFunction;
  70480. private drag;
  70481. private drop;
  70482. private _traverseFolder;
  70483. private _processFiles;
  70484. /**
  70485. * Load files from a drop event
  70486. * @param event defines the drop event to use as source
  70487. */
  70488. loadFiles(event: any): void;
  70489. private _processReload;
  70490. /**
  70491. * Reload the current scene from the loaded files
  70492. */
  70493. reload(): void;
  70494. }
  70495. }
  70496. declare module "babylonjs/Misc/HighDynamicRange/index" {
  70497. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  70498. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  70499. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  70500. }
  70501. declare module "babylonjs/Misc/sceneOptimizer" {
  70502. import { Scene, IDisposable } from "babylonjs/scene";
  70503. import { Observable } from "babylonjs/Misc/observable";
  70504. /**
  70505. * Defines the root class used to create scene optimization to use with SceneOptimizer
  70506. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70507. */
  70508. export class SceneOptimization {
  70509. /**
  70510. * Defines the priority of this optimization (0 by default which means first in the list)
  70511. */
  70512. priority: number;
  70513. /**
  70514. * Gets a string describing the action executed by the current optimization
  70515. * @returns description string
  70516. */
  70517. getDescription(): string;
  70518. /**
  70519. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70520. * @param scene defines the current scene where to apply this optimization
  70521. * @param optimizer defines the current optimizer
  70522. * @returns true if everything that can be done was applied
  70523. */
  70524. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70525. /**
  70526. * Creates the SceneOptimization object
  70527. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70528. * @param desc defines the description associated with the optimization
  70529. */
  70530. constructor(
  70531. /**
  70532. * Defines the priority of this optimization (0 by default which means first in the list)
  70533. */
  70534. priority?: number);
  70535. }
  70536. /**
  70537. * Defines an optimization used to reduce the size of render target textures
  70538. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70539. */
  70540. export class TextureOptimization extends SceneOptimization {
  70541. /**
  70542. * Defines the priority of this optimization (0 by default which means first in the list)
  70543. */
  70544. priority: number;
  70545. /**
  70546. * 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
  70547. */
  70548. maximumSize: number;
  70549. /**
  70550. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70551. */
  70552. step: number;
  70553. /**
  70554. * Gets a string describing the action executed by the current optimization
  70555. * @returns description string
  70556. */
  70557. getDescription(): string;
  70558. /**
  70559. * Creates the TextureOptimization object
  70560. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70561. * @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
  70562. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70563. */
  70564. constructor(
  70565. /**
  70566. * Defines the priority of this optimization (0 by default which means first in the list)
  70567. */
  70568. priority?: number,
  70569. /**
  70570. * 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
  70571. */
  70572. maximumSize?: number,
  70573. /**
  70574. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  70575. */
  70576. step?: number);
  70577. /**
  70578. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70579. * @param scene defines the current scene where to apply this optimization
  70580. * @param optimizer defines the current optimizer
  70581. * @returns true if everything that can be done was applied
  70582. */
  70583. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70584. }
  70585. /**
  70586. * Defines an optimization used to increase or decrease the rendering resolution
  70587. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70588. */
  70589. export class HardwareScalingOptimization extends SceneOptimization {
  70590. /**
  70591. * Defines the priority of this optimization (0 by default which means first in the list)
  70592. */
  70593. priority: number;
  70594. /**
  70595. * Defines the maximum scale to use (2 by default)
  70596. */
  70597. maximumScale: number;
  70598. /**
  70599. * Defines the step to use between two passes (0.5 by default)
  70600. */
  70601. step: number;
  70602. private _currentScale;
  70603. private _directionOffset;
  70604. /**
  70605. * Gets a string describing the action executed by the current optimization
  70606. * @return description string
  70607. */
  70608. getDescription(): string;
  70609. /**
  70610. * Creates the HardwareScalingOptimization object
  70611. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70612. * @param maximumScale defines the maximum scale to use (2 by default)
  70613. * @param step defines the step to use between two passes (0.5 by default)
  70614. */
  70615. constructor(
  70616. /**
  70617. * Defines the priority of this optimization (0 by default which means first in the list)
  70618. */
  70619. priority?: number,
  70620. /**
  70621. * Defines the maximum scale to use (2 by default)
  70622. */
  70623. maximumScale?: number,
  70624. /**
  70625. * Defines the step to use between two passes (0.5 by default)
  70626. */
  70627. step?: number);
  70628. /**
  70629. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70630. * @param scene defines the current scene where to apply this optimization
  70631. * @param optimizer defines the current optimizer
  70632. * @returns true if everything that can be done was applied
  70633. */
  70634. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70635. }
  70636. /**
  70637. * Defines an optimization used to remove shadows
  70638. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70639. */
  70640. export class ShadowsOptimization extends SceneOptimization {
  70641. /**
  70642. * Gets a string describing the action executed by the current optimization
  70643. * @return description string
  70644. */
  70645. getDescription(): string;
  70646. /**
  70647. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70648. * @param scene defines the current scene where to apply this optimization
  70649. * @param optimizer defines the current optimizer
  70650. * @returns true if everything that can be done was applied
  70651. */
  70652. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70653. }
  70654. /**
  70655. * Defines an optimization used to turn post-processes off
  70656. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70657. */
  70658. export class PostProcessesOptimization extends SceneOptimization {
  70659. /**
  70660. * Gets a string describing the action executed by the current optimization
  70661. * @return description string
  70662. */
  70663. getDescription(): string;
  70664. /**
  70665. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70666. * @param scene defines the current scene where to apply this optimization
  70667. * @param optimizer defines the current optimizer
  70668. * @returns true if everything that can be done was applied
  70669. */
  70670. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70671. }
  70672. /**
  70673. * Defines an optimization used to turn lens flares off
  70674. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70675. */
  70676. export class LensFlaresOptimization extends SceneOptimization {
  70677. /**
  70678. * Gets a string describing the action executed by the current optimization
  70679. * @return description string
  70680. */
  70681. getDescription(): string;
  70682. /**
  70683. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70684. * @param scene defines the current scene where to apply this optimization
  70685. * @param optimizer defines the current optimizer
  70686. * @returns true if everything that can be done was applied
  70687. */
  70688. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70689. }
  70690. /**
  70691. * Defines an optimization based on user defined callback.
  70692. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70693. */
  70694. export class CustomOptimization extends SceneOptimization {
  70695. /**
  70696. * Callback called to apply the custom optimization.
  70697. */
  70698. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  70699. /**
  70700. * Callback called to get custom description
  70701. */
  70702. onGetDescription: () => string;
  70703. /**
  70704. * Gets a string describing the action executed by the current optimization
  70705. * @returns description string
  70706. */
  70707. getDescription(): string;
  70708. /**
  70709. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70710. * @param scene defines the current scene where to apply this optimization
  70711. * @param optimizer defines the current optimizer
  70712. * @returns true if everything that can be done was applied
  70713. */
  70714. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70715. }
  70716. /**
  70717. * Defines an optimization used to turn particles off
  70718. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70719. */
  70720. export class ParticlesOptimization extends SceneOptimization {
  70721. /**
  70722. * Gets a string describing the action executed by the current optimization
  70723. * @return description string
  70724. */
  70725. getDescription(): string;
  70726. /**
  70727. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70728. * @param scene defines the current scene where to apply this optimization
  70729. * @param optimizer defines the current optimizer
  70730. * @returns true if everything that can be done was applied
  70731. */
  70732. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70733. }
  70734. /**
  70735. * Defines an optimization used to turn render targets off
  70736. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70737. */
  70738. export class RenderTargetsOptimization extends SceneOptimization {
  70739. /**
  70740. * Gets a string describing the action executed by the current optimization
  70741. * @return description string
  70742. */
  70743. getDescription(): string;
  70744. /**
  70745. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70746. * @param scene defines the current scene where to apply this optimization
  70747. * @param optimizer defines the current optimizer
  70748. * @returns true if everything that can be done was applied
  70749. */
  70750. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  70751. }
  70752. /**
  70753. * Defines an optimization used to merge meshes with compatible materials
  70754. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70755. */
  70756. export class MergeMeshesOptimization extends SceneOptimization {
  70757. private static _UpdateSelectionTree;
  70758. /**
  70759. * Gets or sets a boolean which defines if optimization octree has to be updated
  70760. */
  70761. static get UpdateSelectionTree(): boolean;
  70762. /**
  70763. * Gets or sets a boolean which defines if optimization octree has to be updated
  70764. */
  70765. static set UpdateSelectionTree(value: boolean);
  70766. /**
  70767. * Gets a string describing the action executed by the current optimization
  70768. * @return description string
  70769. */
  70770. getDescription(): string;
  70771. private _canBeMerged;
  70772. /**
  70773. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  70774. * @param scene defines the current scene where to apply this optimization
  70775. * @param optimizer defines the current optimizer
  70776. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  70777. * @returns true if everything that can be done was applied
  70778. */
  70779. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  70780. }
  70781. /**
  70782. * Defines a list of options used by SceneOptimizer
  70783. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70784. */
  70785. export class SceneOptimizerOptions {
  70786. /**
  70787. * Defines the target frame rate to reach (60 by default)
  70788. */
  70789. targetFrameRate: number;
  70790. /**
  70791. * Defines the interval between two checkes (2000ms by default)
  70792. */
  70793. trackerDuration: number;
  70794. /**
  70795. * Gets the list of optimizations to apply
  70796. */
  70797. optimizations: SceneOptimization[];
  70798. /**
  70799. * Creates a new list of options used by SceneOptimizer
  70800. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  70801. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  70802. */
  70803. constructor(
  70804. /**
  70805. * Defines the target frame rate to reach (60 by default)
  70806. */
  70807. targetFrameRate?: number,
  70808. /**
  70809. * Defines the interval between two checkes (2000ms by default)
  70810. */
  70811. trackerDuration?: number);
  70812. /**
  70813. * Add a new optimization
  70814. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  70815. * @returns the current SceneOptimizerOptions
  70816. */
  70817. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  70818. /**
  70819. * Add a new custom optimization
  70820. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  70821. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  70822. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  70823. * @returns the current SceneOptimizerOptions
  70824. */
  70825. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  70826. /**
  70827. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  70828. * @param targetFrameRate defines the target frame rate (60 by default)
  70829. * @returns a SceneOptimizerOptions object
  70830. */
  70831. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70832. /**
  70833. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  70834. * @param targetFrameRate defines the target frame rate (60 by default)
  70835. * @returns a SceneOptimizerOptions object
  70836. */
  70837. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70838. /**
  70839. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  70840. * @param targetFrameRate defines the target frame rate (60 by default)
  70841. * @returns a SceneOptimizerOptions object
  70842. */
  70843. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  70844. }
  70845. /**
  70846. * Class used to run optimizations in order to reach a target frame rate
  70847. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  70848. */
  70849. export class SceneOptimizer implements IDisposable {
  70850. private _isRunning;
  70851. private _options;
  70852. private _scene;
  70853. private _currentPriorityLevel;
  70854. private _targetFrameRate;
  70855. private _trackerDuration;
  70856. private _currentFrameRate;
  70857. private _sceneDisposeObserver;
  70858. private _improvementMode;
  70859. /**
  70860. * Defines an observable called when the optimizer reaches the target frame rate
  70861. */
  70862. onSuccessObservable: Observable<SceneOptimizer>;
  70863. /**
  70864. * Defines an observable called when the optimizer enables an optimization
  70865. */
  70866. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  70867. /**
  70868. * Defines an observable called when the optimizer is not able to reach the target frame rate
  70869. */
  70870. onFailureObservable: Observable<SceneOptimizer>;
  70871. /**
  70872. * Gets a boolean indicating if the optimizer is in improvement mode
  70873. */
  70874. get isInImprovementMode(): boolean;
  70875. /**
  70876. * Gets the current priority level (0 at start)
  70877. */
  70878. get currentPriorityLevel(): number;
  70879. /**
  70880. * Gets the current frame rate checked by the SceneOptimizer
  70881. */
  70882. get currentFrameRate(): number;
  70883. /**
  70884. * Gets or sets the current target frame rate (60 by default)
  70885. */
  70886. get targetFrameRate(): number;
  70887. /**
  70888. * Gets or sets the current target frame rate (60 by default)
  70889. */
  70890. set targetFrameRate(value: number);
  70891. /**
  70892. * Gets or sets the current interval between two checks (every 2000ms by default)
  70893. */
  70894. get trackerDuration(): number;
  70895. /**
  70896. * Gets or sets the current interval between two checks (every 2000ms by default)
  70897. */
  70898. set trackerDuration(value: number);
  70899. /**
  70900. * Gets the list of active optimizations
  70901. */
  70902. get optimizations(): SceneOptimization[];
  70903. /**
  70904. * Creates a new SceneOptimizer
  70905. * @param scene defines the scene to work on
  70906. * @param options defines the options to use with the SceneOptimizer
  70907. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  70908. * @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)
  70909. */
  70910. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  70911. /**
  70912. * Stops the current optimizer
  70913. */
  70914. stop(): void;
  70915. /**
  70916. * Reset the optimizer to initial step (current priority level = 0)
  70917. */
  70918. reset(): void;
  70919. /**
  70920. * Start the optimizer. By default it will try to reach a specific framerate
  70921. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  70922. */
  70923. start(): void;
  70924. private _checkCurrentState;
  70925. /**
  70926. * Release all resources
  70927. */
  70928. dispose(): void;
  70929. /**
  70930. * Helper function to create a SceneOptimizer with one single line of code
  70931. * @param scene defines the scene to work on
  70932. * @param options defines the options to use with the SceneOptimizer
  70933. * @param onSuccess defines a callback to call on success
  70934. * @param onFailure defines a callback to call on failure
  70935. * @returns the new SceneOptimizer object
  70936. */
  70937. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  70938. }
  70939. }
  70940. declare module "babylonjs/Misc/sceneSerializer" {
  70941. import { Scene } from "babylonjs/scene";
  70942. /**
  70943. * Class used to serialize a scene into a string
  70944. */
  70945. export class SceneSerializer {
  70946. /**
  70947. * Clear cache used by a previous serialization
  70948. */
  70949. static ClearCache(): void;
  70950. /**
  70951. * Serialize a scene into a JSON compatible object
  70952. * @param scene defines the scene to serialize
  70953. * @returns a JSON compatible object
  70954. */
  70955. static Serialize(scene: Scene): any;
  70956. /**
  70957. * Serialize a mesh into a JSON compatible object
  70958. * @param toSerialize defines the mesh to serialize
  70959. * @param withParents defines if parents must be serialized as well
  70960. * @param withChildren defines if children must be serialized as well
  70961. * @returns a JSON compatible object
  70962. */
  70963. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  70964. }
  70965. }
  70966. declare module "babylonjs/Misc/textureTools" {
  70967. import { Texture } from "babylonjs/Materials/Textures/texture";
  70968. /**
  70969. * Class used to host texture specific utilities
  70970. */
  70971. export class TextureTools {
  70972. /**
  70973. * Uses the GPU to create a copy texture rescaled at a given size
  70974. * @param texture Texture to copy from
  70975. * @param width defines the desired width
  70976. * @param height defines the desired height
  70977. * @param useBilinearMode defines if bilinear mode has to be used
  70978. * @return the generated texture
  70979. */
  70980. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  70981. }
  70982. }
  70983. declare module "babylonjs/Misc/videoRecorder" {
  70984. import { Nullable } from "babylonjs/types";
  70985. import { Engine } from "babylonjs/Engines/engine";
  70986. /**
  70987. * This represents the different options available for the video capture.
  70988. */
  70989. export interface VideoRecorderOptions {
  70990. /** Defines the mime type of the video. */
  70991. mimeType: string;
  70992. /** Defines the FPS the video should be recorded at. */
  70993. fps: number;
  70994. /** Defines the chunk size for the recording data. */
  70995. recordChunckSize: number;
  70996. /** The audio tracks to attach to the recording. */
  70997. audioTracks?: MediaStreamTrack[];
  70998. }
  70999. /**
  71000. * This can help with recording videos from BabylonJS.
  71001. * This is based on the available WebRTC functionalities of the browser.
  71002. *
  71003. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  71004. */
  71005. export class VideoRecorder {
  71006. private static readonly _defaultOptions;
  71007. /**
  71008. * Returns whether or not the VideoRecorder is available in your browser.
  71009. * @param engine Defines the Babylon Engine.
  71010. * @returns true if supported otherwise false.
  71011. */
  71012. static IsSupported(engine: Engine): boolean;
  71013. private readonly _options;
  71014. private _canvas;
  71015. private _mediaRecorder;
  71016. private _recordedChunks;
  71017. private _fileName;
  71018. private _resolve;
  71019. private _reject;
  71020. /**
  71021. * True when a recording is already in progress.
  71022. */
  71023. get isRecording(): boolean;
  71024. /**
  71025. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  71026. * @param engine Defines the BabylonJS Engine you wish to record.
  71027. * @param options Defines options that can be used to customize the capture.
  71028. */
  71029. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  71030. /**
  71031. * Stops the current recording before the default capture timeout passed in the startRecording function.
  71032. */
  71033. stopRecording(): void;
  71034. /**
  71035. * Starts recording the canvas for a max duration specified in parameters.
  71036. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  71037. * If null no automatic download will start and you can rely on the promise to get the data back.
  71038. * @param maxDuration Defines the maximum recording time in seconds.
  71039. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  71040. * @return A promise callback at the end of the recording with the video data in Blob.
  71041. */
  71042. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  71043. /**
  71044. * Releases internal resources used during the recording.
  71045. */
  71046. dispose(): void;
  71047. private _handleDataAvailable;
  71048. private _handleError;
  71049. private _handleStop;
  71050. }
  71051. }
  71052. declare module "babylonjs/Misc/screenshotTools" {
  71053. import { Camera } from "babylonjs/Cameras/camera";
  71054. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  71055. import { Engine } from "babylonjs/Engines/engine";
  71056. /**
  71057. * Class containing a set of static utilities functions for screenshots
  71058. */
  71059. export class ScreenshotTools {
  71060. /**
  71061. * Captures a screenshot of the current rendering
  71062. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71063. * @param engine defines the rendering engine
  71064. * @param camera defines the source camera
  71065. * @param size This parameter can be set to a single number or to an object with the
  71066. * following (optional) properties: precision, width, height. If a single number is passed,
  71067. * it will be used for both width and height. If an object is passed, the screenshot size
  71068. * will be derived from the parameters. The precision property is a multiplier allowing
  71069. * rendering at a higher or lower resolution
  71070. * @param successCallback defines the callback receives a single parameter which contains the
  71071. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71072. * src parameter of an <img> to display it
  71073. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71074. * Check your browser for supported MIME types
  71075. */
  71076. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  71077. /**
  71078. * Captures a screenshot of the current rendering
  71079. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71080. * @param engine defines the rendering engine
  71081. * @param camera defines the source camera
  71082. * @param size This parameter can be set to a single number or to an object with the
  71083. * following (optional) properties: precision, width, height. If a single number is passed,
  71084. * it will be used for both width and height. If an object is passed, the screenshot size
  71085. * will be derived from the parameters. The precision property is a multiplier allowing
  71086. * rendering at a higher or lower resolution
  71087. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  71088. * Check your browser for supported MIME types
  71089. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71090. * to the src parameter of an <img> to display it
  71091. */
  71092. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  71093. /**
  71094. * Generates an image screenshot from the specified camera.
  71095. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71096. * @param engine The engine to use for rendering
  71097. * @param camera The camera to use for rendering
  71098. * @param size This parameter can be set to a single number or to an object with the
  71099. * following (optional) properties: precision, width, height. If a single number is passed,
  71100. * it will be used for both width and height. If an object is passed, the screenshot size
  71101. * will be derived from the parameters. The precision property is a multiplier allowing
  71102. * rendering at a higher or lower resolution
  71103. * @param successCallback The callback receives a single parameter which contains the
  71104. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  71105. * src parameter of an <img> to display it
  71106. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71107. * Check your browser for supported MIME types
  71108. * @param samples Texture samples (default: 1)
  71109. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71110. * @param fileName A name for for the downloaded file.
  71111. */
  71112. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  71113. /**
  71114. * Generates an image screenshot from the specified camera.
  71115. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  71116. * @param engine The engine to use for rendering
  71117. * @param camera The camera to use for rendering
  71118. * @param size This parameter can be set to a single number or to an object with the
  71119. * following (optional) properties: precision, width, height. If a single number is passed,
  71120. * it will be used for both width and height. If an object is passed, the screenshot size
  71121. * will be derived from the parameters. The precision property is a multiplier allowing
  71122. * rendering at a higher or lower resolution
  71123. * @param mimeType The MIME type of the screenshot image (default: image/png).
  71124. * Check your browser for supported MIME types
  71125. * @param samples Texture samples (default: 1)
  71126. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  71127. * @param fileName A name for for the downloaded file.
  71128. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  71129. * to the src parameter of an <img> to display it
  71130. */
  71131. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  71132. /**
  71133. * Gets height and width for screenshot size
  71134. * @private
  71135. */
  71136. private static _getScreenshotSize;
  71137. }
  71138. }
  71139. declare module "babylonjs/Misc/dataReader" {
  71140. /**
  71141. * Interface for a data buffer
  71142. */
  71143. export interface IDataBuffer {
  71144. /**
  71145. * Reads bytes from the data buffer.
  71146. * @param byteOffset The byte offset to read
  71147. * @param byteLength The byte length to read
  71148. * @returns A promise that resolves when the bytes are read
  71149. */
  71150. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  71151. /**
  71152. * The byte length of the buffer.
  71153. */
  71154. readonly byteLength: number;
  71155. }
  71156. /**
  71157. * Utility class for reading from a data buffer
  71158. */
  71159. export class DataReader {
  71160. /**
  71161. * The data buffer associated with this data reader.
  71162. */
  71163. readonly buffer: IDataBuffer;
  71164. /**
  71165. * The current byte offset from the beginning of the data buffer.
  71166. */
  71167. byteOffset: number;
  71168. private _dataView;
  71169. private _dataByteOffset;
  71170. /**
  71171. * Constructor
  71172. * @param buffer The buffer to read
  71173. */
  71174. constructor(buffer: IDataBuffer);
  71175. /**
  71176. * Loads the given byte length.
  71177. * @param byteLength The byte length to load
  71178. * @returns A promise that resolves when the load is complete
  71179. */
  71180. loadAsync(byteLength: number): Promise<void>;
  71181. /**
  71182. * Read a unsigned 32-bit integer from the currently loaded data range.
  71183. * @returns The 32-bit integer read
  71184. */
  71185. readUint32(): number;
  71186. /**
  71187. * Read a byte array from the currently loaded data range.
  71188. * @param byteLength The byte length to read
  71189. * @returns The byte array read
  71190. */
  71191. readUint8Array(byteLength: number): Uint8Array;
  71192. /**
  71193. * Read a string from the currently loaded data range.
  71194. * @param byteLength The byte length to read
  71195. * @returns The string read
  71196. */
  71197. readString(byteLength: number): string;
  71198. /**
  71199. * Skips the given byte length the currently loaded data range.
  71200. * @param byteLength The byte length to skip
  71201. */
  71202. skipBytes(byteLength: number): void;
  71203. }
  71204. }
  71205. declare module "babylonjs/Misc/index" {
  71206. export * from "babylonjs/Misc/andOrNotEvaluator";
  71207. export * from "babylonjs/Misc/assetsManager";
  71208. export * from "babylonjs/Misc/basis";
  71209. export * from "babylonjs/Misc/dds";
  71210. export * from "babylonjs/Misc/decorators";
  71211. export * from "babylonjs/Misc/deferred";
  71212. export * from "babylonjs/Misc/environmentTextureTools";
  71213. export * from "babylonjs/Misc/meshExploder";
  71214. export * from "babylonjs/Misc/filesInput";
  71215. export * from "babylonjs/Misc/HighDynamicRange/index";
  71216. export * from "babylonjs/Misc/khronosTextureContainer";
  71217. export * from "babylonjs/Misc/observable";
  71218. export * from "babylonjs/Misc/performanceMonitor";
  71219. export * from "babylonjs/Misc/promise";
  71220. export * from "babylonjs/Misc/sceneOptimizer";
  71221. export * from "babylonjs/Misc/sceneSerializer";
  71222. export * from "babylonjs/Misc/smartArray";
  71223. export * from "babylonjs/Misc/stringDictionary";
  71224. export * from "babylonjs/Misc/tags";
  71225. export * from "babylonjs/Misc/textureTools";
  71226. export * from "babylonjs/Misc/tga";
  71227. export * from "babylonjs/Misc/tools";
  71228. export * from "babylonjs/Misc/videoRecorder";
  71229. export * from "babylonjs/Misc/virtualJoystick";
  71230. export * from "babylonjs/Misc/workerPool";
  71231. export * from "babylonjs/Misc/logger";
  71232. export * from "babylonjs/Misc/typeStore";
  71233. export * from "babylonjs/Misc/filesInputStore";
  71234. export * from "babylonjs/Misc/deepCopier";
  71235. export * from "babylonjs/Misc/pivotTools";
  71236. export * from "babylonjs/Misc/precisionDate";
  71237. export * from "babylonjs/Misc/screenshotTools";
  71238. export * from "babylonjs/Misc/typeStore";
  71239. export * from "babylonjs/Misc/webRequest";
  71240. export * from "babylonjs/Misc/iInspectable";
  71241. export * from "babylonjs/Misc/brdfTextureTools";
  71242. export * from "babylonjs/Misc/rgbdTextureTools";
  71243. export * from "babylonjs/Misc/gradients";
  71244. export * from "babylonjs/Misc/perfCounter";
  71245. export * from "babylonjs/Misc/fileRequest";
  71246. export * from "babylonjs/Misc/customAnimationFrameRequester";
  71247. export * from "babylonjs/Misc/retryStrategy";
  71248. export * from "babylonjs/Misc/interfaces/screenshotSize";
  71249. export * from "babylonjs/Misc/canvasGenerator";
  71250. export * from "babylonjs/Misc/fileTools";
  71251. export * from "babylonjs/Misc/stringTools";
  71252. export * from "babylonjs/Misc/dataReader";
  71253. }
  71254. declare module "babylonjs/index" {
  71255. export * from "babylonjs/abstractScene";
  71256. export * from "babylonjs/Actions/index";
  71257. export * from "babylonjs/Animations/index";
  71258. export * from "babylonjs/assetContainer";
  71259. export * from "babylonjs/Audio/index";
  71260. export * from "babylonjs/Behaviors/index";
  71261. export * from "babylonjs/Bones/index";
  71262. export * from "babylonjs/Cameras/index";
  71263. export * from "babylonjs/Collisions/index";
  71264. export * from "babylonjs/Culling/index";
  71265. export * from "babylonjs/Debug/index";
  71266. export * from "babylonjs/Engines/index";
  71267. export * from "babylonjs/Events/index";
  71268. export * from "babylonjs/Gamepads/index";
  71269. export * from "babylonjs/Gizmos/index";
  71270. export * from "babylonjs/Helpers/index";
  71271. export * from "babylonjs/Instrumentation/index";
  71272. export * from "babylonjs/Layers/index";
  71273. export * from "babylonjs/LensFlares/index";
  71274. export * from "babylonjs/Lights/index";
  71275. export * from "babylonjs/Loading/index";
  71276. export * from "babylonjs/Materials/index";
  71277. export * from "babylonjs/Maths/index";
  71278. export * from "babylonjs/Meshes/index";
  71279. export * from "babylonjs/Morph/index";
  71280. export * from "babylonjs/Navigation/index";
  71281. export * from "babylonjs/node";
  71282. export * from "babylonjs/Offline/index";
  71283. export * from "babylonjs/Particles/index";
  71284. export * from "babylonjs/Physics/index";
  71285. export * from "babylonjs/PostProcesses/index";
  71286. export * from "babylonjs/Probes/index";
  71287. export * from "babylonjs/Rendering/index";
  71288. export * from "babylonjs/scene";
  71289. export * from "babylonjs/sceneComponent";
  71290. export * from "babylonjs/Sprites/index";
  71291. export * from "babylonjs/States/index";
  71292. export * from "babylonjs/Misc/index";
  71293. export * from "babylonjs/types";
  71294. }
  71295. declare module "babylonjs/Animations/pathCursor" {
  71296. import { Vector3 } from "babylonjs/Maths/math.vector";
  71297. import { Path2 } from "babylonjs/Maths/math.path";
  71298. /**
  71299. * A cursor which tracks a point on a path
  71300. */
  71301. export class PathCursor {
  71302. private path;
  71303. /**
  71304. * Stores path cursor callbacks for when an onchange event is triggered
  71305. */
  71306. private _onchange;
  71307. /**
  71308. * The value of the path cursor
  71309. */
  71310. value: number;
  71311. /**
  71312. * The animation array of the path cursor
  71313. */
  71314. animations: Animation[];
  71315. /**
  71316. * Initializes the path cursor
  71317. * @param path The path to track
  71318. */
  71319. constructor(path: Path2);
  71320. /**
  71321. * Gets the cursor point on the path
  71322. * @returns A point on the path cursor at the cursor location
  71323. */
  71324. getPoint(): Vector3;
  71325. /**
  71326. * Moves the cursor ahead by the step amount
  71327. * @param step The amount to move the cursor forward
  71328. * @returns This path cursor
  71329. */
  71330. moveAhead(step?: number): PathCursor;
  71331. /**
  71332. * Moves the cursor behind by the step amount
  71333. * @param step The amount to move the cursor back
  71334. * @returns This path cursor
  71335. */
  71336. moveBack(step?: number): PathCursor;
  71337. /**
  71338. * Moves the cursor by the step amount
  71339. * If the step amount is greater than one, an exception is thrown
  71340. * @param step The amount to move the cursor
  71341. * @returns This path cursor
  71342. */
  71343. move(step: number): PathCursor;
  71344. /**
  71345. * Ensures that the value is limited between zero and one
  71346. * @returns This path cursor
  71347. */
  71348. private ensureLimits;
  71349. /**
  71350. * Runs onchange callbacks on change (used by the animation engine)
  71351. * @returns This path cursor
  71352. */
  71353. private raiseOnChange;
  71354. /**
  71355. * Executes a function on change
  71356. * @param f A path cursor onchange callback
  71357. * @returns This path cursor
  71358. */
  71359. onchange(f: (cursor: PathCursor) => void): PathCursor;
  71360. }
  71361. }
  71362. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  71363. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  71364. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  71365. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  71366. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  71367. }
  71368. declare module "babylonjs/Engines/Processors/Expressions/index" {
  71369. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  71370. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  71371. }
  71372. declare module "babylonjs/Engines/Processors/index" {
  71373. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  71374. export * from "babylonjs/Engines/Processors/Expressions/index";
  71375. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  71376. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  71377. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  71378. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  71379. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  71380. export * from "babylonjs/Engines/Processors/shaderProcessor";
  71381. }
  71382. declare module "babylonjs/Legacy/legacy" {
  71383. import * as Babylon from "babylonjs/index";
  71384. export * from "babylonjs/index";
  71385. }
  71386. declare module "babylonjs/Shaders/blur.fragment" {
  71387. /** @hidden */
  71388. export var blurPixelShader: {
  71389. name: string;
  71390. shader: string;
  71391. };
  71392. }
  71393. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  71394. /** @hidden */
  71395. export var pointCloudVertexDeclaration: {
  71396. name: string;
  71397. shader: string;
  71398. };
  71399. }
  71400. declare module "babylonjs" {
  71401. export * from "babylonjs/Legacy/legacy";
  71402. }
  71403. declare module BABYLON {
  71404. /** Alias type for value that can be null */
  71405. export type Nullable<T> = T | null;
  71406. /**
  71407. * Alias type for number that are floats
  71408. * @ignorenaming
  71409. */
  71410. export type float = number;
  71411. /**
  71412. * Alias type for number that are doubles.
  71413. * @ignorenaming
  71414. */
  71415. export type double = number;
  71416. /**
  71417. * Alias type for number that are integer
  71418. * @ignorenaming
  71419. */
  71420. export type int = number;
  71421. /** Alias type for number array or Float32Array */
  71422. export type FloatArray = number[] | Float32Array;
  71423. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  71424. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  71425. /**
  71426. * Alias for types that can be used by a Buffer or VertexBuffer.
  71427. */
  71428. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  71429. /**
  71430. * Alias type for primitive types
  71431. * @ignorenaming
  71432. */
  71433. type Primitive = undefined | null | boolean | string | number | Function;
  71434. /**
  71435. * Type modifier to make all the properties of an object Readonly
  71436. */
  71437. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  71438. /**
  71439. * Type modifier to make all the properties of an object Readonly recursively
  71440. */
  71441. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  71442. /**
  71443. * Type modifier to make object properties readonly.
  71444. */
  71445. export type DeepImmutableObject<T> = {
  71446. readonly [K in keyof T]: DeepImmutable<T[K]>;
  71447. };
  71448. /** @hidden */
  71449. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  71450. }
  71451. }
  71452. declare module BABYLON {
  71453. /**
  71454. * A class serves as a medium between the observable and its observers
  71455. */
  71456. export class EventState {
  71457. /**
  71458. * Create a new EventState
  71459. * @param mask defines the mask associated with this state
  71460. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  71461. * @param target defines the original target of the state
  71462. * @param currentTarget defines the current target of the state
  71463. */
  71464. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  71465. /**
  71466. * Initialize the current event state
  71467. * @param mask defines the mask associated with this state
  71468. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  71469. * @param target defines the original target of the state
  71470. * @param currentTarget defines the current target of the state
  71471. * @returns the current event state
  71472. */
  71473. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71474. /**
  71475. * An Observer can set this property to true to prevent subsequent observers of being notified
  71476. */
  71477. skipNextObservers: boolean;
  71478. /**
  71479. * Get the mask value that were used to trigger the event corresponding to this EventState object
  71480. */
  71481. mask: number;
  71482. /**
  71483. * The object that originally notified the event
  71484. */
  71485. target?: any;
  71486. /**
  71487. * The current object in the bubbling phase
  71488. */
  71489. currentTarget?: any;
  71490. /**
  71491. * This will be populated with the return value of the last function that was executed.
  71492. * If it is the first function in the callback chain it will be the event data.
  71493. */
  71494. lastReturnValue?: any;
  71495. }
  71496. /**
  71497. * Represent an Observer registered to a given Observable object.
  71498. */
  71499. export class Observer<T> {
  71500. /**
  71501. * Defines the callback to call when the observer is notified
  71502. */
  71503. callback: (eventData: T, eventState: EventState) => void;
  71504. /**
  71505. * Defines the mask of the observer (used to filter notifications)
  71506. */
  71507. mask: number;
  71508. /**
  71509. * Defines the current scope used to restore the JS context
  71510. */
  71511. scope: any;
  71512. /** @hidden */
  71513. _willBeUnregistered: boolean;
  71514. /**
  71515. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  71516. */
  71517. unregisterOnNextCall: boolean;
  71518. /**
  71519. * Creates a new observer
  71520. * @param callback defines the callback to call when the observer is notified
  71521. * @param mask defines the mask of the observer (used to filter notifications)
  71522. * @param scope defines the current scope used to restore the JS context
  71523. */
  71524. constructor(
  71525. /**
  71526. * Defines the callback to call when the observer is notified
  71527. */
  71528. callback: (eventData: T, eventState: EventState) => void,
  71529. /**
  71530. * Defines the mask of the observer (used to filter notifications)
  71531. */
  71532. mask: number,
  71533. /**
  71534. * Defines the current scope used to restore the JS context
  71535. */
  71536. scope?: any);
  71537. }
  71538. /**
  71539. * Represent a list of observers registered to multiple Observables object.
  71540. */
  71541. export class MultiObserver<T> {
  71542. private _observers;
  71543. private _observables;
  71544. /**
  71545. * Release associated resources
  71546. */
  71547. dispose(): void;
  71548. /**
  71549. * Raise a callback when one of the observable will notify
  71550. * @param observables defines a list of observables to watch
  71551. * @param callback defines the callback to call on notification
  71552. * @param mask defines the mask used to filter notifications
  71553. * @param scope defines the current scope used to restore the JS context
  71554. * @returns the new MultiObserver
  71555. */
  71556. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  71557. }
  71558. /**
  71559. * The Observable class is a simple implementation of the Observable pattern.
  71560. *
  71561. * 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.
  71562. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  71563. * 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).
  71564. * 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.
  71565. */
  71566. export class Observable<T> {
  71567. private _observers;
  71568. private _eventState;
  71569. private _onObserverAdded;
  71570. /**
  71571. * Gets the list of observers
  71572. */
  71573. get observers(): Array<Observer<T>>;
  71574. /**
  71575. * Creates a new observable
  71576. * @param onObserverAdded defines a callback to call when a new observer is added
  71577. */
  71578. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  71579. /**
  71580. * Create a new Observer with the specified callback
  71581. * @param callback the callback that will be executed for that Observer
  71582. * @param mask the mask used to filter observers
  71583. * @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.
  71584. * @param scope optional scope for the callback to be called from
  71585. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  71586. * @returns the new observer created for the callback
  71587. */
  71588. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  71589. /**
  71590. * Create a new Observer with the specified callback and unregisters after the next notification
  71591. * @param callback the callback that will be executed for that Observer
  71592. * @returns the new observer created for the callback
  71593. */
  71594. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  71595. /**
  71596. * Remove an Observer from the Observable object
  71597. * @param observer the instance of the Observer to remove
  71598. * @returns false if it doesn't belong to this Observable
  71599. */
  71600. remove(observer: Nullable<Observer<T>>): boolean;
  71601. /**
  71602. * Remove a callback from the Observable object
  71603. * @param callback the callback to remove
  71604. * @param scope optional scope. If used only the callbacks with this scope will be removed
  71605. * @returns false if it doesn't belong to this Observable
  71606. */
  71607. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  71608. private _deferUnregister;
  71609. private _remove;
  71610. /**
  71611. * Moves the observable to the top of the observer list making it get called first when notified
  71612. * @param observer the observer to move
  71613. */
  71614. makeObserverTopPriority(observer: Observer<T>): void;
  71615. /**
  71616. * Moves the observable to the bottom of the observer list making it get called last when notified
  71617. * @param observer the observer to move
  71618. */
  71619. makeObserverBottomPriority(observer: Observer<T>): void;
  71620. /**
  71621. * Notify all Observers by calling their respective callback with the given data
  71622. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  71623. * @param eventData defines the data to send to all observers
  71624. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  71625. * @param target defines the original target of the state
  71626. * @param currentTarget defines the current target of the state
  71627. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  71628. */
  71629. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  71630. /**
  71631. * Calling this will execute each callback, expecting it to be a promise or return a value.
  71632. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  71633. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  71634. * and it is crucial that all callbacks will be executed.
  71635. * The order of the callbacks is kept, callbacks are not executed parallel.
  71636. *
  71637. * @param eventData The data to be sent to each callback
  71638. * @param mask is used to filter observers defaults to -1
  71639. * @param target defines the callback target (see EventState)
  71640. * @param currentTarget defines he current object in the bubbling phase
  71641. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  71642. */
  71643. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  71644. /**
  71645. * Notify a specific observer
  71646. * @param observer defines the observer to notify
  71647. * @param eventData defines the data to be sent to each callback
  71648. * @param mask is used to filter observers defaults to -1
  71649. */
  71650. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  71651. /**
  71652. * Gets a boolean indicating if the observable has at least one observer
  71653. * @returns true is the Observable has at least one Observer registered
  71654. */
  71655. hasObservers(): boolean;
  71656. /**
  71657. * Clear the list of observers
  71658. */
  71659. clear(): void;
  71660. /**
  71661. * Clone the current observable
  71662. * @returns a new observable
  71663. */
  71664. clone(): Observable<T>;
  71665. /**
  71666. * Does this observable handles observer registered with a given mask
  71667. * @param mask defines the mask to be tested
  71668. * @return whether or not one observer registered with the given mask is handeled
  71669. **/
  71670. hasSpecificMask(mask?: number): boolean;
  71671. }
  71672. }
  71673. declare module BABYLON {
  71674. /**
  71675. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  71676. * Babylon.js
  71677. */
  71678. export class DomManagement {
  71679. /**
  71680. * Checks if the window object exists
  71681. * @returns true if the window object exists
  71682. */
  71683. static IsWindowObjectExist(): boolean;
  71684. /**
  71685. * Checks if the navigator object exists
  71686. * @returns true if the navigator object exists
  71687. */
  71688. static IsNavigatorAvailable(): boolean;
  71689. /**
  71690. * Extracts text content from a DOM element hierarchy
  71691. * @param element defines the root element
  71692. * @returns a string
  71693. */
  71694. static GetDOMTextContent(element: HTMLElement): string;
  71695. }
  71696. }
  71697. declare module BABYLON {
  71698. /**
  71699. * Logger used througouht the application to allow configuration of
  71700. * the log level required for the messages.
  71701. */
  71702. export class Logger {
  71703. /**
  71704. * No log
  71705. */
  71706. static readonly NoneLogLevel: number;
  71707. /**
  71708. * Only message logs
  71709. */
  71710. static readonly MessageLogLevel: number;
  71711. /**
  71712. * Only warning logs
  71713. */
  71714. static readonly WarningLogLevel: number;
  71715. /**
  71716. * Only error logs
  71717. */
  71718. static readonly ErrorLogLevel: number;
  71719. /**
  71720. * All logs
  71721. */
  71722. static readonly AllLogLevel: number;
  71723. private static _LogCache;
  71724. /**
  71725. * Gets a value indicating the number of loading errors
  71726. * @ignorenaming
  71727. */
  71728. static errorsCount: number;
  71729. /**
  71730. * Callback called when a new log is added
  71731. */
  71732. static OnNewCacheEntry: (entry: string) => void;
  71733. private static _AddLogEntry;
  71734. private static _FormatMessage;
  71735. private static _LogDisabled;
  71736. private static _LogEnabled;
  71737. private static _WarnDisabled;
  71738. private static _WarnEnabled;
  71739. private static _ErrorDisabled;
  71740. private static _ErrorEnabled;
  71741. /**
  71742. * Log a message to the console
  71743. */
  71744. static Log: (message: string) => void;
  71745. /**
  71746. * Write a warning message to the console
  71747. */
  71748. static Warn: (message: string) => void;
  71749. /**
  71750. * Write an error message to the console
  71751. */
  71752. static Error: (message: string) => void;
  71753. /**
  71754. * Gets current log cache (list of logs)
  71755. */
  71756. static get LogCache(): string;
  71757. /**
  71758. * Clears the log cache
  71759. */
  71760. static ClearLogCache(): void;
  71761. /**
  71762. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  71763. */
  71764. static set LogLevels(level: number);
  71765. }
  71766. }
  71767. declare module BABYLON {
  71768. /** @hidden */
  71769. export class _TypeStore {
  71770. /** @hidden */
  71771. static RegisteredTypes: {
  71772. [key: string]: Object;
  71773. };
  71774. /** @hidden */
  71775. static GetClass(fqdn: string): any;
  71776. }
  71777. }
  71778. declare module BABYLON {
  71779. /**
  71780. * Helper to manipulate strings
  71781. */
  71782. export class StringTools {
  71783. /**
  71784. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71785. * @param str Source string
  71786. * @param suffix Suffix to search for in the source string
  71787. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71788. */
  71789. static EndsWith(str: string, suffix: string): boolean;
  71790. /**
  71791. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71792. * @param str Source string
  71793. * @param suffix Suffix to search for in the source string
  71794. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71795. */
  71796. static StartsWith(str: string, suffix: string): boolean;
  71797. /**
  71798. * Decodes a buffer into a string
  71799. * @param buffer The buffer to decode
  71800. * @returns The decoded string
  71801. */
  71802. static Decode(buffer: Uint8Array | Uint16Array): string;
  71803. /**
  71804. * Encode a buffer to a base64 string
  71805. * @param buffer defines the buffer to encode
  71806. * @returns the encoded string
  71807. */
  71808. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  71809. }
  71810. }
  71811. declare module BABYLON {
  71812. /**
  71813. * Class containing a set of static utilities functions for deep copy.
  71814. */
  71815. export class DeepCopier {
  71816. /**
  71817. * Tries to copy an object by duplicating every property
  71818. * @param source defines the source object
  71819. * @param destination defines the target object
  71820. * @param doNotCopyList defines a list of properties to avoid
  71821. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  71822. */
  71823. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  71824. }
  71825. }
  71826. declare module BABYLON {
  71827. /**
  71828. * Class containing a set of static utilities functions for precision date
  71829. */
  71830. export class PrecisionDate {
  71831. /**
  71832. * Gets either window.performance.now() if supported or Date.now() else
  71833. */
  71834. static get Now(): number;
  71835. }
  71836. }
  71837. declare module BABYLON {
  71838. /** @hidden */
  71839. export class _DevTools {
  71840. static WarnImport(name: string): string;
  71841. }
  71842. }
  71843. declare module BABYLON {
  71844. /**
  71845. * Interface used to define the mechanism to get data from the network
  71846. */
  71847. export interface IWebRequest {
  71848. /**
  71849. * Returns client's response url
  71850. */
  71851. responseURL: string;
  71852. /**
  71853. * Returns client's status
  71854. */
  71855. status: number;
  71856. /**
  71857. * Returns client's status as a text
  71858. */
  71859. statusText: string;
  71860. }
  71861. }
  71862. declare module BABYLON {
  71863. /**
  71864. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  71865. */
  71866. export class WebRequest implements IWebRequest {
  71867. private _xhr;
  71868. /**
  71869. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  71870. * i.e. when loading files, where the server/service expects an Authorization header
  71871. */
  71872. static CustomRequestHeaders: {
  71873. [key: string]: string;
  71874. };
  71875. /**
  71876. * Add callback functions in this array to update all the requests before they get sent to the network
  71877. */
  71878. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  71879. private _injectCustomRequestHeaders;
  71880. /**
  71881. * Gets or sets a function to be called when loading progress changes
  71882. */
  71883. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  71884. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  71885. /**
  71886. * Returns client's state
  71887. */
  71888. get readyState(): number;
  71889. /**
  71890. * Returns client's status
  71891. */
  71892. get status(): number;
  71893. /**
  71894. * Returns client's status as a text
  71895. */
  71896. get statusText(): string;
  71897. /**
  71898. * Returns client's response
  71899. */
  71900. get response(): any;
  71901. /**
  71902. * Returns client's response url
  71903. */
  71904. get responseURL(): string;
  71905. /**
  71906. * Returns client's response as text
  71907. */
  71908. get responseText(): string;
  71909. /**
  71910. * Gets or sets the expected response type
  71911. */
  71912. get responseType(): XMLHttpRequestResponseType;
  71913. set responseType(value: XMLHttpRequestResponseType);
  71914. /** @hidden */
  71915. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  71916. /** @hidden */
  71917. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  71918. /**
  71919. * Cancels any network activity
  71920. */
  71921. abort(): void;
  71922. /**
  71923. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  71924. * @param body defines an optional request body
  71925. */
  71926. send(body?: Document | BodyInit | null): void;
  71927. /**
  71928. * Sets the request method, request URL
  71929. * @param method defines the method to use (GET, POST, etc..)
  71930. * @param url defines the url to connect with
  71931. */
  71932. open(method: string, url: string): void;
  71933. /**
  71934. * Sets the value of a request header.
  71935. * @param name The name of the header whose value is to be set
  71936. * @param value The value to set as the body of the header
  71937. */
  71938. setRequestHeader(name: string, value: string): void;
  71939. /**
  71940. * Get the string containing the text of a particular header's value.
  71941. * @param name The name of the header
  71942. * @returns The string containing the text of the given header name
  71943. */
  71944. getResponseHeader(name: string): Nullable<string>;
  71945. }
  71946. }
  71947. declare module BABYLON {
  71948. /**
  71949. * File request interface
  71950. */
  71951. export interface IFileRequest {
  71952. /**
  71953. * Raised when the request is complete (success or error).
  71954. */
  71955. onCompleteObservable: Observable<IFileRequest>;
  71956. /**
  71957. * Aborts the request for a file.
  71958. */
  71959. abort: () => void;
  71960. }
  71961. }
  71962. declare module BABYLON {
  71963. /**
  71964. * Define options used to create a render target texture
  71965. */
  71966. export class RenderTargetCreationOptions {
  71967. /**
  71968. * Specifies is mipmaps must be generated
  71969. */
  71970. generateMipMaps?: boolean;
  71971. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71972. generateDepthBuffer?: boolean;
  71973. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71974. generateStencilBuffer?: boolean;
  71975. /** Defines texture type (int by default) */
  71976. type?: number;
  71977. /** Defines sampling mode (trilinear by default) */
  71978. samplingMode?: number;
  71979. /** Defines format (RGBA by default) */
  71980. format?: number;
  71981. }
  71982. }
  71983. declare module BABYLON {
  71984. /**
  71985. * @hidden
  71986. **/
  71987. export class _TimeToken {
  71988. _startTimeQuery: Nullable<WebGLQuery>;
  71989. _endTimeQuery: Nullable<WebGLQuery>;
  71990. _timeElapsedQuery: Nullable<WebGLQuery>;
  71991. _timeElapsedQueryEnded: boolean;
  71992. }
  71993. }
  71994. declare module BABYLON {
  71995. /** Defines the cross module used constants to avoid circular dependncies */
  71996. export class Constants {
  71997. /** Defines that alpha blending is disabled */
  71998. static readonly ALPHA_DISABLE: number;
  71999. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  72000. static readonly ALPHA_ADD: number;
  72001. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  72002. static readonly ALPHA_COMBINE: number;
  72003. /** Defines that alpha blending is DEST - SRC * DEST */
  72004. static readonly ALPHA_SUBTRACT: number;
  72005. /** Defines that alpha blending is SRC * DEST */
  72006. static readonly ALPHA_MULTIPLY: number;
  72007. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  72008. static readonly ALPHA_MAXIMIZED: number;
  72009. /** Defines that alpha blending is SRC + DEST */
  72010. static readonly ALPHA_ONEONE: number;
  72011. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  72012. static readonly ALPHA_PREMULTIPLIED: number;
  72013. /**
  72014. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  72015. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  72016. */
  72017. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  72018. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  72019. static readonly ALPHA_INTERPOLATE: number;
  72020. /**
  72021. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  72022. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  72023. */
  72024. static readonly ALPHA_SCREENMODE: number;
  72025. /**
  72026. * Defines that alpha blending is SRC + DST
  72027. * Alpha will be set to SRC ALPHA + DST ALPHA
  72028. */
  72029. static readonly ALPHA_ONEONE_ONEONE: number;
  72030. /**
  72031. * Defines that alpha blending is SRC * DST ALPHA + DST
  72032. * Alpha will be set to 0
  72033. */
  72034. static readonly ALPHA_ALPHATOCOLOR: number;
  72035. /**
  72036. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  72037. */
  72038. static readonly ALPHA_REVERSEONEMINUS: number;
  72039. /**
  72040. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  72041. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  72042. */
  72043. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  72044. /**
  72045. * Defines that alpha blending is SRC + DST
  72046. * Alpha will be set to SRC ALPHA
  72047. */
  72048. static readonly ALPHA_ONEONE_ONEZERO: number;
  72049. /**
  72050. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  72051. * Alpha will be set to DST ALPHA
  72052. */
  72053. static readonly ALPHA_EXCLUSION: number;
  72054. /** Defines that alpha blending equation a SUM */
  72055. static readonly ALPHA_EQUATION_ADD: number;
  72056. /** Defines that alpha blending equation a SUBSTRACTION */
  72057. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  72058. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  72059. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  72060. /** Defines that alpha blending equation a MAX operation */
  72061. static readonly ALPHA_EQUATION_MAX: number;
  72062. /** Defines that alpha blending equation a MIN operation */
  72063. static readonly ALPHA_EQUATION_MIN: number;
  72064. /**
  72065. * Defines that alpha blending equation a DARKEN operation:
  72066. * It takes the min of the src and sums the alpha channels.
  72067. */
  72068. static readonly ALPHA_EQUATION_DARKEN: number;
  72069. /** Defines that the ressource is not delayed*/
  72070. static readonly DELAYLOADSTATE_NONE: number;
  72071. /** Defines that the ressource was successfully delay loaded */
  72072. static readonly DELAYLOADSTATE_LOADED: number;
  72073. /** Defines that the ressource is currently delay loading */
  72074. static readonly DELAYLOADSTATE_LOADING: number;
  72075. /** Defines that the ressource is delayed and has not started loading */
  72076. static readonly DELAYLOADSTATE_NOTLOADED: number;
  72077. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  72078. static readonly NEVER: number;
  72079. /** 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 */
  72080. static readonly ALWAYS: number;
  72081. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  72082. static readonly LESS: number;
  72083. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  72084. static readonly EQUAL: number;
  72085. /** 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 */
  72086. static readonly LEQUAL: number;
  72087. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  72088. static readonly GREATER: number;
  72089. /** 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 */
  72090. static readonly GEQUAL: number;
  72091. /** 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 */
  72092. static readonly NOTEQUAL: number;
  72093. /** Passed to stencilOperation to specify that stencil value must be kept */
  72094. static readonly KEEP: number;
  72095. /** Passed to stencilOperation to specify that stencil value must be replaced */
  72096. static readonly REPLACE: number;
  72097. /** Passed to stencilOperation to specify that stencil value must be incremented */
  72098. static readonly INCR: number;
  72099. /** Passed to stencilOperation to specify that stencil value must be decremented */
  72100. static readonly DECR: number;
  72101. /** Passed to stencilOperation to specify that stencil value must be inverted */
  72102. static readonly INVERT: number;
  72103. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  72104. static readonly INCR_WRAP: number;
  72105. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  72106. static readonly DECR_WRAP: number;
  72107. /** Texture is not repeating outside of 0..1 UVs */
  72108. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  72109. /** Texture is repeating outside of 0..1 UVs */
  72110. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  72111. /** Texture is repeating and mirrored */
  72112. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  72113. /** ALPHA */
  72114. static readonly TEXTUREFORMAT_ALPHA: number;
  72115. /** LUMINANCE */
  72116. static readonly TEXTUREFORMAT_LUMINANCE: number;
  72117. /** LUMINANCE_ALPHA */
  72118. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  72119. /** RGB */
  72120. static readonly TEXTUREFORMAT_RGB: number;
  72121. /** RGBA */
  72122. static readonly TEXTUREFORMAT_RGBA: number;
  72123. /** RED */
  72124. static readonly TEXTUREFORMAT_RED: number;
  72125. /** RED (2nd reference) */
  72126. static readonly TEXTUREFORMAT_R: number;
  72127. /** RG */
  72128. static readonly TEXTUREFORMAT_RG: number;
  72129. /** RED_INTEGER */
  72130. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  72131. /** RED_INTEGER (2nd reference) */
  72132. static readonly TEXTUREFORMAT_R_INTEGER: number;
  72133. /** RG_INTEGER */
  72134. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  72135. /** RGB_INTEGER */
  72136. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  72137. /** RGBA_INTEGER */
  72138. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  72139. /** UNSIGNED_BYTE */
  72140. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  72141. /** UNSIGNED_BYTE (2nd reference) */
  72142. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  72143. /** FLOAT */
  72144. static readonly TEXTURETYPE_FLOAT: number;
  72145. /** HALF_FLOAT */
  72146. static readonly TEXTURETYPE_HALF_FLOAT: number;
  72147. /** BYTE */
  72148. static readonly TEXTURETYPE_BYTE: number;
  72149. /** SHORT */
  72150. static readonly TEXTURETYPE_SHORT: number;
  72151. /** UNSIGNED_SHORT */
  72152. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  72153. /** INT */
  72154. static readonly TEXTURETYPE_INT: number;
  72155. /** UNSIGNED_INT */
  72156. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  72157. /** UNSIGNED_SHORT_4_4_4_4 */
  72158. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  72159. /** UNSIGNED_SHORT_5_5_5_1 */
  72160. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  72161. /** UNSIGNED_SHORT_5_6_5 */
  72162. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  72163. /** UNSIGNED_INT_2_10_10_10_REV */
  72164. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  72165. /** UNSIGNED_INT_24_8 */
  72166. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  72167. /** UNSIGNED_INT_10F_11F_11F_REV */
  72168. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  72169. /** UNSIGNED_INT_5_9_9_9_REV */
  72170. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  72171. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  72172. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  72173. /** nearest is mag = nearest and min = nearest and no mip */
  72174. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  72175. /** mag = nearest and min = nearest and mip = none */
  72176. static readonly TEXTURE_NEAREST_NEAREST: number;
  72177. /** Bilinear is mag = linear and min = linear and no mip */
  72178. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  72179. /** mag = linear and min = linear and mip = none */
  72180. static readonly TEXTURE_LINEAR_LINEAR: number;
  72181. /** Trilinear is mag = linear and min = linear and mip = linear */
  72182. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  72183. /** Trilinear is mag = linear and min = linear and mip = linear */
  72184. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  72185. /** mag = nearest and min = nearest and mip = nearest */
  72186. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  72187. /** mag = nearest and min = linear and mip = nearest */
  72188. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  72189. /** mag = nearest and min = linear and mip = linear */
  72190. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  72191. /** mag = nearest and min = linear and mip = none */
  72192. static readonly TEXTURE_NEAREST_LINEAR: number;
  72193. /** nearest is mag = nearest and min = nearest and mip = linear */
  72194. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  72195. /** mag = linear and min = nearest and mip = nearest */
  72196. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  72197. /** mag = linear and min = nearest and mip = linear */
  72198. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  72199. /** Bilinear is mag = linear and min = linear and mip = nearest */
  72200. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  72201. /** mag = linear and min = nearest and mip = none */
  72202. static readonly TEXTURE_LINEAR_NEAREST: number;
  72203. /** Explicit coordinates mode */
  72204. static readonly TEXTURE_EXPLICIT_MODE: number;
  72205. /** Spherical coordinates mode */
  72206. static readonly TEXTURE_SPHERICAL_MODE: number;
  72207. /** Planar coordinates mode */
  72208. static readonly TEXTURE_PLANAR_MODE: number;
  72209. /** Cubic coordinates mode */
  72210. static readonly TEXTURE_CUBIC_MODE: number;
  72211. /** Projection coordinates mode */
  72212. static readonly TEXTURE_PROJECTION_MODE: number;
  72213. /** Skybox coordinates mode */
  72214. static readonly TEXTURE_SKYBOX_MODE: number;
  72215. /** Inverse Cubic coordinates mode */
  72216. static readonly TEXTURE_INVCUBIC_MODE: number;
  72217. /** Equirectangular coordinates mode */
  72218. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  72219. /** Equirectangular Fixed coordinates mode */
  72220. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  72221. /** Equirectangular Fixed Mirrored coordinates mode */
  72222. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  72223. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  72224. static readonly SCALEMODE_FLOOR: number;
  72225. /** Defines that texture rescaling will look for the nearest power of 2 size */
  72226. static readonly SCALEMODE_NEAREST: number;
  72227. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  72228. static readonly SCALEMODE_CEILING: number;
  72229. /**
  72230. * The dirty texture flag value
  72231. */
  72232. static readonly MATERIAL_TextureDirtyFlag: number;
  72233. /**
  72234. * The dirty light flag value
  72235. */
  72236. static readonly MATERIAL_LightDirtyFlag: number;
  72237. /**
  72238. * The dirty fresnel flag value
  72239. */
  72240. static readonly MATERIAL_FresnelDirtyFlag: number;
  72241. /**
  72242. * The dirty attribute flag value
  72243. */
  72244. static readonly MATERIAL_AttributesDirtyFlag: number;
  72245. /**
  72246. * The dirty misc flag value
  72247. */
  72248. static readonly MATERIAL_MiscDirtyFlag: number;
  72249. /**
  72250. * The all dirty flag value
  72251. */
  72252. static readonly MATERIAL_AllDirtyFlag: number;
  72253. /**
  72254. * Returns the triangle fill mode
  72255. */
  72256. static readonly MATERIAL_TriangleFillMode: number;
  72257. /**
  72258. * Returns the wireframe mode
  72259. */
  72260. static readonly MATERIAL_WireFrameFillMode: number;
  72261. /**
  72262. * Returns the point fill mode
  72263. */
  72264. static readonly MATERIAL_PointFillMode: number;
  72265. /**
  72266. * Returns the point list draw mode
  72267. */
  72268. static readonly MATERIAL_PointListDrawMode: number;
  72269. /**
  72270. * Returns the line list draw mode
  72271. */
  72272. static readonly MATERIAL_LineListDrawMode: number;
  72273. /**
  72274. * Returns the line loop draw mode
  72275. */
  72276. static readonly MATERIAL_LineLoopDrawMode: number;
  72277. /**
  72278. * Returns the line strip draw mode
  72279. */
  72280. static readonly MATERIAL_LineStripDrawMode: number;
  72281. /**
  72282. * Returns the triangle strip draw mode
  72283. */
  72284. static readonly MATERIAL_TriangleStripDrawMode: number;
  72285. /**
  72286. * Returns the triangle fan draw mode
  72287. */
  72288. static readonly MATERIAL_TriangleFanDrawMode: number;
  72289. /**
  72290. * Stores the clock-wise side orientation
  72291. */
  72292. static readonly MATERIAL_ClockWiseSideOrientation: number;
  72293. /**
  72294. * Stores the counter clock-wise side orientation
  72295. */
  72296. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  72297. /**
  72298. * Nothing
  72299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72300. */
  72301. static readonly ACTION_NothingTrigger: number;
  72302. /**
  72303. * On pick
  72304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72305. */
  72306. static readonly ACTION_OnPickTrigger: number;
  72307. /**
  72308. * On left pick
  72309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72310. */
  72311. static readonly ACTION_OnLeftPickTrigger: number;
  72312. /**
  72313. * On right pick
  72314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72315. */
  72316. static readonly ACTION_OnRightPickTrigger: number;
  72317. /**
  72318. * On center pick
  72319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72320. */
  72321. static readonly ACTION_OnCenterPickTrigger: number;
  72322. /**
  72323. * On pick down
  72324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72325. */
  72326. static readonly ACTION_OnPickDownTrigger: number;
  72327. /**
  72328. * On double pick
  72329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72330. */
  72331. static readonly ACTION_OnDoublePickTrigger: number;
  72332. /**
  72333. * On pick up
  72334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72335. */
  72336. static readonly ACTION_OnPickUpTrigger: number;
  72337. /**
  72338. * On pick out.
  72339. * This trigger will only be raised if you also declared a OnPickDown
  72340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72341. */
  72342. static readonly ACTION_OnPickOutTrigger: number;
  72343. /**
  72344. * On long press
  72345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72346. */
  72347. static readonly ACTION_OnLongPressTrigger: number;
  72348. /**
  72349. * On pointer over
  72350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72351. */
  72352. static readonly ACTION_OnPointerOverTrigger: number;
  72353. /**
  72354. * On pointer out
  72355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72356. */
  72357. static readonly ACTION_OnPointerOutTrigger: number;
  72358. /**
  72359. * On every frame
  72360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72361. */
  72362. static readonly ACTION_OnEveryFrameTrigger: number;
  72363. /**
  72364. * On intersection enter
  72365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72366. */
  72367. static readonly ACTION_OnIntersectionEnterTrigger: number;
  72368. /**
  72369. * On intersection exit
  72370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72371. */
  72372. static readonly ACTION_OnIntersectionExitTrigger: number;
  72373. /**
  72374. * On key down
  72375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72376. */
  72377. static readonly ACTION_OnKeyDownTrigger: number;
  72378. /**
  72379. * On key up
  72380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  72381. */
  72382. static readonly ACTION_OnKeyUpTrigger: number;
  72383. /**
  72384. * Billboard mode will only apply to Y axis
  72385. */
  72386. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  72387. /**
  72388. * Billboard mode will apply to all axes
  72389. */
  72390. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  72391. /**
  72392. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  72393. */
  72394. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  72395. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  72396. * Test order :
  72397. * Is the bounding sphere outside the frustum ?
  72398. * If not, are the bounding box vertices outside the frustum ?
  72399. * It not, then the cullable object is in the frustum.
  72400. */
  72401. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  72402. /** Culling strategy : Bounding Sphere Only.
  72403. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  72404. * It's also less accurate than the standard because some not visible objects can still be selected.
  72405. * Test : is the bounding sphere outside the frustum ?
  72406. * If not, then the cullable object is in the frustum.
  72407. */
  72408. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  72409. /** Culling strategy : Optimistic Inclusion.
  72410. * This in an inclusion test first, then the standard exclusion test.
  72411. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  72412. * 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.
  72413. * Anyway, it's as accurate as the standard strategy.
  72414. * Test :
  72415. * Is the cullable object bounding sphere center in the frustum ?
  72416. * If not, apply the default culling strategy.
  72417. */
  72418. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  72419. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  72420. * This in an inclusion test first, then the bounding sphere only exclusion test.
  72421. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  72422. * 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.
  72423. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  72424. * Test :
  72425. * Is the cullable object bounding sphere center in the frustum ?
  72426. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  72427. */
  72428. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  72429. /**
  72430. * No logging while loading
  72431. */
  72432. static readonly SCENELOADER_NO_LOGGING: number;
  72433. /**
  72434. * Minimal logging while loading
  72435. */
  72436. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  72437. /**
  72438. * Summary logging while loading
  72439. */
  72440. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  72441. /**
  72442. * Detailled logging while loading
  72443. */
  72444. static readonly SCENELOADER_DETAILED_LOGGING: number;
  72445. }
  72446. }
  72447. declare module BABYLON {
  72448. /**
  72449. * This represents the required contract to create a new type of texture loader.
  72450. */
  72451. export interface IInternalTextureLoader {
  72452. /**
  72453. * Defines wether the loader supports cascade loading the different faces.
  72454. */
  72455. supportCascades: boolean;
  72456. /**
  72457. * This returns if the loader support the current file information.
  72458. * @param extension defines the file extension of the file being loaded
  72459. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72460. * @param fallback defines the fallback internal texture if any
  72461. * @param isBase64 defines whether the texture is encoded as a base64
  72462. * @param isBuffer defines whether the texture data are stored as a buffer
  72463. * @returns true if the loader can load the specified file
  72464. */
  72465. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  72466. /**
  72467. * Transform the url before loading if required.
  72468. * @param rootUrl the url of the texture
  72469. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72470. * @returns the transformed texture
  72471. */
  72472. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  72473. /**
  72474. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  72475. * @param rootUrl the url of the texture
  72476. * @param textureFormatInUse defines the current compressed format in use iun the engine
  72477. * @returns the fallback texture
  72478. */
  72479. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  72480. /**
  72481. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  72482. * @param data contains the texture data
  72483. * @param texture defines the BabylonJS internal texture
  72484. * @param createPolynomials will be true if polynomials have been requested
  72485. * @param onLoad defines the callback to trigger once the texture is ready
  72486. * @param onError defines the callback to trigger in case of error
  72487. */
  72488. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  72489. /**
  72490. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  72491. * @param data contains the texture data
  72492. * @param texture defines the BabylonJS internal texture
  72493. * @param callback defines the method to call once ready to upload
  72494. */
  72495. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  72496. }
  72497. }
  72498. declare module BABYLON {
  72499. /**
  72500. * Class used to store and describe the pipeline context associated with an effect
  72501. */
  72502. export interface IPipelineContext {
  72503. /**
  72504. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  72505. */
  72506. isAsync: boolean;
  72507. /**
  72508. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  72509. */
  72510. isReady: boolean;
  72511. /** @hidden */
  72512. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  72513. }
  72514. }
  72515. declare module BABYLON {
  72516. /**
  72517. * Class used to store gfx data (like WebGLBuffer)
  72518. */
  72519. export class DataBuffer {
  72520. /**
  72521. * Gets or sets the number of objects referencing this buffer
  72522. */
  72523. references: number;
  72524. /** Gets or sets the size of the underlying buffer */
  72525. capacity: number;
  72526. /**
  72527. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  72528. */
  72529. is32Bits: boolean;
  72530. /**
  72531. * Gets the underlying buffer
  72532. */
  72533. get underlyingResource(): any;
  72534. }
  72535. }
  72536. declare module BABYLON {
  72537. /** @hidden */
  72538. export interface IShaderProcessor {
  72539. attributeProcessor?: (attribute: string) => string;
  72540. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  72541. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  72542. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  72543. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  72544. lineProcessor?: (line: string, isFragment: boolean) => string;
  72545. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  72546. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  72547. }
  72548. }
  72549. declare module BABYLON {
  72550. /** @hidden */
  72551. export interface ProcessingOptions {
  72552. defines: string[];
  72553. indexParameters: any;
  72554. isFragment: boolean;
  72555. shouldUseHighPrecisionShader: boolean;
  72556. supportsUniformBuffers: boolean;
  72557. shadersRepository: string;
  72558. includesShadersStore: {
  72559. [key: string]: string;
  72560. };
  72561. processor?: IShaderProcessor;
  72562. version: string;
  72563. platformName: string;
  72564. lookForClosingBracketForUniformBuffer?: boolean;
  72565. }
  72566. }
  72567. declare module BABYLON {
  72568. /** @hidden */
  72569. export class ShaderCodeNode {
  72570. line: string;
  72571. children: ShaderCodeNode[];
  72572. additionalDefineKey?: string;
  72573. additionalDefineValue?: string;
  72574. isValid(preprocessors: {
  72575. [key: string]: string;
  72576. }): boolean;
  72577. process(preprocessors: {
  72578. [key: string]: string;
  72579. }, options: ProcessingOptions): string;
  72580. }
  72581. }
  72582. declare module BABYLON {
  72583. /** @hidden */
  72584. export class ShaderCodeCursor {
  72585. private _lines;
  72586. lineIndex: number;
  72587. get currentLine(): string;
  72588. get canRead(): boolean;
  72589. set lines(value: string[]);
  72590. }
  72591. }
  72592. declare module BABYLON {
  72593. /** @hidden */
  72594. export class ShaderCodeConditionNode extends ShaderCodeNode {
  72595. process(preprocessors: {
  72596. [key: string]: string;
  72597. }, options: ProcessingOptions): string;
  72598. }
  72599. }
  72600. declare module BABYLON {
  72601. /** @hidden */
  72602. export class ShaderDefineExpression {
  72603. isTrue(preprocessors: {
  72604. [key: string]: string;
  72605. }): boolean;
  72606. }
  72607. }
  72608. declare module BABYLON {
  72609. /** @hidden */
  72610. export class ShaderCodeTestNode extends ShaderCodeNode {
  72611. testExpression: ShaderDefineExpression;
  72612. isValid(preprocessors: {
  72613. [key: string]: string;
  72614. }): boolean;
  72615. }
  72616. }
  72617. declare module BABYLON {
  72618. /** @hidden */
  72619. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  72620. define: string;
  72621. not: boolean;
  72622. constructor(define: string, not?: boolean);
  72623. isTrue(preprocessors: {
  72624. [key: string]: string;
  72625. }): boolean;
  72626. }
  72627. }
  72628. declare module BABYLON {
  72629. /** @hidden */
  72630. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  72631. leftOperand: ShaderDefineExpression;
  72632. rightOperand: ShaderDefineExpression;
  72633. isTrue(preprocessors: {
  72634. [key: string]: string;
  72635. }): boolean;
  72636. }
  72637. }
  72638. declare module BABYLON {
  72639. /** @hidden */
  72640. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  72641. leftOperand: ShaderDefineExpression;
  72642. rightOperand: ShaderDefineExpression;
  72643. isTrue(preprocessors: {
  72644. [key: string]: string;
  72645. }): boolean;
  72646. }
  72647. }
  72648. declare module BABYLON {
  72649. /** @hidden */
  72650. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  72651. define: string;
  72652. operand: string;
  72653. testValue: string;
  72654. constructor(define: string, operand: string, testValue: string);
  72655. isTrue(preprocessors: {
  72656. [key: string]: string;
  72657. }): boolean;
  72658. }
  72659. }
  72660. declare module BABYLON {
  72661. /**
  72662. * Class used to enable access to offline support
  72663. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72664. */
  72665. export interface IOfflineProvider {
  72666. /**
  72667. * Gets a boolean indicating if scene must be saved in the database
  72668. */
  72669. enableSceneOffline: boolean;
  72670. /**
  72671. * Gets a boolean indicating if textures must be saved in the database
  72672. */
  72673. enableTexturesOffline: boolean;
  72674. /**
  72675. * Open the offline support and make it available
  72676. * @param successCallback defines the callback to call on success
  72677. * @param errorCallback defines the callback to call on error
  72678. */
  72679. open(successCallback: () => void, errorCallback: () => void): void;
  72680. /**
  72681. * Loads an image from the offline support
  72682. * @param url defines the url to load from
  72683. * @param image defines the target DOM image
  72684. */
  72685. loadImage(url: string, image: HTMLImageElement): void;
  72686. /**
  72687. * Loads a file from offline support
  72688. * @param url defines the URL to load from
  72689. * @param sceneLoaded defines a callback to call on success
  72690. * @param progressCallBack defines a callback to call when progress changed
  72691. * @param errorCallback defines a callback to call on error
  72692. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72693. */
  72694. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72695. }
  72696. }
  72697. declare module BABYLON {
  72698. /**
  72699. * Class used to help managing file picking and drag'n'drop
  72700. * File Storage
  72701. */
  72702. export class FilesInputStore {
  72703. /**
  72704. * List of files ready to be loaded
  72705. */
  72706. static FilesToLoad: {
  72707. [key: string]: File;
  72708. };
  72709. }
  72710. }
  72711. declare module BABYLON {
  72712. /**
  72713. * Class used to define a retry strategy when error happens while loading assets
  72714. */
  72715. export class RetryStrategy {
  72716. /**
  72717. * Function used to defines an exponential back off strategy
  72718. * @param maxRetries defines the maximum number of retries (3 by default)
  72719. * @param baseInterval defines the interval between retries
  72720. * @returns the strategy function to use
  72721. */
  72722. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  72723. }
  72724. }
  72725. declare module BABYLON {
  72726. /**
  72727. * @ignore
  72728. * Application error to support additional information when loading a file
  72729. */
  72730. export abstract class BaseError extends Error {
  72731. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  72732. }
  72733. }
  72734. declare module BABYLON {
  72735. /** @ignore */
  72736. export class LoadFileError extends BaseError {
  72737. request?: WebRequest;
  72738. file?: File;
  72739. /**
  72740. * Creates a new LoadFileError
  72741. * @param message defines the message of the error
  72742. * @param request defines the optional web request
  72743. * @param file defines the optional file
  72744. */
  72745. constructor(message: string, object?: WebRequest | File);
  72746. }
  72747. /** @ignore */
  72748. export class RequestFileError extends BaseError {
  72749. request: WebRequest;
  72750. /**
  72751. * Creates a new LoadFileError
  72752. * @param message defines the message of the error
  72753. * @param request defines the optional web request
  72754. */
  72755. constructor(message: string, request: WebRequest);
  72756. }
  72757. /** @ignore */
  72758. export class ReadFileError extends BaseError {
  72759. file: File;
  72760. /**
  72761. * Creates a new ReadFileError
  72762. * @param message defines the message of the error
  72763. * @param file defines the optional file
  72764. */
  72765. constructor(message: string, file: File);
  72766. }
  72767. /**
  72768. * @hidden
  72769. */
  72770. export class FileTools {
  72771. /**
  72772. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  72773. */
  72774. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  72775. /**
  72776. * Gets or sets the base URL to use to load assets
  72777. */
  72778. static BaseUrl: string;
  72779. /**
  72780. * Default behaviour for cors in the application.
  72781. * It can be a string if the expected behavior is identical in the entire app.
  72782. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  72783. */
  72784. static CorsBehavior: string | ((url: string | string[]) => string);
  72785. /**
  72786. * Gets or sets a function used to pre-process url before using them to load assets
  72787. */
  72788. static PreprocessUrl: (url: string) => string;
  72789. /**
  72790. * Removes unwanted characters from an url
  72791. * @param url defines the url to clean
  72792. * @returns the cleaned url
  72793. */
  72794. private static _CleanUrl;
  72795. /**
  72796. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  72797. * @param url define the url we are trying
  72798. * @param element define the dom element where to configure the cors policy
  72799. */
  72800. static SetCorsBehavior(url: string | string[], element: {
  72801. crossOrigin: string | null;
  72802. }): void;
  72803. /**
  72804. * Loads an image as an HTMLImageElement.
  72805. * @param input url string, ArrayBuffer, or Blob to load
  72806. * @param onLoad callback called when the image successfully loads
  72807. * @param onError callback called when the image fails to load
  72808. * @param offlineProvider offline provider for caching
  72809. * @param mimeType optional mime type
  72810. * @returns the HTMLImageElement of the loaded image
  72811. */
  72812. 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>;
  72813. /**
  72814. * Reads a file from a File object
  72815. * @param file defines the file to load
  72816. * @param onSuccess defines the callback to call when data is loaded
  72817. * @param onProgress defines the callback to call during loading process
  72818. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  72819. * @param onError defines the callback to call when an error occurs
  72820. * @returns a file request object
  72821. */
  72822. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  72823. /**
  72824. * Loads a file from a url
  72825. * @param url url to load
  72826. * @param onSuccess callback called when the file successfully loads
  72827. * @param onProgress callback called while file is loading (if the server supports this mode)
  72828. * @param offlineProvider defines the offline provider for caching
  72829. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72830. * @param onError callback called when the file fails to load
  72831. * @returns a file request object
  72832. */
  72833. 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;
  72834. /**
  72835. * Loads a file
  72836. * @param url url to load
  72837. * @param onSuccess callback called when the file successfully loads
  72838. * @param onProgress callback called while file is loading (if the server supports this mode)
  72839. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72840. * @param onError callback called when the file fails to load
  72841. * @param onOpened callback called when the web request is opened
  72842. * @returns a file request object
  72843. */
  72844. 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;
  72845. /**
  72846. * Checks if the loaded document was accessed via `file:`-Protocol.
  72847. * @returns boolean
  72848. */
  72849. static IsFileURL(): boolean;
  72850. }
  72851. }
  72852. declare module BABYLON {
  72853. /** @hidden */
  72854. export class ShaderProcessor {
  72855. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  72856. private static _ProcessPrecision;
  72857. private static _ExtractOperation;
  72858. private static _BuildSubExpression;
  72859. private static _BuildExpression;
  72860. private static _MoveCursorWithinIf;
  72861. private static _MoveCursor;
  72862. private static _EvaluatePreProcessors;
  72863. private static _PreparePreProcessors;
  72864. private static _ProcessShaderConversion;
  72865. private static _ProcessIncludes;
  72866. /**
  72867. * Loads a file from a url
  72868. * @param url url to load
  72869. * @param onSuccess callback called when the file successfully loads
  72870. * @param onProgress callback called while file is loading (if the server supports this mode)
  72871. * @param offlineProvider defines the offline provider for caching
  72872. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  72873. * @param onError callback called when the file fails to load
  72874. * @returns a file request object
  72875. * @hidden
  72876. */
  72877. 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;
  72878. }
  72879. }
  72880. declare module BABYLON {
  72881. /**
  72882. * @hidden
  72883. */
  72884. export interface IColor4Like {
  72885. r: float;
  72886. g: float;
  72887. b: float;
  72888. a: float;
  72889. }
  72890. /**
  72891. * @hidden
  72892. */
  72893. export interface IColor3Like {
  72894. r: float;
  72895. g: float;
  72896. b: float;
  72897. }
  72898. /**
  72899. * @hidden
  72900. */
  72901. export interface IVector4Like {
  72902. x: float;
  72903. y: float;
  72904. z: float;
  72905. w: float;
  72906. }
  72907. /**
  72908. * @hidden
  72909. */
  72910. export interface IVector3Like {
  72911. x: float;
  72912. y: float;
  72913. z: float;
  72914. }
  72915. /**
  72916. * @hidden
  72917. */
  72918. export interface IVector2Like {
  72919. x: float;
  72920. y: float;
  72921. }
  72922. /**
  72923. * @hidden
  72924. */
  72925. export interface IMatrixLike {
  72926. toArray(): DeepImmutable<Float32Array>;
  72927. updateFlag: int;
  72928. }
  72929. /**
  72930. * @hidden
  72931. */
  72932. export interface IViewportLike {
  72933. x: float;
  72934. y: float;
  72935. width: float;
  72936. height: float;
  72937. }
  72938. /**
  72939. * @hidden
  72940. */
  72941. export interface IPlaneLike {
  72942. normal: IVector3Like;
  72943. d: float;
  72944. normalize(): void;
  72945. }
  72946. }
  72947. declare module BABYLON {
  72948. /**
  72949. * Interface used to define common properties for effect fallbacks
  72950. */
  72951. export interface IEffectFallbacks {
  72952. /**
  72953. * Removes the defines that should be removed when falling back.
  72954. * @param currentDefines defines the current define statements for the shader.
  72955. * @param effect defines the current effect we try to compile
  72956. * @returns The resulting defines with defines of the current rank removed.
  72957. */
  72958. reduce(currentDefines: string, effect: Effect): string;
  72959. /**
  72960. * Removes the fallback from the bound mesh.
  72961. */
  72962. unBindMesh(): void;
  72963. /**
  72964. * Checks to see if more fallbacks are still availible.
  72965. */
  72966. hasMoreFallbacks: boolean;
  72967. }
  72968. }
  72969. declare module BABYLON {
  72970. /**
  72971. * Class used to evalaute queries containing `and` and `or` operators
  72972. */
  72973. export class AndOrNotEvaluator {
  72974. /**
  72975. * Evaluate a query
  72976. * @param query defines the query to evaluate
  72977. * @param evaluateCallback defines the callback used to filter result
  72978. * @returns true if the query matches
  72979. */
  72980. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  72981. private static _HandleParenthesisContent;
  72982. private static _SimplifyNegation;
  72983. }
  72984. }
  72985. declare module BABYLON {
  72986. /**
  72987. * Class used to store custom tags
  72988. */
  72989. export class Tags {
  72990. /**
  72991. * Adds support for tags on the given object
  72992. * @param obj defines the object to use
  72993. */
  72994. static EnableFor(obj: any): void;
  72995. /**
  72996. * Removes tags support
  72997. * @param obj defines the object to use
  72998. */
  72999. static DisableFor(obj: any): void;
  73000. /**
  73001. * Gets a boolean indicating if the given object has tags
  73002. * @param obj defines the object to use
  73003. * @returns a boolean
  73004. */
  73005. static HasTags(obj: any): boolean;
  73006. /**
  73007. * Gets the tags available on a given object
  73008. * @param obj defines the object to use
  73009. * @param asString defines if the tags must be returned as a string instead of an array of strings
  73010. * @returns the tags
  73011. */
  73012. static GetTags(obj: any, asString?: boolean): any;
  73013. /**
  73014. * Adds tags to an object
  73015. * @param obj defines the object to use
  73016. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  73017. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  73018. */
  73019. static AddTagsTo(obj: any, tagsString: string): void;
  73020. /**
  73021. * @hidden
  73022. */
  73023. static _AddTagTo(obj: any, tag: string): void;
  73024. /**
  73025. * Removes specific tags from a specific object
  73026. * @param obj defines the object to use
  73027. * @param tagsString defines the tags to remove
  73028. */
  73029. static RemoveTagsFrom(obj: any, tagsString: string): void;
  73030. /**
  73031. * @hidden
  73032. */
  73033. static _RemoveTagFrom(obj: any, tag: string): void;
  73034. /**
  73035. * Defines if tags hosted on an object match a given query
  73036. * @param obj defines the object to use
  73037. * @param tagsQuery defines the tag query
  73038. * @returns a boolean
  73039. */
  73040. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  73041. }
  73042. }
  73043. declare module BABYLON {
  73044. /**
  73045. * Scalar computation library
  73046. */
  73047. export class Scalar {
  73048. /**
  73049. * Two pi constants convenient for computation.
  73050. */
  73051. static TwoPi: number;
  73052. /**
  73053. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  73054. * @param a number
  73055. * @param b number
  73056. * @param epsilon (default = 1.401298E-45)
  73057. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  73058. */
  73059. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  73060. /**
  73061. * Returns a string : the upper case translation of the number i to hexadecimal.
  73062. * @param i number
  73063. * @returns the upper case translation of the number i to hexadecimal.
  73064. */
  73065. static ToHex(i: number): string;
  73066. /**
  73067. * Returns -1 if value is negative and +1 is value is positive.
  73068. * @param value the value
  73069. * @returns the value itself if it's equal to zero.
  73070. */
  73071. static Sign(value: number): number;
  73072. /**
  73073. * Returns the value itself if it's between min and max.
  73074. * Returns min if the value is lower than min.
  73075. * Returns max if the value is greater than max.
  73076. * @param value the value to clmap
  73077. * @param min the min value to clamp to (default: 0)
  73078. * @param max the max value to clamp to (default: 1)
  73079. * @returns the clamped value
  73080. */
  73081. static Clamp(value: number, min?: number, max?: number): number;
  73082. /**
  73083. * the log2 of value.
  73084. * @param value the value to compute log2 of
  73085. * @returns the log2 of value.
  73086. */
  73087. static Log2(value: number): number;
  73088. /**
  73089. * Loops the value, so that it is never larger than length and never smaller than 0.
  73090. *
  73091. * This is similar to the modulo operator but it works with floating point numbers.
  73092. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  73093. * With t = 5 and length = 2.5, the result would be 0.0.
  73094. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  73095. * @param value the value
  73096. * @param length the length
  73097. * @returns the looped value
  73098. */
  73099. static Repeat(value: number, length: number): number;
  73100. /**
  73101. * Normalize the value between 0.0 and 1.0 using min and max values
  73102. * @param value value to normalize
  73103. * @param min max to normalize between
  73104. * @param max min to normalize between
  73105. * @returns the normalized value
  73106. */
  73107. static Normalize(value: number, min: number, max: number): number;
  73108. /**
  73109. * Denormalize the value from 0.0 and 1.0 using min and max values
  73110. * @param normalized value to denormalize
  73111. * @param min max to denormalize between
  73112. * @param max min to denormalize between
  73113. * @returns the denormalized value
  73114. */
  73115. static Denormalize(normalized: number, min: number, max: number): number;
  73116. /**
  73117. * Calculates the shortest difference between two given angles given in degrees.
  73118. * @param current current angle in degrees
  73119. * @param target target angle in degrees
  73120. * @returns the delta
  73121. */
  73122. static DeltaAngle(current: number, target: number): number;
  73123. /**
  73124. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  73125. * @param tx value
  73126. * @param length length
  73127. * @returns The returned value will move back and forth between 0 and length
  73128. */
  73129. static PingPong(tx: number, length: number): number;
  73130. /**
  73131. * Interpolates between min and max with smoothing at the limits.
  73132. *
  73133. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  73134. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  73135. * @param from from
  73136. * @param to to
  73137. * @param tx value
  73138. * @returns the smooth stepped value
  73139. */
  73140. static SmoothStep(from: number, to: number, tx: number): number;
  73141. /**
  73142. * Moves a value current towards target.
  73143. *
  73144. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  73145. * Negative values of maxDelta pushes the value away from target.
  73146. * @param current current value
  73147. * @param target target value
  73148. * @param maxDelta max distance to move
  73149. * @returns resulting value
  73150. */
  73151. static MoveTowards(current: number, target: number, maxDelta: number): number;
  73152. /**
  73153. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  73154. *
  73155. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  73156. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  73157. * @param current current value
  73158. * @param target target value
  73159. * @param maxDelta max distance to move
  73160. * @returns resulting angle
  73161. */
  73162. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  73163. /**
  73164. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  73165. * @param start start value
  73166. * @param end target value
  73167. * @param amount amount to lerp between
  73168. * @returns the lerped value
  73169. */
  73170. static Lerp(start: number, end: number, amount: number): number;
  73171. /**
  73172. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  73173. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  73174. * @param start start value
  73175. * @param end target value
  73176. * @param amount amount to lerp between
  73177. * @returns the lerped value
  73178. */
  73179. static LerpAngle(start: number, end: number, amount: number): number;
  73180. /**
  73181. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  73182. * @param a start value
  73183. * @param b target value
  73184. * @param value value between a and b
  73185. * @returns the inverseLerp value
  73186. */
  73187. static InverseLerp(a: number, b: number, value: number): number;
  73188. /**
  73189. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  73190. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  73191. * @param value1 spline value
  73192. * @param tangent1 spline value
  73193. * @param value2 spline value
  73194. * @param tangent2 spline value
  73195. * @param amount input value
  73196. * @returns hermite result
  73197. */
  73198. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  73199. /**
  73200. * Returns a random float number between and min and max values
  73201. * @param min min value of random
  73202. * @param max max value of random
  73203. * @returns random value
  73204. */
  73205. static RandomRange(min: number, max: number): number;
  73206. /**
  73207. * This function returns percentage of a number in a given range.
  73208. *
  73209. * RangeToPercent(40,20,60) will return 0.5 (50%)
  73210. * RangeToPercent(34,0,100) will return 0.34 (34%)
  73211. * @param number to convert to percentage
  73212. * @param min min range
  73213. * @param max max range
  73214. * @returns the percentage
  73215. */
  73216. static RangeToPercent(number: number, min: number, max: number): number;
  73217. /**
  73218. * This function returns number that corresponds to the percentage in a given range.
  73219. *
  73220. * PercentToRange(0.34,0,100) will return 34.
  73221. * @param percent to convert to number
  73222. * @param min min range
  73223. * @param max max range
  73224. * @returns the number
  73225. */
  73226. static PercentToRange(percent: number, min: number, max: number): number;
  73227. /**
  73228. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  73229. * @param angle The angle to normalize in radian.
  73230. * @return The converted angle.
  73231. */
  73232. static NormalizeRadians(angle: number): number;
  73233. }
  73234. }
  73235. declare module BABYLON {
  73236. /**
  73237. * Constant used to convert a value to gamma space
  73238. * @ignorenaming
  73239. */
  73240. export const ToGammaSpace: number;
  73241. /**
  73242. * Constant used to convert a value to linear space
  73243. * @ignorenaming
  73244. */
  73245. export const ToLinearSpace = 2.2;
  73246. /**
  73247. * Constant used to define the minimal number value in Babylon.js
  73248. * @ignorenaming
  73249. */
  73250. let Epsilon: number;
  73251. }
  73252. declare module BABYLON {
  73253. /**
  73254. * Class used to represent a viewport on screen
  73255. */
  73256. export class Viewport {
  73257. /** viewport left coordinate */
  73258. x: number;
  73259. /** viewport top coordinate */
  73260. y: number;
  73261. /**viewport width */
  73262. width: number;
  73263. /** viewport height */
  73264. height: number;
  73265. /**
  73266. * Creates a Viewport object located at (x, y) and sized (width, height)
  73267. * @param x defines viewport left coordinate
  73268. * @param y defines viewport top coordinate
  73269. * @param width defines the viewport width
  73270. * @param height defines the viewport height
  73271. */
  73272. constructor(
  73273. /** viewport left coordinate */
  73274. x: number,
  73275. /** viewport top coordinate */
  73276. y: number,
  73277. /**viewport width */
  73278. width: number,
  73279. /** viewport height */
  73280. height: number);
  73281. /**
  73282. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  73283. * @param renderWidth defines the rendering width
  73284. * @param renderHeight defines the rendering height
  73285. * @returns a new Viewport
  73286. */
  73287. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  73288. /**
  73289. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  73290. * @param renderWidth defines the rendering width
  73291. * @param renderHeight defines the rendering height
  73292. * @param ref defines the target viewport
  73293. * @returns the current viewport
  73294. */
  73295. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  73296. /**
  73297. * Returns a new Viewport copied from the current one
  73298. * @returns a new Viewport
  73299. */
  73300. clone(): Viewport;
  73301. }
  73302. }
  73303. declare module BABYLON {
  73304. /**
  73305. * Class containing a set of static utilities functions for arrays.
  73306. */
  73307. export class ArrayTools {
  73308. /**
  73309. * Returns an array of the given size filled with element built from the given constructor and the paramters
  73310. * @param size the number of element to construct and put in the array
  73311. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  73312. * @returns a new array filled with new objects
  73313. */
  73314. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  73315. }
  73316. }
  73317. declare module BABYLON {
  73318. /**
  73319. * Class representing a vector containing 2 coordinates
  73320. */
  73321. export class Vector2 {
  73322. /** defines the first coordinate */
  73323. x: number;
  73324. /** defines the second coordinate */
  73325. y: number;
  73326. /**
  73327. * Creates a new Vector2 from the given x and y coordinates
  73328. * @param x defines the first coordinate
  73329. * @param y defines the second coordinate
  73330. */
  73331. constructor(
  73332. /** defines the first coordinate */
  73333. x?: number,
  73334. /** defines the second coordinate */
  73335. y?: number);
  73336. /**
  73337. * Gets a string with the Vector2 coordinates
  73338. * @returns a string with the Vector2 coordinates
  73339. */
  73340. toString(): string;
  73341. /**
  73342. * Gets class name
  73343. * @returns the string "Vector2"
  73344. */
  73345. getClassName(): string;
  73346. /**
  73347. * Gets current vector hash code
  73348. * @returns the Vector2 hash code as a number
  73349. */
  73350. getHashCode(): number;
  73351. /**
  73352. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  73353. * @param array defines the source array
  73354. * @param index defines the offset in source array
  73355. * @returns the current Vector2
  73356. */
  73357. toArray(array: FloatArray, index?: number): Vector2;
  73358. /**
  73359. * Copy the current vector to an array
  73360. * @returns a new array with 2 elements: the Vector2 coordinates.
  73361. */
  73362. asArray(): number[];
  73363. /**
  73364. * Sets the Vector2 coordinates with the given Vector2 coordinates
  73365. * @param source defines the source Vector2
  73366. * @returns the current updated Vector2
  73367. */
  73368. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  73369. /**
  73370. * Sets the Vector2 coordinates with the given floats
  73371. * @param x defines the first coordinate
  73372. * @param y defines the second coordinate
  73373. * @returns the current updated Vector2
  73374. */
  73375. copyFromFloats(x: number, y: number): Vector2;
  73376. /**
  73377. * Sets the Vector2 coordinates with the given floats
  73378. * @param x defines the first coordinate
  73379. * @param y defines the second coordinate
  73380. * @returns the current updated Vector2
  73381. */
  73382. set(x: number, y: number): Vector2;
  73383. /**
  73384. * Add another vector with the current one
  73385. * @param otherVector defines the other vector
  73386. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  73387. */
  73388. add(otherVector: DeepImmutable<Vector2>): Vector2;
  73389. /**
  73390. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  73391. * @param otherVector defines the other vector
  73392. * @param result defines the target vector
  73393. * @returns the unmodified current Vector2
  73394. */
  73395. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  73396. /**
  73397. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  73398. * @param otherVector defines the other vector
  73399. * @returns the current updated Vector2
  73400. */
  73401. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  73402. /**
  73403. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  73404. * @param otherVector defines the other vector
  73405. * @returns a new Vector2
  73406. */
  73407. addVector3(otherVector: Vector3): Vector2;
  73408. /**
  73409. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  73410. * @param otherVector defines the other vector
  73411. * @returns a new Vector2
  73412. */
  73413. subtract(otherVector: Vector2): Vector2;
  73414. /**
  73415. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  73416. * @param otherVector defines the other vector
  73417. * @param result defines the target vector
  73418. * @returns the unmodified current Vector2
  73419. */
  73420. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  73421. /**
  73422. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  73423. * @param otherVector defines the other vector
  73424. * @returns the current updated Vector2
  73425. */
  73426. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  73427. /**
  73428. * Multiplies in place the current Vector2 coordinates by the given ones
  73429. * @param otherVector defines the other vector
  73430. * @returns the current updated Vector2
  73431. */
  73432. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  73433. /**
  73434. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  73435. * @param otherVector defines the other vector
  73436. * @returns a new Vector2
  73437. */
  73438. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  73439. /**
  73440. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  73441. * @param otherVector defines the other vector
  73442. * @param result defines the target vector
  73443. * @returns the unmodified current Vector2
  73444. */
  73445. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  73446. /**
  73447. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  73448. * @param x defines the first coordinate
  73449. * @param y defines the second coordinate
  73450. * @returns a new Vector2
  73451. */
  73452. multiplyByFloats(x: number, y: number): Vector2;
  73453. /**
  73454. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  73455. * @param otherVector defines the other vector
  73456. * @returns a new Vector2
  73457. */
  73458. divide(otherVector: Vector2): Vector2;
  73459. /**
  73460. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  73461. * @param otherVector defines the other vector
  73462. * @param result defines the target vector
  73463. * @returns the unmodified current Vector2
  73464. */
  73465. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  73466. /**
  73467. * Divides the current Vector2 coordinates by the given ones
  73468. * @param otherVector defines the other vector
  73469. * @returns the current updated Vector2
  73470. */
  73471. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  73472. /**
  73473. * Gets a new Vector2 with current Vector2 negated coordinates
  73474. * @returns a new Vector2
  73475. */
  73476. negate(): Vector2;
  73477. /**
  73478. * Multiply the Vector2 coordinates by scale
  73479. * @param scale defines the scaling factor
  73480. * @returns the current updated Vector2
  73481. */
  73482. scaleInPlace(scale: number): Vector2;
  73483. /**
  73484. * Returns a new Vector2 scaled by "scale" from the current Vector2
  73485. * @param scale defines the scaling factor
  73486. * @returns a new Vector2
  73487. */
  73488. scale(scale: number): Vector2;
  73489. /**
  73490. * Scale the current Vector2 values by a factor to a given Vector2
  73491. * @param scale defines the scale factor
  73492. * @param result defines the Vector2 object where to store the result
  73493. * @returns the unmodified current Vector2
  73494. */
  73495. scaleToRef(scale: number, result: Vector2): Vector2;
  73496. /**
  73497. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  73498. * @param scale defines the scale factor
  73499. * @param result defines the Vector2 object where to store the result
  73500. * @returns the unmodified current Vector2
  73501. */
  73502. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  73503. /**
  73504. * Gets a boolean if two vectors are equals
  73505. * @param otherVector defines the other vector
  73506. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  73507. */
  73508. equals(otherVector: DeepImmutable<Vector2>): boolean;
  73509. /**
  73510. * Gets a boolean if two vectors are equals (using an epsilon value)
  73511. * @param otherVector defines the other vector
  73512. * @param epsilon defines the minimal distance to consider equality
  73513. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  73514. */
  73515. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  73516. /**
  73517. * Gets a new Vector2 from current Vector2 floored values
  73518. * @returns a new Vector2
  73519. */
  73520. floor(): Vector2;
  73521. /**
  73522. * Gets a new Vector2 from current Vector2 floored values
  73523. * @returns a new Vector2
  73524. */
  73525. fract(): Vector2;
  73526. /**
  73527. * Gets the length of the vector
  73528. * @returns the vector length (float)
  73529. */
  73530. length(): number;
  73531. /**
  73532. * Gets the vector squared length
  73533. * @returns the vector squared length (float)
  73534. */
  73535. lengthSquared(): number;
  73536. /**
  73537. * Normalize the vector
  73538. * @returns the current updated Vector2
  73539. */
  73540. normalize(): Vector2;
  73541. /**
  73542. * Gets a new Vector2 copied from the Vector2
  73543. * @returns a new Vector2
  73544. */
  73545. clone(): Vector2;
  73546. /**
  73547. * Gets a new Vector2(0, 0)
  73548. * @returns a new Vector2
  73549. */
  73550. static Zero(): Vector2;
  73551. /**
  73552. * Gets a new Vector2(1, 1)
  73553. * @returns a new Vector2
  73554. */
  73555. static One(): Vector2;
  73556. /**
  73557. * Gets a new Vector2 set from the given index element of the given array
  73558. * @param array defines the data source
  73559. * @param offset defines the offset in the data source
  73560. * @returns a new Vector2
  73561. */
  73562. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  73563. /**
  73564. * Sets "result" from the given index element of the given array
  73565. * @param array defines the data source
  73566. * @param offset defines the offset in the data source
  73567. * @param result defines the target vector
  73568. */
  73569. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  73570. /**
  73571. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  73572. * @param value1 defines 1st point of control
  73573. * @param value2 defines 2nd point of control
  73574. * @param value3 defines 3rd point of control
  73575. * @param value4 defines 4th point of control
  73576. * @param amount defines the interpolation factor
  73577. * @returns a new Vector2
  73578. */
  73579. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  73580. /**
  73581. * 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".
  73582. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  73583. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  73584. * @param value defines the value to clamp
  73585. * @param min defines the lower limit
  73586. * @param max defines the upper limit
  73587. * @returns a new Vector2
  73588. */
  73589. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  73590. /**
  73591. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  73592. * @param value1 defines the 1st control point
  73593. * @param tangent1 defines the outgoing tangent
  73594. * @param value2 defines the 2nd control point
  73595. * @param tangent2 defines the incoming tangent
  73596. * @param amount defines the interpolation factor
  73597. * @returns a new Vector2
  73598. */
  73599. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  73600. /**
  73601. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  73602. * @param start defines the start vector
  73603. * @param end defines the end vector
  73604. * @param amount defines the interpolation factor
  73605. * @returns a new Vector2
  73606. */
  73607. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  73608. /**
  73609. * Gets the dot product of the vector "left" and the vector "right"
  73610. * @param left defines first vector
  73611. * @param right defines second vector
  73612. * @returns the dot product (float)
  73613. */
  73614. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  73615. /**
  73616. * Returns a new Vector2 equal to the normalized given vector
  73617. * @param vector defines the vector to normalize
  73618. * @returns a new Vector2
  73619. */
  73620. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  73621. /**
  73622. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  73623. * @param left defines 1st vector
  73624. * @param right defines 2nd vector
  73625. * @returns a new Vector2
  73626. */
  73627. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  73628. /**
  73629. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  73630. * @param left defines 1st vector
  73631. * @param right defines 2nd vector
  73632. * @returns a new Vector2
  73633. */
  73634. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  73635. /**
  73636. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  73637. * @param vector defines the vector to transform
  73638. * @param transformation defines the matrix to apply
  73639. * @returns a new Vector2
  73640. */
  73641. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  73642. /**
  73643. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  73644. * @param vector defines the vector to transform
  73645. * @param transformation defines the matrix to apply
  73646. * @param result defines the target vector
  73647. */
  73648. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  73649. /**
  73650. * Determines if a given vector is included in a triangle
  73651. * @param p defines the vector to test
  73652. * @param p0 defines 1st triangle point
  73653. * @param p1 defines 2nd triangle point
  73654. * @param p2 defines 3rd triangle point
  73655. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  73656. */
  73657. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  73658. /**
  73659. * Gets the distance between the vectors "value1" and "value2"
  73660. * @param value1 defines first vector
  73661. * @param value2 defines second vector
  73662. * @returns the distance between vectors
  73663. */
  73664. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  73665. /**
  73666. * Returns the squared distance between the vectors "value1" and "value2"
  73667. * @param value1 defines first vector
  73668. * @param value2 defines second vector
  73669. * @returns the squared distance between vectors
  73670. */
  73671. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  73672. /**
  73673. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  73674. * @param value1 defines first vector
  73675. * @param value2 defines second vector
  73676. * @returns a new Vector2
  73677. */
  73678. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  73679. /**
  73680. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  73681. * @param p defines the middle point
  73682. * @param segA defines one point of the segment
  73683. * @param segB defines the other point of the segment
  73684. * @returns the shortest distance
  73685. */
  73686. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  73687. }
  73688. /**
  73689. * Class used to store (x,y,z) vector representation
  73690. * A Vector3 is the main object used in 3D geometry
  73691. * It can represent etiher the coordinates of a point the space, either a direction
  73692. * Reminder: js uses a left handed forward facing system
  73693. */
  73694. export class Vector3 {
  73695. /**
  73696. * Defines the first coordinates (on X axis)
  73697. */
  73698. x: number;
  73699. /**
  73700. * Defines the second coordinates (on Y axis)
  73701. */
  73702. y: number;
  73703. /**
  73704. * Defines the third coordinates (on Z axis)
  73705. */
  73706. z: number;
  73707. private static _UpReadOnly;
  73708. private static _ZeroReadOnly;
  73709. /**
  73710. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  73711. * @param x defines the first coordinates (on X axis)
  73712. * @param y defines the second coordinates (on Y axis)
  73713. * @param z defines the third coordinates (on Z axis)
  73714. */
  73715. constructor(
  73716. /**
  73717. * Defines the first coordinates (on X axis)
  73718. */
  73719. x?: number,
  73720. /**
  73721. * Defines the second coordinates (on Y axis)
  73722. */
  73723. y?: number,
  73724. /**
  73725. * Defines the third coordinates (on Z axis)
  73726. */
  73727. z?: number);
  73728. /**
  73729. * Creates a string representation of the Vector3
  73730. * @returns a string with the Vector3 coordinates.
  73731. */
  73732. toString(): string;
  73733. /**
  73734. * Gets the class name
  73735. * @returns the string "Vector3"
  73736. */
  73737. getClassName(): string;
  73738. /**
  73739. * Creates the Vector3 hash code
  73740. * @returns a number which tends to be unique between Vector3 instances
  73741. */
  73742. getHashCode(): number;
  73743. /**
  73744. * Creates an array containing three elements : the coordinates of the Vector3
  73745. * @returns a new array of numbers
  73746. */
  73747. asArray(): number[];
  73748. /**
  73749. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  73750. * @param array defines the destination array
  73751. * @param index defines the offset in the destination array
  73752. * @returns the current Vector3
  73753. */
  73754. toArray(array: FloatArray, index?: number): Vector3;
  73755. /**
  73756. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  73757. * @returns a new Quaternion object, computed from the Vector3 coordinates
  73758. */
  73759. toQuaternion(): Quaternion;
  73760. /**
  73761. * Adds the given vector to the current Vector3
  73762. * @param otherVector defines the second operand
  73763. * @returns the current updated Vector3
  73764. */
  73765. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73766. /**
  73767. * Adds the given coordinates to the current Vector3
  73768. * @param x defines the x coordinate of the operand
  73769. * @param y defines the y coordinate of the operand
  73770. * @param z defines the z coordinate of the operand
  73771. * @returns the current updated Vector3
  73772. */
  73773. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73774. /**
  73775. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  73776. * @param otherVector defines the second operand
  73777. * @returns the resulting Vector3
  73778. */
  73779. add(otherVector: DeepImmutable<Vector3>): Vector3;
  73780. /**
  73781. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  73782. * @param otherVector defines the second operand
  73783. * @param result defines the Vector3 object where to store the result
  73784. * @returns the current Vector3
  73785. */
  73786. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73787. /**
  73788. * Subtract the given vector from the current Vector3
  73789. * @param otherVector defines the second operand
  73790. * @returns the current updated Vector3
  73791. */
  73792. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73793. /**
  73794. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  73795. * @param otherVector defines the second operand
  73796. * @returns the resulting Vector3
  73797. */
  73798. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  73799. /**
  73800. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  73801. * @param otherVector defines the second operand
  73802. * @param result defines the Vector3 object where to store the result
  73803. * @returns the current Vector3
  73804. */
  73805. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73806. /**
  73807. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  73808. * @param x defines the x coordinate of the operand
  73809. * @param y defines the y coordinate of the operand
  73810. * @param z defines the z coordinate of the operand
  73811. * @returns the resulting Vector3
  73812. */
  73813. subtractFromFloats(x: number, y: number, z: number): Vector3;
  73814. /**
  73815. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  73816. * @param x defines the x coordinate of the operand
  73817. * @param y defines the y coordinate of the operand
  73818. * @param z defines the z coordinate of the operand
  73819. * @param result defines the Vector3 object where to store the result
  73820. * @returns the current Vector3
  73821. */
  73822. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  73823. /**
  73824. * Gets a new Vector3 set with the current Vector3 negated coordinates
  73825. * @returns a new Vector3
  73826. */
  73827. negate(): Vector3;
  73828. /**
  73829. * Negate this vector in place
  73830. * @returns this
  73831. */
  73832. negateInPlace(): Vector3;
  73833. /**
  73834. * Multiplies the Vector3 coordinates by the float "scale"
  73835. * @param scale defines the multiplier factor
  73836. * @returns the current updated Vector3
  73837. */
  73838. scaleInPlace(scale: number): Vector3;
  73839. /**
  73840. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  73841. * @param scale defines the multiplier factor
  73842. * @returns a new Vector3
  73843. */
  73844. scale(scale: number): Vector3;
  73845. /**
  73846. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  73847. * @param scale defines the multiplier factor
  73848. * @param result defines the Vector3 object where to store the result
  73849. * @returns the current Vector3
  73850. */
  73851. scaleToRef(scale: number, result: Vector3): Vector3;
  73852. /**
  73853. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  73854. * @param scale defines the scale factor
  73855. * @param result defines the Vector3 object where to store the result
  73856. * @returns the unmodified current Vector3
  73857. */
  73858. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  73859. /**
  73860. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  73861. * @param otherVector defines the second operand
  73862. * @returns true if both vectors are equals
  73863. */
  73864. equals(otherVector: DeepImmutable<Vector3>): boolean;
  73865. /**
  73866. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  73867. * @param otherVector defines the second operand
  73868. * @param epsilon defines the minimal distance to define values as equals
  73869. * @returns true if both vectors are distant less than epsilon
  73870. */
  73871. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  73872. /**
  73873. * Returns true if the current Vector3 coordinates equals the given floats
  73874. * @param x defines the x coordinate of the operand
  73875. * @param y defines the y coordinate of the operand
  73876. * @param z defines the z coordinate of the operand
  73877. * @returns true if both vectors are equals
  73878. */
  73879. equalsToFloats(x: number, y: number, z: number): boolean;
  73880. /**
  73881. * Multiplies the current Vector3 coordinates by the given ones
  73882. * @param otherVector defines the second operand
  73883. * @returns the current updated Vector3
  73884. */
  73885. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  73886. /**
  73887. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  73888. * @param otherVector defines the second operand
  73889. * @returns the new Vector3
  73890. */
  73891. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  73892. /**
  73893. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  73894. * @param otherVector defines the second operand
  73895. * @param result defines the Vector3 object where to store the result
  73896. * @returns the current Vector3
  73897. */
  73898. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73899. /**
  73900. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  73901. * @param x defines the x coordinate of the operand
  73902. * @param y defines the y coordinate of the operand
  73903. * @param z defines the z coordinate of the operand
  73904. * @returns the new Vector3
  73905. */
  73906. multiplyByFloats(x: number, y: number, z: number): Vector3;
  73907. /**
  73908. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  73909. * @param otherVector defines the second operand
  73910. * @returns the new Vector3
  73911. */
  73912. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  73913. /**
  73914. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  73915. * @param otherVector defines the second operand
  73916. * @param result defines the Vector3 object where to store the result
  73917. * @returns the current Vector3
  73918. */
  73919. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  73920. /**
  73921. * Divides the current Vector3 coordinates by the given ones.
  73922. * @param otherVector defines the second operand
  73923. * @returns the current updated Vector3
  73924. */
  73925. divideInPlace(otherVector: Vector3): Vector3;
  73926. /**
  73927. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  73928. * @param other defines the second operand
  73929. * @returns the current updated Vector3
  73930. */
  73931. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73932. /**
  73933. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  73934. * @param other defines the second operand
  73935. * @returns the current updated Vector3
  73936. */
  73937. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  73938. /**
  73939. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  73940. * @param x defines the x coordinate of the operand
  73941. * @param y defines the y coordinate of the operand
  73942. * @param z defines the z coordinate of the operand
  73943. * @returns the current updated Vector3
  73944. */
  73945. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73946. /**
  73947. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  73948. * @param x defines the x coordinate of the operand
  73949. * @param y defines the y coordinate of the operand
  73950. * @param z defines the z coordinate of the operand
  73951. * @returns the current updated Vector3
  73952. */
  73953. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  73954. /**
  73955. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  73956. * Check if is non uniform within a certain amount of decimal places to account for this
  73957. * @param epsilon the amount the values can differ
  73958. * @returns if the the vector is non uniform to a certain number of decimal places
  73959. */
  73960. isNonUniformWithinEpsilon(epsilon: number): boolean;
  73961. /**
  73962. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  73963. */
  73964. get isNonUniform(): boolean;
  73965. /**
  73966. * Gets a new Vector3 from current Vector3 floored values
  73967. * @returns a new Vector3
  73968. */
  73969. floor(): Vector3;
  73970. /**
  73971. * Gets a new Vector3 from current Vector3 floored values
  73972. * @returns a new Vector3
  73973. */
  73974. fract(): Vector3;
  73975. /**
  73976. * Gets the length of the Vector3
  73977. * @returns the length of the Vector3
  73978. */
  73979. length(): number;
  73980. /**
  73981. * Gets the squared length of the Vector3
  73982. * @returns squared length of the Vector3
  73983. */
  73984. lengthSquared(): number;
  73985. /**
  73986. * Normalize the current Vector3.
  73987. * Please note that this is an in place operation.
  73988. * @returns the current updated Vector3
  73989. */
  73990. normalize(): Vector3;
  73991. /**
  73992. * Reorders the x y z properties of the vector in place
  73993. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  73994. * @returns the current updated vector
  73995. */
  73996. reorderInPlace(order: string): this;
  73997. /**
  73998. * Rotates the vector around 0,0,0 by a quaternion
  73999. * @param quaternion the rotation quaternion
  74000. * @param result vector to store the result
  74001. * @returns the resulting vector
  74002. */
  74003. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  74004. /**
  74005. * Rotates a vector around a given point
  74006. * @param quaternion the rotation quaternion
  74007. * @param point the point to rotate around
  74008. * @param result vector to store the result
  74009. * @returns the resulting vector
  74010. */
  74011. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  74012. /**
  74013. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  74014. * The cross product is then orthogonal to both current and "other"
  74015. * @param other defines the right operand
  74016. * @returns the cross product
  74017. */
  74018. cross(other: Vector3): Vector3;
  74019. /**
  74020. * Normalize the current Vector3 with the given input length.
  74021. * Please note that this is an in place operation.
  74022. * @param len the length of the vector
  74023. * @returns the current updated Vector3
  74024. */
  74025. normalizeFromLength(len: number): Vector3;
  74026. /**
  74027. * Normalize the current Vector3 to a new vector
  74028. * @returns the new Vector3
  74029. */
  74030. normalizeToNew(): Vector3;
  74031. /**
  74032. * Normalize the current Vector3 to the reference
  74033. * @param reference define the Vector3 to update
  74034. * @returns the updated Vector3
  74035. */
  74036. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  74037. /**
  74038. * Creates a new Vector3 copied from the current Vector3
  74039. * @returns the new Vector3
  74040. */
  74041. clone(): Vector3;
  74042. /**
  74043. * Copies the given vector coordinates to the current Vector3 ones
  74044. * @param source defines the source Vector3
  74045. * @returns the current updated Vector3
  74046. */
  74047. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  74048. /**
  74049. * Copies the given floats to the current Vector3 coordinates
  74050. * @param x defines the x coordinate of the operand
  74051. * @param y defines the y coordinate of the operand
  74052. * @param z defines the z coordinate of the operand
  74053. * @returns the current updated Vector3
  74054. */
  74055. copyFromFloats(x: number, y: number, z: number): Vector3;
  74056. /**
  74057. * Copies the given floats to the current Vector3 coordinates
  74058. * @param x defines the x coordinate of the operand
  74059. * @param y defines the y coordinate of the operand
  74060. * @param z defines the z coordinate of the operand
  74061. * @returns the current updated Vector3
  74062. */
  74063. set(x: number, y: number, z: number): Vector3;
  74064. /**
  74065. * Copies the given float to the current Vector3 coordinates
  74066. * @param v defines the x, y and z coordinates of the operand
  74067. * @returns the current updated Vector3
  74068. */
  74069. setAll(v: number): Vector3;
  74070. /**
  74071. * Get the clip factor between two vectors
  74072. * @param vector0 defines the first operand
  74073. * @param vector1 defines the second operand
  74074. * @param axis defines the axis to use
  74075. * @param size defines the size along the axis
  74076. * @returns the clip factor
  74077. */
  74078. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  74079. /**
  74080. * Get angle between two vectors
  74081. * @param vector0 angle between vector0 and vector1
  74082. * @param vector1 angle between vector0 and vector1
  74083. * @param normal direction of the normal
  74084. * @return the angle between vector0 and vector1
  74085. */
  74086. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  74087. /**
  74088. * Returns a new Vector3 set from the index "offset" of the given array
  74089. * @param array defines the source array
  74090. * @param offset defines the offset in the source array
  74091. * @returns the new Vector3
  74092. */
  74093. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  74094. /**
  74095. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  74096. * @param array defines the source array
  74097. * @param offset defines the offset in the source array
  74098. * @returns the new Vector3
  74099. * @deprecated Please use FromArray instead.
  74100. */
  74101. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  74102. /**
  74103. * Sets the given vector "result" with the element values from the index "offset" of the given array
  74104. * @param array defines the source array
  74105. * @param offset defines the offset in the source array
  74106. * @param result defines the Vector3 where to store the result
  74107. */
  74108. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  74109. /**
  74110. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  74111. * @param array defines the source array
  74112. * @param offset defines the offset in the source array
  74113. * @param result defines the Vector3 where to store the result
  74114. * @deprecated Please use FromArrayToRef instead.
  74115. */
  74116. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  74117. /**
  74118. * Sets the given vector "result" with the given floats.
  74119. * @param x defines the x coordinate of the source
  74120. * @param y defines the y coordinate of the source
  74121. * @param z defines the z coordinate of the source
  74122. * @param result defines the Vector3 where to store the result
  74123. */
  74124. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  74125. /**
  74126. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  74127. * @returns a new empty Vector3
  74128. */
  74129. static Zero(): Vector3;
  74130. /**
  74131. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  74132. * @returns a new unit Vector3
  74133. */
  74134. static One(): Vector3;
  74135. /**
  74136. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  74137. * @returns a new up Vector3
  74138. */
  74139. static Up(): Vector3;
  74140. /**
  74141. * Gets a up Vector3 that must not be updated
  74142. */
  74143. static get UpReadOnly(): DeepImmutable<Vector3>;
  74144. /**
  74145. * Gets a zero Vector3 that must not be updated
  74146. */
  74147. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  74148. /**
  74149. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  74150. * @returns a new down Vector3
  74151. */
  74152. static Down(): Vector3;
  74153. /**
  74154. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  74155. * @returns a new forward Vector3
  74156. */
  74157. static Forward(): Vector3;
  74158. /**
  74159. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  74160. * @returns a new forward Vector3
  74161. */
  74162. static Backward(): Vector3;
  74163. /**
  74164. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  74165. * @returns a new right Vector3
  74166. */
  74167. static Right(): Vector3;
  74168. /**
  74169. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  74170. * @returns a new left Vector3
  74171. */
  74172. static Left(): Vector3;
  74173. /**
  74174. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  74175. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  74176. * @param vector defines the Vector3 to transform
  74177. * @param transformation defines the transformation matrix
  74178. * @returns the transformed Vector3
  74179. */
  74180. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  74181. /**
  74182. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  74183. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  74184. * @param vector defines the Vector3 to transform
  74185. * @param transformation defines the transformation matrix
  74186. * @param result defines the Vector3 where to store the result
  74187. */
  74188. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  74189. /**
  74190. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  74191. * This method computes tranformed coordinates only, not transformed direction vectors
  74192. * @param x define the x coordinate of the source vector
  74193. * @param y define the y coordinate of the source vector
  74194. * @param z define the z coordinate of the source vector
  74195. * @param transformation defines the transformation matrix
  74196. * @param result defines the Vector3 where to store the result
  74197. */
  74198. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  74199. /**
  74200. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  74201. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  74202. * @param vector defines the Vector3 to transform
  74203. * @param transformation defines the transformation matrix
  74204. * @returns the new Vector3
  74205. */
  74206. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  74207. /**
  74208. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  74209. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  74210. * @param vector defines the Vector3 to transform
  74211. * @param transformation defines the transformation matrix
  74212. * @param result defines the Vector3 where to store the result
  74213. */
  74214. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  74215. /**
  74216. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  74217. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  74218. * @param x define the x coordinate of the source vector
  74219. * @param y define the y coordinate of the source vector
  74220. * @param z define the z coordinate of the source vector
  74221. * @param transformation defines the transformation matrix
  74222. * @param result defines the Vector3 where to store the result
  74223. */
  74224. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  74225. /**
  74226. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  74227. * @param value1 defines the first control point
  74228. * @param value2 defines the second control point
  74229. * @param value3 defines the third control point
  74230. * @param value4 defines the fourth control point
  74231. * @param amount defines the amount on the spline to use
  74232. * @returns the new Vector3
  74233. */
  74234. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  74235. /**
  74236. * 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"
  74237. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  74238. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  74239. * @param value defines the current value
  74240. * @param min defines the lower range value
  74241. * @param max defines the upper range value
  74242. * @returns the new Vector3
  74243. */
  74244. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  74245. /**
  74246. * 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"
  74247. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  74248. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  74249. * @param value defines the current value
  74250. * @param min defines the lower range value
  74251. * @param max defines the upper range value
  74252. * @param result defines the Vector3 where to store the result
  74253. */
  74254. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  74255. /**
  74256. * Checks if a given vector is inside a specific range
  74257. * @param v defines the vector to test
  74258. * @param min defines the minimum range
  74259. * @param max defines the maximum range
  74260. */
  74261. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  74262. /**
  74263. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  74264. * @param value1 defines the first control point
  74265. * @param tangent1 defines the first tangent vector
  74266. * @param value2 defines the second control point
  74267. * @param tangent2 defines the second tangent vector
  74268. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  74269. * @returns the new Vector3
  74270. */
  74271. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  74272. /**
  74273. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  74274. * @param start defines the start value
  74275. * @param end defines the end value
  74276. * @param amount max defines amount between both (between 0 and 1)
  74277. * @returns the new Vector3
  74278. */
  74279. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  74280. /**
  74281. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  74282. * @param start defines the start value
  74283. * @param end defines the end value
  74284. * @param amount max defines amount between both (between 0 and 1)
  74285. * @param result defines the Vector3 where to store the result
  74286. */
  74287. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  74288. /**
  74289. * Returns the dot product (float) between the vectors "left" and "right"
  74290. * @param left defines the left operand
  74291. * @param right defines the right operand
  74292. * @returns the dot product
  74293. */
  74294. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  74295. /**
  74296. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  74297. * The cross product is then orthogonal to both "left" and "right"
  74298. * @param left defines the left operand
  74299. * @param right defines the right operand
  74300. * @returns the cross product
  74301. */
  74302. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  74303. /**
  74304. * Sets the given vector "result" with the cross product of "left" and "right"
  74305. * The cross product is then orthogonal to both "left" and "right"
  74306. * @param left defines the left operand
  74307. * @param right defines the right operand
  74308. * @param result defines the Vector3 where to store the result
  74309. */
  74310. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  74311. /**
  74312. * Returns a new Vector3 as the normalization of the given vector
  74313. * @param vector defines the Vector3 to normalize
  74314. * @returns the new Vector3
  74315. */
  74316. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  74317. /**
  74318. * Sets the given vector "result" with the normalization of the given first vector
  74319. * @param vector defines the Vector3 to normalize
  74320. * @param result defines the Vector3 where to store the result
  74321. */
  74322. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  74323. /**
  74324. * Project a Vector3 onto screen space
  74325. * @param vector defines the Vector3 to project
  74326. * @param world defines the world matrix to use
  74327. * @param transform defines the transform (view x projection) matrix to use
  74328. * @param viewport defines the screen viewport to use
  74329. * @returns the new Vector3
  74330. */
  74331. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  74332. /** @hidden */
  74333. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  74334. /**
  74335. * Unproject from screen space to object space
  74336. * @param source defines the screen space Vector3 to use
  74337. * @param viewportWidth defines the current width of the viewport
  74338. * @param viewportHeight defines the current height of the viewport
  74339. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74340. * @param transform defines the transform (view x projection) matrix to use
  74341. * @returns the new Vector3
  74342. */
  74343. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  74344. /**
  74345. * Unproject from screen space to object space
  74346. * @param source defines the screen space Vector3 to use
  74347. * @param viewportWidth defines the current width of the viewport
  74348. * @param viewportHeight defines the current height of the viewport
  74349. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74350. * @param view defines the view matrix to use
  74351. * @param projection defines the projection matrix to use
  74352. * @returns the new Vector3
  74353. */
  74354. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  74355. /**
  74356. * Unproject from screen space to object space
  74357. * @param source defines the screen space Vector3 to use
  74358. * @param viewportWidth defines the current width of the viewport
  74359. * @param viewportHeight defines the current height of the viewport
  74360. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74361. * @param view defines the view matrix to use
  74362. * @param projection defines the projection matrix to use
  74363. * @param result defines the Vector3 where to store the result
  74364. */
  74365. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  74366. /**
  74367. * Unproject from screen space to object space
  74368. * @param sourceX defines the screen space x coordinate to use
  74369. * @param sourceY defines the screen space y coordinate to use
  74370. * @param sourceZ defines the screen space z coordinate to use
  74371. * @param viewportWidth defines the current width of the viewport
  74372. * @param viewportHeight defines the current height of the viewport
  74373. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74374. * @param view defines the view matrix to use
  74375. * @param projection defines the projection matrix to use
  74376. * @param result defines the Vector3 where to store the result
  74377. */
  74378. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  74379. /**
  74380. * Gets the minimal coordinate values between two Vector3
  74381. * @param left defines the first operand
  74382. * @param right defines the second operand
  74383. * @returns the new Vector3
  74384. */
  74385. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  74386. /**
  74387. * Gets the maximal coordinate values between two Vector3
  74388. * @param left defines the first operand
  74389. * @param right defines the second operand
  74390. * @returns the new Vector3
  74391. */
  74392. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  74393. /**
  74394. * Returns the distance between the vectors "value1" and "value2"
  74395. * @param value1 defines the first operand
  74396. * @param value2 defines the second operand
  74397. * @returns the distance
  74398. */
  74399. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  74400. /**
  74401. * Returns the squared distance between the vectors "value1" and "value2"
  74402. * @param value1 defines the first operand
  74403. * @param value2 defines the second operand
  74404. * @returns the squared distance
  74405. */
  74406. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  74407. /**
  74408. * Returns a new Vector3 located at the center between "value1" and "value2"
  74409. * @param value1 defines the first operand
  74410. * @param value2 defines the second operand
  74411. * @returns the new Vector3
  74412. */
  74413. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  74414. /**
  74415. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  74416. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  74417. * to something in order to rotate it from its local system to the given target system
  74418. * Note: axis1, axis2 and axis3 are normalized during this operation
  74419. * @param axis1 defines the first axis
  74420. * @param axis2 defines the second axis
  74421. * @param axis3 defines the third axis
  74422. * @returns a new Vector3
  74423. */
  74424. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  74425. /**
  74426. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  74427. * @param axis1 defines the first axis
  74428. * @param axis2 defines the second axis
  74429. * @param axis3 defines the third axis
  74430. * @param ref defines the Vector3 where to store the result
  74431. */
  74432. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  74433. }
  74434. /**
  74435. * Vector4 class created for EulerAngle class conversion to Quaternion
  74436. */
  74437. export class Vector4 {
  74438. /** x value of the vector */
  74439. x: number;
  74440. /** y value of the vector */
  74441. y: number;
  74442. /** z value of the vector */
  74443. z: number;
  74444. /** w value of the vector */
  74445. w: number;
  74446. /**
  74447. * Creates a Vector4 object from the given floats.
  74448. * @param x x value of the vector
  74449. * @param y y value of the vector
  74450. * @param z z value of the vector
  74451. * @param w w value of the vector
  74452. */
  74453. constructor(
  74454. /** x value of the vector */
  74455. x: number,
  74456. /** y value of the vector */
  74457. y: number,
  74458. /** z value of the vector */
  74459. z: number,
  74460. /** w value of the vector */
  74461. w: number);
  74462. /**
  74463. * Returns the string with the Vector4 coordinates.
  74464. * @returns a string containing all the vector values
  74465. */
  74466. toString(): string;
  74467. /**
  74468. * Returns the string "Vector4".
  74469. * @returns "Vector4"
  74470. */
  74471. getClassName(): string;
  74472. /**
  74473. * Returns the Vector4 hash code.
  74474. * @returns a unique hash code
  74475. */
  74476. getHashCode(): number;
  74477. /**
  74478. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  74479. * @returns the resulting array
  74480. */
  74481. asArray(): number[];
  74482. /**
  74483. * Populates the given array from the given index with the Vector4 coordinates.
  74484. * @param array array to populate
  74485. * @param index index of the array to start at (default: 0)
  74486. * @returns the Vector4.
  74487. */
  74488. toArray(array: FloatArray, index?: number): Vector4;
  74489. /**
  74490. * Adds the given vector to the current Vector4.
  74491. * @param otherVector the vector to add
  74492. * @returns the updated Vector4.
  74493. */
  74494. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  74495. /**
  74496. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  74497. * @param otherVector the vector to add
  74498. * @returns the resulting vector
  74499. */
  74500. add(otherVector: DeepImmutable<Vector4>): Vector4;
  74501. /**
  74502. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  74503. * @param otherVector the vector to add
  74504. * @param result the vector to store the result
  74505. * @returns the current Vector4.
  74506. */
  74507. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  74508. /**
  74509. * Subtract in place the given vector from the current Vector4.
  74510. * @param otherVector the vector to subtract
  74511. * @returns the updated Vector4.
  74512. */
  74513. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  74514. /**
  74515. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  74516. * @param otherVector the vector to add
  74517. * @returns the new vector with the result
  74518. */
  74519. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  74520. /**
  74521. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  74522. * @param otherVector the vector to subtract
  74523. * @param result the vector to store the result
  74524. * @returns the current Vector4.
  74525. */
  74526. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  74527. /**
  74528. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  74529. */
  74530. /**
  74531. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  74532. * @param x value to subtract
  74533. * @param y value to subtract
  74534. * @param z value to subtract
  74535. * @param w value to subtract
  74536. * @returns new vector containing the result
  74537. */
  74538. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  74539. /**
  74540. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  74541. * @param x value to subtract
  74542. * @param y value to subtract
  74543. * @param z value to subtract
  74544. * @param w value to subtract
  74545. * @param result the vector to store the result in
  74546. * @returns the current Vector4.
  74547. */
  74548. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  74549. /**
  74550. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  74551. * @returns a new vector with the negated values
  74552. */
  74553. negate(): Vector4;
  74554. /**
  74555. * Multiplies the current Vector4 coordinates by scale (float).
  74556. * @param scale the number to scale with
  74557. * @returns the updated Vector4.
  74558. */
  74559. scaleInPlace(scale: number): Vector4;
  74560. /**
  74561. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  74562. * @param scale the number to scale with
  74563. * @returns a new vector with the result
  74564. */
  74565. scale(scale: number): Vector4;
  74566. /**
  74567. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  74568. * @param scale the number to scale with
  74569. * @param result a vector to store the result in
  74570. * @returns the current Vector4.
  74571. */
  74572. scaleToRef(scale: number, result: Vector4): Vector4;
  74573. /**
  74574. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  74575. * @param scale defines the scale factor
  74576. * @param result defines the Vector4 object where to store the result
  74577. * @returns the unmodified current Vector4
  74578. */
  74579. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  74580. /**
  74581. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  74582. * @param otherVector the vector to compare against
  74583. * @returns true if they are equal
  74584. */
  74585. equals(otherVector: DeepImmutable<Vector4>): boolean;
  74586. /**
  74587. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  74588. * @param otherVector vector to compare against
  74589. * @param epsilon (Default: very small number)
  74590. * @returns true if they are equal
  74591. */
  74592. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  74593. /**
  74594. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  74595. * @param x x value to compare against
  74596. * @param y y value to compare against
  74597. * @param z z value to compare against
  74598. * @param w w value to compare against
  74599. * @returns true if equal
  74600. */
  74601. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  74602. /**
  74603. * Multiplies in place the current Vector4 by the given one.
  74604. * @param otherVector vector to multiple with
  74605. * @returns the updated Vector4.
  74606. */
  74607. multiplyInPlace(otherVector: Vector4): Vector4;
  74608. /**
  74609. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  74610. * @param otherVector vector to multiple with
  74611. * @returns resulting new vector
  74612. */
  74613. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  74614. /**
  74615. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  74616. * @param otherVector vector to multiple with
  74617. * @param result vector to store the result
  74618. * @returns the current Vector4.
  74619. */
  74620. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  74621. /**
  74622. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  74623. * @param x x value multiply with
  74624. * @param y y value multiply with
  74625. * @param z z value multiply with
  74626. * @param w w value multiply with
  74627. * @returns resulting new vector
  74628. */
  74629. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  74630. /**
  74631. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  74632. * @param otherVector vector to devide with
  74633. * @returns resulting new vector
  74634. */
  74635. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  74636. /**
  74637. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  74638. * @param otherVector vector to devide with
  74639. * @param result vector to store the result
  74640. * @returns the current Vector4.
  74641. */
  74642. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  74643. /**
  74644. * Divides the current Vector3 coordinates by the given ones.
  74645. * @param otherVector vector to devide with
  74646. * @returns the updated Vector3.
  74647. */
  74648. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  74649. /**
  74650. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  74651. * @param other defines the second operand
  74652. * @returns the current updated Vector4
  74653. */
  74654. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  74655. /**
  74656. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  74657. * @param other defines the second operand
  74658. * @returns the current updated Vector4
  74659. */
  74660. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  74661. /**
  74662. * Gets a new Vector4 from current Vector4 floored values
  74663. * @returns a new Vector4
  74664. */
  74665. floor(): Vector4;
  74666. /**
  74667. * Gets a new Vector4 from current Vector3 floored values
  74668. * @returns a new Vector4
  74669. */
  74670. fract(): Vector4;
  74671. /**
  74672. * Returns the Vector4 length (float).
  74673. * @returns the length
  74674. */
  74675. length(): number;
  74676. /**
  74677. * Returns the Vector4 squared length (float).
  74678. * @returns the length squared
  74679. */
  74680. lengthSquared(): number;
  74681. /**
  74682. * Normalizes in place the Vector4.
  74683. * @returns the updated Vector4.
  74684. */
  74685. normalize(): Vector4;
  74686. /**
  74687. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  74688. * @returns this converted to a new vector3
  74689. */
  74690. toVector3(): Vector3;
  74691. /**
  74692. * Returns a new Vector4 copied from the current one.
  74693. * @returns the new cloned vector
  74694. */
  74695. clone(): Vector4;
  74696. /**
  74697. * Updates the current Vector4 with the given one coordinates.
  74698. * @param source the source vector to copy from
  74699. * @returns the updated Vector4.
  74700. */
  74701. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  74702. /**
  74703. * Updates the current Vector4 coordinates with the given floats.
  74704. * @param x float to copy from
  74705. * @param y float to copy from
  74706. * @param z float to copy from
  74707. * @param w float to copy from
  74708. * @returns the updated Vector4.
  74709. */
  74710. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  74711. /**
  74712. * Updates the current Vector4 coordinates with the given floats.
  74713. * @param x float to set from
  74714. * @param y float to set from
  74715. * @param z float to set from
  74716. * @param w float to set from
  74717. * @returns the updated Vector4.
  74718. */
  74719. set(x: number, y: number, z: number, w: number): Vector4;
  74720. /**
  74721. * Copies the given float to the current Vector3 coordinates
  74722. * @param v defines the x, y, z and w coordinates of the operand
  74723. * @returns the current updated Vector3
  74724. */
  74725. setAll(v: number): Vector4;
  74726. /**
  74727. * Returns a new Vector4 set from the starting index of the given array.
  74728. * @param array the array to pull values from
  74729. * @param offset the offset into the array to start at
  74730. * @returns the new vector
  74731. */
  74732. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  74733. /**
  74734. * Updates the given vector "result" from the starting index of the given array.
  74735. * @param array the array to pull values from
  74736. * @param offset the offset into the array to start at
  74737. * @param result the vector to store the result in
  74738. */
  74739. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  74740. /**
  74741. * Updates the given vector "result" from the starting index of the given Float32Array.
  74742. * @param array the array to pull values from
  74743. * @param offset the offset into the array to start at
  74744. * @param result the vector to store the result in
  74745. */
  74746. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  74747. /**
  74748. * Updates the given vector "result" coordinates from the given floats.
  74749. * @param x float to set from
  74750. * @param y float to set from
  74751. * @param z float to set from
  74752. * @param w float to set from
  74753. * @param result the vector to the floats in
  74754. */
  74755. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  74756. /**
  74757. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  74758. * @returns the new vector
  74759. */
  74760. static Zero(): Vector4;
  74761. /**
  74762. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  74763. * @returns the new vector
  74764. */
  74765. static One(): Vector4;
  74766. /**
  74767. * Returns a new normalized Vector4 from the given one.
  74768. * @param vector the vector to normalize
  74769. * @returns the vector
  74770. */
  74771. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  74772. /**
  74773. * Updates the given vector "result" from the normalization of the given one.
  74774. * @param vector the vector to normalize
  74775. * @param result the vector to store the result in
  74776. */
  74777. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  74778. /**
  74779. * Returns a vector with the minimum values from the left and right vectors
  74780. * @param left left vector to minimize
  74781. * @param right right vector to minimize
  74782. * @returns a new vector with the minimum of the left and right vector values
  74783. */
  74784. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74785. /**
  74786. * Returns a vector with the maximum values from the left and right vectors
  74787. * @param left left vector to maximize
  74788. * @param right right vector to maximize
  74789. * @returns a new vector with the maximum of the left and right vector values
  74790. */
  74791. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  74792. /**
  74793. * Returns the distance (float) between the vectors "value1" and "value2".
  74794. * @param value1 value to calulate the distance between
  74795. * @param value2 value to calulate the distance between
  74796. * @return the distance between the two vectors
  74797. */
  74798. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74799. /**
  74800. * Returns the squared distance (float) between the vectors "value1" and "value2".
  74801. * @param value1 value to calulate the distance between
  74802. * @param value2 value to calulate the distance between
  74803. * @return the distance between the two vectors squared
  74804. */
  74805. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  74806. /**
  74807. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  74808. * @param value1 value to calulate the center between
  74809. * @param value2 value to calulate the center between
  74810. * @return the center between the two vectors
  74811. */
  74812. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  74813. /**
  74814. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  74815. * This methods computes transformed normalized direction vectors only.
  74816. * @param vector the vector to transform
  74817. * @param transformation the transformation matrix to apply
  74818. * @returns the new vector
  74819. */
  74820. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  74821. /**
  74822. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  74823. * This methods computes transformed normalized direction vectors only.
  74824. * @param vector the vector to transform
  74825. * @param transformation the transformation matrix to apply
  74826. * @param result the vector to store the result in
  74827. */
  74828. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74829. /**
  74830. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  74831. * This methods computes transformed normalized direction vectors only.
  74832. * @param x value to transform
  74833. * @param y value to transform
  74834. * @param z value to transform
  74835. * @param w value to transform
  74836. * @param transformation the transformation matrix to apply
  74837. * @param result the vector to store the results in
  74838. */
  74839. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  74840. /**
  74841. * Creates a new Vector4 from a Vector3
  74842. * @param source defines the source data
  74843. * @param w defines the 4th component (default is 0)
  74844. * @returns a new Vector4
  74845. */
  74846. static FromVector3(source: Vector3, w?: number): Vector4;
  74847. }
  74848. /**
  74849. * Class used to store quaternion data
  74850. * @see https://en.wikipedia.org/wiki/Quaternion
  74851. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  74852. */
  74853. export class Quaternion {
  74854. /** defines the first component (0 by default) */
  74855. x: number;
  74856. /** defines the second component (0 by default) */
  74857. y: number;
  74858. /** defines the third component (0 by default) */
  74859. z: number;
  74860. /** defines the fourth component (1.0 by default) */
  74861. w: number;
  74862. /**
  74863. * Creates a new Quaternion from the given floats
  74864. * @param x defines the first component (0 by default)
  74865. * @param y defines the second component (0 by default)
  74866. * @param z defines the third component (0 by default)
  74867. * @param w defines the fourth component (1.0 by default)
  74868. */
  74869. constructor(
  74870. /** defines the first component (0 by default) */
  74871. x?: number,
  74872. /** defines the second component (0 by default) */
  74873. y?: number,
  74874. /** defines the third component (0 by default) */
  74875. z?: number,
  74876. /** defines the fourth component (1.0 by default) */
  74877. w?: number);
  74878. /**
  74879. * Gets a string representation for the current quaternion
  74880. * @returns a string with the Quaternion coordinates
  74881. */
  74882. toString(): string;
  74883. /**
  74884. * Gets the class name of the quaternion
  74885. * @returns the string "Quaternion"
  74886. */
  74887. getClassName(): string;
  74888. /**
  74889. * Gets a hash code for this quaternion
  74890. * @returns the quaternion hash code
  74891. */
  74892. getHashCode(): number;
  74893. /**
  74894. * Copy the quaternion to an array
  74895. * @returns a new array populated with 4 elements from the quaternion coordinates
  74896. */
  74897. asArray(): number[];
  74898. /**
  74899. * Check if two quaternions are equals
  74900. * @param otherQuaternion defines the second operand
  74901. * @return true if the current quaternion and the given one coordinates are strictly equals
  74902. */
  74903. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  74904. /**
  74905. * Gets a boolean if two quaternions are equals (using an epsilon value)
  74906. * @param otherQuaternion defines the other quaternion
  74907. * @param epsilon defines the minimal distance to consider equality
  74908. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  74909. */
  74910. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  74911. /**
  74912. * Clone the current quaternion
  74913. * @returns a new quaternion copied from the current one
  74914. */
  74915. clone(): Quaternion;
  74916. /**
  74917. * Copy a quaternion to the current one
  74918. * @param other defines the other quaternion
  74919. * @returns the updated current quaternion
  74920. */
  74921. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  74922. /**
  74923. * Updates the current quaternion with the given float coordinates
  74924. * @param x defines the x coordinate
  74925. * @param y defines the y coordinate
  74926. * @param z defines the z coordinate
  74927. * @param w defines the w coordinate
  74928. * @returns the updated current quaternion
  74929. */
  74930. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  74931. /**
  74932. * Updates the current quaternion from the given float coordinates
  74933. * @param x defines the x coordinate
  74934. * @param y defines the y coordinate
  74935. * @param z defines the z coordinate
  74936. * @param w defines the w coordinate
  74937. * @returns the updated current quaternion
  74938. */
  74939. set(x: number, y: number, z: number, w: number): Quaternion;
  74940. /**
  74941. * Adds two quaternions
  74942. * @param other defines the second operand
  74943. * @returns a new quaternion as the addition result of the given one and the current quaternion
  74944. */
  74945. add(other: DeepImmutable<Quaternion>): Quaternion;
  74946. /**
  74947. * Add a quaternion to the current one
  74948. * @param other defines the quaternion to add
  74949. * @returns the current quaternion
  74950. */
  74951. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  74952. /**
  74953. * Subtract two quaternions
  74954. * @param other defines the second operand
  74955. * @returns a new quaternion as the subtraction result of the given one from the current one
  74956. */
  74957. subtract(other: Quaternion): Quaternion;
  74958. /**
  74959. * Multiplies the current quaternion by a scale factor
  74960. * @param value defines the scale factor
  74961. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  74962. */
  74963. scale(value: number): Quaternion;
  74964. /**
  74965. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  74966. * @param scale defines the scale factor
  74967. * @param result defines the Quaternion object where to store the result
  74968. * @returns the unmodified current quaternion
  74969. */
  74970. scaleToRef(scale: number, result: Quaternion): Quaternion;
  74971. /**
  74972. * Multiplies in place the current quaternion by a scale factor
  74973. * @param value defines the scale factor
  74974. * @returns the current modified quaternion
  74975. */
  74976. scaleInPlace(value: number): Quaternion;
  74977. /**
  74978. * Scale the current quaternion values by a factor and add the result to a given quaternion
  74979. * @param scale defines the scale factor
  74980. * @param result defines the Quaternion object where to store the result
  74981. * @returns the unmodified current quaternion
  74982. */
  74983. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  74984. /**
  74985. * Multiplies two quaternions
  74986. * @param q1 defines the second operand
  74987. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  74988. */
  74989. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  74990. /**
  74991. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  74992. * @param q1 defines the second operand
  74993. * @param result defines the target quaternion
  74994. * @returns the current quaternion
  74995. */
  74996. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  74997. /**
  74998. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  74999. * @param q1 defines the second operand
  75000. * @returns the currentupdated quaternion
  75001. */
  75002. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  75003. /**
  75004. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  75005. * @param ref defines the target quaternion
  75006. * @returns the current quaternion
  75007. */
  75008. conjugateToRef(ref: Quaternion): Quaternion;
  75009. /**
  75010. * Conjugates in place (1-q) the current quaternion
  75011. * @returns the current updated quaternion
  75012. */
  75013. conjugateInPlace(): Quaternion;
  75014. /**
  75015. * Conjugates in place (1-q) the current quaternion
  75016. * @returns a new quaternion
  75017. */
  75018. conjugate(): Quaternion;
  75019. /**
  75020. * Gets length of current quaternion
  75021. * @returns the quaternion length (float)
  75022. */
  75023. length(): number;
  75024. /**
  75025. * Normalize in place the current quaternion
  75026. * @returns the current updated quaternion
  75027. */
  75028. normalize(): Quaternion;
  75029. /**
  75030. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  75031. * @param order is a reserved parameter and is ignore for now
  75032. * @returns a new Vector3 containing the Euler angles
  75033. */
  75034. toEulerAngles(order?: string): Vector3;
  75035. /**
  75036. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  75037. * @param result defines the vector which will be filled with the Euler angles
  75038. * @param order is a reserved parameter and is ignore for now
  75039. * @returns the current unchanged quaternion
  75040. */
  75041. toEulerAnglesToRef(result: Vector3): Quaternion;
  75042. /**
  75043. * Updates the given rotation matrix with the current quaternion values
  75044. * @param result defines the target matrix
  75045. * @returns the current unchanged quaternion
  75046. */
  75047. toRotationMatrix(result: Matrix): Quaternion;
  75048. /**
  75049. * Updates the current quaternion from the given rotation matrix values
  75050. * @param matrix defines the source matrix
  75051. * @returns the current updated quaternion
  75052. */
  75053. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  75054. /**
  75055. * Creates a new quaternion from a rotation matrix
  75056. * @param matrix defines the source matrix
  75057. * @returns a new quaternion created from the given rotation matrix values
  75058. */
  75059. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  75060. /**
  75061. * Updates the given quaternion with the given rotation matrix values
  75062. * @param matrix defines the source matrix
  75063. * @param result defines the target quaternion
  75064. */
  75065. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  75066. /**
  75067. * Returns the dot product (float) between the quaternions "left" and "right"
  75068. * @param left defines the left operand
  75069. * @param right defines the right operand
  75070. * @returns the dot product
  75071. */
  75072. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  75073. /**
  75074. * Checks if the two quaternions are close to each other
  75075. * @param quat0 defines the first quaternion to check
  75076. * @param quat1 defines the second quaternion to check
  75077. * @returns true if the two quaternions are close to each other
  75078. */
  75079. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  75080. /**
  75081. * Creates an empty quaternion
  75082. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  75083. */
  75084. static Zero(): Quaternion;
  75085. /**
  75086. * Inverse a given quaternion
  75087. * @param q defines the source quaternion
  75088. * @returns a new quaternion as the inverted current quaternion
  75089. */
  75090. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  75091. /**
  75092. * Inverse a given quaternion
  75093. * @param q defines the source quaternion
  75094. * @param result the quaternion the result will be stored in
  75095. * @returns the result quaternion
  75096. */
  75097. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  75098. /**
  75099. * Creates an identity quaternion
  75100. * @returns the identity quaternion
  75101. */
  75102. static Identity(): Quaternion;
  75103. /**
  75104. * Gets a boolean indicating if the given quaternion is identity
  75105. * @param quaternion defines the quaternion to check
  75106. * @returns true if the quaternion is identity
  75107. */
  75108. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  75109. /**
  75110. * Creates a quaternion from a rotation around an axis
  75111. * @param axis defines the axis to use
  75112. * @param angle defines the angle to use
  75113. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  75114. */
  75115. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  75116. /**
  75117. * Creates a rotation around an axis and stores it into the given quaternion
  75118. * @param axis defines the axis to use
  75119. * @param angle defines the angle to use
  75120. * @param result defines the target quaternion
  75121. * @returns the target quaternion
  75122. */
  75123. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  75124. /**
  75125. * Creates a new quaternion from data stored into an array
  75126. * @param array defines the data source
  75127. * @param offset defines the offset in the source array where the data starts
  75128. * @returns a new quaternion
  75129. */
  75130. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  75131. /**
  75132. * Create a quaternion from Euler rotation angles
  75133. * @param x Pitch
  75134. * @param y Yaw
  75135. * @param z Roll
  75136. * @returns the new Quaternion
  75137. */
  75138. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  75139. /**
  75140. * Updates a quaternion from Euler rotation angles
  75141. * @param x Pitch
  75142. * @param y Yaw
  75143. * @param z Roll
  75144. * @param result the quaternion to store the result
  75145. * @returns the updated quaternion
  75146. */
  75147. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  75148. /**
  75149. * Create a quaternion from Euler rotation vector
  75150. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  75151. * @returns the new Quaternion
  75152. */
  75153. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  75154. /**
  75155. * Updates a quaternion from Euler rotation vector
  75156. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  75157. * @param result the quaternion to store the result
  75158. * @returns the updated quaternion
  75159. */
  75160. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  75161. /**
  75162. * Creates a new quaternion from the given Euler float angles (y, x, z)
  75163. * @param yaw defines the rotation around Y axis
  75164. * @param pitch defines the rotation around X axis
  75165. * @param roll defines the rotation around Z axis
  75166. * @returns the new quaternion
  75167. */
  75168. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  75169. /**
  75170. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  75171. * @param yaw defines the rotation around Y axis
  75172. * @param pitch defines the rotation around X axis
  75173. * @param roll defines the rotation around Z axis
  75174. * @param result defines the target quaternion
  75175. */
  75176. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  75177. /**
  75178. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  75179. * @param alpha defines the rotation around first axis
  75180. * @param beta defines the rotation around second axis
  75181. * @param gamma defines the rotation around third axis
  75182. * @returns the new quaternion
  75183. */
  75184. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  75185. /**
  75186. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  75187. * @param alpha defines the rotation around first axis
  75188. * @param beta defines the rotation around second axis
  75189. * @param gamma defines the rotation around third axis
  75190. * @param result defines the target quaternion
  75191. */
  75192. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  75193. /**
  75194. * 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)
  75195. * @param axis1 defines the first axis
  75196. * @param axis2 defines the second axis
  75197. * @param axis3 defines the third axis
  75198. * @returns the new quaternion
  75199. */
  75200. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  75201. /**
  75202. * 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
  75203. * @param axis1 defines the first axis
  75204. * @param axis2 defines the second axis
  75205. * @param axis3 defines the third axis
  75206. * @param ref defines the target quaternion
  75207. */
  75208. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  75209. /**
  75210. * Interpolates between two quaternions
  75211. * @param left defines first quaternion
  75212. * @param right defines second quaternion
  75213. * @param amount defines the gradient to use
  75214. * @returns the new interpolated quaternion
  75215. */
  75216. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  75217. /**
  75218. * Interpolates between two quaternions and stores it into a target quaternion
  75219. * @param left defines first quaternion
  75220. * @param right defines second quaternion
  75221. * @param amount defines the gradient to use
  75222. * @param result defines the target quaternion
  75223. */
  75224. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  75225. /**
  75226. * Interpolate between two quaternions using Hermite interpolation
  75227. * @param value1 defines first quaternion
  75228. * @param tangent1 defines the incoming tangent
  75229. * @param value2 defines second quaternion
  75230. * @param tangent2 defines the outgoing tangent
  75231. * @param amount defines the target quaternion
  75232. * @returns the new interpolated quaternion
  75233. */
  75234. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  75235. }
  75236. /**
  75237. * Class used to store matrix data (4x4)
  75238. */
  75239. export class Matrix {
  75240. private static _updateFlagSeed;
  75241. private static _identityReadOnly;
  75242. private _isIdentity;
  75243. private _isIdentityDirty;
  75244. private _isIdentity3x2;
  75245. private _isIdentity3x2Dirty;
  75246. /**
  75247. * Gets the update flag of the matrix which is an unique number for the matrix.
  75248. * It will be incremented every time the matrix data change.
  75249. * You can use it to speed the comparison between two versions of the same matrix.
  75250. */
  75251. updateFlag: number;
  75252. private readonly _m;
  75253. /**
  75254. * Gets the internal data of the matrix
  75255. */
  75256. get m(): DeepImmutable<Float32Array>;
  75257. /** @hidden */
  75258. _markAsUpdated(): void;
  75259. /** @hidden */
  75260. private _updateIdentityStatus;
  75261. /**
  75262. * Creates an empty matrix (filled with zeros)
  75263. */
  75264. constructor();
  75265. /**
  75266. * Check if the current matrix is identity
  75267. * @returns true is the matrix is the identity matrix
  75268. */
  75269. isIdentity(): boolean;
  75270. /**
  75271. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  75272. * @returns true is the matrix is the identity matrix
  75273. */
  75274. isIdentityAs3x2(): boolean;
  75275. /**
  75276. * Gets the determinant of the matrix
  75277. * @returns the matrix determinant
  75278. */
  75279. determinant(): number;
  75280. /**
  75281. * Returns the matrix as a Float32Array
  75282. * @returns the matrix underlying array
  75283. */
  75284. toArray(): DeepImmutable<Float32Array>;
  75285. /**
  75286. * Returns the matrix as a Float32Array
  75287. * @returns the matrix underlying array.
  75288. */
  75289. asArray(): DeepImmutable<Float32Array>;
  75290. /**
  75291. * Inverts the current matrix in place
  75292. * @returns the current inverted matrix
  75293. */
  75294. invert(): Matrix;
  75295. /**
  75296. * Sets all the matrix elements to zero
  75297. * @returns the current matrix
  75298. */
  75299. reset(): Matrix;
  75300. /**
  75301. * Adds the current matrix with a second one
  75302. * @param other defines the matrix to add
  75303. * @returns a new matrix as the addition of the current matrix and the given one
  75304. */
  75305. add(other: DeepImmutable<Matrix>): Matrix;
  75306. /**
  75307. * Sets the given matrix "result" to the addition of the current matrix and the given one
  75308. * @param other defines the matrix to add
  75309. * @param result defines the target matrix
  75310. * @returns the current matrix
  75311. */
  75312. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  75313. /**
  75314. * Adds in place the given matrix to the current matrix
  75315. * @param other defines the second operand
  75316. * @returns the current updated matrix
  75317. */
  75318. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  75319. /**
  75320. * Sets the given matrix to the current inverted Matrix
  75321. * @param other defines the target matrix
  75322. * @returns the unmodified current matrix
  75323. */
  75324. invertToRef(other: Matrix): Matrix;
  75325. /**
  75326. * add a value at the specified position in the current Matrix
  75327. * @param index the index of the value within the matrix. between 0 and 15.
  75328. * @param value the value to be added
  75329. * @returns the current updated matrix
  75330. */
  75331. addAtIndex(index: number, value: number): Matrix;
  75332. /**
  75333. * mutiply the specified position in the current Matrix by a value
  75334. * @param index the index of the value within the matrix. between 0 and 15.
  75335. * @param value the value to be added
  75336. * @returns the current updated matrix
  75337. */
  75338. multiplyAtIndex(index: number, value: number): Matrix;
  75339. /**
  75340. * Inserts the translation vector (using 3 floats) in the current matrix
  75341. * @param x defines the 1st component of the translation
  75342. * @param y defines the 2nd component of the translation
  75343. * @param z defines the 3rd component of the translation
  75344. * @returns the current updated matrix
  75345. */
  75346. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  75347. /**
  75348. * Adds the translation vector (using 3 floats) in the current matrix
  75349. * @param x defines the 1st component of the translation
  75350. * @param y defines the 2nd component of the translation
  75351. * @param z defines the 3rd component of the translation
  75352. * @returns the current updated matrix
  75353. */
  75354. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  75355. /**
  75356. * Inserts the translation vector in the current matrix
  75357. * @param vector3 defines the translation to insert
  75358. * @returns the current updated matrix
  75359. */
  75360. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  75361. /**
  75362. * Gets the translation value of the current matrix
  75363. * @returns a new Vector3 as the extracted translation from the matrix
  75364. */
  75365. getTranslation(): Vector3;
  75366. /**
  75367. * Fill a Vector3 with the extracted translation from the matrix
  75368. * @param result defines the Vector3 where to store the translation
  75369. * @returns the current matrix
  75370. */
  75371. getTranslationToRef(result: Vector3): Matrix;
  75372. /**
  75373. * Remove rotation and scaling part from the matrix
  75374. * @returns the updated matrix
  75375. */
  75376. removeRotationAndScaling(): Matrix;
  75377. /**
  75378. * Multiply two matrices
  75379. * @param other defines the second operand
  75380. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  75381. */
  75382. multiply(other: DeepImmutable<Matrix>): Matrix;
  75383. /**
  75384. * Copy the current matrix from the given one
  75385. * @param other defines the source matrix
  75386. * @returns the current updated matrix
  75387. */
  75388. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  75389. /**
  75390. * Populates the given array from the starting index with the current matrix values
  75391. * @param array defines the target array
  75392. * @param offset defines the offset in the target array where to start storing values
  75393. * @returns the current matrix
  75394. */
  75395. copyToArray(array: Float32Array, offset?: number): Matrix;
  75396. /**
  75397. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  75398. * @param other defines the second operand
  75399. * @param result defines the matrix where to store the multiplication
  75400. * @returns the current matrix
  75401. */
  75402. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  75403. /**
  75404. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  75405. * @param other defines the second operand
  75406. * @param result defines the array where to store the multiplication
  75407. * @param offset defines the offset in the target array where to start storing values
  75408. * @returns the current matrix
  75409. */
  75410. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  75411. /**
  75412. * Check equality between this matrix and a second one
  75413. * @param value defines the second matrix to compare
  75414. * @returns true is the current matrix and the given one values are strictly equal
  75415. */
  75416. equals(value: DeepImmutable<Matrix>): boolean;
  75417. /**
  75418. * Clone the current matrix
  75419. * @returns a new matrix from the current matrix
  75420. */
  75421. clone(): Matrix;
  75422. /**
  75423. * Returns the name of the current matrix class
  75424. * @returns the string "Matrix"
  75425. */
  75426. getClassName(): string;
  75427. /**
  75428. * Gets the hash code of the current matrix
  75429. * @returns the hash code
  75430. */
  75431. getHashCode(): number;
  75432. /**
  75433. * Decomposes the current Matrix into a translation, rotation and scaling components
  75434. * @param scale defines the scale vector3 given as a reference to update
  75435. * @param rotation defines the rotation quaternion given as a reference to update
  75436. * @param translation defines the translation vector3 given as a reference to update
  75437. * @returns true if operation was successful
  75438. */
  75439. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  75440. /**
  75441. * Gets specific row of the matrix
  75442. * @param index defines the number of the row to get
  75443. * @returns the index-th row of the current matrix as a new Vector4
  75444. */
  75445. getRow(index: number): Nullable<Vector4>;
  75446. /**
  75447. * Sets the index-th row of the current matrix to the vector4 values
  75448. * @param index defines the number of the row to set
  75449. * @param row defines the target vector4
  75450. * @returns the updated current matrix
  75451. */
  75452. setRow(index: number, row: Vector4): Matrix;
  75453. /**
  75454. * Compute the transpose of the matrix
  75455. * @returns the new transposed matrix
  75456. */
  75457. transpose(): Matrix;
  75458. /**
  75459. * Compute the transpose of the matrix and store it in a given matrix
  75460. * @param result defines the target matrix
  75461. * @returns the current matrix
  75462. */
  75463. transposeToRef(result: Matrix): Matrix;
  75464. /**
  75465. * Sets the index-th row of the current matrix with the given 4 x float values
  75466. * @param index defines the row index
  75467. * @param x defines the x component to set
  75468. * @param y defines the y component to set
  75469. * @param z defines the z component to set
  75470. * @param w defines the w component to set
  75471. * @returns the updated current matrix
  75472. */
  75473. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  75474. /**
  75475. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  75476. * @param scale defines the scale factor
  75477. * @returns a new matrix
  75478. */
  75479. scale(scale: number): Matrix;
  75480. /**
  75481. * Scale the current matrix values by a factor to a given result matrix
  75482. * @param scale defines the scale factor
  75483. * @param result defines the matrix to store the result
  75484. * @returns the current matrix
  75485. */
  75486. scaleToRef(scale: number, result: Matrix): Matrix;
  75487. /**
  75488. * Scale the current matrix values by a factor and add the result to a given matrix
  75489. * @param scale defines the scale factor
  75490. * @param result defines the Matrix to store the result
  75491. * @returns the current matrix
  75492. */
  75493. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  75494. /**
  75495. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  75496. * @param ref matrix to store the result
  75497. */
  75498. toNormalMatrix(ref: Matrix): void;
  75499. /**
  75500. * Gets only rotation part of the current matrix
  75501. * @returns a new matrix sets to the extracted rotation matrix from the current one
  75502. */
  75503. getRotationMatrix(): Matrix;
  75504. /**
  75505. * Extracts the rotation matrix from the current one and sets it as the given "result"
  75506. * @param result defines the target matrix to store data to
  75507. * @returns the current matrix
  75508. */
  75509. getRotationMatrixToRef(result: Matrix): Matrix;
  75510. /**
  75511. * Toggles model matrix from being right handed to left handed in place and vice versa
  75512. */
  75513. toggleModelMatrixHandInPlace(): void;
  75514. /**
  75515. * Toggles projection matrix from being right handed to left handed in place and vice versa
  75516. */
  75517. toggleProjectionMatrixHandInPlace(): void;
  75518. /**
  75519. * Creates a matrix from an array
  75520. * @param array defines the source array
  75521. * @param offset defines an offset in the source array
  75522. * @returns a new Matrix set from the starting index of the given array
  75523. */
  75524. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  75525. /**
  75526. * Copy the content of an array into a given matrix
  75527. * @param array defines the source array
  75528. * @param offset defines an offset in the source array
  75529. * @param result defines the target matrix
  75530. */
  75531. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  75532. /**
  75533. * Stores an array into a matrix after having multiplied each component by a given factor
  75534. * @param array defines the source array
  75535. * @param offset defines the offset in the source array
  75536. * @param scale defines the scaling factor
  75537. * @param result defines the target matrix
  75538. */
  75539. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  75540. /**
  75541. * Gets an identity matrix that must not be updated
  75542. */
  75543. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  75544. /**
  75545. * Stores a list of values (16) inside a given matrix
  75546. * @param initialM11 defines 1st value of 1st row
  75547. * @param initialM12 defines 2nd value of 1st row
  75548. * @param initialM13 defines 3rd value of 1st row
  75549. * @param initialM14 defines 4th value of 1st row
  75550. * @param initialM21 defines 1st value of 2nd row
  75551. * @param initialM22 defines 2nd value of 2nd row
  75552. * @param initialM23 defines 3rd value of 2nd row
  75553. * @param initialM24 defines 4th value of 2nd row
  75554. * @param initialM31 defines 1st value of 3rd row
  75555. * @param initialM32 defines 2nd value of 3rd row
  75556. * @param initialM33 defines 3rd value of 3rd row
  75557. * @param initialM34 defines 4th value of 3rd row
  75558. * @param initialM41 defines 1st value of 4th row
  75559. * @param initialM42 defines 2nd value of 4th row
  75560. * @param initialM43 defines 3rd value of 4th row
  75561. * @param initialM44 defines 4th value of 4th row
  75562. * @param result defines the target matrix
  75563. */
  75564. 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;
  75565. /**
  75566. * Creates new matrix from a list of values (16)
  75567. * @param initialM11 defines 1st value of 1st row
  75568. * @param initialM12 defines 2nd value of 1st row
  75569. * @param initialM13 defines 3rd value of 1st row
  75570. * @param initialM14 defines 4th value of 1st row
  75571. * @param initialM21 defines 1st value of 2nd row
  75572. * @param initialM22 defines 2nd value of 2nd row
  75573. * @param initialM23 defines 3rd value of 2nd row
  75574. * @param initialM24 defines 4th value of 2nd row
  75575. * @param initialM31 defines 1st value of 3rd row
  75576. * @param initialM32 defines 2nd value of 3rd row
  75577. * @param initialM33 defines 3rd value of 3rd row
  75578. * @param initialM34 defines 4th value of 3rd row
  75579. * @param initialM41 defines 1st value of 4th row
  75580. * @param initialM42 defines 2nd value of 4th row
  75581. * @param initialM43 defines 3rd value of 4th row
  75582. * @param initialM44 defines 4th value of 4th row
  75583. * @returns the new matrix
  75584. */
  75585. 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;
  75586. /**
  75587. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75588. * @param scale defines the scale vector3
  75589. * @param rotation defines the rotation quaternion
  75590. * @param translation defines the translation vector3
  75591. * @returns a new matrix
  75592. */
  75593. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  75594. /**
  75595. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  75596. * @param scale defines the scale vector3
  75597. * @param rotation defines the rotation quaternion
  75598. * @param translation defines the translation vector3
  75599. * @param result defines the target matrix
  75600. */
  75601. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  75602. /**
  75603. * Creates a new identity matrix
  75604. * @returns a new identity matrix
  75605. */
  75606. static Identity(): Matrix;
  75607. /**
  75608. * Creates a new identity matrix and stores the result in a given matrix
  75609. * @param result defines the target matrix
  75610. */
  75611. static IdentityToRef(result: Matrix): void;
  75612. /**
  75613. * Creates a new zero matrix
  75614. * @returns a new zero matrix
  75615. */
  75616. static Zero(): Matrix;
  75617. /**
  75618. * Creates a new rotation matrix for "angle" radians around the X axis
  75619. * @param angle defines the angle (in radians) to use
  75620. * @return the new matrix
  75621. */
  75622. static RotationX(angle: number): Matrix;
  75623. /**
  75624. * Creates a new matrix as the invert of a given matrix
  75625. * @param source defines the source matrix
  75626. * @returns the new matrix
  75627. */
  75628. static Invert(source: DeepImmutable<Matrix>): Matrix;
  75629. /**
  75630. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  75631. * @param angle defines the angle (in radians) to use
  75632. * @param result defines the target matrix
  75633. */
  75634. static RotationXToRef(angle: number, result: Matrix): void;
  75635. /**
  75636. * Creates a new rotation matrix for "angle" radians around the Y axis
  75637. * @param angle defines the angle (in radians) to use
  75638. * @return the new matrix
  75639. */
  75640. static RotationY(angle: number): Matrix;
  75641. /**
  75642. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  75643. * @param angle defines the angle (in radians) to use
  75644. * @param result defines the target matrix
  75645. */
  75646. static RotationYToRef(angle: number, result: Matrix): void;
  75647. /**
  75648. * Creates a new rotation matrix for "angle" radians around the Z axis
  75649. * @param angle defines the angle (in radians) to use
  75650. * @return the new matrix
  75651. */
  75652. static RotationZ(angle: number): Matrix;
  75653. /**
  75654. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  75655. * @param angle defines the angle (in radians) to use
  75656. * @param result defines the target matrix
  75657. */
  75658. static RotationZToRef(angle: number, result: Matrix): void;
  75659. /**
  75660. * Creates a new rotation matrix for "angle" radians around the given axis
  75661. * @param axis defines the axis to use
  75662. * @param angle defines the angle (in radians) to use
  75663. * @return the new matrix
  75664. */
  75665. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  75666. /**
  75667. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  75668. * @param axis defines the axis to use
  75669. * @param angle defines the angle (in radians) to use
  75670. * @param result defines the target matrix
  75671. */
  75672. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  75673. /**
  75674. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  75675. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  75676. * @param from defines the vector to align
  75677. * @param to defines the vector to align to
  75678. * @param result defines the target matrix
  75679. */
  75680. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  75681. /**
  75682. * Creates a rotation matrix
  75683. * @param yaw defines the yaw angle in radians (Y axis)
  75684. * @param pitch defines the pitch angle in radians (X axis)
  75685. * @param roll defines the roll angle in radians (X axis)
  75686. * @returns the new rotation matrix
  75687. */
  75688. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  75689. /**
  75690. * Creates a rotation matrix and stores it in a given matrix
  75691. * @param yaw defines the yaw angle in radians (Y axis)
  75692. * @param pitch defines the pitch angle in radians (X axis)
  75693. * @param roll defines the roll angle in radians (X axis)
  75694. * @param result defines the target matrix
  75695. */
  75696. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  75697. /**
  75698. * Creates a scaling matrix
  75699. * @param x defines the scale factor on X axis
  75700. * @param y defines the scale factor on Y axis
  75701. * @param z defines the scale factor on Z axis
  75702. * @returns the new matrix
  75703. */
  75704. static Scaling(x: number, y: number, z: number): Matrix;
  75705. /**
  75706. * Creates a scaling matrix and stores it in a given matrix
  75707. * @param x defines the scale factor on X axis
  75708. * @param y defines the scale factor on Y axis
  75709. * @param z defines the scale factor on Z axis
  75710. * @param result defines the target matrix
  75711. */
  75712. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  75713. /**
  75714. * Creates a translation matrix
  75715. * @param x defines the translation on X axis
  75716. * @param y defines the translation on Y axis
  75717. * @param z defines the translationon Z axis
  75718. * @returns the new matrix
  75719. */
  75720. static Translation(x: number, y: number, z: number): Matrix;
  75721. /**
  75722. * Creates a translation matrix and stores it in a given matrix
  75723. * @param x defines the translation on X axis
  75724. * @param y defines the translation on Y axis
  75725. * @param z defines the translationon Z axis
  75726. * @param result defines the target matrix
  75727. */
  75728. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  75729. /**
  75730. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75731. * @param startValue defines the start value
  75732. * @param endValue defines the end value
  75733. * @param gradient defines the gradient factor
  75734. * @returns the new matrix
  75735. */
  75736. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  75737. /**
  75738. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  75739. * @param startValue defines the start value
  75740. * @param endValue defines the end value
  75741. * @param gradient defines the gradient factor
  75742. * @param result defines the Matrix object where to store data
  75743. */
  75744. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  75745. /**
  75746. * Builds a new matrix whose values are computed by:
  75747. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75748. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75749. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75750. * @param startValue defines the first matrix
  75751. * @param endValue defines the second matrix
  75752. * @param gradient defines the gradient between the two matrices
  75753. * @returns the new matrix
  75754. */
  75755. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  75756. /**
  75757. * Update a matrix to values which are computed by:
  75758. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  75759. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  75760. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  75761. * @param startValue defines the first matrix
  75762. * @param endValue defines the second matrix
  75763. * @param gradient defines the gradient between the two matrices
  75764. * @param result defines the target matrix
  75765. */
  75766. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  75767. /**
  75768. * 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"
  75769. * This function works in left handed mode
  75770. * @param eye defines the final position of the entity
  75771. * @param target defines where the entity should look at
  75772. * @param up defines the up vector for the entity
  75773. * @returns the new matrix
  75774. */
  75775. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75776. /**
  75777. * 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".
  75778. * This function works in left handed mode
  75779. * @param eye defines the final position of the entity
  75780. * @param target defines where the entity should look at
  75781. * @param up defines the up vector for the entity
  75782. * @param result defines the target matrix
  75783. */
  75784. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75785. /**
  75786. * 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"
  75787. * This function works in right handed mode
  75788. * @param eye defines the final position of the entity
  75789. * @param target defines where the entity should look at
  75790. * @param up defines the up vector for the entity
  75791. * @returns the new matrix
  75792. */
  75793. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  75794. /**
  75795. * 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".
  75796. * This function works in right handed mode
  75797. * @param eye defines the final position of the entity
  75798. * @param target defines where the entity should look at
  75799. * @param up defines the up vector for the entity
  75800. * @param result defines the target matrix
  75801. */
  75802. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  75803. /**
  75804. * Create a left-handed orthographic projection matrix
  75805. * @param width defines the viewport width
  75806. * @param height defines the viewport height
  75807. * @param znear defines the near clip plane
  75808. * @param zfar defines the far clip plane
  75809. * @returns a new matrix as a left-handed orthographic projection matrix
  75810. */
  75811. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75812. /**
  75813. * Store a left-handed orthographic projection to a given matrix
  75814. * @param width defines the viewport width
  75815. * @param height defines the viewport height
  75816. * @param znear defines the near clip plane
  75817. * @param zfar defines the far clip plane
  75818. * @param result defines the target matrix
  75819. */
  75820. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  75821. /**
  75822. * Create a left-handed orthographic projection matrix
  75823. * @param left defines the viewport left coordinate
  75824. * @param right defines the viewport right coordinate
  75825. * @param bottom defines the viewport bottom coordinate
  75826. * @param top defines the viewport top coordinate
  75827. * @param znear defines the near clip plane
  75828. * @param zfar defines the far clip plane
  75829. * @returns a new matrix as a left-handed orthographic projection matrix
  75830. */
  75831. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75832. /**
  75833. * Stores a left-handed orthographic projection into a given matrix
  75834. * @param left defines the viewport left coordinate
  75835. * @param right defines the viewport right coordinate
  75836. * @param bottom defines the viewport bottom coordinate
  75837. * @param top defines the viewport top coordinate
  75838. * @param znear defines the near clip plane
  75839. * @param zfar defines the far clip plane
  75840. * @param result defines the target matrix
  75841. */
  75842. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75843. /**
  75844. * Creates a right-handed orthographic projection matrix
  75845. * @param left defines the viewport left coordinate
  75846. * @param right defines the viewport right coordinate
  75847. * @param bottom defines the viewport bottom coordinate
  75848. * @param top defines the viewport top coordinate
  75849. * @param znear defines the near clip plane
  75850. * @param zfar defines the far clip plane
  75851. * @returns a new matrix as a right-handed orthographic projection matrix
  75852. */
  75853. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  75854. /**
  75855. * Stores a right-handed orthographic projection into a given matrix
  75856. * @param left defines the viewport left coordinate
  75857. * @param right defines the viewport right coordinate
  75858. * @param bottom defines the viewport bottom coordinate
  75859. * @param top defines the viewport top coordinate
  75860. * @param znear defines the near clip plane
  75861. * @param zfar defines the far clip plane
  75862. * @param result defines the target matrix
  75863. */
  75864. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  75865. /**
  75866. * Creates a left-handed perspective projection matrix
  75867. * @param width defines the viewport width
  75868. * @param height defines the viewport height
  75869. * @param znear defines the near clip plane
  75870. * @param zfar defines the far clip plane
  75871. * @returns a new matrix as a left-handed perspective projection matrix
  75872. */
  75873. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  75874. /**
  75875. * Creates a left-handed perspective projection matrix
  75876. * @param fov defines the horizontal field of view
  75877. * @param aspect defines the aspect ratio
  75878. * @param znear defines the near clip plane
  75879. * @param zfar defines the far clip plane
  75880. * @returns a new matrix as a left-handed perspective projection matrix
  75881. */
  75882. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75883. /**
  75884. * Stores a left-handed perspective projection into a given matrix
  75885. * @param fov defines the horizontal field of view
  75886. * @param aspect defines the aspect ratio
  75887. * @param znear defines the near clip plane
  75888. * @param zfar defines the far clip plane
  75889. * @param result defines the target matrix
  75890. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75891. */
  75892. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75893. /**
  75894. * Stores a left-handed perspective projection into a given matrix with depth reversed
  75895. * @param fov defines the horizontal field of view
  75896. * @param aspect defines the aspect ratio
  75897. * @param znear defines the near clip plane
  75898. * @param zfar not used as infinity is used as far clip
  75899. * @param result defines the target matrix
  75900. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75901. */
  75902. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75903. /**
  75904. * Creates a right-handed perspective projection matrix
  75905. * @param fov defines the horizontal field of view
  75906. * @param aspect defines the aspect ratio
  75907. * @param znear defines the near clip plane
  75908. * @param zfar defines the far clip plane
  75909. * @returns a new matrix as a right-handed perspective projection matrix
  75910. */
  75911. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  75912. /**
  75913. * Stores a right-handed perspective projection into a given matrix
  75914. * @param fov defines the horizontal field of view
  75915. * @param aspect defines the aspect ratio
  75916. * @param znear defines the near clip plane
  75917. * @param zfar defines the far clip plane
  75918. * @param result defines the target matrix
  75919. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75920. */
  75921. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75922. /**
  75923. * Stores a right-handed perspective projection into a given matrix
  75924. * @param fov defines the horizontal field of view
  75925. * @param aspect defines the aspect ratio
  75926. * @param znear defines the near clip plane
  75927. * @param zfar not used as infinity is used as far clip
  75928. * @param result defines the target matrix
  75929. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  75930. */
  75931. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  75932. /**
  75933. * Stores a perspective projection for WebVR info a given matrix
  75934. * @param fov defines the field of view
  75935. * @param znear defines the near clip plane
  75936. * @param zfar defines the far clip plane
  75937. * @param result defines the target matrix
  75938. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  75939. */
  75940. static PerspectiveFovWebVRToRef(fov: {
  75941. upDegrees: number;
  75942. downDegrees: number;
  75943. leftDegrees: number;
  75944. rightDegrees: number;
  75945. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  75946. /**
  75947. * Computes a complete transformation matrix
  75948. * @param viewport defines the viewport to use
  75949. * @param world defines the world matrix
  75950. * @param view defines the view matrix
  75951. * @param projection defines the projection matrix
  75952. * @param zmin defines the near clip plane
  75953. * @param zmax defines the far clip plane
  75954. * @returns the transformation matrix
  75955. */
  75956. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  75957. /**
  75958. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  75959. * @param matrix defines the matrix to use
  75960. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  75961. */
  75962. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  75963. /**
  75964. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  75965. * @param matrix defines the matrix to use
  75966. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  75967. */
  75968. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  75969. /**
  75970. * Compute the transpose of a given matrix
  75971. * @param matrix defines the matrix to transpose
  75972. * @returns the new matrix
  75973. */
  75974. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  75975. /**
  75976. * Compute the transpose of a matrix and store it in a target matrix
  75977. * @param matrix defines the matrix to transpose
  75978. * @param result defines the target matrix
  75979. */
  75980. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  75981. /**
  75982. * Computes a reflection matrix from a plane
  75983. * @param plane defines the reflection plane
  75984. * @returns a new matrix
  75985. */
  75986. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  75987. /**
  75988. * Computes a reflection matrix from a plane
  75989. * @param plane defines the reflection plane
  75990. * @param result defines the target matrix
  75991. */
  75992. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  75993. /**
  75994. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  75995. * @param xaxis defines the value of the 1st axis
  75996. * @param yaxis defines the value of the 2nd axis
  75997. * @param zaxis defines the value of the 3rd axis
  75998. * @param result defines the target matrix
  75999. */
  76000. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  76001. /**
  76002. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  76003. * @param quat defines the quaternion to use
  76004. * @param result defines the target matrix
  76005. */
  76006. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  76007. }
  76008. /**
  76009. * @hidden
  76010. */
  76011. export class TmpVectors {
  76012. static Vector2: Vector2[];
  76013. static Vector3: Vector3[];
  76014. static Vector4: Vector4[];
  76015. static Quaternion: Quaternion[];
  76016. static Matrix: Matrix[];
  76017. }
  76018. }
  76019. declare module BABYLON {
  76020. /**
  76021. * Defines potential orientation for back face culling
  76022. */
  76023. export enum Orientation {
  76024. /**
  76025. * Clockwise
  76026. */
  76027. CW = 0,
  76028. /** Counter clockwise */
  76029. CCW = 1
  76030. }
  76031. /** Class used to represent a Bezier curve */
  76032. export class BezierCurve {
  76033. /**
  76034. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  76035. * @param t defines the time
  76036. * @param x1 defines the left coordinate on X axis
  76037. * @param y1 defines the left coordinate on Y axis
  76038. * @param x2 defines the right coordinate on X axis
  76039. * @param y2 defines the right coordinate on Y axis
  76040. * @returns the interpolated value
  76041. */
  76042. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  76043. }
  76044. /**
  76045. * Defines angle representation
  76046. */
  76047. export class Angle {
  76048. private _radians;
  76049. /**
  76050. * Creates an Angle object of "radians" radians (float).
  76051. * @param radians the angle in radians
  76052. */
  76053. constructor(radians: number);
  76054. /**
  76055. * Get value in degrees
  76056. * @returns the Angle value in degrees (float)
  76057. */
  76058. degrees(): number;
  76059. /**
  76060. * Get value in radians
  76061. * @returns the Angle value in radians (float)
  76062. */
  76063. radians(): number;
  76064. /**
  76065. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  76066. * @param a defines first vector
  76067. * @param b defines second vector
  76068. * @returns a new Angle
  76069. */
  76070. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  76071. /**
  76072. * Gets a new Angle object from the given float in radians
  76073. * @param radians defines the angle value in radians
  76074. * @returns a new Angle
  76075. */
  76076. static FromRadians(radians: number): Angle;
  76077. /**
  76078. * Gets a new Angle object from the given float in degrees
  76079. * @param degrees defines the angle value in degrees
  76080. * @returns a new Angle
  76081. */
  76082. static FromDegrees(degrees: number): Angle;
  76083. }
  76084. /**
  76085. * This represents an arc in a 2d space.
  76086. */
  76087. export class Arc2 {
  76088. /** Defines the start point of the arc */
  76089. startPoint: Vector2;
  76090. /** Defines the mid point of the arc */
  76091. midPoint: Vector2;
  76092. /** Defines the end point of the arc */
  76093. endPoint: Vector2;
  76094. /**
  76095. * Defines the center point of the arc.
  76096. */
  76097. centerPoint: Vector2;
  76098. /**
  76099. * Defines the radius of the arc.
  76100. */
  76101. radius: number;
  76102. /**
  76103. * Defines the angle of the arc (from mid point to end point).
  76104. */
  76105. angle: Angle;
  76106. /**
  76107. * Defines the start angle of the arc (from start point to middle point).
  76108. */
  76109. startAngle: Angle;
  76110. /**
  76111. * Defines the orientation of the arc (clock wise/counter clock wise).
  76112. */
  76113. orientation: Orientation;
  76114. /**
  76115. * Creates an Arc object from the three given points : start, middle and end.
  76116. * @param startPoint Defines the start point of the arc
  76117. * @param midPoint Defines the midlle point of the arc
  76118. * @param endPoint Defines the end point of the arc
  76119. */
  76120. constructor(
  76121. /** Defines the start point of the arc */
  76122. startPoint: Vector2,
  76123. /** Defines the mid point of the arc */
  76124. midPoint: Vector2,
  76125. /** Defines the end point of the arc */
  76126. endPoint: Vector2);
  76127. }
  76128. /**
  76129. * Represents a 2D path made up of multiple 2D points
  76130. */
  76131. export class Path2 {
  76132. private _points;
  76133. private _length;
  76134. /**
  76135. * If the path start and end point are the same
  76136. */
  76137. closed: boolean;
  76138. /**
  76139. * Creates a Path2 object from the starting 2D coordinates x and y.
  76140. * @param x the starting points x value
  76141. * @param y the starting points y value
  76142. */
  76143. constructor(x: number, y: number);
  76144. /**
  76145. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  76146. * @param x the added points x value
  76147. * @param y the added points y value
  76148. * @returns the updated Path2.
  76149. */
  76150. addLineTo(x: number, y: number): Path2;
  76151. /**
  76152. * 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.
  76153. * @param midX middle point x value
  76154. * @param midY middle point y value
  76155. * @param endX end point x value
  76156. * @param endY end point y value
  76157. * @param numberOfSegments (default: 36)
  76158. * @returns the updated Path2.
  76159. */
  76160. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  76161. /**
  76162. * Closes the Path2.
  76163. * @returns the Path2.
  76164. */
  76165. close(): Path2;
  76166. /**
  76167. * Gets the sum of the distance between each sequential point in the path
  76168. * @returns the Path2 total length (float).
  76169. */
  76170. length(): number;
  76171. /**
  76172. * Gets the points which construct the path
  76173. * @returns the Path2 internal array of points.
  76174. */
  76175. getPoints(): Vector2[];
  76176. /**
  76177. * Retreives the point at the distance aways from the starting point
  76178. * @param normalizedLengthPosition the length along the path to retreive the point from
  76179. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  76180. */
  76181. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  76182. /**
  76183. * Creates a new path starting from an x and y position
  76184. * @param x starting x value
  76185. * @param y starting y value
  76186. * @returns a new Path2 starting at the coordinates (x, y).
  76187. */
  76188. static StartingAt(x: number, y: number): Path2;
  76189. }
  76190. /**
  76191. * Represents a 3D path made up of multiple 3D points
  76192. */
  76193. export class Path3D {
  76194. /**
  76195. * an array of Vector3, the curve axis of the Path3D
  76196. */
  76197. path: Vector3[];
  76198. private _curve;
  76199. private _distances;
  76200. private _tangents;
  76201. private _normals;
  76202. private _binormals;
  76203. private _raw;
  76204. private _alignTangentsWithPath;
  76205. private readonly _pointAtData;
  76206. /**
  76207. * new Path3D(path, normal, raw)
  76208. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  76209. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  76210. * @param path an array of Vector3, the curve axis of the Path3D
  76211. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  76212. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  76213. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  76214. */
  76215. constructor(
  76216. /**
  76217. * an array of Vector3, the curve axis of the Path3D
  76218. */
  76219. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  76220. /**
  76221. * Returns the Path3D array of successive Vector3 designing its curve.
  76222. * @returns the Path3D array of successive Vector3 designing its curve.
  76223. */
  76224. getCurve(): Vector3[];
  76225. /**
  76226. * Returns the Path3D array of successive Vector3 designing its curve.
  76227. * @returns the Path3D array of successive Vector3 designing its curve.
  76228. */
  76229. getPoints(): Vector3[];
  76230. /**
  76231. * @returns the computed length (float) of the path.
  76232. */
  76233. length(): number;
  76234. /**
  76235. * Returns an array populated with tangent vectors on each Path3D curve point.
  76236. * @returns an array populated with tangent vectors on each Path3D curve point.
  76237. */
  76238. getTangents(): Vector3[];
  76239. /**
  76240. * Returns an array populated with normal vectors on each Path3D curve point.
  76241. * @returns an array populated with normal vectors on each Path3D curve point.
  76242. */
  76243. getNormals(): Vector3[];
  76244. /**
  76245. * Returns an array populated with binormal vectors on each Path3D curve point.
  76246. * @returns an array populated with binormal vectors on each Path3D curve point.
  76247. */
  76248. getBinormals(): Vector3[];
  76249. /**
  76250. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  76251. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  76252. */
  76253. getDistances(): number[];
  76254. /**
  76255. * Returns an interpolated point along this path
  76256. * @param position the position of the point along this path, from 0.0 to 1.0
  76257. * @returns a new Vector3 as the point
  76258. */
  76259. getPointAt(position: number): Vector3;
  76260. /**
  76261. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  76262. * @param position the position of the point along this path, from 0.0 to 1.0
  76263. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  76264. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  76265. */
  76266. getTangentAt(position: number, interpolated?: boolean): Vector3;
  76267. /**
  76268. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  76269. * @param position the position of the point along this path, from 0.0 to 1.0
  76270. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  76271. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  76272. */
  76273. getNormalAt(position: number, interpolated?: boolean): Vector3;
  76274. /**
  76275. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  76276. * @param position the position of the point along this path, from 0.0 to 1.0
  76277. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  76278. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  76279. */
  76280. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  76281. /**
  76282. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  76283. * @param position the position of the point along this path, from 0.0 to 1.0
  76284. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  76285. */
  76286. getDistanceAt(position: number): number;
  76287. /**
  76288. * Returns the array index of the previous point of an interpolated point along this path
  76289. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  76290. * @returns the array index
  76291. */
  76292. getPreviousPointIndexAt(position: number): number;
  76293. /**
  76294. * 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)
  76295. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  76296. * @returns the sub position
  76297. */
  76298. getSubPositionAt(position: number): number;
  76299. /**
  76300. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  76301. * @param target the vector of which to get the closest position to
  76302. * @returns the position of the closest virtual point on this path to the target vector
  76303. */
  76304. getClosestPositionTo(target: Vector3): number;
  76305. /**
  76306. * Returns a sub path (slice) of this path
  76307. * @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
  76308. * @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
  76309. * @returns a sub path (slice) of this path
  76310. */
  76311. slice(start?: number, end?: number): Path3D;
  76312. /**
  76313. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  76314. * @param path path which all values are copied into the curves points
  76315. * @param firstNormal which should be projected onto the curve
  76316. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  76317. * @returns the same object updated.
  76318. */
  76319. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  76320. private _compute;
  76321. private _getFirstNonNullVector;
  76322. private _getLastNonNullVector;
  76323. private _normalVector;
  76324. /**
  76325. * Updates the point at data for an interpolated point along this curve
  76326. * @param position the position of the point along this curve, from 0.0 to 1.0
  76327. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  76328. * @returns the (updated) point at data
  76329. */
  76330. private _updatePointAtData;
  76331. /**
  76332. * Updates the point at data from the specified parameters
  76333. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  76334. * @param point the interpolated point
  76335. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  76336. */
  76337. private _setPointAtData;
  76338. /**
  76339. * Updates the point at interpolation matrix for the tangents, normals and binormals
  76340. */
  76341. private _updateInterpolationMatrix;
  76342. }
  76343. /**
  76344. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  76345. * A Curve3 is designed from a series of successive Vector3.
  76346. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  76347. */
  76348. export class Curve3 {
  76349. private _points;
  76350. private _length;
  76351. /**
  76352. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  76353. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  76354. * @param v1 (Vector3) the control point
  76355. * @param v2 (Vector3) the end point of the Quadratic Bezier
  76356. * @param nbPoints (integer) the wanted number of points in the curve
  76357. * @returns the created Curve3
  76358. */
  76359. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  76360. /**
  76361. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  76362. * @param v0 (Vector3) the origin point of the Cubic Bezier
  76363. * @param v1 (Vector3) the first control point
  76364. * @param v2 (Vector3) the second control point
  76365. * @param v3 (Vector3) the end point of the Cubic Bezier
  76366. * @param nbPoints (integer) the wanted number of points in the curve
  76367. * @returns the created Curve3
  76368. */
  76369. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  76370. /**
  76371. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  76372. * @param p1 (Vector3) the origin point of the Hermite Spline
  76373. * @param t1 (Vector3) the tangent vector at the origin point
  76374. * @param p2 (Vector3) the end point of the Hermite Spline
  76375. * @param t2 (Vector3) the tangent vector at the end point
  76376. * @param nbPoints (integer) the wanted number of points in the curve
  76377. * @returns the created Curve3
  76378. */
  76379. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  76380. /**
  76381. * Returns a Curve3 object along a CatmullRom Spline curve :
  76382. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  76383. * @param nbPoints (integer) the wanted number of points between each curve control points
  76384. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  76385. * @returns the created Curve3
  76386. */
  76387. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  76388. /**
  76389. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  76390. * A Curve3 is designed from a series of successive Vector3.
  76391. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  76392. * @param points points which make up the curve
  76393. */
  76394. constructor(points: Vector3[]);
  76395. /**
  76396. * @returns the Curve3 stored array of successive Vector3
  76397. */
  76398. getPoints(): Vector3[];
  76399. /**
  76400. * @returns the computed length (float) of the curve.
  76401. */
  76402. length(): number;
  76403. /**
  76404. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  76405. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  76406. * curveA and curveB keep unchanged.
  76407. * @param curve the curve to continue from this curve
  76408. * @returns the newly constructed curve
  76409. */
  76410. continue(curve: DeepImmutable<Curve3>): Curve3;
  76411. private _computeLength;
  76412. }
  76413. }
  76414. declare module BABYLON {
  76415. /**
  76416. * This represents the main contract an easing function should follow.
  76417. * Easing functions are used throughout the animation system.
  76418. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76419. */
  76420. export interface IEasingFunction {
  76421. /**
  76422. * Given an input gradient between 0 and 1, this returns the corrseponding value
  76423. * of the easing function.
  76424. * The link below provides some of the most common examples of easing functions.
  76425. * @see https://easings.net/
  76426. * @param gradient Defines the value between 0 and 1 we want the easing value for
  76427. * @returns the corresponding value on the curve defined by the easing function
  76428. */
  76429. ease(gradient: number): number;
  76430. }
  76431. /**
  76432. * Base class used for every default easing function.
  76433. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76434. */
  76435. export class EasingFunction implements IEasingFunction {
  76436. /**
  76437. * Interpolation follows the mathematical formula associated with the easing function.
  76438. */
  76439. static readonly EASINGMODE_EASEIN: number;
  76440. /**
  76441. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  76442. */
  76443. static readonly EASINGMODE_EASEOUT: number;
  76444. /**
  76445. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  76446. */
  76447. static readonly EASINGMODE_EASEINOUT: number;
  76448. private _easingMode;
  76449. /**
  76450. * Sets the easing mode of the current function.
  76451. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  76452. */
  76453. setEasingMode(easingMode: number): void;
  76454. /**
  76455. * Gets the current easing mode.
  76456. * @returns the easing mode
  76457. */
  76458. getEasingMode(): number;
  76459. /**
  76460. * @hidden
  76461. */
  76462. easeInCore(gradient: number): number;
  76463. /**
  76464. * Given an input gradient between 0 and 1, this returns the corresponding value
  76465. * of the easing function.
  76466. * @param gradient Defines the value between 0 and 1 we want the easing value for
  76467. * @returns the corresponding value on the curve defined by the easing function
  76468. */
  76469. ease(gradient: number): number;
  76470. }
  76471. /**
  76472. * Easing function with a circle shape (see link below).
  76473. * @see https://easings.net/#easeInCirc
  76474. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76475. */
  76476. export class CircleEase extends EasingFunction implements IEasingFunction {
  76477. /** @hidden */
  76478. easeInCore(gradient: number): number;
  76479. }
  76480. /**
  76481. * Easing function with a ease back shape (see link below).
  76482. * @see https://easings.net/#easeInBack
  76483. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76484. */
  76485. export class BackEase extends EasingFunction implements IEasingFunction {
  76486. /** Defines the amplitude of the function */
  76487. amplitude: number;
  76488. /**
  76489. * Instantiates a back ease easing
  76490. * @see https://easings.net/#easeInBack
  76491. * @param amplitude Defines the amplitude of the function
  76492. */
  76493. constructor(
  76494. /** Defines the amplitude of the function */
  76495. amplitude?: number);
  76496. /** @hidden */
  76497. easeInCore(gradient: number): number;
  76498. }
  76499. /**
  76500. * Easing function with a bouncing shape (see link below).
  76501. * @see https://easings.net/#easeInBounce
  76502. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76503. */
  76504. export class BounceEase extends EasingFunction implements IEasingFunction {
  76505. /** Defines the number of bounces */
  76506. bounces: number;
  76507. /** Defines the amplitude of the bounce */
  76508. bounciness: number;
  76509. /**
  76510. * Instantiates a bounce easing
  76511. * @see https://easings.net/#easeInBounce
  76512. * @param bounces Defines the number of bounces
  76513. * @param bounciness Defines the amplitude of the bounce
  76514. */
  76515. constructor(
  76516. /** Defines the number of bounces */
  76517. bounces?: number,
  76518. /** Defines the amplitude of the bounce */
  76519. bounciness?: number);
  76520. /** @hidden */
  76521. easeInCore(gradient: number): number;
  76522. }
  76523. /**
  76524. * Easing function with a power of 3 shape (see link below).
  76525. * @see https://easings.net/#easeInCubic
  76526. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76527. */
  76528. export class CubicEase extends EasingFunction implements IEasingFunction {
  76529. /** @hidden */
  76530. easeInCore(gradient: number): number;
  76531. }
  76532. /**
  76533. * Easing function with an elastic shape (see link below).
  76534. * @see https://easings.net/#easeInElastic
  76535. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76536. */
  76537. export class ElasticEase extends EasingFunction implements IEasingFunction {
  76538. /** Defines the number of oscillations*/
  76539. oscillations: number;
  76540. /** Defines the amplitude of the oscillations*/
  76541. springiness: number;
  76542. /**
  76543. * Instantiates an elastic easing function
  76544. * @see https://easings.net/#easeInElastic
  76545. * @param oscillations Defines the number of oscillations
  76546. * @param springiness Defines the amplitude of the oscillations
  76547. */
  76548. constructor(
  76549. /** Defines the number of oscillations*/
  76550. oscillations?: number,
  76551. /** Defines the amplitude of the oscillations*/
  76552. springiness?: number);
  76553. /** @hidden */
  76554. easeInCore(gradient: number): number;
  76555. }
  76556. /**
  76557. * Easing function with an exponential shape (see link below).
  76558. * @see https://easings.net/#easeInExpo
  76559. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76560. */
  76561. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  76562. /** Defines the exponent of the function */
  76563. exponent: number;
  76564. /**
  76565. * Instantiates an exponential easing function
  76566. * @see https://easings.net/#easeInExpo
  76567. * @param exponent Defines the exponent of the function
  76568. */
  76569. constructor(
  76570. /** Defines the exponent of the function */
  76571. exponent?: number);
  76572. /** @hidden */
  76573. easeInCore(gradient: number): number;
  76574. }
  76575. /**
  76576. * Easing function with a power shape (see link below).
  76577. * @see https://easings.net/#easeInQuad
  76578. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76579. */
  76580. export class PowerEase extends EasingFunction implements IEasingFunction {
  76581. /** Defines the power of the function */
  76582. power: number;
  76583. /**
  76584. * Instantiates an power base easing function
  76585. * @see https://easings.net/#easeInQuad
  76586. * @param power Defines the power of the function
  76587. */
  76588. constructor(
  76589. /** Defines the power of the function */
  76590. power?: number);
  76591. /** @hidden */
  76592. easeInCore(gradient: number): number;
  76593. }
  76594. /**
  76595. * Easing function with a power of 2 shape (see link below).
  76596. * @see https://easings.net/#easeInQuad
  76597. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76598. */
  76599. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  76600. /** @hidden */
  76601. easeInCore(gradient: number): number;
  76602. }
  76603. /**
  76604. * Easing function with a power of 4 shape (see link below).
  76605. * @see https://easings.net/#easeInQuart
  76606. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76607. */
  76608. export class QuarticEase extends EasingFunction implements IEasingFunction {
  76609. /** @hidden */
  76610. easeInCore(gradient: number): number;
  76611. }
  76612. /**
  76613. * Easing function with a power of 5 shape (see link below).
  76614. * @see https://easings.net/#easeInQuint
  76615. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76616. */
  76617. export class QuinticEase extends EasingFunction implements IEasingFunction {
  76618. /** @hidden */
  76619. easeInCore(gradient: number): number;
  76620. }
  76621. /**
  76622. * Easing function with a sin shape (see link below).
  76623. * @see https://easings.net/#easeInSine
  76624. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76625. */
  76626. export class SineEase extends EasingFunction implements IEasingFunction {
  76627. /** @hidden */
  76628. easeInCore(gradient: number): number;
  76629. }
  76630. /**
  76631. * Easing function with a bezier shape (see link below).
  76632. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  76633. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  76634. */
  76635. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  76636. /** Defines the x component of the start tangent in the bezier curve */
  76637. x1: number;
  76638. /** Defines the y component of the start tangent in the bezier curve */
  76639. y1: number;
  76640. /** Defines the x component of the end tangent in the bezier curve */
  76641. x2: number;
  76642. /** Defines the y component of the end tangent in the bezier curve */
  76643. y2: number;
  76644. /**
  76645. * Instantiates a bezier function
  76646. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  76647. * @param x1 Defines the x component of the start tangent in the bezier curve
  76648. * @param y1 Defines the y component of the start tangent in the bezier curve
  76649. * @param x2 Defines the x component of the end tangent in the bezier curve
  76650. * @param y2 Defines the y component of the end tangent in the bezier curve
  76651. */
  76652. constructor(
  76653. /** Defines the x component of the start tangent in the bezier curve */
  76654. x1?: number,
  76655. /** Defines the y component of the start tangent in the bezier curve */
  76656. y1?: number,
  76657. /** Defines the x component of the end tangent in the bezier curve */
  76658. x2?: number,
  76659. /** Defines the y component of the end tangent in the bezier curve */
  76660. y2?: number);
  76661. /** @hidden */
  76662. easeInCore(gradient: number): number;
  76663. }
  76664. }
  76665. declare module BABYLON {
  76666. /**
  76667. * Class used to hold a RBG color
  76668. */
  76669. export class Color3 {
  76670. /**
  76671. * Defines the red component (between 0 and 1, default is 0)
  76672. */
  76673. r: number;
  76674. /**
  76675. * Defines the green component (between 0 and 1, default is 0)
  76676. */
  76677. g: number;
  76678. /**
  76679. * Defines the blue component (between 0 and 1, default is 0)
  76680. */
  76681. b: number;
  76682. /**
  76683. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  76684. * @param r defines the red component (between 0 and 1, default is 0)
  76685. * @param g defines the green component (between 0 and 1, default is 0)
  76686. * @param b defines the blue component (between 0 and 1, default is 0)
  76687. */
  76688. constructor(
  76689. /**
  76690. * Defines the red component (between 0 and 1, default is 0)
  76691. */
  76692. r?: number,
  76693. /**
  76694. * Defines the green component (between 0 and 1, default is 0)
  76695. */
  76696. g?: number,
  76697. /**
  76698. * Defines the blue component (between 0 and 1, default is 0)
  76699. */
  76700. b?: number);
  76701. /**
  76702. * Creates a string with the Color3 current values
  76703. * @returns the string representation of the Color3 object
  76704. */
  76705. toString(): string;
  76706. /**
  76707. * Returns the string "Color3"
  76708. * @returns "Color3"
  76709. */
  76710. getClassName(): string;
  76711. /**
  76712. * Compute the Color3 hash code
  76713. * @returns an unique number that can be used to hash Color3 objects
  76714. */
  76715. getHashCode(): number;
  76716. /**
  76717. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  76718. * @param array defines the array where to store the r,g,b components
  76719. * @param index defines an optional index in the target array to define where to start storing values
  76720. * @returns the current Color3 object
  76721. */
  76722. toArray(array: FloatArray, index?: number): Color3;
  76723. /**
  76724. * Returns a new Color4 object from the current Color3 and the given alpha
  76725. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  76726. * @returns a new Color4 object
  76727. */
  76728. toColor4(alpha?: number): Color4;
  76729. /**
  76730. * Returns a new array populated with 3 numeric elements : red, green and blue values
  76731. * @returns the new array
  76732. */
  76733. asArray(): number[];
  76734. /**
  76735. * Returns the luminance value
  76736. * @returns a float value
  76737. */
  76738. toLuminance(): number;
  76739. /**
  76740. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  76741. * @param otherColor defines the second operand
  76742. * @returns the new Color3 object
  76743. */
  76744. multiply(otherColor: DeepImmutable<Color3>): Color3;
  76745. /**
  76746. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  76747. * @param otherColor defines the second operand
  76748. * @param result defines the Color3 object where to store the result
  76749. * @returns the current Color3
  76750. */
  76751. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76752. /**
  76753. * Determines equality between Color3 objects
  76754. * @param otherColor defines the second operand
  76755. * @returns true if the rgb values are equal to the given ones
  76756. */
  76757. equals(otherColor: DeepImmutable<Color3>): boolean;
  76758. /**
  76759. * Determines equality between the current Color3 object and a set of r,b,g values
  76760. * @param r defines the red component to check
  76761. * @param g defines the green component to check
  76762. * @param b defines the blue component to check
  76763. * @returns true if the rgb values are equal to the given ones
  76764. */
  76765. equalsFloats(r: number, g: number, b: number): boolean;
  76766. /**
  76767. * Multiplies in place each rgb value by scale
  76768. * @param scale defines the scaling factor
  76769. * @returns the updated Color3
  76770. */
  76771. scale(scale: number): Color3;
  76772. /**
  76773. * Multiplies the rgb values by scale and stores the result into "result"
  76774. * @param scale defines the scaling factor
  76775. * @param result defines the Color3 object where to store the result
  76776. * @returns the unmodified current Color3
  76777. */
  76778. scaleToRef(scale: number, result: Color3): Color3;
  76779. /**
  76780. * Scale the current Color3 values by a factor and add the result to a given Color3
  76781. * @param scale defines the scale factor
  76782. * @param result defines color to store the result into
  76783. * @returns the unmodified current Color3
  76784. */
  76785. scaleAndAddToRef(scale: number, result: Color3): Color3;
  76786. /**
  76787. * Clamps the rgb values by the min and max values and stores the result into "result"
  76788. * @param min defines minimum clamping value (default is 0)
  76789. * @param max defines maximum clamping value (default is 1)
  76790. * @param result defines color to store the result into
  76791. * @returns the original Color3
  76792. */
  76793. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  76794. /**
  76795. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  76796. * @param otherColor defines the second operand
  76797. * @returns the new Color3
  76798. */
  76799. add(otherColor: DeepImmutable<Color3>): Color3;
  76800. /**
  76801. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  76802. * @param otherColor defines the second operand
  76803. * @param result defines Color3 object to store the result into
  76804. * @returns the unmodified current Color3
  76805. */
  76806. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76807. /**
  76808. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  76809. * @param otherColor defines the second operand
  76810. * @returns the new Color3
  76811. */
  76812. subtract(otherColor: DeepImmutable<Color3>): Color3;
  76813. /**
  76814. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  76815. * @param otherColor defines the second operand
  76816. * @param result defines Color3 object to store the result into
  76817. * @returns the unmodified current Color3
  76818. */
  76819. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  76820. /**
  76821. * Copy the current object
  76822. * @returns a new Color3 copied the current one
  76823. */
  76824. clone(): Color3;
  76825. /**
  76826. * Copies the rgb values from the source in the current Color3
  76827. * @param source defines the source Color3 object
  76828. * @returns the updated Color3 object
  76829. */
  76830. copyFrom(source: DeepImmutable<Color3>): Color3;
  76831. /**
  76832. * Updates the Color3 rgb values from the given floats
  76833. * @param r defines the red component to read from
  76834. * @param g defines the green component to read from
  76835. * @param b defines the blue component to read from
  76836. * @returns the current Color3 object
  76837. */
  76838. copyFromFloats(r: number, g: number, b: number): Color3;
  76839. /**
  76840. * Updates the Color3 rgb values from the given floats
  76841. * @param r defines the red component to read from
  76842. * @param g defines the green component to read from
  76843. * @param b defines the blue component to read from
  76844. * @returns the current Color3 object
  76845. */
  76846. set(r: number, g: number, b: number): Color3;
  76847. /**
  76848. * Compute the Color3 hexadecimal code as a string
  76849. * @returns a string containing the hexadecimal representation of the Color3 object
  76850. */
  76851. toHexString(): string;
  76852. /**
  76853. * Computes a new Color3 converted from the current one to linear space
  76854. * @returns a new Color3 object
  76855. */
  76856. toLinearSpace(): Color3;
  76857. /**
  76858. * Converts current color in rgb space to HSV values
  76859. * @returns a new color3 representing the HSV values
  76860. */
  76861. toHSV(): Color3;
  76862. /**
  76863. * Converts current color in rgb space to HSV values
  76864. * @param result defines the Color3 where to store the HSV values
  76865. */
  76866. toHSVToRef(result: Color3): void;
  76867. /**
  76868. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  76869. * @param convertedColor defines the Color3 object where to store the linear space version
  76870. * @returns the unmodified Color3
  76871. */
  76872. toLinearSpaceToRef(convertedColor: Color3): Color3;
  76873. /**
  76874. * Computes a new Color3 converted from the current one to gamma space
  76875. * @returns a new Color3 object
  76876. */
  76877. toGammaSpace(): Color3;
  76878. /**
  76879. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  76880. * @param convertedColor defines the Color3 object where to store the gamma space version
  76881. * @returns the unmodified Color3
  76882. */
  76883. toGammaSpaceToRef(convertedColor: Color3): Color3;
  76884. private static _BlackReadOnly;
  76885. /**
  76886. * Convert Hue, saturation and value to a Color3 (RGB)
  76887. * @param hue defines the hue
  76888. * @param saturation defines the saturation
  76889. * @param value defines the value
  76890. * @param result defines the Color3 where to store the RGB values
  76891. */
  76892. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  76893. /**
  76894. * Creates a new Color3 from the string containing valid hexadecimal values
  76895. * @param hex defines a string containing valid hexadecimal values
  76896. * @returns a new Color3 object
  76897. */
  76898. static FromHexString(hex: string): Color3;
  76899. /**
  76900. * Creates a new Color3 from the starting index of the given array
  76901. * @param array defines the source array
  76902. * @param offset defines an offset in the source array
  76903. * @returns a new Color3 object
  76904. */
  76905. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  76906. /**
  76907. * Creates a new Color3 from integer values (< 256)
  76908. * @param r defines the red component to read from (value between 0 and 255)
  76909. * @param g defines the green component to read from (value between 0 and 255)
  76910. * @param b defines the blue component to read from (value between 0 and 255)
  76911. * @returns a new Color3 object
  76912. */
  76913. static FromInts(r: number, g: number, b: number): Color3;
  76914. /**
  76915. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76916. * @param start defines the start Color3 value
  76917. * @param end defines the end Color3 value
  76918. * @param amount defines the gradient value between start and end
  76919. * @returns a new Color3 object
  76920. */
  76921. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  76922. /**
  76923. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  76924. * @param left defines the start value
  76925. * @param right defines the end value
  76926. * @param amount defines the gradient factor
  76927. * @param result defines the Color3 object where to store the result
  76928. */
  76929. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  76930. /**
  76931. * Returns a Color3 value containing a red color
  76932. * @returns a new Color3 object
  76933. */
  76934. static Red(): Color3;
  76935. /**
  76936. * Returns a Color3 value containing a green color
  76937. * @returns a new Color3 object
  76938. */
  76939. static Green(): Color3;
  76940. /**
  76941. * Returns a Color3 value containing a blue color
  76942. * @returns a new Color3 object
  76943. */
  76944. static Blue(): Color3;
  76945. /**
  76946. * Returns a Color3 value containing a black color
  76947. * @returns a new Color3 object
  76948. */
  76949. static Black(): Color3;
  76950. /**
  76951. * Gets a Color3 value containing a black color that must not be updated
  76952. */
  76953. static get BlackReadOnly(): DeepImmutable<Color3>;
  76954. /**
  76955. * Returns a Color3 value containing a white color
  76956. * @returns a new Color3 object
  76957. */
  76958. static White(): Color3;
  76959. /**
  76960. * Returns a Color3 value containing a purple color
  76961. * @returns a new Color3 object
  76962. */
  76963. static Purple(): Color3;
  76964. /**
  76965. * Returns a Color3 value containing a magenta color
  76966. * @returns a new Color3 object
  76967. */
  76968. static Magenta(): Color3;
  76969. /**
  76970. * Returns a Color3 value containing a yellow color
  76971. * @returns a new Color3 object
  76972. */
  76973. static Yellow(): Color3;
  76974. /**
  76975. * Returns a Color3 value containing a gray color
  76976. * @returns a new Color3 object
  76977. */
  76978. static Gray(): Color3;
  76979. /**
  76980. * Returns a Color3 value containing a teal color
  76981. * @returns a new Color3 object
  76982. */
  76983. static Teal(): Color3;
  76984. /**
  76985. * Returns a Color3 value containing a random color
  76986. * @returns a new Color3 object
  76987. */
  76988. static Random(): Color3;
  76989. }
  76990. /**
  76991. * Class used to hold a RBGA color
  76992. */
  76993. export class Color4 {
  76994. /**
  76995. * Defines the red component (between 0 and 1, default is 0)
  76996. */
  76997. r: number;
  76998. /**
  76999. * Defines the green component (between 0 and 1, default is 0)
  77000. */
  77001. g: number;
  77002. /**
  77003. * Defines the blue component (between 0 and 1, default is 0)
  77004. */
  77005. b: number;
  77006. /**
  77007. * Defines the alpha component (between 0 and 1, default is 1)
  77008. */
  77009. a: number;
  77010. /**
  77011. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  77012. * @param r defines the red component (between 0 and 1, default is 0)
  77013. * @param g defines the green component (between 0 and 1, default is 0)
  77014. * @param b defines the blue component (between 0 and 1, default is 0)
  77015. * @param a defines the alpha component (between 0 and 1, default is 1)
  77016. */
  77017. constructor(
  77018. /**
  77019. * Defines the red component (between 0 and 1, default is 0)
  77020. */
  77021. r?: number,
  77022. /**
  77023. * Defines the green component (between 0 and 1, default is 0)
  77024. */
  77025. g?: number,
  77026. /**
  77027. * Defines the blue component (between 0 and 1, default is 0)
  77028. */
  77029. b?: number,
  77030. /**
  77031. * Defines the alpha component (between 0 and 1, default is 1)
  77032. */
  77033. a?: number);
  77034. /**
  77035. * Adds in place the given Color4 values to the current Color4 object
  77036. * @param right defines the second operand
  77037. * @returns the current updated Color4 object
  77038. */
  77039. addInPlace(right: DeepImmutable<Color4>): Color4;
  77040. /**
  77041. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  77042. * @returns the new array
  77043. */
  77044. asArray(): number[];
  77045. /**
  77046. * Stores from the starting index in the given array the Color4 successive values
  77047. * @param array defines the array where to store the r,g,b components
  77048. * @param index defines an optional index in the target array to define where to start storing values
  77049. * @returns the current Color4 object
  77050. */
  77051. toArray(array: number[], index?: number): Color4;
  77052. /**
  77053. * Determines equality between Color4 objects
  77054. * @param otherColor defines the second operand
  77055. * @returns true if the rgba values are equal to the given ones
  77056. */
  77057. equals(otherColor: DeepImmutable<Color4>): boolean;
  77058. /**
  77059. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  77060. * @param right defines the second operand
  77061. * @returns a new Color4 object
  77062. */
  77063. add(right: DeepImmutable<Color4>): Color4;
  77064. /**
  77065. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  77066. * @param right defines the second operand
  77067. * @returns a new Color4 object
  77068. */
  77069. subtract(right: DeepImmutable<Color4>): Color4;
  77070. /**
  77071. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  77072. * @param right defines the second operand
  77073. * @param result defines the Color4 object where to store the result
  77074. * @returns the current Color4 object
  77075. */
  77076. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  77077. /**
  77078. * Creates a new Color4 with the current Color4 values multiplied by scale
  77079. * @param scale defines the scaling factor to apply
  77080. * @returns a new Color4 object
  77081. */
  77082. scale(scale: number): Color4;
  77083. /**
  77084. * Multiplies the current Color4 values by scale and stores the result in "result"
  77085. * @param scale defines the scaling factor to apply
  77086. * @param result defines the Color4 object where to store the result
  77087. * @returns the current unmodified Color4
  77088. */
  77089. scaleToRef(scale: number, result: Color4): Color4;
  77090. /**
  77091. * Scale the current Color4 values by a factor and add the result to a given Color4
  77092. * @param scale defines the scale factor
  77093. * @param result defines the Color4 object where to store the result
  77094. * @returns the unmodified current Color4
  77095. */
  77096. scaleAndAddToRef(scale: number, result: Color4): Color4;
  77097. /**
  77098. * Clamps the rgb values by the min and max values and stores the result into "result"
  77099. * @param min defines minimum clamping value (default is 0)
  77100. * @param max defines maximum clamping value (default is 1)
  77101. * @param result defines color to store the result into.
  77102. * @returns the cuurent Color4
  77103. */
  77104. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  77105. /**
  77106. * Multipy an Color4 value by another and return a new Color4 object
  77107. * @param color defines the Color4 value to multiply by
  77108. * @returns a new Color4 object
  77109. */
  77110. multiply(color: Color4): Color4;
  77111. /**
  77112. * Multipy a Color4 value by another and push the result in a reference value
  77113. * @param color defines the Color4 value to multiply by
  77114. * @param result defines the Color4 to fill the result in
  77115. * @returns the result Color4
  77116. */
  77117. multiplyToRef(color: Color4, result: Color4): Color4;
  77118. /**
  77119. * Creates a string with the Color4 current values
  77120. * @returns the string representation of the Color4 object
  77121. */
  77122. toString(): string;
  77123. /**
  77124. * Returns the string "Color4"
  77125. * @returns "Color4"
  77126. */
  77127. getClassName(): string;
  77128. /**
  77129. * Compute the Color4 hash code
  77130. * @returns an unique number that can be used to hash Color4 objects
  77131. */
  77132. getHashCode(): number;
  77133. /**
  77134. * Creates a new Color4 copied from the current one
  77135. * @returns a new Color4 object
  77136. */
  77137. clone(): Color4;
  77138. /**
  77139. * Copies the given Color4 values into the current one
  77140. * @param source defines the source Color4 object
  77141. * @returns the current updated Color4 object
  77142. */
  77143. copyFrom(source: Color4): Color4;
  77144. /**
  77145. * Copies the given float values into the current one
  77146. * @param r defines the red component to read from
  77147. * @param g defines the green component to read from
  77148. * @param b defines the blue component to read from
  77149. * @param a defines the alpha component to read from
  77150. * @returns the current updated Color4 object
  77151. */
  77152. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  77153. /**
  77154. * Copies the given float values into the current one
  77155. * @param r defines the red component to read from
  77156. * @param g defines the green component to read from
  77157. * @param b defines the blue component to read from
  77158. * @param a defines the alpha component to read from
  77159. * @returns the current updated Color4 object
  77160. */
  77161. set(r: number, g: number, b: number, a: number): Color4;
  77162. /**
  77163. * Compute the Color4 hexadecimal code as a string
  77164. * @returns a string containing the hexadecimal representation of the Color4 object
  77165. */
  77166. toHexString(): string;
  77167. /**
  77168. * Computes a new Color4 converted from the current one to linear space
  77169. * @returns a new Color4 object
  77170. */
  77171. toLinearSpace(): Color4;
  77172. /**
  77173. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  77174. * @param convertedColor defines the Color4 object where to store the linear space version
  77175. * @returns the unmodified Color4
  77176. */
  77177. toLinearSpaceToRef(convertedColor: Color4): Color4;
  77178. /**
  77179. * Computes a new Color4 converted from the current one to gamma space
  77180. * @returns a new Color4 object
  77181. */
  77182. toGammaSpace(): Color4;
  77183. /**
  77184. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  77185. * @param convertedColor defines the Color4 object where to store the gamma space version
  77186. * @returns the unmodified Color4
  77187. */
  77188. toGammaSpaceToRef(convertedColor: Color4): Color4;
  77189. /**
  77190. * Creates a new Color4 from the string containing valid hexadecimal values
  77191. * @param hex defines a string containing valid hexadecimal values
  77192. * @returns a new Color4 object
  77193. */
  77194. static FromHexString(hex: string): Color4;
  77195. /**
  77196. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  77197. * @param left defines the start value
  77198. * @param right defines the end value
  77199. * @param amount defines the gradient factor
  77200. * @returns a new Color4 object
  77201. */
  77202. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  77203. /**
  77204. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  77205. * @param left defines the start value
  77206. * @param right defines the end value
  77207. * @param amount defines the gradient factor
  77208. * @param result defines the Color4 object where to store data
  77209. */
  77210. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  77211. /**
  77212. * Creates a new Color4 from a Color3 and an alpha value
  77213. * @param color3 defines the source Color3 to read from
  77214. * @param alpha defines the alpha component (1.0 by default)
  77215. * @returns a new Color4 object
  77216. */
  77217. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  77218. /**
  77219. * Creates a new Color4 from the starting index element of the given array
  77220. * @param array defines the source array to read from
  77221. * @param offset defines the offset in the source array
  77222. * @returns a new Color4 object
  77223. */
  77224. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  77225. /**
  77226. * Creates a new Color3 from integer values (< 256)
  77227. * @param r defines the red component to read from (value between 0 and 255)
  77228. * @param g defines the green component to read from (value between 0 and 255)
  77229. * @param b defines the blue component to read from (value between 0 and 255)
  77230. * @param a defines the alpha component to read from (value between 0 and 255)
  77231. * @returns a new Color3 object
  77232. */
  77233. static FromInts(r: number, g: number, b: number, a: number): Color4;
  77234. /**
  77235. * Check the content of a given array and convert it to an array containing RGBA data
  77236. * If the original array was already containing count * 4 values then it is returned directly
  77237. * @param colors defines the array to check
  77238. * @param count defines the number of RGBA data to expect
  77239. * @returns an array containing count * 4 values (RGBA)
  77240. */
  77241. static CheckColors4(colors: number[], count: number): number[];
  77242. }
  77243. /**
  77244. * @hidden
  77245. */
  77246. export class TmpColors {
  77247. static Color3: Color3[];
  77248. static Color4: Color4[];
  77249. }
  77250. }
  77251. declare module BABYLON {
  77252. /**
  77253. * Defines an interface which represents an animation key frame
  77254. */
  77255. export interface IAnimationKey {
  77256. /**
  77257. * Frame of the key frame
  77258. */
  77259. frame: number;
  77260. /**
  77261. * Value at the specifies key frame
  77262. */
  77263. value: any;
  77264. /**
  77265. * The input tangent for the cubic hermite spline
  77266. */
  77267. inTangent?: any;
  77268. /**
  77269. * The output tangent for the cubic hermite spline
  77270. */
  77271. outTangent?: any;
  77272. /**
  77273. * The animation interpolation type
  77274. */
  77275. interpolation?: AnimationKeyInterpolation;
  77276. }
  77277. /**
  77278. * Enum for the animation key frame interpolation type
  77279. */
  77280. export enum AnimationKeyInterpolation {
  77281. /**
  77282. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  77283. */
  77284. STEP = 1
  77285. }
  77286. }
  77287. declare module BABYLON {
  77288. /**
  77289. * Represents the range of an animation
  77290. */
  77291. export class AnimationRange {
  77292. /**The name of the animation range**/
  77293. name: string;
  77294. /**The starting frame of the animation */
  77295. from: number;
  77296. /**The ending frame of the animation*/
  77297. to: number;
  77298. /**
  77299. * Initializes the range of an animation
  77300. * @param name The name of the animation range
  77301. * @param from The starting frame of the animation
  77302. * @param to The ending frame of the animation
  77303. */
  77304. constructor(
  77305. /**The name of the animation range**/
  77306. name: string,
  77307. /**The starting frame of the animation */
  77308. from: number,
  77309. /**The ending frame of the animation*/
  77310. to: number);
  77311. /**
  77312. * Makes a copy of the animation range
  77313. * @returns A copy of the animation range
  77314. */
  77315. clone(): AnimationRange;
  77316. }
  77317. }
  77318. declare module BABYLON {
  77319. /**
  77320. * Composed of a frame, and an action function
  77321. */
  77322. export class AnimationEvent {
  77323. /** The frame for which the event is triggered **/
  77324. frame: number;
  77325. /** The event to perform when triggered **/
  77326. action: (currentFrame: number) => void;
  77327. /** Specifies if the event should be triggered only once**/
  77328. onlyOnce?: boolean | undefined;
  77329. /**
  77330. * Specifies if the animation event is done
  77331. */
  77332. isDone: boolean;
  77333. /**
  77334. * Initializes the animation event
  77335. * @param frame The frame for which the event is triggered
  77336. * @param action The event to perform when triggered
  77337. * @param onlyOnce Specifies if the event should be triggered only once
  77338. */
  77339. constructor(
  77340. /** The frame for which the event is triggered **/
  77341. frame: number,
  77342. /** The event to perform when triggered **/
  77343. action: (currentFrame: number) => void,
  77344. /** Specifies if the event should be triggered only once**/
  77345. onlyOnce?: boolean | undefined);
  77346. /** @hidden */
  77347. _clone(): AnimationEvent;
  77348. }
  77349. }
  77350. declare module BABYLON {
  77351. /**
  77352. * Interface used to define a behavior
  77353. */
  77354. export interface Behavior<T> {
  77355. /** gets or sets behavior's name */
  77356. name: string;
  77357. /**
  77358. * Function called when the behavior needs to be initialized (after attaching it to a target)
  77359. */
  77360. init(): void;
  77361. /**
  77362. * Called when the behavior is attached to a target
  77363. * @param target defines the target where the behavior is attached to
  77364. */
  77365. attach(target: T): void;
  77366. /**
  77367. * Called when the behavior is detached from its target
  77368. */
  77369. detach(): void;
  77370. }
  77371. /**
  77372. * Interface implemented by classes supporting behaviors
  77373. */
  77374. export interface IBehaviorAware<T> {
  77375. /**
  77376. * Attach a behavior
  77377. * @param behavior defines the behavior to attach
  77378. * @returns the current host
  77379. */
  77380. addBehavior(behavior: Behavior<T>): T;
  77381. /**
  77382. * Remove a behavior from the current object
  77383. * @param behavior defines the behavior to detach
  77384. * @returns the current host
  77385. */
  77386. removeBehavior(behavior: Behavior<T>): T;
  77387. /**
  77388. * Gets a behavior using its name to search
  77389. * @param name defines the name to search
  77390. * @returns the behavior or null if not found
  77391. */
  77392. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  77393. }
  77394. }
  77395. declare module BABYLON {
  77396. /**
  77397. * Defines an array and its length.
  77398. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  77399. */
  77400. export interface ISmartArrayLike<T> {
  77401. /**
  77402. * The data of the array.
  77403. */
  77404. data: Array<T>;
  77405. /**
  77406. * The active length of the array.
  77407. */
  77408. length: number;
  77409. }
  77410. /**
  77411. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  77412. */
  77413. export class SmartArray<T> implements ISmartArrayLike<T> {
  77414. /**
  77415. * The full set of data from the array.
  77416. */
  77417. data: Array<T>;
  77418. /**
  77419. * The active length of the array.
  77420. */
  77421. length: number;
  77422. protected _id: number;
  77423. /**
  77424. * Instantiates a Smart Array.
  77425. * @param capacity defines the default capacity of the array.
  77426. */
  77427. constructor(capacity: number);
  77428. /**
  77429. * Pushes a value at the end of the active data.
  77430. * @param value defines the object to push in the array.
  77431. */
  77432. push(value: T): void;
  77433. /**
  77434. * Iterates over the active data and apply the lambda to them.
  77435. * @param func defines the action to apply on each value.
  77436. */
  77437. forEach(func: (content: T) => void): void;
  77438. /**
  77439. * Sorts the full sets of data.
  77440. * @param compareFn defines the comparison function to apply.
  77441. */
  77442. sort(compareFn: (a: T, b: T) => number): void;
  77443. /**
  77444. * Resets the active data to an empty array.
  77445. */
  77446. reset(): void;
  77447. /**
  77448. * Releases all the data from the array as well as the array.
  77449. */
  77450. dispose(): void;
  77451. /**
  77452. * Concats the active data with a given array.
  77453. * @param array defines the data to concatenate with.
  77454. */
  77455. concat(array: any): void;
  77456. /**
  77457. * Returns the position of a value in the active data.
  77458. * @param value defines the value to find the index for
  77459. * @returns the index if found in the active data otherwise -1
  77460. */
  77461. indexOf(value: T): number;
  77462. /**
  77463. * Returns whether an element is part of the active data.
  77464. * @param value defines the value to look for
  77465. * @returns true if found in the active data otherwise false
  77466. */
  77467. contains(value: T): boolean;
  77468. private static _GlobalId;
  77469. }
  77470. /**
  77471. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  77472. * The data in this array can only be present once
  77473. */
  77474. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  77475. private _duplicateId;
  77476. /**
  77477. * Pushes a value at the end of the active data.
  77478. * THIS DOES NOT PREVENT DUPPLICATE DATA
  77479. * @param value defines the object to push in the array.
  77480. */
  77481. push(value: T): void;
  77482. /**
  77483. * Pushes a value at the end of the active data.
  77484. * If the data is already present, it won t be added again
  77485. * @param value defines the object to push in the array.
  77486. * @returns true if added false if it was already present
  77487. */
  77488. pushNoDuplicate(value: T): boolean;
  77489. /**
  77490. * Resets the active data to an empty array.
  77491. */
  77492. reset(): void;
  77493. /**
  77494. * Concats the active data with a given array.
  77495. * This ensures no dupplicate will be present in the result.
  77496. * @param array defines the data to concatenate with.
  77497. */
  77498. concatWithNoDuplicate(array: any): void;
  77499. }
  77500. }
  77501. declare module BABYLON {
  77502. /**
  77503. * @ignore
  77504. * This is a list of all the different input types that are available in the application.
  77505. * Fo instance: ArcRotateCameraGamepadInput...
  77506. */
  77507. export var CameraInputTypes: {};
  77508. /**
  77509. * This is the contract to implement in order to create a new input class.
  77510. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  77511. */
  77512. export interface ICameraInput<TCamera extends Camera> {
  77513. /**
  77514. * Defines the camera the input is attached to.
  77515. */
  77516. camera: Nullable<TCamera>;
  77517. /**
  77518. * Gets the class name of the current intput.
  77519. * @returns the class name
  77520. */
  77521. getClassName(): string;
  77522. /**
  77523. * Get the friendly name associated with the input class.
  77524. * @returns the input friendly name
  77525. */
  77526. getSimpleName(): string;
  77527. /**
  77528. * Attach the input controls to a specific dom element to get the input from.
  77529. * @param element Defines the element the controls should be listened from
  77530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77531. */
  77532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  77533. /**
  77534. * Detach the current controls from the specified dom element.
  77535. * @param element Defines the element to stop listening the inputs from
  77536. */
  77537. detachControl(element: Nullable<HTMLElement>): void;
  77538. /**
  77539. * Update the current camera state depending on the inputs that have been used this frame.
  77540. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77541. */
  77542. checkInputs?: () => void;
  77543. }
  77544. /**
  77545. * Represents a map of input types to input instance or input index to input instance.
  77546. */
  77547. export interface CameraInputsMap<TCamera extends Camera> {
  77548. /**
  77549. * Accessor to the input by input type.
  77550. */
  77551. [name: string]: ICameraInput<TCamera>;
  77552. /**
  77553. * Accessor to the input by input index.
  77554. */
  77555. [idx: number]: ICameraInput<TCamera>;
  77556. }
  77557. /**
  77558. * This represents the input manager used within a camera.
  77559. * It helps dealing with all the different kind of input attached to a camera.
  77560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77561. */
  77562. export class CameraInputsManager<TCamera extends Camera> {
  77563. /**
  77564. * Defines the list of inputs attahed to the camera.
  77565. */
  77566. attached: CameraInputsMap<TCamera>;
  77567. /**
  77568. * Defines the dom element the camera is collecting inputs from.
  77569. * This is null if the controls have not been attached.
  77570. */
  77571. attachedElement: Nullable<HTMLElement>;
  77572. /**
  77573. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77574. */
  77575. noPreventDefault: boolean;
  77576. /**
  77577. * Defined the camera the input manager belongs to.
  77578. */
  77579. camera: TCamera;
  77580. /**
  77581. * Update the current camera state depending on the inputs that have been used this frame.
  77582. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  77583. */
  77584. checkInputs: () => void;
  77585. /**
  77586. * Instantiate a new Camera Input Manager.
  77587. * @param camera Defines the camera the input manager blongs to
  77588. */
  77589. constructor(camera: TCamera);
  77590. /**
  77591. * Add an input method to a camera
  77592. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  77593. * @param input camera input method
  77594. */
  77595. add(input: ICameraInput<TCamera>): void;
  77596. /**
  77597. * Remove a specific input method from a camera
  77598. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  77599. * @param inputToRemove camera input method
  77600. */
  77601. remove(inputToRemove: ICameraInput<TCamera>): void;
  77602. /**
  77603. * Remove a specific input type from a camera
  77604. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  77605. * @param inputType the type of the input to remove
  77606. */
  77607. removeByType(inputType: string): void;
  77608. private _addCheckInputs;
  77609. /**
  77610. * Attach the input controls to the currently attached dom element to listen the events from.
  77611. * @param input Defines the input to attach
  77612. */
  77613. attachInput(input: ICameraInput<TCamera>): void;
  77614. /**
  77615. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  77616. * @param element Defines the dom element to collect the events from
  77617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  77618. */
  77619. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  77620. /**
  77621. * Detach the current manager inputs controls from a specific dom element.
  77622. * @param element Defines the dom element to collect the events from
  77623. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  77624. */
  77625. detachElement(element: HTMLElement, disconnect?: boolean): void;
  77626. /**
  77627. * Rebuild the dynamic inputCheck function from the current list of
  77628. * defined inputs in the manager.
  77629. */
  77630. rebuildInputCheck(): void;
  77631. /**
  77632. * Remove all attached input methods from a camera
  77633. */
  77634. clear(): void;
  77635. /**
  77636. * Serialize the current input manager attached to a camera.
  77637. * This ensures than once parsed,
  77638. * the input associated to the camera will be identical to the current ones
  77639. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  77640. */
  77641. serialize(serializedCamera: any): void;
  77642. /**
  77643. * Parses an input manager serialized JSON to restore the previous list of inputs
  77644. * and states associated to a camera.
  77645. * @param parsedCamera Defines the JSON to parse
  77646. */
  77647. parse(parsedCamera: any): void;
  77648. }
  77649. }
  77650. declare module BABYLON {
  77651. /**
  77652. * Class used to store data that will be store in GPU memory
  77653. */
  77654. export class Buffer {
  77655. private _engine;
  77656. private _buffer;
  77657. /** @hidden */
  77658. _data: Nullable<DataArray>;
  77659. private _updatable;
  77660. private _instanced;
  77661. private _divisor;
  77662. /**
  77663. * Gets the byte stride.
  77664. */
  77665. readonly byteStride: number;
  77666. /**
  77667. * Constructor
  77668. * @param engine the engine
  77669. * @param data the data to use for this buffer
  77670. * @param updatable whether the data is updatable
  77671. * @param stride the stride (optional)
  77672. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  77673. * @param instanced whether the buffer is instanced (optional)
  77674. * @param useBytes set to true if the stride in in bytes (optional)
  77675. * @param divisor sets an optional divisor for instances (1 by default)
  77676. */
  77677. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  77678. /**
  77679. * Create a new VertexBuffer based on the current buffer
  77680. * @param kind defines the vertex buffer kind (position, normal, etc.)
  77681. * @param offset defines offset in the buffer (0 by default)
  77682. * @param size defines the size in floats of attributes (position is 3 for instance)
  77683. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  77684. * @param instanced defines if the vertex buffer contains indexed data
  77685. * @param useBytes defines if the offset and stride are in bytes *
  77686. * @param divisor sets an optional divisor for instances (1 by default)
  77687. * @returns the new vertex buffer
  77688. */
  77689. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  77690. /**
  77691. * Gets a boolean indicating if the Buffer is updatable?
  77692. * @returns true if the buffer is updatable
  77693. */
  77694. isUpdatable(): boolean;
  77695. /**
  77696. * Gets current buffer's data
  77697. * @returns a DataArray or null
  77698. */
  77699. getData(): Nullable<DataArray>;
  77700. /**
  77701. * Gets underlying native buffer
  77702. * @returns underlying native buffer
  77703. */
  77704. getBuffer(): Nullable<DataBuffer>;
  77705. /**
  77706. * Gets the stride in float32 units (i.e. byte stride / 4).
  77707. * May not be an integer if the byte stride is not divisible by 4.
  77708. * @returns the stride in float32 units
  77709. * @deprecated Please use byteStride instead.
  77710. */
  77711. getStrideSize(): number;
  77712. /**
  77713. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77714. * @param data defines the data to store
  77715. */
  77716. create(data?: Nullable<DataArray>): void;
  77717. /** @hidden */
  77718. _rebuild(): void;
  77719. /**
  77720. * Update current buffer data
  77721. * @param data defines the data to store
  77722. */
  77723. update(data: DataArray): void;
  77724. /**
  77725. * Updates the data directly.
  77726. * @param data the new data
  77727. * @param offset the new offset
  77728. * @param vertexCount the vertex count (optional)
  77729. * @param useBytes set to true if the offset is in bytes
  77730. */
  77731. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  77732. /**
  77733. * Release all resources
  77734. */
  77735. dispose(): void;
  77736. }
  77737. /**
  77738. * Specialized buffer used to store vertex data
  77739. */
  77740. export class VertexBuffer {
  77741. /** @hidden */
  77742. _buffer: Buffer;
  77743. private _kind;
  77744. private _size;
  77745. private _ownsBuffer;
  77746. private _instanced;
  77747. private _instanceDivisor;
  77748. /**
  77749. * The byte type.
  77750. */
  77751. static readonly BYTE: number;
  77752. /**
  77753. * The unsigned byte type.
  77754. */
  77755. static readonly UNSIGNED_BYTE: number;
  77756. /**
  77757. * The short type.
  77758. */
  77759. static readonly SHORT: number;
  77760. /**
  77761. * The unsigned short type.
  77762. */
  77763. static readonly UNSIGNED_SHORT: number;
  77764. /**
  77765. * The integer type.
  77766. */
  77767. static readonly INT: number;
  77768. /**
  77769. * The unsigned integer type.
  77770. */
  77771. static readonly UNSIGNED_INT: number;
  77772. /**
  77773. * The float type.
  77774. */
  77775. static readonly FLOAT: number;
  77776. /**
  77777. * Gets or sets the instance divisor when in instanced mode
  77778. */
  77779. get instanceDivisor(): number;
  77780. set instanceDivisor(value: number);
  77781. /**
  77782. * Gets the byte stride.
  77783. */
  77784. readonly byteStride: number;
  77785. /**
  77786. * Gets the byte offset.
  77787. */
  77788. readonly byteOffset: number;
  77789. /**
  77790. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  77791. */
  77792. readonly normalized: boolean;
  77793. /**
  77794. * Gets the data type of each component in the array.
  77795. */
  77796. readonly type: number;
  77797. /**
  77798. * Constructor
  77799. * @param engine the engine
  77800. * @param data the data to use for this vertex buffer
  77801. * @param kind the vertex buffer kind
  77802. * @param updatable whether the data is updatable
  77803. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  77804. * @param stride the stride (optional)
  77805. * @param instanced whether the buffer is instanced (optional)
  77806. * @param offset the offset of the data (optional)
  77807. * @param size the number of components (optional)
  77808. * @param type the type of the component (optional)
  77809. * @param normalized whether the data contains normalized data (optional)
  77810. * @param useBytes set to true if stride and offset are in bytes (optional)
  77811. * @param divisor defines the instance divisor to use (1 by default)
  77812. */
  77813. 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);
  77814. /** @hidden */
  77815. _rebuild(): void;
  77816. /**
  77817. * Returns the kind of the VertexBuffer (string)
  77818. * @returns a string
  77819. */
  77820. getKind(): string;
  77821. /**
  77822. * Gets a boolean indicating if the VertexBuffer is updatable?
  77823. * @returns true if the buffer is updatable
  77824. */
  77825. isUpdatable(): boolean;
  77826. /**
  77827. * Gets current buffer's data
  77828. * @returns a DataArray or null
  77829. */
  77830. getData(): Nullable<DataArray>;
  77831. /**
  77832. * Gets underlying native buffer
  77833. * @returns underlying native buffer
  77834. */
  77835. getBuffer(): Nullable<DataBuffer>;
  77836. /**
  77837. * Gets the stride in float32 units (i.e. byte stride / 4).
  77838. * May not be an integer if the byte stride is not divisible by 4.
  77839. * @returns the stride in float32 units
  77840. * @deprecated Please use byteStride instead.
  77841. */
  77842. getStrideSize(): number;
  77843. /**
  77844. * Returns the offset as a multiple of the type byte length.
  77845. * @returns the offset in bytes
  77846. * @deprecated Please use byteOffset instead.
  77847. */
  77848. getOffset(): number;
  77849. /**
  77850. * Returns the number of components per vertex attribute (integer)
  77851. * @returns the size in float
  77852. */
  77853. getSize(): number;
  77854. /**
  77855. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  77856. * @returns true if this buffer is instanced
  77857. */
  77858. getIsInstanced(): boolean;
  77859. /**
  77860. * Returns the instancing divisor, zero for non-instanced (integer).
  77861. * @returns a number
  77862. */
  77863. getInstanceDivisor(): number;
  77864. /**
  77865. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  77866. * @param data defines the data to store
  77867. */
  77868. create(data?: DataArray): void;
  77869. /**
  77870. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  77871. * This function will create a new buffer if the current one is not updatable
  77872. * @param data defines the data to store
  77873. */
  77874. update(data: DataArray): void;
  77875. /**
  77876. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  77877. * Returns the directly updated WebGLBuffer.
  77878. * @param data the new data
  77879. * @param offset the new offset
  77880. * @param useBytes set to true if the offset is in bytes
  77881. */
  77882. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  77883. /**
  77884. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  77885. */
  77886. dispose(): void;
  77887. /**
  77888. * Enumerates each value of this vertex buffer as numbers.
  77889. * @param count the number of values to enumerate
  77890. * @param callback the callback function called for each value
  77891. */
  77892. forEach(count: number, callback: (value: number, index: number) => void): void;
  77893. /**
  77894. * Positions
  77895. */
  77896. static readonly PositionKind: string;
  77897. /**
  77898. * Normals
  77899. */
  77900. static readonly NormalKind: string;
  77901. /**
  77902. * Tangents
  77903. */
  77904. static readonly TangentKind: string;
  77905. /**
  77906. * Texture coordinates
  77907. */
  77908. static readonly UVKind: string;
  77909. /**
  77910. * Texture coordinates 2
  77911. */
  77912. static readonly UV2Kind: string;
  77913. /**
  77914. * Texture coordinates 3
  77915. */
  77916. static readonly UV3Kind: string;
  77917. /**
  77918. * Texture coordinates 4
  77919. */
  77920. static readonly UV4Kind: string;
  77921. /**
  77922. * Texture coordinates 5
  77923. */
  77924. static readonly UV5Kind: string;
  77925. /**
  77926. * Texture coordinates 6
  77927. */
  77928. static readonly UV6Kind: string;
  77929. /**
  77930. * Colors
  77931. */
  77932. static readonly ColorKind: string;
  77933. /**
  77934. * Matrix indices (for bones)
  77935. */
  77936. static readonly MatricesIndicesKind: string;
  77937. /**
  77938. * Matrix weights (for bones)
  77939. */
  77940. static readonly MatricesWeightsKind: string;
  77941. /**
  77942. * Additional matrix indices (for bones)
  77943. */
  77944. static readonly MatricesIndicesExtraKind: string;
  77945. /**
  77946. * Additional matrix weights (for bones)
  77947. */
  77948. static readonly MatricesWeightsExtraKind: string;
  77949. /**
  77950. * Deduces the stride given a kind.
  77951. * @param kind The kind string to deduce
  77952. * @returns The deduced stride
  77953. */
  77954. static DeduceStride(kind: string): number;
  77955. /**
  77956. * Gets the byte length of the given type.
  77957. * @param type the type
  77958. * @returns the number of bytes
  77959. */
  77960. static GetTypeByteLength(type: number): number;
  77961. /**
  77962. * Enumerates each value of the given parameters as numbers.
  77963. * @param data the data to enumerate
  77964. * @param byteOffset the byte offset of the data
  77965. * @param byteStride the byte stride of the data
  77966. * @param componentCount the number of components per element
  77967. * @param componentType the type of the component
  77968. * @param count the number of values to enumerate
  77969. * @param normalized whether the data is normalized
  77970. * @param callback the callback function called for each value
  77971. */
  77972. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  77973. private static _GetFloatValue;
  77974. }
  77975. }
  77976. declare module BABYLON {
  77977. /**
  77978. * @hidden
  77979. */
  77980. export class IntersectionInfo {
  77981. bu: Nullable<number>;
  77982. bv: Nullable<number>;
  77983. distance: number;
  77984. faceId: number;
  77985. subMeshId: number;
  77986. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  77987. }
  77988. }
  77989. declare module BABYLON {
  77990. /**
  77991. * Represens a plane by the equation ax + by + cz + d = 0
  77992. */
  77993. export class Plane {
  77994. private static _TmpMatrix;
  77995. /**
  77996. * Normal of the plane (a,b,c)
  77997. */
  77998. normal: Vector3;
  77999. /**
  78000. * d component of the plane
  78001. */
  78002. d: number;
  78003. /**
  78004. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  78005. * @param a a component of the plane
  78006. * @param b b component of the plane
  78007. * @param c c component of the plane
  78008. * @param d d component of the plane
  78009. */
  78010. constructor(a: number, b: number, c: number, d: number);
  78011. /**
  78012. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  78013. */
  78014. asArray(): number[];
  78015. /**
  78016. * @returns a new plane copied from the current Plane.
  78017. */
  78018. clone(): Plane;
  78019. /**
  78020. * @returns the string "Plane".
  78021. */
  78022. getClassName(): string;
  78023. /**
  78024. * @returns the Plane hash code.
  78025. */
  78026. getHashCode(): number;
  78027. /**
  78028. * Normalize the current Plane in place.
  78029. * @returns the updated Plane.
  78030. */
  78031. normalize(): Plane;
  78032. /**
  78033. * Applies a transformation the plane and returns the result
  78034. * @param transformation the transformation matrix to be applied to the plane
  78035. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  78036. */
  78037. transform(transformation: DeepImmutable<Matrix>): Plane;
  78038. /**
  78039. * Calcualtte the dot product between the point and the plane normal
  78040. * @param point point to calculate the dot product with
  78041. * @returns the dot product (float) of the point coordinates and the plane normal.
  78042. */
  78043. dotCoordinate(point: DeepImmutable<Vector3>): number;
  78044. /**
  78045. * Updates the current Plane from the plane defined by the three given points.
  78046. * @param point1 one of the points used to contruct the plane
  78047. * @param point2 one of the points used to contruct the plane
  78048. * @param point3 one of the points used to contruct the plane
  78049. * @returns the updated Plane.
  78050. */
  78051. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  78052. /**
  78053. * Checks if the plane is facing a given direction
  78054. * @param direction the direction to check if the plane is facing
  78055. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  78056. * @returns True is the vector "direction" is the same side than the plane normal.
  78057. */
  78058. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  78059. /**
  78060. * Calculates the distance to a point
  78061. * @param point point to calculate distance to
  78062. * @returns the signed distance (float) from the given point to the Plane.
  78063. */
  78064. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  78065. /**
  78066. * Creates a plane from an array
  78067. * @param array the array to create a plane from
  78068. * @returns a new Plane from the given array.
  78069. */
  78070. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  78071. /**
  78072. * Creates a plane from three points
  78073. * @param point1 point used to create the plane
  78074. * @param point2 point used to create the plane
  78075. * @param point3 point used to create the plane
  78076. * @returns a new Plane defined by the three given points.
  78077. */
  78078. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  78079. /**
  78080. * Creates a plane from an origin point and a normal
  78081. * @param origin origin of the plane to be constructed
  78082. * @param normal normal of the plane to be constructed
  78083. * @returns a new Plane the normal vector to this plane at the given origin point.
  78084. * Note : the vector "normal" is updated because normalized.
  78085. */
  78086. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  78087. /**
  78088. * Calculates the distance from a plane and a point
  78089. * @param origin origin of the plane to be constructed
  78090. * @param normal normal of the plane to be constructed
  78091. * @param point point to calculate distance to
  78092. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  78093. */
  78094. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  78095. }
  78096. }
  78097. declare module BABYLON {
  78098. /**
  78099. * Class used to store bounding sphere information
  78100. */
  78101. export class BoundingSphere {
  78102. /**
  78103. * Gets the center of the bounding sphere in local space
  78104. */
  78105. readonly center: Vector3;
  78106. /**
  78107. * Radius of the bounding sphere in local space
  78108. */
  78109. radius: number;
  78110. /**
  78111. * Gets the center of the bounding sphere in world space
  78112. */
  78113. readonly centerWorld: Vector3;
  78114. /**
  78115. * Radius of the bounding sphere in world space
  78116. */
  78117. radiusWorld: number;
  78118. /**
  78119. * Gets the minimum vector in local space
  78120. */
  78121. readonly minimum: Vector3;
  78122. /**
  78123. * Gets the maximum vector in local space
  78124. */
  78125. readonly maximum: Vector3;
  78126. private _worldMatrix;
  78127. private static readonly TmpVector3;
  78128. /**
  78129. * Creates a new bounding sphere
  78130. * @param min defines the minimum vector (in local space)
  78131. * @param max defines the maximum vector (in local space)
  78132. * @param worldMatrix defines the new world matrix
  78133. */
  78134. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  78135. /**
  78136. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  78137. * @param min defines the new minimum vector (in local space)
  78138. * @param max defines the new maximum vector (in local space)
  78139. * @param worldMatrix defines the new world matrix
  78140. */
  78141. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  78142. /**
  78143. * Scale the current bounding sphere by applying a scale factor
  78144. * @param factor defines the scale factor to apply
  78145. * @returns the current bounding box
  78146. */
  78147. scale(factor: number): BoundingSphere;
  78148. /**
  78149. * Gets the world matrix of the bounding box
  78150. * @returns a matrix
  78151. */
  78152. getWorldMatrix(): DeepImmutable<Matrix>;
  78153. /** @hidden */
  78154. _update(worldMatrix: DeepImmutable<Matrix>): void;
  78155. /**
  78156. * Tests if the bounding sphere is intersecting the frustum planes
  78157. * @param frustumPlanes defines the frustum planes to test
  78158. * @returns true if there is an intersection
  78159. */
  78160. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78161. /**
  78162. * Tests if the bounding sphere center is in between the frustum planes.
  78163. * Used for optimistic fast inclusion.
  78164. * @param frustumPlanes defines the frustum planes to test
  78165. * @returns true if the sphere center is in between the frustum planes
  78166. */
  78167. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78168. /**
  78169. * Tests if a point is inside the bounding sphere
  78170. * @param point defines the point to test
  78171. * @returns true if the point is inside the bounding sphere
  78172. */
  78173. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  78174. /**
  78175. * Checks if two sphere intersct
  78176. * @param sphere0 sphere 0
  78177. * @param sphere1 sphere 1
  78178. * @returns true if the speres intersect
  78179. */
  78180. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  78181. }
  78182. }
  78183. declare module BABYLON {
  78184. /**
  78185. * Class used to store bounding box information
  78186. */
  78187. export class BoundingBox implements ICullable {
  78188. /**
  78189. * Gets the 8 vectors representing the bounding box in local space
  78190. */
  78191. readonly vectors: Vector3[];
  78192. /**
  78193. * Gets the center of the bounding box in local space
  78194. */
  78195. readonly center: Vector3;
  78196. /**
  78197. * Gets the center of the bounding box in world space
  78198. */
  78199. readonly centerWorld: Vector3;
  78200. /**
  78201. * Gets the extend size in local space
  78202. */
  78203. readonly extendSize: Vector3;
  78204. /**
  78205. * Gets the extend size in world space
  78206. */
  78207. readonly extendSizeWorld: Vector3;
  78208. /**
  78209. * Gets the OBB (object bounding box) directions
  78210. */
  78211. readonly directions: Vector3[];
  78212. /**
  78213. * Gets the 8 vectors representing the bounding box in world space
  78214. */
  78215. readonly vectorsWorld: Vector3[];
  78216. /**
  78217. * Gets the minimum vector in world space
  78218. */
  78219. readonly minimumWorld: Vector3;
  78220. /**
  78221. * Gets the maximum vector in world space
  78222. */
  78223. readonly maximumWorld: Vector3;
  78224. /**
  78225. * Gets the minimum vector in local space
  78226. */
  78227. readonly minimum: Vector3;
  78228. /**
  78229. * Gets the maximum vector in local space
  78230. */
  78231. readonly maximum: Vector3;
  78232. private _worldMatrix;
  78233. private static readonly TmpVector3;
  78234. /**
  78235. * @hidden
  78236. */
  78237. _tag: number;
  78238. /**
  78239. * Creates a new bounding box
  78240. * @param min defines the minimum vector (in local space)
  78241. * @param max defines the maximum vector (in local space)
  78242. * @param worldMatrix defines the new world matrix
  78243. */
  78244. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  78245. /**
  78246. * Recreates the entire bounding box from scratch as if we call the constructor in place
  78247. * @param min defines the new minimum vector (in local space)
  78248. * @param max defines the new maximum vector (in local space)
  78249. * @param worldMatrix defines the new world matrix
  78250. */
  78251. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  78252. /**
  78253. * Scale the current bounding box by applying a scale factor
  78254. * @param factor defines the scale factor to apply
  78255. * @returns the current bounding box
  78256. */
  78257. scale(factor: number): BoundingBox;
  78258. /**
  78259. * Gets the world matrix of the bounding box
  78260. * @returns a matrix
  78261. */
  78262. getWorldMatrix(): DeepImmutable<Matrix>;
  78263. /** @hidden */
  78264. _update(world: DeepImmutable<Matrix>): void;
  78265. /**
  78266. * Tests if the bounding box is intersecting the frustum planes
  78267. * @param frustumPlanes defines the frustum planes to test
  78268. * @returns true if there is an intersection
  78269. */
  78270. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78271. /**
  78272. * Tests if the bounding box is entirely inside the frustum planes
  78273. * @param frustumPlanes defines the frustum planes to test
  78274. * @returns true if there is an inclusion
  78275. */
  78276. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78277. /**
  78278. * Tests if a point is inside the bounding box
  78279. * @param point defines the point to test
  78280. * @returns true if the point is inside the bounding box
  78281. */
  78282. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  78283. /**
  78284. * Tests if the bounding box intersects with a bounding sphere
  78285. * @param sphere defines the sphere to test
  78286. * @returns true if there is an intersection
  78287. */
  78288. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  78289. /**
  78290. * Tests if the bounding box intersects with a box defined by a min and max vectors
  78291. * @param min defines the min vector to use
  78292. * @param max defines the max vector to use
  78293. * @returns true if there is an intersection
  78294. */
  78295. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  78296. /**
  78297. * Tests if two bounding boxes are intersections
  78298. * @param box0 defines the first box to test
  78299. * @param box1 defines the second box to test
  78300. * @returns true if there is an intersection
  78301. */
  78302. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  78303. /**
  78304. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  78305. * @param minPoint defines the minimum vector of the bounding box
  78306. * @param maxPoint defines the maximum vector of the bounding box
  78307. * @param sphereCenter defines the sphere center
  78308. * @param sphereRadius defines the sphere radius
  78309. * @returns true if there is an intersection
  78310. */
  78311. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  78312. /**
  78313. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  78314. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  78315. * @param frustumPlanes defines the frustum planes to test
  78316. * @return true if there is an inclusion
  78317. */
  78318. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78319. /**
  78320. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  78321. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  78322. * @param frustumPlanes defines the frustum planes to test
  78323. * @return true if there is an intersection
  78324. */
  78325. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78326. }
  78327. }
  78328. declare module BABYLON {
  78329. /** @hidden */
  78330. export class Collider {
  78331. /** Define if a collision was found */
  78332. collisionFound: boolean;
  78333. /**
  78334. * Define last intersection point in local space
  78335. */
  78336. intersectionPoint: Vector3;
  78337. /**
  78338. * Define last collided mesh
  78339. */
  78340. collidedMesh: Nullable<AbstractMesh>;
  78341. private _collisionPoint;
  78342. private _planeIntersectionPoint;
  78343. private _tempVector;
  78344. private _tempVector2;
  78345. private _tempVector3;
  78346. private _tempVector4;
  78347. private _edge;
  78348. private _baseToVertex;
  78349. private _destinationPoint;
  78350. private _slidePlaneNormal;
  78351. private _displacementVector;
  78352. /** @hidden */
  78353. _radius: Vector3;
  78354. /** @hidden */
  78355. _retry: number;
  78356. private _velocity;
  78357. private _basePoint;
  78358. private _epsilon;
  78359. /** @hidden */
  78360. _velocityWorldLength: number;
  78361. /** @hidden */
  78362. _basePointWorld: Vector3;
  78363. private _velocityWorld;
  78364. private _normalizedVelocity;
  78365. /** @hidden */
  78366. _initialVelocity: Vector3;
  78367. /** @hidden */
  78368. _initialPosition: Vector3;
  78369. private _nearestDistance;
  78370. private _collisionMask;
  78371. get collisionMask(): number;
  78372. set collisionMask(mask: number);
  78373. /**
  78374. * Gets the plane normal used to compute the sliding response (in local space)
  78375. */
  78376. get slidePlaneNormal(): Vector3;
  78377. /** @hidden */
  78378. _initialize(source: Vector3, dir: Vector3, e: number): void;
  78379. /** @hidden */
  78380. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  78381. /** @hidden */
  78382. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  78383. /** @hidden */
  78384. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  78385. /** @hidden */
  78386. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  78387. /** @hidden */
  78388. _getResponse(pos: Vector3, vel: Vector3): void;
  78389. }
  78390. }
  78391. declare module BABYLON {
  78392. /**
  78393. * Interface for cullable objects
  78394. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  78395. */
  78396. export interface ICullable {
  78397. /**
  78398. * Checks if the object or part of the object is in the frustum
  78399. * @param frustumPlanes Camera near/planes
  78400. * @returns true if the object is in frustum otherwise false
  78401. */
  78402. isInFrustum(frustumPlanes: Plane[]): boolean;
  78403. /**
  78404. * Checks if a cullable object (mesh...) is in the camera frustum
  78405. * Unlike isInFrustum this cheks the full bounding box
  78406. * @param frustumPlanes Camera near/planes
  78407. * @returns true if the object is in frustum otherwise false
  78408. */
  78409. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  78410. }
  78411. /**
  78412. * Info for a bounding data of a mesh
  78413. */
  78414. export class BoundingInfo implements ICullable {
  78415. /**
  78416. * Bounding box for the mesh
  78417. */
  78418. readonly boundingBox: BoundingBox;
  78419. /**
  78420. * Bounding sphere for the mesh
  78421. */
  78422. readonly boundingSphere: BoundingSphere;
  78423. private _isLocked;
  78424. private static readonly TmpVector3;
  78425. /**
  78426. * Constructs bounding info
  78427. * @param minimum min vector of the bounding box/sphere
  78428. * @param maximum max vector of the bounding box/sphere
  78429. * @param worldMatrix defines the new world matrix
  78430. */
  78431. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  78432. /**
  78433. * Recreates the entire bounding info from scratch as if we call the constructor in place
  78434. * @param min defines the new minimum vector (in local space)
  78435. * @param max defines the new maximum vector (in local space)
  78436. * @param worldMatrix defines the new world matrix
  78437. */
  78438. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  78439. /**
  78440. * min vector of the bounding box/sphere
  78441. */
  78442. get minimum(): Vector3;
  78443. /**
  78444. * max vector of the bounding box/sphere
  78445. */
  78446. get maximum(): Vector3;
  78447. /**
  78448. * If the info is locked and won't be updated to avoid perf overhead
  78449. */
  78450. get isLocked(): boolean;
  78451. set isLocked(value: boolean);
  78452. /**
  78453. * Updates the bounding sphere and box
  78454. * @param world world matrix to be used to update
  78455. */
  78456. update(world: DeepImmutable<Matrix>): void;
  78457. /**
  78458. * Recreate the bounding info to be centered around a specific point given a specific extend.
  78459. * @param center New center of the bounding info
  78460. * @param extend New extend of the bounding info
  78461. * @returns the current bounding info
  78462. */
  78463. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  78464. /**
  78465. * Scale the current bounding info by applying a scale factor
  78466. * @param factor defines the scale factor to apply
  78467. * @returns the current bounding info
  78468. */
  78469. scale(factor: number): BoundingInfo;
  78470. /**
  78471. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  78472. * @param frustumPlanes defines the frustum to test
  78473. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  78474. * @returns true if the bounding info is in the frustum planes
  78475. */
  78476. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  78477. /**
  78478. * Gets the world distance between the min and max points of the bounding box
  78479. */
  78480. get diagonalLength(): number;
  78481. /**
  78482. * Checks if a cullable object (mesh...) is in the camera frustum
  78483. * Unlike isInFrustum this cheks the full bounding box
  78484. * @param frustumPlanes Camera near/planes
  78485. * @returns true if the object is in frustum otherwise false
  78486. */
  78487. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  78488. /** @hidden */
  78489. _checkCollision(collider: Collider): boolean;
  78490. /**
  78491. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  78492. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  78493. * @param point the point to check intersection with
  78494. * @returns if the point intersects
  78495. */
  78496. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  78497. /**
  78498. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  78499. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  78500. * @param boundingInfo the bounding info to check intersection with
  78501. * @param precise if the intersection should be done using OBB
  78502. * @returns if the bounding info intersects
  78503. */
  78504. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  78505. }
  78506. }
  78507. declare module BABYLON {
  78508. /**
  78509. * Extracts minimum and maximum values from a list of indexed positions
  78510. * @param positions defines the positions to use
  78511. * @param indices defines the indices to the positions
  78512. * @param indexStart defines the start index
  78513. * @param indexCount defines the end index
  78514. * @param bias defines bias value to add to the result
  78515. * @return minimum and maximum values
  78516. */
  78517. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  78518. minimum: Vector3;
  78519. maximum: Vector3;
  78520. };
  78521. /**
  78522. * Extracts minimum and maximum values from a list of positions
  78523. * @param positions defines the positions to use
  78524. * @param start defines the start index in the positions array
  78525. * @param count defines the number of positions to handle
  78526. * @param bias defines bias value to add to the result
  78527. * @param stride defines the stride size to use (distance between two positions in the positions array)
  78528. * @return minimum and maximum values
  78529. */
  78530. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  78531. minimum: Vector3;
  78532. maximum: Vector3;
  78533. };
  78534. }
  78535. declare module BABYLON {
  78536. /** @hidden */
  78537. export class WebGLDataBuffer extends DataBuffer {
  78538. private _buffer;
  78539. constructor(resource: WebGLBuffer);
  78540. get underlyingResource(): any;
  78541. }
  78542. }
  78543. declare module BABYLON {
  78544. /** @hidden */
  78545. export class WebGLPipelineContext implements IPipelineContext {
  78546. engine: ThinEngine;
  78547. program: Nullable<WebGLProgram>;
  78548. context?: WebGLRenderingContext;
  78549. vertexShader?: WebGLShader;
  78550. fragmentShader?: WebGLShader;
  78551. isParallelCompiled: boolean;
  78552. onCompiled?: () => void;
  78553. transformFeedback?: WebGLTransformFeedback | null;
  78554. vertexCompilationError: Nullable<string>;
  78555. fragmentCompilationError: Nullable<string>;
  78556. programLinkError: Nullable<string>;
  78557. programValidationError: Nullable<string>;
  78558. get isAsync(): boolean;
  78559. get isReady(): boolean;
  78560. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  78561. }
  78562. }
  78563. declare module BABYLON {
  78564. interface ThinEngine {
  78565. /**
  78566. * Create an uniform buffer
  78567. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  78568. * @param elements defines the content of the uniform buffer
  78569. * @returns the webGL uniform buffer
  78570. */
  78571. createUniformBuffer(elements: FloatArray): DataBuffer;
  78572. /**
  78573. * Create a dynamic uniform buffer
  78574. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  78575. * @param elements defines the content of the uniform buffer
  78576. * @returns the webGL uniform buffer
  78577. */
  78578. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  78579. /**
  78580. * Update an existing uniform buffer
  78581. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  78582. * @param uniformBuffer defines the target uniform buffer
  78583. * @param elements defines the content to update
  78584. * @param offset defines the offset in the uniform buffer where update should start
  78585. * @param count defines the size of the data to update
  78586. */
  78587. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  78588. /**
  78589. * Bind an uniform buffer to the current webGL context
  78590. * @param buffer defines the buffer to bind
  78591. */
  78592. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  78593. /**
  78594. * Bind a buffer to the current webGL context at a given location
  78595. * @param buffer defines the buffer to bind
  78596. * @param location defines the index where to bind the buffer
  78597. */
  78598. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  78599. /**
  78600. * Bind a specific block at a given index in a specific shader program
  78601. * @param pipelineContext defines the pipeline context to use
  78602. * @param blockName defines the block name
  78603. * @param index defines the index where to bind the block
  78604. */
  78605. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  78606. }
  78607. }
  78608. declare module BABYLON {
  78609. /**
  78610. * Uniform buffer objects.
  78611. *
  78612. * Handles blocks of uniform on the GPU.
  78613. *
  78614. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  78615. *
  78616. * For more information, please refer to :
  78617. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  78618. */
  78619. export class UniformBuffer {
  78620. private _engine;
  78621. private _buffer;
  78622. private _data;
  78623. private _bufferData;
  78624. private _dynamic?;
  78625. private _uniformLocations;
  78626. private _uniformSizes;
  78627. private _uniformLocationPointer;
  78628. private _needSync;
  78629. private _noUBO;
  78630. private _currentEffect;
  78631. /** @hidden */
  78632. _alreadyBound: boolean;
  78633. private static _MAX_UNIFORM_SIZE;
  78634. private static _tempBuffer;
  78635. /**
  78636. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  78637. * This is dynamic to allow compat with webgl 1 and 2.
  78638. * You will need to pass the name of the uniform as well as the value.
  78639. */
  78640. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  78641. /**
  78642. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  78643. * This is dynamic to allow compat with webgl 1 and 2.
  78644. * You will need to pass the name of the uniform as well as the value.
  78645. */
  78646. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  78647. /**
  78648. * Lambda to Update a single float in a uniform buffer.
  78649. * This is dynamic to allow compat with webgl 1 and 2.
  78650. * You will need to pass the name of the uniform as well as the value.
  78651. */
  78652. updateFloat: (name: string, x: number) => void;
  78653. /**
  78654. * Lambda to Update a vec2 of float in a uniform buffer.
  78655. * This is dynamic to allow compat with webgl 1 and 2.
  78656. * You will need to pass the name of the uniform as well as the value.
  78657. */
  78658. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  78659. /**
  78660. * Lambda to Update a vec3 of float in a uniform buffer.
  78661. * This is dynamic to allow compat with webgl 1 and 2.
  78662. * You will need to pass the name of the uniform as well as the value.
  78663. */
  78664. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  78665. /**
  78666. * Lambda to Update a vec4 of float in a uniform buffer.
  78667. * This is dynamic to allow compat with webgl 1 and 2.
  78668. * You will need to pass the name of the uniform as well as the value.
  78669. */
  78670. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  78671. /**
  78672. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  78673. * This is dynamic to allow compat with webgl 1 and 2.
  78674. * You will need to pass the name of the uniform as well as the value.
  78675. */
  78676. updateMatrix: (name: string, mat: Matrix) => void;
  78677. /**
  78678. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  78679. * This is dynamic to allow compat with webgl 1 and 2.
  78680. * You will need to pass the name of the uniform as well as the value.
  78681. */
  78682. updateVector3: (name: string, vector: Vector3) => void;
  78683. /**
  78684. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  78685. * This is dynamic to allow compat with webgl 1 and 2.
  78686. * You will need to pass the name of the uniform as well as the value.
  78687. */
  78688. updateVector4: (name: string, vector: Vector4) => void;
  78689. /**
  78690. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  78691. * This is dynamic to allow compat with webgl 1 and 2.
  78692. * You will need to pass the name of the uniform as well as the value.
  78693. */
  78694. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  78695. /**
  78696. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  78697. * This is dynamic to allow compat with webgl 1 and 2.
  78698. * You will need to pass the name of the uniform as well as the value.
  78699. */
  78700. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  78701. /**
  78702. * Instantiates a new Uniform buffer objects.
  78703. *
  78704. * Handles blocks of uniform on the GPU.
  78705. *
  78706. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  78707. *
  78708. * For more information, please refer to :
  78709. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  78710. * @param engine Define the engine the buffer is associated with
  78711. * @param data Define the data contained in the buffer
  78712. * @param dynamic Define if the buffer is updatable
  78713. */
  78714. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  78715. /**
  78716. * Indicates if the buffer is using the WebGL2 UBO implementation,
  78717. * or just falling back on setUniformXXX calls.
  78718. */
  78719. get useUbo(): boolean;
  78720. /**
  78721. * Indicates if the WebGL underlying uniform buffer is in sync
  78722. * with the javascript cache data.
  78723. */
  78724. get isSync(): boolean;
  78725. /**
  78726. * Indicates if the WebGL underlying uniform buffer is dynamic.
  78727. * Also, a dynamic UniformBuffer will disable cache verification and always
  78728. * update the underlying WebGL uniform buffer to the GPU.
  78729. * @returns if Dynamic, otherwise false
  78730. */
  78731. isDynamic(): boolean;
  78732. /**
  78733. * The data cache on JS side.
  78734. * @returns the underlying data as a float array
  78735. */
  78736. getData(): Float32Array;
  78737. /**
  78738. * The underlying WebGL Uniform buffer.
  78739. * @returns the webgl buffer
  78740. */
  78741. getBuffer(): Nullable<DataBuffer>;
  78742. /**
  78743. * std140 layout specifies how to align data within an UBO structure.
  78744. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  78745. * for specs.
  78746. */
  78747. private _fillAlignment;
  78748. /**
  78749. * Adds an uniform in the buffer.
  78750. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  78751. * for the layout to be correct !
  78752. * @param name Name of the uniform, as used in the uniform block in the shader.
  78753. * @param size Data size, or data directly.
  78754. */
  78755. addUniform(name: string, size: number | number[]): void;
  78756. /**
  78757. * Adds a Matrix 4x4 to the uniform buffer.
  78758. * @param name Name of the uniform, as used in the uniform block in the shader.
  78759. * @param mat A 4x4 matrix.
  78760. */
  78761. addMatrix(name: string, mat: Matrix): void;
  78762. /**
  78763. * Adds a vec2 to the uniform buffer.
  78764. * @param name Name of the uniform, as used in the uniform block in the shader.
  78765. * @param x Define the x component value of the vec2
  78766. * @param y Define the y component value of the vec2
  78767. */
  78768. addFloat2(name: string, x: number, y: number): void;
  78769. /**
  78770. * Adds a vec3 to the uniform buffer.
  78771. * @param name Name of the uniform, as used in the uniform block in the shader.
  78772. * @param x Define the x component value of the vec3
  78773. * @param y Define the y component value of the vec3
  78774. * @param z Define the z component value of the vec3
  78775. */
  78776. addFloat3(name: string, x: number, y: number, z: number): void;
  78777. /**
  78778. * Adds a vec3 to the uniform buffer.
  78779. * @param name Name of the uniform, as used in the uniform block in the shader.
  78780. * @param color Define the vec3 from a Color
  78781. */
  78782. addColor3(name: string, color: Color3): void;
  78783. /**
  78784. * Adds a vec4 to the uniform buffer.
  78785. * @param name Name of the uniform, as used in the uniform block in the shader.
  78786. * @param color Define the rgb components from a Color
  78787. * @param alpha Define the a component of the vec4
  78788. */
  78789. addColor4(name: string, color: Color3, alpha: number): void;
  78790. /**
  78791. * Adds a vec3 to the uniform buffer.
  78792. * @param name Name of the uniform, as used in the uniform block in the shader.
  78793. * @param vector Define the vec3 components from a Vector
  78794. */
  78795. addVector3(name: string, vector: Vector3): void;
  78796. /**
  78797. * Adds a Matrix 3x3 to the uniform buffer.
  78798. * @param name Name of the uniform, as used in the uniform block in the shader.
  78799. */
  78800. addMatrix3x3(name: string): void;
  78801. /**
  78802. * Adds a Matrix 2x2 to the uniform buffer.
  78803. * @param name Name of the uniform, as used in the uniform block in the shader.
  78804. */
  78805. addMatrix2x2(name: string): void;
  78806. /**
  78807. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  78808. */
  78809. create(): void;
  78810. /** @hidden */
  78811. _rebuild(): void;
  78812. /**
  78813. * Updates the WebGL Uniform Buffer on the GPU.
  78814. * If the `dynamic` flag is set to true, no cache comparison is done.
  78815. * Otherwise, the buffer will be updated only if the cache differs.
  78816. */
  78817. update(): void;
  78818. /**
  78819. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  78820. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78821. * @param data Define the flattened data
  78822. * @param size Define the size of the data.
  78823. */
  78824. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  78825. private _valueCache;
  78826. private _cacheMatrix;
  78827. private _updateMatrix3x3ForUniform;
  78828. private _updateMatrix3x3ForEffect;
  78829. private _updateMatrix2x2ForEffect;
  78830. private _updateMatrix2x2ForUniform;
  78831. private _updateFloatForEffect;
  78832. private _updateFloatForUniform;
  78833. private _updateFloat2ForEffect;
  78834. private _updateFloat2ForUniform;
  78835. private _updateFloat3ForEffect;
  78836. private _updateFloat3ForUniform;
  78837. private _updateFloat4ForEffect;
  78838. private _updateFloat4ForUniform;
  78839. private _updateMatrixForEffect;
  78840. private _updateMatrixForUniform;
  78841. private _updateVector3ForEffect;
  78842. private _updateVector3ForUniform;
  78843. private _updateVector4ForEffect;
  78844. private _updateVector4ForUniform;
  78845. private _updateColor3ForEffect;
  78846. private _updateColor3ForUniform;
  78847. private _updateColor4ForEffect;
  78848. private _updateColor4ForUniform;
  78849. /**
  78850. * Sets a sampler uniform on the effect.
  78851. * @param name Define the name of the sampler.
  78852. * @param texture Define the texture to set in the sampler
  78853. */
  78854. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  78855. /**
  78856. * Directly updates the value of the uniform in the cache AND on the GPU.
  78857. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  78858. * @param data Define the flattened data
  78859. */
  78860. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  78861. /**
  78862. * Binds this uniform buffer to an effect.
  78863. * @param effect Define the effect to bind the buffer to
  78864. * @param name Name of the uniform block in the shader.
  78865. */
  78866. bindToEffect(effect: Effect, name: string): void;
  78867. /**
  78868. * Disposes the uniform buffer.
  78869. */
  78870. dispose(): void;
  78871. }
  78872. }
  78873. declare module BABYLON {
  78874. /**
  78875. * Enum that determines the text-wrapping mode to use.
  78876. */
  78877. export enum InspectableType {
  78878. /**
  78879. * Checkbox for booleans
  78880. */
  78881. Checkbox = 0,
  78882. /**
  78883. * Sliders for numbers
  78884. */
  78885. Slider = 1,
  78886. /**
  78887. * Vector3
  78888. */
  78889. Vector3 = 2,
  78890. /**
  78891. * Quaternions
  78892. */
  78893. Quaternion = 3,
  78894. /**
  78895. * Color3
  78896. */
  78897. Color3 = 4,
  78898. /**
  78899. * String
  78900. */
  78901. String = 5
  78902. }
  78903. /**
  78904. * Interface used to define custom inspectable properties.
  78905. * This interface is used by the inspector to display custom property grids
  78906. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78907. */
  78908. export interface IInspectable {
  78909. /**
  78910. * Gets the label to display
  78911. */
  78912. label: string;
  78913. /**
  78914. * Gets the name of the property to edit
  78915. */
  78916. propertyName: string;
  78917. /**
  78918. * Gets the type of the editor to use
  78919. */
  78920. type: InspectableType;
  78921. /**
  78922. * Gets the minimum value of the property when using in "slider" mode
  78923. */
  78924. min?: number;
  78925. /**
  78926. * Gets the maximum value of the property when using in "slider" mode
  78927. */
  78928. max?: number;
  78929. /**
  78930. * Gets the setp to use when using in "slider" mode
  78931. */
  78932. step?: number;
  78933. }
  78934. }
  78935. declare module BABYLON {
  78936. /**
  78937. * Class used to provide helper for timing
  78938. */
  78939. export class TimingTools {
  78940. /**
  78941. * Polyfill for setImmediate
  78942. * @param action defines the action to execute after the current execution block
  78943. */
  78944. static SetImmediate(action: () => void): void;
  78945. }
  78946. }
  78947. declare module BABYLON {
  78948. /**
  78949. * Class used to enable instatition of objects by class name
  78950. */
  78951. export class InstantiationTools {
  78952. /**
  78953. * Use this object to register external classes like custom textures or material
  78954. * to allow the laoders to instantiate them
  78955. */
  78956. static RegisteredExternalClasses: {
  78957. [key: string]: Object;
  78958. };
  78959. /**
  78960. * Tries to instantiate a new object from a given class name
  78961. * @param className defines the class name to instantiate
  78962. * @returns the new object or null if the system was not able to do the instantiation
  78963. */
  78964. static Instantiate(className: string): any;
  78965. }
  78966. }
  78967. declare module BABYLON {
  78968. /**
  78969. * Define options used to create a depth texture
  78970. */
  78971. export class DepthTextureCreationOptions {
  78972. /** Specifies whether or not a stencil should be allocated in the texture */
  78973. generateStencil?: boolean;
  78974. /** Specifies whether or not bilinear filtering is enable on the texture */
  78975. bilinearFiltering?: boolean;
  78976. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  78977. comparisonFunction?: number;
  78978. /** Specifies if the created texture is a cube texture */
  78979. isCube?: boolean;
  78980. }
  78981. }
  78982. declare module BABYLON {
  78983. interface ThinEngine {
  78984. /**
  78985. * Creates a depth stencil cube texture.
  78986. * This is only available in WebGL 2.
  78987. * @param size The size of face edge in the cube texture.
  78988. * @param options The options defining the cube texture.
  78989. * @returns The cube texture
  78990. */
  78991. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  78992. /**
  78993. * Creates a cube texture
  78994. * @param rootUrl defines the url where the files to load is located
  78995. * @param scene defines the current scene
  78996. * @param files defines the list of files to load (1 per face)
  78997. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  78998. * @param onLoad defines an optional callback raised when the texture is loaded
  78999. * @param onError defines an optional callback raised if there is an issue to load the texture
  79000. * @param format defines the format of the data
  79001. * @param forcedExtension defines the extension to use to pick the right loader
  79002. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  79003. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  79004. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  79005. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  79006. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  79007. * @returns the cube texture as an InternalTexture
  79008. */
  79009. 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>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  79010. /**
  79011. * Creates a cube texture
  79012. * @param rootUrl defines the url where the files to load is located
  79013. * @param scene defines the current scene
  79014. * @param files defines the list of files to load (1 per face)
  79015. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  79016. * @param onLoad defines an optional callback raised when the texture is loaded
  79017. * @param onError defines an optional callback raised if there is an issue to load the texture
  79018. * @param format defines the format of the data
  79019. * @param forcedExtension defines the extension to use to pick the right loader
  79020. * @returns the cube texture as an InternalTexture
  79021. */
  79022. 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;
  79023. /**
  79024. * Creates a cube texture
  79025. * @param rootUrl defines the url where the files to load is located
  79026. * @param scene defines the current scene
  79027. * @param files defines the list of files to load (1 per face)
  79028. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  79029. * @param onLoad defines an optional callback raised when the texture is loaded
  79030. * @param onError defines an optional callback raised if there is an issue to load the texture
  79031. * @param format defines the format of the data
  79032. * @param forcedExtension defines the extension to use to pick the right loader
  79033. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  79034. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  79035. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  79036. * @returns the cube texture as an InternalTexture
  79037. */
  79038. 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;
  79039. /** @hidden */
  79040. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  79041. /** @hidden */
  79042. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  79043. /** @hidden */
  79044. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  79045. /** @hidden */
  79046. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  79047. /**
  79048. * @hidden
  79049. */
  79050. _setCubeMapTextureParams(loadMipmap: boolean): void;
  79051. }
  79052. }
  79053. declare module BABYLON {
  79054. /**
  79055. * Class for creating a cube texture
  79056. */
  79057. export class CubeTexture extends BaseTexture {
  79058. private _delayedOnLoad;
  79059. /**
  79060. * The url of the texture
  79061. */
  79062. url: string;
  79063. /**
  79064. * Gets or sets the center of the bounding box associated with the cube texture.
  79065. * It must define where the camera used to render the texture was set
  79066. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  79067. */
  79068. boundingBoxPosition: Vector3;
  79069. private _boundingBoxSize;
  79070. /**
  79071. * Gets or sets the size of the bounding box associated with the cube texture
  79072. * When defined, the cubemap will switch to local mode
  79073. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  79074. * @example https://www.babylonjs-playground.com/#RNASML
  79075. */
  79076. set boundingBoxSize(value: Vector3);
  79077. /**
  79078. * Returns the bounding box size
  79079. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  79080. */
  79081. get boundingBoxSize(): Vector3;
  79082. protected _rotationY: number;
  79083. /**
  79084. * Sets texture matrix rotation angle around Y axis in radians.
  79085. */
  79086. set rotationY(value: number);
  79087. /**
  79088. * Gets texture matrix rotation angle around Y axis radians.
  79089. */
  79090. get rotationY(): number;
  79091. /**
  79092. * Are mip maps generated for this texture or not.
  79093. */
  79094. get noMipmap(): boolean;
  79095. private _noMipmap;
  79096. private _files;
  79097. protected _forcedExtension: Nullable<string>;
  79098. private _extensions;
  79099. private _textureMatrix;
  79100. private _format;
  79101. private _createPolynomials;
  79102. /** @hidden */
  79103. _prefiltered: boolean;
  79104. /**
  79105. * Creates a cube texture from an array of image urls
  79106. * @param files defines an array of image urls
  79107. * @param scene defines the hosting scene
  79108. * @param noMipmap specifies if mip maps are not used
  79109. * @returns a cube texture
  79110. */
  79111. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  79112. /**
  79113. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  79114. * @param url defines the url of the prefiltered texture
  79115. * @param scene defines the scene the texture is attached to
  79116. * @param forcedExtension defines the extension of the file if different from the url
  79117. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  79118. * @return the prefiltered texture
  79119. */
  79120. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  79121. /**
  79122. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  79123. * as prefiltered data.
  79124. * @param rootUrl defines the url of the texture or the root name of the six images
  79125. * @param scene defines the scene the texture is attached to
  79126. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  79127. * @param noMipmap defines if mipmaps should be created or not
  79128. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  79129. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  79130. * @param onError defines a callback triggered in case of error during load
  79131. * @param format defines the internal format to use for the texture once loaded
  79132. * @param prefiltered defines whether or not the texture is created from prefiltered data
  79133. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  79134. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  79135. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  79136. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  79137. * @return the cube texture
  79138. */
  79139. 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);
  79140. /**
  79141. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  79142. */
  79143. get isPrefiltered(): boolean;
  79144. /**
  79145. * Get the current class name of the texture useful for serialization or dynamic coding.
  79146. * @returns "CubeTexture"
  79147. */
  79148. getClassName(): string;
  79149. /**
  79150. * Update the url (and optional buffer) of this texture if url was null during construction.
  79151. * @param url the url of the texture
  79152. * @param forcedExtension defines the extension to use
  79153. * @param onLoad callback called when the texture is loaded (defaults to null)
  79154. * @param prefiltered Defines whether the updated texture is prefiltered or not
  79155. */
  79156. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  79157. /**
  79158. * Delays loading of the cube texture
  79159. * @param forcedExtension defines the extension to use
  79160. */
  79161. delayLoad(forcedExtension?: string): void;
  79162. /**
  79163. * Returns the reflection texture matrix
  79164. * @returns the reflection texture matrix
  79165. */
  79166. getReflectionTextureMatrix(): Matrix;
  79167. /**
  79168. * Sets the reflection texture matrix
  79169. * @param value Reflection texture matrix
  79170. */
  79171. setReflectionTextureMatrix(value: Matrix): void;
  79172. /**
  79173. * Parses text to create a cube texture
  79174. * @param parsedTexture define the serialized text to read from
  79175. * @param scene defines the hosting scene
  79176. * @param rootUrl defines the root url of the cube texture
  79177. * @returns a cube texture
  79178. */
  79179. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  79180. /**
  79181. * Makes a clone, or deep copy, of the cube texture
  79182. * @returns a new cube texture
  79183. */
  79184. clone(): CubeTexture;
  79185. }
  79186. }
  79187. declare module BABYLON {
  79188. /**
  79189. * Manages the defines for the Material
  79190. */
  79191. export class MaterialDefines {
  79192. /** @hidden */
  79193. protected _keys: string[];
  79194. private _isDirty;
  79195. /** @hidden */
  79196. _renderId: number;
  79197. /** @hidden */
  79198. _areLightsDirty: boolean;
  79199. /** @hidden */
  79200. _areLightsDisposed: boolean;
  79201. /** @hidden */
  79202. _areAttributesDirty: boolean;
  79203. /** @hidden */
  79204. _areTexturesDirty: boolean;
  79205. /** @hidden */
  79206. _areFresnelDirty: boolean;
  79207. /** @hidden */
  79208. _areMiscDirty: boolean;
  79209. /** @hidden */
  79210. _areImageProcessingDirty: boolean;
  79211. /** @hidden */
  79212. _normals: boolean;
  79213. /** @hidden */
  79214. _uvs: boolean;
  79215. /** @hidden */
  79216. _needNormals: boolean;
  79217. /** @hidden */
  79218. _needUVs: boolean;
  79219. [id: string]: any;
  79220. /**
  79221. * Specifies if the material needs to be re-calculated
  79222. */
  79223. get isDirty(): boolean;
  79224. /**
  79225. * Marks the material to indicate that it has been re-calculated
  79226. */
  79227. markAsProcessed(): void;
  79228. /**
  79229. * Marks the material to indicate that it needs to be re-calculated
  79230. */
  79231. markAsUnprocessed(): void;
  79232. /**
  79233. * Marks the material to indicate all of its defines need to be re-calculated
  79234. */
  79235. markAllAsDirty(): void;
  79236. /**
  79237. * Marks the material to indicate that image processing needs to be re-calculated
  79238. */
  79239. markAsImageProcessingDirty(): void;
  79240. /**
  79241. * Marks the material to indicate the lights need to be re-calculated
  79242. * @param disposed Defines whether the light is dirty due to dispose or not
  79243. */
  79244. markAsLightDirty(disposed?: boolean): void;
  79245. /**
  79246. * Marks the attribute state as changed
  79247. */
  79248. markAsAttributesDirty(): void;
  79249. /**
  79250. * Marks the texture state as changed
  79251. */
  79252. markAsTexturesDirty(): void;
  79253. /**
  79254. * Marks the fresnel state as changed
  79255. */
  79256. markAsFresnelDirty(): void;
  79257. /**
  79258. * Marks the misc state as changed
  79259. */
  79260. markAsMiscDirty(): void;
  79261. /**
  79262. * Rebuilds the material defines
  79263. */
  79264. rebuild(): void;
  79265. /**
  79266. * Specifies if two material defines are equal
  79267. * @param other - A material define instance to compare to
  79268. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  79269. */
  79270. isEqual(other: MaterialDefines): boolean;
  79271. /**
  79272. * Clones this instance's defines to another instance
  79273. * @param other - material defines to clone values to
  79274. */
  79275. cloneTo(other: MaterialDefines): void;
  79276. /**
  79277. * Resets the material define values
  79278. */
  79279. reset(): void;
  79280. /**
  79281. * Converts the material define values to a string
  79282. * @returns - String of material define information
  79283. */
  79284. toString(): string;
  79285. }
  79286. }
  79287. declare module BABYLON {
  79288. /**
  79289. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  79290. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  79291. * 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;
  79292. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  79293. */
  79294. export class ColorCurves {
  79295. private _dirty;
  79296. private _tempColor;
  79297. private _globalCurve;
  79298. private _highlightsCurve;
  79299. private _midtonesCurve;
  79300. private _shadowsCurve;
  79301. private _positiveCurve;
  79302. private _negativeCurve;
  79303. private _globalHue;
  79304. private _globalDensity;
  79305. private _globalSaturation;
  79306. private _globalExposure;
  79307. /**
  79308. * Gets the global Hue value.
  79309. * 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).
  79310. */
  79311. get globalHue(): number;
  79312. /**
  79313. * Sets the global Hue value.
  79314. * 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).
  79315. */
  79316. set globalHue(value: number);
  79317. /**
  79318. * Gets the global Density value.
  79319. * 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.
  79320. * Values less than zero provide a filter of opposite hue.
  79321. */
  79322. get globalDensity(): number;
  79323. /**
  79324. * Sets the global Density value.
  79325. * 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.
  79326. * Values less than zero provide a filter of opposite hue.
  79327. */
  79328. set globalDensity(value: number);
  79329. /**
  79330. * Gets the global Saturation value.
  79331. * 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.
  79332. */
  79333. get globalSaturation(): number;
  79334. /**
  79335. * Sets the global Saturation value.
  79336. * 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.
  79337. */
  79338. set globalSaturation(value: number);
  79339. /**
  79340. * Gets the global Exposure value.
  79341. * 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.
  79342. */
  79343. get globalExposure(): number;
  79344. /**
  79345. * Sets the global Exposure value.
  79346. * 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.
  79347. */
  79348. set globalExposure(value: number);
  79349. private _highlightsHue;
  79350. private _highlightsDensity;
  79351. private _highlightsSaturation;
  79352. private _highlightsExposure;
  79353. /**
  79354. * Gets the highlights Hue value.
  79355. * 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).
  79356. */
  79357. get highlightsHue(): number;
  79358. /**
  79359. * Sets the highlights Hue value.
  79360. * 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).
  79361. */
  79362. set highlightsHue(value: number);
  79363. /**
  79364. * Gets the highlights Density value.
  79365. * 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.
  79366. * Values less than zero provide a filter of opposite hue.
  79367. */
  79368. get highlightsDensity(): number;
  79369. /**
  79370. * Sets the highlights Density value.
  79371. * 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.
  79372. * Values less than zero provide a filter of opposite hue.
  79373. */
  79374. set highlightsDensity(value: number);
  79375. /**
  79376. * Gets the highlights Saturation value.
  79377. * 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.
  79378. */
  79379. get highlightsSaturation(): number;
  79380. /**
  79381. * Sets the highlights Saturation value.
  79382. * 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.
  79383. */
  79384. set highlightsSaturation(value: number);
  79385. /**
  79386. * Gets the highlights Exposure value.
  79387. * 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.
  79388. */
  79389. get highlightsExposure(): number;
  79390. /**
  79391. * Sets the highlights Exposure value.
  79392. * 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.
  79393. */
  79394. set highlightsExposure(value: number);
  79395. private _midtonesHue;
  79396. private _midtonesDensity;
  79397. private _midtonesSaturation;
  79398. private _midtonesExposure;
  79399. /**
  79400. * Gets the midtones Hue value.
  79401. * 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).
  79402. */
  79403. get midtonesHue(): number;
  79404. /**
  79405. * Sets the midtones Hue value.
  79406. * 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).
  79407. */
  79408. set midtonesHue(value: number);
  79409. /**
  79410. * Gets the midtones Density value.
  79411. * 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.
  79412. * Values less than zero provide a filter of opposite hue.
  79413. */
  79414. get midtonesDensity(): number;
  79415. /**
  79416. * Sets the midtones Density value.
  79417. * 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.
  79418. * Values less than zero provide a filter of opposite hue.
  79419. */
  79420. set midtonesDensity(value: number);
  79421. /**
  79422. * Gets the midtones Saturation value.
  79423. * 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.
  79424. */
  79425. get midtonesSaturation(): number;
  79426. /**
  79427. * Sets the midtones Saturation value.
  79428. * 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.
  79429. */
  79430. set midtonesSaturation(value: number);
  79431. /**
  79432. * Gets the midtones Exposure value.
  79433. * 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.
  79434. */
  79435. get midtonesExposure(): number;
  79436. /**
  79437. * Sets the midtones Exposure value.
  79438. * 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.
  79439. */
  79440. set midtonesExposure(value: number);
  79441. private _shadowsHue;
  79442. private _shadowsDensity;
  79443. private _shadowsSaturation;
  79444. private _shadowsExposure;
  79445. /**
  79446. * Gets the shadows Hue value.
  79447. * 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).
  79448. */
  79449. get shadowsHue(): number;
  79450. /**
  79451. * Sets the shadows Hue value.
  79452. * 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).
  79453. */
  79454. set shadowsHue(value: number);
  79455. /**
  79456. * Gets the shadows Density value.
  79457. * 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.
  79458. * Values less than zero provide a filter of opposite hue.
  79459. */
  79460. get shadowsDensity(): number;
  79461. /**
  79462. * Sets the shadows Density value.
  79463. * 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.
  79464. * Values less than zero provide a filter of opposite hue.
  79465. */
  79466. set shadowsDensity(value: number);
  79467. /**
  79468. * Gets the shadows Saturation value.
  79469. * 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.
  79470. */
  79471. get shadowsSaturation(): number;
  79472. /**
  79473. * Sets the shadows Saturation value.
  79474. * 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.
  79475. */
  79476. set shadowsSaturation(value: number);
  79477. /**
  79478. * Gets the shadows Exposure value.
  79479. * 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.
  79480. */
  79481. get shadowsExposure(): number;
  79482. /**
  79483. * Sets the shadows Exposure value.
  79484. * 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.
  79485. */
  79486. set shadowsExposure(value: number);
  79487. /**
  79488. * Returns the class name
  79489. * @returns The class name
  79490. */
  79491. getClassName(): string;
  79492. /**
  79493. * Binds the color curves to the shader.
  79494. * @param colorCurves The color curve to bind
  79495. * @param effect The effect to bind to
  79496. * @param positiveUniform The positive uniform shader parameter
  79497. * @param neutralUniform The neutral uniform shader parameter
  79498. * @param negativeUniform The negative uniform shader parameter
  79499. */
  79500. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  79501. /**
  79502. * Prepare the list of uniforms associated with the ColorCurves effects.
  79503. * @param uniformsList The list of uniforms used in the effect
  79504. */
  79505. static PrepareUniforms(uniformsList: string[]): void;
  79506. /**
  79507. * Returns color grading data based on a hue, density, saturation and exposure value.
  79508. * @param filterHue The hue of the color filter.
  79509. * @param filterDensity The density of the color filter.
  79510. * @param saturation The saturation.
  79511. * @param exposure The exposure.
  79512. * @param result The result data container.
  79513. */
  79514. private getColorGradingDataToRef;
  79515. /**
  79516. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  79517. * @param value The input slider value in range [-100,100].
  79518. * @returns Adjusted value.
  79519. */
  79520. private static applyColorGradingSliderNonlinear;
  79521. /**
  79522. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  79523. * @param hue The hue (H) input.
  79524. * @param saturation The saturation (S) input.
  79525. * @param brightness The brightness (B) input.
  79526. * @result An RGBA color represented as Vector4.
  79527. */
  79528. private static fromHSBToRef;
  79529. /**
  79530. * Returns a value clamped between min and max
  79531. * @param value The value to clamp
  79532. * @param min The minimum of value
  79533. * @param max The maximum of value
  79534. * @returns The clamped value.
  79535. */
  79536. private static clamp;
  79537. /**
  79538. * Clones the current color curve instance.
  79539. * @return The cloned curves
  79540. */
  79541. clone(): ColorCurves;
  79542. /**
  79543. * Serializes the current color curve instance to a json representation.
  79544. * @return a JSON representation
  79545. */
  79546. serialize(): any;
  79547. /**
  79548. * Parses the color curve from a json representation.
  79549. * @param source the JSON source to parse
  79550. * @return The parsed curves
  79551. */
  79552. static Parse(source: any): ColorCurves;
  79553. }
  79554. }
  79555. declare module BABYLON {
  79556. /**
  79557. * Interface to follow in your material defines to integrate easily the
  79558. * Image proccessing functions.
  79559. * @hidden
  79560. */
  79561. export interface IImageProcessingConfigurationDefines {
  79562. IMAGEPROCESSING: boolean;
  79563. VIGNETTE: boolean;
  79564. VIGNETTEBLENDMODEMULTIPLY: boolean;
  79565. VIGNETTEBLENDMODEOPAQUE: boolean;
  79566. TONEMAPPING: boolean;
  79567. TONEMAPPING_ACES: boolean;
  79568. CONTRAST: boolean;
  79569. EXPOSURE: boolean;
  79570. COLORCURVES: boolean;
  79571. COLORGRADING: boolean;
  79572. COLORGRADING3D: boolean;
  79573. SAMPLER3DGREENDEPTH: boolean;
  79574. SAMPLER3DBGRMAP: boolean;
  79575. IMAGEPROCESSINGPOSTPROCESS: boolean;
  79576. }
  79577. /**
  79578. * @hidden
  79579. */
  79580. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  79581. IMAGEPROCESSING: boolean;
  79582. VIGNETTE: boolean;
  79583. VIGNETTEBLENDMODEMULTIPLY: boolean;
  79584. VIGNETTEBLENDMODEOPAQUE: boolean;
  79585. TONEMAPPING: boolean;
  79586. TONEMAPPING_ACES: boolean;
  79587. CONTRAST: boolean;
  79588. COLORCURVES: boolean;
  79589. COLORGRADING: boolean;
  79590. COLORGRADING3D: boolean;
  79591. SAMPLER3DGREENDEPTH: boolean;
  79592. SAMPLER3DBGRMAP: boolean;
  79593. IMAGEPROCESSINGPOSTPROCESS: boolean;
  79594. EXPOSURE: boolean;
  79595. constructor();
  79596. }
  79597. /**
  79598. * This groups together the common properties used for image processing either in direct forward pass
  79599. * or through post processing effect depending on the use of the image processing pipeline in your scene
  79600. * or not.
  79601. */
  79602. export class ImageProcessingConfiguration {
  79603. /**
  79604. * Default tone mapping applied in BabylonJS.
  79605. */
  79606. static readonly TONEMAPPING_STANDARD: number;
  79607. /**
  79608. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  79609. * to other engines rendering to increase portability.
  79610. */
  79611. static readonly TONEMAPPING_ACES: number;
  79612. /**
  79613. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  79614. */
  79615. colorCurves: Nullable<ColorCurves>;
  79616. private _colorCurvesEnabled;
  79617. /**
  79618. * Gets wether the color curves effect is enabled.
  79619. */
  79620. get colorCurvesEnabled(): boolean;
  79621. /**
  79622. * Sets wether the color curves effect is enabled.
  79623. */
  79624. set colorCurvesEnabled(value: boolean);
  79625. private _colorGradingTexture;
  79626. /**
  79627. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  79628. */
  79629. get colorGradingTexture(): Nullable<BaseTexture>;
  79630. /**
  79631. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  79632. */
  79633. set colorGradingTexture(value: Nullable<BaseTexture>);
  79634. private _colorGradingEnabled;
  79635. /**
  79636. * Gets wether the color grading effect is enabled.
  79637. */
  79638. get colorGradingEnabled(): boolean;
  79639. /**
  79640. * Sets wether the color grading effect is enabled.
  79641. */
  79642. set colorGradingEnabled(value: boolean);
  79643. private _colorGradingWithGreenDepth;
  79644. /**
  79645. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  79646. */
  79647. get colorGradingWithGreenDepth(): boolean;
  79648. /**
  79649. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  79650. */
  79651. set colorGradingWithGreenDepth(value: boolean);
  79652. private _colorGradingBGR;
  79653. /**
  79654. * Gets wether the color grading texture contains BGR values.
  79655. */
  79656. get colorGradingBGR(): boolean;
  79657. /**
  79658. * Sets wether the color grading texture contains BGR values.
  79659. */
  79660. set colorGradingBGR(value: boolean);
  79661. /** @hidden */
  79662. _exposure: number;
  79663. /**
  79664. * Gets the Exposure used in the effect.
  79665. */
  79666. get exposure(): number;
  79667. /**
  79668. * Sets the Exposure used in the effect.
  79669. */
  79670. set exposure(value: number);
  79671. private _toneMappingEnabled;
  79672. /**
  79673. * Gets wether the tone mapping effect is enabled.
  79674. */
  79675. get toneMappingEnabled(): boolean;
  79676. /**
  79677. * Sets wether the tone mapping effect is enabled.
  79678. */
  79679. set toneMappingEnabled(value: boolean);
  79680. private _toneMappingType;
  79681. /**
  79682. * Gets the type of tone mapping effect.
  79683. */
  79684. get toneMappingType(): number;
  79685. /**
  79686. * Sets the type of tone mapping effect used in BabylonJS.
  79687. */
  79688. set toneMappingType(value: number);
  79689. protected _contrast: number;
  79690. /**
  79691. * Gets the contrast used in the effect.
  79692. */
  79693. get contrast(): number;
  79694. /**
  79695. * Sets the contrast used in the effect.
  79696. */
  79697. set contrast(value: number);
  79698. /**
  79699. * Vignette stretch size.
  79700. */
  79701. vignetteStretch: number;
  79702. /**
  79703. * Vignette centre X Offset.
  79704. */
  79705. vignetteCentreX: number;
  79706. /**
  79707. * Vignette centre Y Offset.
  79708. */
  79709. vignetteCentreY: number;
  79710. /**
  79711. * Vignette weight or intensity of the vignette effect.
  79712. */
  79713. vignetteWeight: number;
  79714. /**
  79715. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  79716. * if vignetteEnabled is set to true.
  79717. */
  79718. vignetteColor: Color4;
  79719. /**
  79720. * Camera field of view used by the Vignette effect.
  79721. */
  79722. vignetteCameraFov: number;
  79723. private _vignetteBlendMode;
  79724. /**
  79725. * Gets the vignette blend mode allowing different kind of effect.
  79726. */
  79727. get vignetteBlendMode(): number;
  79728. /**
  79729. * Sets the vignette blend mode allowing different kind of effect.
  79730. */
  79731. set vignetteBlendMode(value: number);
  79732. private _vignetteEnabled;
  79733. /**
  79734. * Gets wether the vignette effect is enabled.
  79735. */
  79736. get vignetteEnabled(): boolean;
  79737. /**
  79738. * Sets wether the vignette effect is enabled.
  79739. */
  79740. set vignetteEnabled(value: boolean);
  79741. private _applyByPostProcess;
  79742. /**
  79743. * Gets wether the image processing is applied through a post process or not.
  79744. */
  79745. get applyByPostProcess(): boolean;
  79746. /**
  79747. * Sets wether the image processing is applied through a post process or not.
  79748. */
  79749. set applyByPostProcess(value: boolean);
  79750. private _isEnabled;
  79751. /**
  79752. * Gets wether the image processing is enabled or not.
  79753. */
  79754. get isEnabled(): boolean;
  79755. /**
  79756. * Sets wether the image processing is enabled or not.
  79757. */
  79758. set isEnabled(value: boolean);
  79759. /**
  79760. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  79761. */
  79762. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  79763. /**
  79764. * Method called each time the image processing information changes requires to recompile the effect.
  79765. */
  79766. protected _updateParameters(): void;
  79767. /**
  79768. * Gets the current class name.
  79769. * @return "ImageProcessingConfiguration"
  79770. */
  79771. getClassName(): string;
  79772. /**
  79773. * Prepare the list of uniforms associated with the Image Processing effects.
  79774. * @param uniforms The list of uniforms used in the effect
  79775. * @param defines the list of defines currently in use
  79776. */
  79777. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  79778. /**
  79779. * Prepare the list of samplers associated with the Image Processing effects.
  79780. * @param samplersList The list of uniforms used in the effect
  79781. * @param defines the list of defines currently in use
  79782. */
  79783. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  79784. /**
  79785. * Prepare the list of defines associated to the shader.
  79786. * @param defines the list of defines to complete
  79787. * @param forPostProcess Define if we are currently in post process mode or not
  79788. */
  79789. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  79790. /**
  79791. * Returns true if all the image processing information are ready.
  79792. * @returns True if ready, otherwise, false
  79793. */
  79794. isReady(): boolean;
  79795. /**
  79796. * Binds the image processing to the shader.
  79797. * @param effect The effect to bind to
  79798. * @param overrideAspectRatio Override the aspect ratio of the effect
  79799. */
  79800. bind(effect: Effect, overrideAspectRatio?: number): void;
  79801. /**
  79802. * Clones the current image processing instance.
  79803. * @return The cloned image processing
  79804. */
  79805. clone(): ImageProcessingConfiguration;
  79806. /**
  79807. * Serializes the current image processing instance to a json representation.
  79808. * @return a JSON representation
  79809. */
  79810. serialize(): any;
  79811. /**
  79812. * Parses the image processing from a json representation.
  79813. * @param source the JSON source to parse
  79814. * @return The parsed image processing
  79815. */
  79816. static Parse(source: any): ImageProcessingConfiguration;
  79817. private static _VIGNETTEMODE_MULTIPLY;
  79818. private static _VIGNETTEMODE_OPAQUE;
  79819. /**
  79820. * Used to apply the vignette as a mix with the pixel color.
  79821. */
  79822. static get VIGNETTEMODE_MULTIPLY(): number;
  79823. /**
  79824. * Used to apply the vignette as a replacement of the pixel color.
  79825. */
  79826. static get VIGNETTEMODE_OPAQUE(): number;
  79827. }
  79828. }
  79829. declare module BABYLON {
  79830. /** @hidden */
  79831. export var postprocessVertexShader: {
  79832. name: string;
  79833. shader: string;
  79834. };
  79835. }
  79836. declare module BABYLON {
  79837. interface ThinEngine {
  79838. /**
  79839. * Creates a new render target texture
  79840. * @param size defines the size of the texture
  79841. * @param options defines the options used to create the texture
  79842. * @returns a new render target texture stored in an InternalTexture
  79843. */
  79844. createRenderTargetTexture(size: number | {
  79845. width: number;
  79846. height: number;
  79847. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  79848. /**
  79849. * Creates a depth stencil texture.
  79850. * This is only available in WebGL 2 or with the depth texture extension available.
  79851. * @param size The size of face edge in the texture.
  79852. * @param options The options defining the texture.
  79853. * @returns The texture
  79854. */
  79855. createDepthStencilTexture(size: number | {
  79856. width: number;
  79857. height: number;
  79858. }, options: DepthTextureCreationOptions): InternalTexture;
  79859. /** @hidden */
  79860. _createDepthStencilTexture(size: number | {
  79861. width: number;
  79862. height: number;
  79863. }, options: DepthTextureCreationOptions): InternalTexture;
  79864. }
  79865. }
  79866. declare module BABYLON {
  79867. /** Defines supported spaces */
  79868. export enum Space {
  79869. /** Local (object) space */
  79870. LOCAL = 0,
  79871. /** World space */
  79872. WORLD = 1,
  79873. /** Bone space */
  79874. BONE = 2
  79875. }
  79876. /** Defines the 3 main axes */
  79877. export class Axis {
  79878. /** X axis */
  79879. static X: Vector3;
  79880. /** Y axis */
  79881. static Y: Vector3;
  79882. /** Z axis */
  79883. static Z: Vector3;
  79884. }
  79885. }
  79886. declare module BABYLON {
  79887. /**
  79888. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  79889. * This is the base of the follow, arc rotate cameras and Free camera
  79890. * @see http://doc.babylonjs.com/features/cameras
  79891. */
  79892. export class TargetCamera extends Camera {
  79893. private static _RigCamTransformMatrix;
  79894. private static _TargetTransformMatrix;
  79895. private static _TargetFocalPoint;
  79896. /**
  79897. * Define the current direction the camera is moving to
  79898. */
  79899. cameraDirection: Vector3;
  79900. /**
  79901. * Define the current rotation the camera is rotating to
  79902. */
  79903. cameraRotation: Vector2;
  79904. /**
  79905. * When set, the up vector of the camera will be updated by the rotation of the camera
  79906. */
  79907. updateUpVectorFromRotation: boolean;
  79908. private _tmpQuaternion;
  79909. /**
  79910. * Define the current rotation of the camera
  79911. */
  79912. rotation: Vector3;
  79913. /**
  79914. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  79915. */
  79916. rotationQuaternion: Quaternion;
  79917. /**
  79918. * Define the current speed of the camera
  79919. */
  79920. speed: number;
  79921. /**
  79922. * Add constraint to the camera to prevent it to move freely in all directions and
  79923. * around all axis.
  79924. */
  79925. noRotationConstraint: boolean;
  79926. /**
  79927. * Define the current target of the camera as an object or a position.
  79928. */
  79929. lockedTarget: any;
  79930. /** @hidden */
  79931. _currentTarget: Vector3;
  79932. /** @hidden */
  79933. _initialFocalDistance: number;
  79934. /** @hidden */
  79935. _viewMatrix: Matrix;
  79936. /** @hidden */
  79937. _camMatrix: Matrix;
  79938. /** @hidden */
  79939. _cameraTransformMatrix: Matrix;
  79940. /** @hidden */
  79941. _cameraRotationMatrix: Matrix;
  79942. /** @hidden */
  79943. _referencePoint: Vector3;
  79944. /** @hidden */
  79945. _transformedReferencePoint: Vector3;
  79946. protected _globalCurrentTarget: Vector3;
  79947. protected _globalCurrentUpVector: Vector3;
  79948. /** @hidden */
  79949. _reset: () => void;
  79950. private _defaultUp;
  79951. /**
  79952. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  79953. * This is the base of the follow, arc rotate cameras and Free camera
  79954. * @see http://doc.babylonjs.com/features/cameras
  79955. * @param name Defines the name of the camera in the scene
  79956. * @param position Defines the start position of the camera in the scene
  79957. * @param scene Defines the scene the camera belongs to
  79958. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79959. */
  79960. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79961. /**
  79962. * Gets the position in front of the camera at a given distance.
  79963. * @param distance The distance from the camera we want the position to be
  79964. * @returns the position
  79965. */
  79966. getFrontPosition(distance: number): Vector3;
  79967. /** @hidden */
  79968. _getLockedTargetPosition(): Nullable<Vector3>;
  79969. private _storedPosition;
  79970. private _storedRotation;
  79971. private _storedRotationQuaternion;
  79972. /**
  79973. * Store current camera state of the camera (fov, position, rotation, etc..)
  79974. * @returns the camera
  79975. */
  79976. storeState(): Camera;
  79977. /**
  79978. * Restored camera state. You must call storeState() first
  79979. * @returns whether it was successful or not
  79980. * @hidden
  79981. */
  79982. _restoreStateValues(): boolean;
  79983. /** @hidden */
  79984. _initCache(): void;
  79985. /** @hidden */
  79986. _updateCache(ignoreParentClass?: boolean): void;
  79987. /** @hidden */
  79988. _isSynchronizedViewMatrix(): boolean;
  79989. /** @hidden */
  79990. _computeLocalCameraSpeed(): number;
  79991. /**
  79992. * Defines the target the camera should look at.
  79993. * @param target Defines the new target as a Vector or a mesh
  79994. */
  79995. setTarget(target: Vector3): void;
  79996. /**
  79997. * Return the current target position of the camera. This value is expressed in local space.
  79998. * @returns the target position
  79999. */
  80000. getTarget(): Vector3;
  80001. /** @hidden */
  80002. _decideIfNeedsToMove(): boolean;
  80003. /** @hidden */
  80004. _updatePosition(): void;
  80005. /** @hidden */
  80006. _checkInputs(): void;
  80007. protected _updateCameraRotationMatrix(): void;
  80008. /**
  80009. * 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)
  80010. * @returns the current camera
  80011. */
  80012. private _rotateUpVectorWithCameraRotationMatrix;
  80013. private _cachedRotationZ;
  80014. private _cachedQuaternionRotationZ;
  80015. /** @hidden */
  80016. _getViewMatrix(): Matrix;
  80017. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  80018. /**
  80019. * @hidden
  80020. */
  80021. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  80022. /**
  80023. * @hidden
  80024. */
  80025. _updateRigCameras(): void;
  80026. private _getRigCamPositionAndTarget;
  80027. /**
  80028. * Gets the current object class name.
  80029. * @return the class name
  80030. */
  80031. getClassName(): string;
  80032. }
  80033. }
  80034. declare module BABYLON {
  80035. /**
  80036. * Gather the list of keyboard event types as constants.
  80037. */
  80038. export class KeyboardEventTypes {
  80039. /**
  80040. * The keydown event is fired when a key becomes active (pressed).
  80041. */
  80042. static readonly KEYDOWN: number;
  80043. /**
  80044. * The keyup event is fired when a key has been released.
  80045. */
  80046. static readonly KEYUP: number;
  80047. }
  80048. /**
  80049. * This class is used to store keyboard related info for the onKeyboardObservable event.
  80050. */
  80051. export class KeyboardInfo {
  80052. /**
  80053. * Defines the type of event (KeyboardEventTypes)
  80054. */
  80055. type: number;
  80056. /**
  80057. * Defines the related dom event
  80058. */
  80059. event: KeyboardEvent;
  80060. /**
  80061. * Instantiates a new keyboard info.
  80062. * This class is used to store keyboard related info for the onKeyboardObservable event.
  80063. * @param type Defines the type of event (KeyboardEventTypes)
  80064. * @param event Defines the related dom event
  80065. */
  80066. constructor(
  80067. /**
  80068. * Defines the type of event (KeyboardEventTypes)
  80069. */
  80070. type: number,
  80071. /**
  80072. * Defines the related dom event
  80073. */
  80074. event: KeyboardEvent);
  80075. }
  80076. /**
  80077. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  80078. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  80079. */
  80080. export class KeyboardInfoPre extends KeyboardInfo {
  80081. /**
  80082. * Defines the type of event (KeyboardEventTypes)
  80083. */
  80084. type: number;
  80085. /**
  80086. * Defines the related dom event
  80087. */
  80088. event: KeyboardEvent;
  80089. /**
  80090. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  80091. */
  80092. skipOnPointerObservable: boolean;
  80093. /**
  80094. * Instantiates a new keyboard pre info.
  80095. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  80096. * @param type Defines the type of event (KeyboardEventTypes)
  80097. * @param event Defines the related dom event
  80098. */
  80099. constructor(
  80100. /**
  80101. * Defines the type of event (KeyboardEventTypes)
  80102. */
  80103. type: number,
  80104. /**
  80105. * Defines the related dom event
  80106. */
  80107. event: KeyboardEvent);
  80108. }
  80109. }
  80110. declare module BABYLON {
  80111. /**
  80112. * Manage the keyboard inputs to control the movement of a free camera.
  80113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80114. */
  80115. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  80116. /**
  80117. * Defines the camera the input is attached to.
  80118. */
  80119. camera: FreeCamera;
  80120. /**
  80121. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  80122. */
  80123. keysUp: number[];
  80124. /**
  80125. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  80126. */
  80127. keysDown: number[];
  80128. /**
  80129. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  80130. */
  80131. keysLeft: number[];
  80132. /**
  80133. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  80134. */
  80135. keysRight: number[];
  80136. private _keys;
  80137. private _onCanvasBlurObserver;
  80138. private _onKeyboardObserver;
  80139. private _engine;
  80140. private _scene;
  80141. /**
  80142. * Attach the input controls to a specific dom element to get the input from.
  80143. * @param element Defines the element the controls should be listened from
  80144. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80145. */
  80146. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80147. /**
  80148. * Detach the current controls from the specified dom element.
  80149. * @param element Defines the element to stop listening the inputs from
  80150. */
  80151. detachControl(element: Nullable<HTMLElement>): void;
  80152. /**
  80153. * Update the current camera state depending on the inputs that have been used this frame.
  80154. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80155. */
  80156. checkInputs(): void;
  80157. /**
  80158. * Gets the class name of the current intput.
  80159. * @returns the class name
  80160. */
  80161. getClassName(): string;
  80162. /** @hidden */
  80163. _onLostFocus(): void;
  80164. /**
  80165. * Get the friendly name associated with the input class.
  80166. * @returns the input friendly name
  80167. */
  80168. getSimpleName(): string;
  80169. }
  80170. }
  80171. declare module BABYLON {
  80172. /**
  80173. * Interface describing all the common properties and methods a shadow light needs to implement.
  80174. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  80175. * as well as binding the different shadow properties to the effects.
  80176. */
  80177. export interface IShadowLight extends Light {
  80178. /**
  80179. * The light id in the scene (used in scene.findLighById for instance)
  80180. */
  80181. id: string;
  80182. /**
  80183. * The position the shdow will be casted from.
  80184. */
  80185. position: Vector3;
  80186. /**
  80187. * In 2d mode (needCube being false), the direction used to cast the shadow.
  80188. */
  80189. direction: Vector3;
  80190. /**
  80191. * The transformed position. Position of the light in world space taking parenting in account.
  80192. */
  80193. transformedPosition: Vector3;
  80194. /**
  80195. * The transformed direction. Direction of the light in world space taking parenting in account.
  80196. */
  80197. transformedDirection: Vector3;
  80198. /**
  80199. * The friendly name of the light in the scene.
  80200. */
  80201. name: string;
  80202. /**
  80203. * Defines the shadow projection clipping minimum z value.
  80204. */
  80205. shadowMinZ: number;
  80206. /**
  80207. * Defines the shadow projection clipping maximum z value.
  80208. */
  80209. shadowMaxZ: number;
  80210. /**
  80211. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  80212. * @returns true if the information has been computed, false if it does not need to (no parenting)
  80213. */
  80214. computeTransformedInformation(): boolean;
  80215. /**
  80216. * Gets the scene the light belongs to.
  80217. * @returns The scene
  80218. */
  80219. getScene(): Scene;
  80220. /**
  80221. * Callback defining a custom Projection Matrix Builder.
  80222. * This can be used to override the default projection matrix computation.
  80223. */
  80224. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  80225. /**
  80226. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  80227. * @param matrix The materix to updated with the projection information
  80228. * @param viewMatrix The transform matrix of the light
  80229. * @param renderList The list of mesh to render in the map
  80230. * @returns The current light
  80231. */
  80232. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  80233. /**
  80234. * Gets the current depth scale used in ESM.
  80235. * @returns The scale
  80236. */
  80237. getDepthScale(): number;
  80238. /**
  80239. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  80240. * @returns true if a cube texture needs to be use
  80241. */
  80242. needCube(): boolean;
  80243. /**
  80244. * Detects if the projection matrix requires to be recomputed this frame.
  80245. * @returns true if it requires to be recomputed otherwise, false.
  80246. */
  80247. needProjectionMatrixCompute(): boolean;
  80248. /**
  80249. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  80250. */
  80251. forceProjectionMatrixCompute(): void;
  80252. /**
  80253. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  80254. * @param faceIndex The index of the face we are computed the direction to generate shadow
  80255. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  80256. */
  80257. getShadowDirection(faceIndex?: number): Vector3;
  80258. /**
  80259. * Gets the minZ used for shadow according to both the scene and the light.
  80260. * @param activeCamera The camera we are returning the min for
  80261. * @returns the depth min z
  80262. */
  80263. getDepthMinZ(activeCamera: Camera): number;
  80264. /**
  80265. * Gets the maxZ used for shadow according to both the scene and the light.
  80266. * @param activeCamera The camera we are returning the max for
  80267. * @returns the depth max z
  80268. */
  80269. getDepthMaxZ(activeCamera: Camera): number;
  80270. }
  80271. /**
  80272. * Base implementation IShadowLight
  80273. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  80274. */
  80275. export abstract class ShadowLight extends Light implements IShadowLight {
  80276. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  80277. protected _position: Vector3;
  80278. protected _setPosition(value: Vector3): void;
  80279. /**
  80280. * Sets the position the shadow will be casted from. Also use as the light position for both
  80281. * point and spot lights.
  80282. */
  80283. get position(): Vector3;
  80284. /**
  80285. * Sets the position the shadow will be casted from. Also use as the light position for both
  80286. * point and spot lights.
  80287. */
  80288. set position(value: Vector3);
  80289. protected _direction: Vector3;
  80290. protected _setDirection(value: Vector3): void;
  80291. /**
  80292. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  80293. * Also use as the light direction on spot and directional lights.
  80294. */
  80295. get direction(): Vector3;
  80296. /**
  80297. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  80298. * Also use as the light direction on spot and directional lights.
  80299. */
  80300. set direction(value: Vector3);
  80301. protected _shadowMinZ: number;
  80302. /**
  80303. * Gets the shadow projection clipping minimum z value.
  80304. */
  80305. get shadowMinZ(): number;
  80306. /**
  80307. * Sets the shadow projection clipping minimum z value.
  80308. */
  80309. set shadowMinZ(value: number);
  80310. protected _shadowMaxZ: number;
  80311. /**
  80312. * Sets the shadow projection clipping maximum z value.
  80313. */
  80314. get shadowMaxZ(): number;
  80315. /**
  80316. * Gets the shadow projection clipping maximum z value.
  80317. */
  80318. set shadowMaxZ(value: number);
  80319. /**
  80320. * Callback defining a custom Projection Matrix Builder.
  80321. * This can be used to override the default projection matrix computation.
  80322. */
  80323. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  80324. /**
  80325. * The transformed position. Position of the light in world space taking parenting in account.
  80326. */
  80327. transformedPosition: Vector3;
  80328. /**
  80329. * The transformed direction. Direction of the light in world space taking parenting in account.
  80330. */
  80331. transformedDirection: Vector3;
  80332. private _needProjectionMatrixCompute;
  80333. /**
  80334. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  80335. * @returns true if the information has been computed, false if it does not need to (no parenting)
  80336. */
  80337. computeTransformedInformation(): boolean;
  80338. /**
  80339. * Return the depth scale used for the shadow map.
  80340. * @returns the depth scale.
  80341. */
  80342. getDepthScale(): number;
  80343. /**
  80344. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  80345. * @param faceIndex The index of the face we are computed the direction to generate shadow
  80346. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  80347. */
  80348. getShadowDirection(faceIndex?: number): Vector3;
  80349. /**
  80350. * Returns the ShadowLight absolute position in the World.
  80351. * @returns the position vector in world space
  80352. */
  80353. getAbsolutePosition(): Vector3;
  80354. /**
  80355. * Sets the ShadowLight direction toward the passed target.
  80356. * @param target The point to target in local space
  80357. * @returns the updated ShadowLight direction
  80358. */
  80359. setDirectionToTarget(target: Vector3): Vector3;
  80360. /**
  80361. * Returns the light rotation in euler definition.
  80362. * @returns the x y z rotation in local space.
  80363. */
  80364. getRotation(): Vector3;
  80365. /**
  80366. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  80367. * @returns true if a cube texture needs to be use
  80368. */
  80369. needCube(): boolean;
  80370. /**
  80371. * Detects if the projection matrix requires to be recomputed this frame.
  80372. * @returns true if it requires to be recomputed otherwise, false.
  80373. */
  80374. needProjectionMatrixCompute(): boolean;
  80375. /**
  80376. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  80377. */
  80378. forceProjectionMatrixCompute(): void;
  80379. /** @hidden */
  80380. _initCache(): void;
  80381. /** @hidden */
  80382. _isSynchronized(): boolean;
  80383. /**
  80384. * Computes the world matrix of the node
  80385. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80386. * @returns the world matrix
  80387. */
  80388. computeWorldMatrix(force?: boolean): Matrix;
  80389. /**
  80390. * Gets the minZ used for shadow according to both the scene and the light.
  80391. * @param activeCamera The camera we are returning the min for
  80392. * @returns the depth min z
  80393. */
  80394. getDepthMinZ(activeCamera: Camera): number;
  80395. /**
  80396. * Gets the maxZ used for shadow according to both the scene and the light.
  80397. * @param activeCamera The camera we are returning the max for
  80398. * @returns the depth max z
  80399. */
  80400. getDepthMaxZ(activeCamera: Camera): number;
  80401. /**
  80402. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  80403. * @param matrix The materix to updated with the projection information
  80404. * @param viewMatrix The transform matrix of the light
  80405. * @param renderList The list of mesh to render in the map
  80406. * @returns The current light
  80407. */
  80408. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  80409. }
  80410. }
  80411. declare module BABYLON {
  80412. /**
  80413. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  80414. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  80415. */
  80416. export class EffectFallbacks implements IEffectFallbacks {
  80417. private _defines;
  80418. private _currentRank;
  80419. private _maxRank;
  80420. private _mesh;
  80421. /**
  80422. * Removes the fallback from the bound mesh.
  80423. */
  80424. unBindMesh(): void;
  80425. /**
  80426. * Adds a fallback on the specified property.
  80427. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  80428. * @param define The name of the define in the shader
  80429. */
  80430. addFallback(rank: number, define: string): void;
  80431. /**
  80432. * Sets the mesh to use CPU skinning when needing to fallback.
  80433. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  80434. * @param mesh The mesh to use the fallbacks.
  80435. */
  80436. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  80437. /**
  80438. * Checks to see if more fallbacks are still availible.
  80439. */
  80440. get hasMoreFallbacks(): boolean;
  80441. /**
  80442. * Removes the defines that should be removed when falling back.
  80443. * @param currentDefines defines the current define statements for the shader.
  80444. * @param effect defines the current effect we try to compile
  80445. * @returns The resulting defines with defines of the current rank removed.
  80446. */
  80447. reduce(currentDefines: string, effect: Effect): string;
  80448. }
  80449. }
  80450. declare module BABYLON {
  80451. /**
  80452. * "Static Class" containing the most commonly used helper while dealing with material for
  80453. * rendering purpose.
  80454. *
  80455. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  80456. *
  80457. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  80458. */
  80459. export class MaterialHelper {
  80460. /**
  80461. * Bind the current view position to an effect.
  80462. * @param effect The effect to be bound
  80463. * @param scene The scene the eyes position is used from
  80464. */
  80465. static BindEyePosition(effect: Effect, scene: Scene): void;
  80466. /**
  80467. * Helps preparing the defines values about the UVs in used in the effect.
  80468. * UVs are shared as much as we can accross channels in the shaders.
  80469. * @param texture The texture we are preparing the UVs for
  80470. * @param defines The defines to update
  80471. * @param key The channel key "diffuse", "specular"... used in the shader
  80472. */
  80473. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  80474. /**
  80475. * Binds a texture matrix value to its corrsponding uniform
  80476. * @param texture The texture to bind the matrix for
  80477. * @param uniformBuffer The uniform buffer receivin the data
  80478. * @param key The channel key "diffuse", "specular"... used in the shader
  80479. */
  80480. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  80481. /**
  80482. * Gets the current status of the fog (should it be enabled?)
  80483. * @param mesh defines the mesh to evaluate for fog support
  80484. * @param scene defines the hosting scene
  80485. * @returns true if fog must be enabled
  80486. */
  80487. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  80488. /**
  80489. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  80490. * @param mesh defines the current mesh
  80491. * @param scene defines the current scene
  80492. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  80493. * @param pointsCloud defines if point cloud rendering has to be turned on
  80494. * @param fogEnabled defines if fog has to be turned on
  80495. * @param alphaTest defines if alpha testing has to be turned on
  80496. * @param defines defines the current list of defines
  80497. */
  80498. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  80499. /**
  80500. * Helper used to prepare the list of defines associated with frame values for shader compilation
  80501. * @param scene defines the current scene
  80502. * @param engine defines the current engine
  80503. * @param defines specifies the list of active defines
  80504. * @param useInstances defines if instances have to be turned on
  80505. * @param useClipPlane defines if clip plane have to be turned on
  80506. */
  80507. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  80508. /**
  80509. * Prepares the defines for bones
  80510. * @param mesh The mesh containing the geometry data we will draw
  80511. * @param defines The defines to update
  80512. */
  80513. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  80514. /**
  80515. * Prepares the defines for morph targets
  80516. * @param mesh The mesh containing the geometry data we will draw
  80517. * @param defines The defines to update
  80518. */
  80519. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  80520. /**
  80521. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  80522. * @param mesh The mesh containing the geometry data we will draw
  80523. * @param defines The defines to update
  80524. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  80525. * @param useBones Precise whether bones should be used or not (override mesh info)
  80526. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  80527. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  80528. * @returns false if defines are considered not dirty and have not been checked
  80529. */
  80530. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  80531. /**
  80532. * Prepares the defines related to multiview
  80533. * @param scene The scene we are intending to draw
  80534. * @param defines The defines to update
  80535. */
  80536. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  80537. /**
  80538. * Prepares the defines related to the light information passed in parameter
  80539. * @param scene The scene we are intending to draw
  80540. * @param mesh The mesh the effect is compiling for
  80541. * @param light The light the effect is compiling for
  80542. * @param lightIndex The index of the light
  80543. * @param defines The defines to update
  80544. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  80545. * @param state Defines the current state regarding what is needed (normals, etc...)
  80546. */
  80547. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  80548. needNormals: boolean;
  80549. needRebuild: boolean;
  80550. shadowEnabled: boolean;
  80551. specularEnabled: boolean;
  80552. lightmapMode: boolean;
  80553. }): void;
  80554. /**
  80555. * Prepares the defines related to the light information passed in parameter
  80556. * @param scene The scene we are intending to draw
  80557. * @param mesh The mesh the effect is compiling for
  80558. * @param defines The defines to update
  80559. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  80560. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  80561. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  80562. * @returns true if normals will be required for the rest of the effect
  80563. */
  80564. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  80565. /**
  80566. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  80567. * @param lightIndex defines the light index
  80568. * @param uniformsList The uniform list
  80569. * @param samplersList The sampler list
  80570. * @param projectedLightTexture defines if projected texture must be used
  80571. * @param uniformBuffersList defines an optional list of uniform buffers
  80572. */
  80573. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  80574. /**
  80575. * Prepares the uniforms and samplers list to be used in the effect
  80576. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  80577. * @param samplersList The sampler list
  80578. * @param defines The defines helping in the list generation
  80579. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  80580. */
  80581. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  80582. /**
  80583. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  80584. * @param defines The defines to update while falling back
  80585. * @param fallbacks The authorized effect fallbacks
  80586. * @param maxSimultaneousLights The maximum number of lights allowed
  80587. * @param rank the current rank of the Effect
  80588. * @returns The newly affected rank
  80589. */
  80590. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  80591. private static _TmpMorphInfluencers;
  80592. /**
  80593. * Prepares the list of attributes required for morph targets according to the effect defines.
  80594. * @param attribs The current list of supported attribs
  80595. * @param mesh The mesh to prepare the morph targets attributes for
  80596. * @param influencers The number of influencers
  80597. */
  80598. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  80599. /**
  80600. * Prepares the list of attributes required for morph targets according to the effect defines.
  80601. * @param attribs The current list of supported attribs
  80602. * @param mesh The mesh to prepare the morph targets attributes for
  80603. * @param defines The current Defines of the effect
  80604. */
  80605. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  80606. /**
  80607. * Prepares the list of attributes required for bones according to the effect defines.
  80608. * @param attribs The current list of supported attribs
  80609. * @param mesh The mesh to prepare the bones attributes for
  80610. * @param defines The current Defines of the effect
  80611. * @param fallbacks The current efffect fallback strategy
  80612. */
  80613. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  80614. /**
  80615. * Check and prepare the list of attributes required for instances according to the effect defines.
  80616. * @param attribs The current list of supported attribs
  80617. * @param defines The current MaterialDefines of the effect
  80618. */
  80619. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  80620. /**
  80621. * Add the list of attributes required for instances to the attribs array.
  80622. * @param attribs The current list of supported attribs
  80623. */
  80624. static PushAttributesForInstances(attribs: string[]): void;
  80625. /**
  80626. * Binds the light information to the effect.
  80627. * @param light The light containing the generator
  80628. * @param effect The effect we are binding the data to
  80629. * @param lightIndex The light index in the effect used to render
  80630. */
  80631. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  80632. /**
  80633. * Binds the lights information from the scene to the effect for the given mesh.
  80634. * @param light Light to bind
  80635. * @param lightIndex Light index
  80636. * @param scene The scene where the light belongs to
  80637. * @param effect The effect we are binding the data to
  80638. * @param useSpecular Defines if specular is supported
  80639. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80640. */
  80641. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  80642. /**
  80643. * Binds the lights information from the scene to the effect for the given mesh.
  80644. * @param scene The scene the lights belongs to
  80645. * @param mesh The mesh we are binding the information to render
  80646. * @param effect The effect we are binding the data to
  80647. * @param defines The generated defines for the effect
  80648. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  80649. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  80650. */
  80651. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  80652. private static _tempFogColor;
  80653. /**
  80654. * Binds the fog information from the scene to the effect for the given mesh.
  80655. * @param scene The scene the lights belongs to
  80656. * @param mesh The mesh we are binding the information to render
  80657. * @param effect The effect we are binding the data to
  80658. * @param linearSpace Defines if the fog effect is applied in linear space
  80659. */
  80660. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  80661. /**
  80662. * Binds the bones information from the mesh to the effect.
  80663. * @param mesh The mesh we are binding the information to render
  80664. * @param effect The effect we are binding the data to
  80665. */
  80666. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  80667. /**
  80668. * Binds the morph targets information from the mesh to the effect.
  80669. * @param abstractMesh The mesh we are binding the information to render
  80670. * @param effect The effect we are binding the data to
  80671. */
  80672. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  80673. /**
  80674. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  80675. * @param defines The generated defines used in the effect
  80676. * @param effect The effect we are binding the data to
  80677. * @param scene The scene we are willing to render with logarithmic scale for
  80678. */
  80679. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  80680. /**
  80681. * Binds the clip plane information from the scene to the effect.
  80682. * @param scene The scene the clip plane information are extracted from
  80683. * @param effect The effect we are binding the data to
  80684. */
  80685. static BindClipPlane(effect: Effect, scene: Scene): void;
  80686. }
  80687. }
  80688. declare module BABYLON {
  80689. /** @hidden */
  80690. export var packingFunctions: {
  80691. name: string;
  80692. shader: string;
  80693. };
  80694. }
  80695. declare module BABYLON {
  80696. /** @hidden */
  80697. export var shadowMapPixelShader: {
  80698. name: string;
  80699. shader: string;
  80700. };
  80701. }
  80702. declare module BABYLON {
  80703. /** @hidden */
  80704. export var bonesDeclaration: {
  80705. name: string;
  80706. shader: string;
  80707. };
  80708. }
  80709. declare module BABYLON {
  80710. /** @hidden */
  80711. export var morphTargetsVertexGlobalDeclaration: {
  80712. name: string;
  80713. shader: string;
  80714. };
  80715. }
  80716. declare module BABYLON {
  80717. /** @hidden */
  80718. export var morphTargetsVertexDeclaration: {
  80719. name: string;
  80720. shader: string;
  80721. };
  80722. }
  80723. declare module BABYLON {
  80724. /** @hidden */
  80725. export var instancesDeclaration: {
  80726. name: string;
  80727. shader: string;
  80728. };
  80729. }
  80730. declare module BABYLON {
  80731. /** @hidden */
  80732. export var helperFunctions: {
  80733. name: string;
  80734. shader: string;
  80735. };
  80736. }
  80737. declare module BABYLON {
  80738. /** @hidden */
  80739. export var morphTargetsVertex: {
  80740. name: string;
  80741. shader: string;
  80742. };
  80743. }
  80744. declare module BABYLON {
  80745. /** @hidden */
  80746. export var instancesVertex: {
  80747. name: string;
  80748. shader: string;
  80749. };
  80750. }
  80751. declare module BABYLON {
  80752. /** @hidden */
  80753. export var bonesVertex: {
  80754. name: string;
  80755. shader: string;
  80756. };
  80757. }
  80758. declare module BABYLON {
  80759. /** @hidden */
  80760. export var shadowMapVertexShader: {
  80761. name: string;
  80762. shader: string;
  80763. };
  80764. }
  80765. declare module BABYLON {
  80766. /** @hidden */
  80767. export var depthBoxBlurPixelShader: {
  80768. name: string;
  80769. shader: string;
  80770. };
  80771. }
  80772. declare module BABYLON {
  80773. /**
  80774. * Defines the options associated with the creation of a custom shader for a shadow generator.
  80775. */
  80776. export interface ICustomShaderOptions {
  80777. /**
  80778. * Gets or sets the custom shader name to use
  80779. */
  80780. shaderName: string;
  80781. /**
  80782. * The list of attribute names used in the shader
  80783. */
  80784. attributes?: string[];
  80785. /**
  80786. * The list of unifrom names used in the shader
  80787. */
  80788. uniforms?: string[];
  80789. /**
  80790. * The list of sampler names used in the shader
  80791. */
  80792. samplers?: string[];
  80793. /**
  80794. * The list of defines used in the shader
  80795. */
  80796. defines?: string[];
  80797. }
  80798. /**
  80799. * Interface to implement to create a shadow generator compatible with BJS.
  80800. */
  80801. export interface IShadowGenerator {
  80802. /**
  80803. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  80804. * @returns The render target texture if present otherwise, null
  80805. */
  80806. getShadowMap(): Nullable<RenderTargetTexture>;
  80807. /**
  80808. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  80809. * @returns The render target texture if the shadow map is present otherwise, null
  80810. */
  80811. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  80812. /**
  80813. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  80814. * @param subMesh The submesh we want to render in the shadow map
  80815. * @param useInstances Defines wether will draw in the map using instances
  80816. * @returns true if ready otherwise, false
  80817. */
  80818. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  80819. /**
  80820. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  80821. * @param defines Defines of the material we want to update
  80822. * @param lightIndex Index of the light in the enabled light list of the material
  80823. */
  80824. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  80825. /**
  80826. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  80827. * defined in the generator but impacting the effect).
  80828. * It implies the unifroms available on the materials are the standard BJS ones.
  80829. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  80830. * @param effect The effect we are binfing the information for
  80831. */
  80832. bindShadowLight(lightIndex: string, effect: Effect): void;
  80833. /**
  80834. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  80835. * (eq to shadow prjection matrix * light transform matrix)
  80836. * @returns The transform matrix used to create the shadow map
  80837. */
  80838. getTransformMatrix(): Matrix;
  80839. /**
  80840. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  80841. * Cube and 2D textures for instance.
  80842. */
  80843. recreateShadowMap(): void;
  80844. /**
  80845. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80846. * @param onCompiled Callback triggered at the and of the effects compilation
  80847. * @param options Sets of optional options forcing the compilation with different modes
  80848. */
  80849. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  80850. useInstances: boolean;
  80851. }>): void;
  80852. /**
  80853. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  80854. * @param options Sets of optional options forcing the compilation with different modes
  80855. * @returns A promise that resolves when the compilation completes
  80856. */
  80857. forceCompilationAsync(options?: Partial<{
  80858. useInstances: boolean;
  80859. }>): Promise<void>;
  80860. /**
  80861. * Serializes the shadow generator setup to a json object.
  80862. * @returns The serialized JSON object
  80863. */
  80864. serialize(): any;
  80865. /**
  80866. * Disposes the Shadow map and related Textures and effects.
  80867. */
  80868. dispose(): void;
  80869. }
  80870. /**
  80871. * Default implementation IShadowGenerator.
  80872. * This is the main object responsible of generating shadows in the framework.
  80873. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  80874. */
  80875. export class ShadowGenerator implements IShadowGenerator {
  80876. /**
  80877. * Shadow generator mode None: no filtering applied.
  80878. */
  80879. static readonly FILTER_NONE: number;
  80880. /**
  80881. * Shadow generator mode ESM: Exponential Shadow Mapping.
  80882. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80883. */
  80884. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  80885. /**
  80886. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  80887. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  80888. */
  80889. static readonly FILTER_POISSONSAMPLING: number;
  80890. /**
  80891. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  80892. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80893. */
  80894. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  80895. /**
  80896. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  80897. * edge artifacts on steep falloff.
  80898. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80899. */
  80900. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  80901. /**
  80902. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  80903. * edge artifacts on steep falloff.
  80904. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  80905. */
  80906. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  80907. /**
  80908. * Shadow generator mode PCF: Percentage Closer Filtering
  80909. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80910. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  80911. */
  80912. static readonly FILTER_PCF: number;
  80913. /**
  80914. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  80915. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  80916. * Contact Hardening
  80917. */
  80918. static readonly FILTER_PCSS: number;
  80919. /**
  80920. * Reserved for PCF and PCSS
  80921. * Highest Quality.
  80922. *
  80923. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  80924. *
  80925. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  80926. */
  80927. static readonly QUALITY_HIGH: number;
  80928. /**
  80929. * Reserved for PCF and PCSS
  80930. * Good tradeoff for quality/perf cross devices
  80931. *
  80932. * Execute PCF on a 3*3 kernel.
  80933. *
  80934. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  80935. */
  80936. static readonly QUALITY_MEDIUM: number;
  80937. /**
  80938. * Reserved for PCF and PCSS
  80939. * The lowest quality but the fastest.
  80940. *
  80941. * Execute PCF on a 1*1 kernel.
  80942. *
  80943. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  80944. */
  80945. static readonly QUALITY_LOW: number;
  80946. /** Gets or sets the custom shader name to use */
  80947. customShaderOptions: ICustomShaderOptions;
  80948. /**
  80949. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  80950. */
  80951. onBeforeShadowMapRenderObservable: Observable<Effect>;
  80952. /**
  80953. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  80954. */
  80955. onAfterShadowMapRenderObservable: Observable<Effect>;
  80956. /**
  80957. * Observable triggered before a mesh is rendered in the shadow map.
  80958. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  80959. */
  80960. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  80961. /**
  80962. * Observable triggered after a mesh is rendered in the shadow map.
  80963. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  80964. */
  80965. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  80966. private _bias;
  80967. /**
  80968. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  80969. */
  80970. get bias(): number;
  80971. /**
  80972. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  80973. */
  80974. set bias(bias: number);
  80975. private _normalBias;
  80976. /**
  80977. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80978. */
  80979. get normalBias(): number;
  80980. /**
  80981. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  80982. */
  80983. set normalBias(normalBias: number);
  80984. private _blurBoxOffset;
  80985. /**
  80986. * Gets the blur box offset: offset applied during the blur pass.
  80987. * Only useful if useKernelBlur = false
  80988. */
  80989. get blurBoxOffset(): number;
  80990. /**
  80991. * Sets the blur box offset: offset applied during the blur pass.
  80992. * Only useful if useKernelBlur = false
  80993. */
  80994. set blurBoxOffset(value: number);
  80995. private _blurScale;
  80996. /**
  80997. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  80998. * 2 means half of the size.
  80999. */
  81000. get blurScale(): number;
  81001. /**
  81002. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  81003. * 2 means half of the size.
  81004. */
  81005. set blurScale(value: number);
  81006. private _blurKernel;
  81007. /**
  81008. * Gets the blur kernel: kernel size of the blur pass.
  81009. * Only useful if useKernelBlur = true
  81010. */
  81011. get blurKernel(): number;
  81012. /**
  81013. * Sets the blur kernel: kernel size of the blur pass.
  81014. * Only useful if useKernelBlur = true
  81015. */
  81016. set blurKernel(value: number);
  81017. private _useKernelBlur;
  81018. /**
  81019. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  81020. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  81021. */
  81022. get useKernelBlur(): boolean;
  81023. /**
  81024. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  81025. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  81026. */
  81027. set useKernelBlur(value: boolean);
  81028. private _depthScale;
  81029. /**
  81030. * Gets the depth scale used in ESM mode.
  81031. */
  81032. get depthScale(): number;
  81033. /**
  81034. * Sets the depth scale used in ESM mode.
  81035. * This can override the scale stored on the light.
  81036. */
  81037. set depthScale(value: number);
  81038. private _filter;
  81039. /**
  81040. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  81041. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  81042. */
  81043. get filter(): number;
  81044. /**
  81045. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  81046. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  81047. */
  81048. set filter(value: number);
  81049. /**
  81050. * Gets if the current filter is set to Poisson Sampling.
  81051. */
  81052. get usePoissonSampling(): boolean;
  81053. /**
  81054. * Sets the current filter to Poisson Sampling.
  81055. */
  81056. set usePoissonSampling(value: boolean);
  81057. /**
  81058. * Gets if the current filter is set to ESM.
  81059. */
  81060. get useExponentialShadowMap(): boolean;
  81061. /**
  81062. * Sets the current filter is to ESM.
  81063. */
  81064. set useExponentialShadowMap(value: boolean);
  81065. /**
  81066. * Gets if the current filter is set to filtered ESM.
  81067. */
  81068. get useBlurExponentialShadowMap(): boolean;
  81069. /**
  81070. * Gets if the current filter is set to filtered ESM.
  81071. */
  81072. set useBlurExponentialShadowMap(value: boolean);
  81073. /**
  81074. * Gets if the current filter is set to "close ESM" (using the inverse of the
  81075. * exponential to prevent steep falloff artifacts).
  81076. */
  81077. get useCloseExponentialShadowMap(): boolean;
  81078. /**
  81079. * Sets the current filter to "close ESM" (using the inverse of the
  81080. * exponential to prevent steep falloff artifacts).
  81081. */
  81082. set useCloseExponentialShadowMap(value: boolean);
  81083. /**
  81084. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  81085. * exponential to prevent steep falloff artifacts).
  81086. */
  81087. get useBlurCloseExponentialShadowMap(): boolean;
  81088. /**
  81089. * Sets the current filter to filtered "close ESM" (using the inverse of the
  81090. * exponential to prevent steep falloff artifacts).
  81091. */
  81092. set useBlurCloseExponentialShadowMap(value: boolean);
  81093. /**
  81094. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  81095. */
  81096. get usePercentageCloserFiltering(): boolean;
  81097. /**
  81098. * Sets the current filter to "PCF" (percentage closer filtering).
  81099. */
  81100. set usePercentageCloserFiltering(value: boolean);
  81101. private _filteringQuality;
  81102. /**
  81103. * Gets the PCF or PCSS Quality.
  81104. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  81105. */
  81106. get filteringQuality(): number;
  81107. /**
  81108. * Sets the PCF or PCSS Quality.
  81109. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  81110. */
  81111. set filteringQuality(filteringQuality: number);
  81112. /**
  81113. * Gets if the current filter is set to "PCSS" (contact hardening).
  81114. */
  81115. get useContactHardeningShadow(): boolean;
  81116. /**
  81117. * Sets the current filter to "PCSS" (contact hardening).
  81118. */
  81119. set useContactHardeningShadow(value: boolean);
  81120. private _contactHardeningLightSizeUVRatio;
  81121. /**
  81122. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  81123. * Using a ratio helps keeping shape stability independently of the map size.
  81124. *
  81125. * It does not account for the light projection as it was having too much
  81126. * instability during the light setup or during light position changes.
  81127. *
  81128. * Only valid if useContactHardeningShadow is true.
  81129. */
  81130. get contactHardeningLightSizeUVRatio(): number;
  81131. /**
  81132. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  81133. * Using a ratio helps keeping shape stability independently of the map size.
  81134. *
  81135. * It does not account for the light projection as it was having too much
  81136. * instability during the light setup or during light position changes.
  81137. *
  81138. * Only valid if useContactHardeningShadow is true.
  81139. */
  81140. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  81141. private _darkness;
  81142. /** Gets or sets the actual darkness of a shadow */
  81143. get darkness(): number;
  81144. set darkness(value: number);
  81145. /**
  81146. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  81147. * 0 means strongest and 1 would means no shadow.
  81148. * @returns the darkness.
  81149. */
  81150. getDarkness(): number;
  81151. /**
  81152. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  81153. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  81154. * @returns the shadow generator allowing fluent coding.
  81155. */
  81156. setDarkness(darkness: number): ShadowGenerator;
  81157. private _transparencyShadow;
  81158. /** Gets or sets the ability to have transparent shadow */
  81159. get transparencyShadow(): boolean;
  81160. set transparencyShadow(value: boolean);
  81161. /**
  81162. * Sets the ability to have transparent shadow (boolean).
  81163. * @param transparent True if transparent else False
  81164. * @returns the shadow generator allowing fluent coding
  81165. */
  81166. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  81167. private _shadowMap;
  81168. private _shadowMap2;
  81169. /**
  81170. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  81171. * @returns The render target texture if present otherwise, null
  81172. */
  81173. getShadowMap(): Nullable<RenderTargetTexture>;
  81174. /**
  81175. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  81176. * @returns The render target texture if the shadow map is present otherwise, null
  81177. */
  81178. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  81179. /**
  81180. * Gets the class name of that object
  81181. * @returns "ShadowGenerator"
  81182. */
  81183. getClassName(): string;
  81184. /**
  81185. * Helper function to add a mesh and its descendants to the list of shadow casters.
  81186. * @param mesh Mesh to add
  81187. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  81188. * @returns the Shadow Generator itself
  81189. */
  81190. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  81191. /**
  81192. * Helper function to remove a mesh and its descendants from the list of shadow casters
  81193. * @param mesh Mesh to remove
  81194. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  81195. * @returns the Shadow Generator itself
  81196. */
  81197. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  81198. /**
  81199. * Controls the extent to which the shadows fade out at the edge of the frustum
  81200. * Used only by directionals and spots
  81201. */
  81202. frustumEdgeFalloff: number;
  81203. private _light;
  81204. /**
  81205. * Returns the associated light object.
  81206. * @returns the light generating the shadow
  81207. */
  81208. getLight(): IShadowLight;
  81209. /**
  81210. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  81211. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  81212. * It might on the other hand introduce peter panning.
  81213. */
  81214. forceBackFacesOnly: boolean;
  81215. private _scene;
  81216. private _lightDirection;
  81217. private _effect;
  81218. private _viewMatrix;
  81219. private _projectionMatrix;
  81220. private _transformMatrix;
  81221. private _cachedPosition;
  81222. private _cachedDirection;
  81223. private _cachedDefines;
  81224. private _currentRenderID;
  81225. private _boxBlurPostprocess;
  81226. private _kernelBlurXPostprocess;
  81227. private _kernelBlurYPostprocess;
  81228. private _blurPostProcesses;
  81229. private _mapSize;
  81230. private _currentFaceIndex;
  81231. private _currentFaceIndexCache;
  81232. private _textureType;
  81233. private _defaultTextureMatrix;
  81234. private _storedUniqueId;
  81235. /** @hidden */
  81236. static _SceneComponentInitialization: (scene: Scene) => void;
  81237. /**
  81238. * Creates a ShadowGenerator object.
  81239. * A ShadowGenerator is the required tool to use the shadows.
  81240. * Each light casting shadows needs to use its own ShadowGenerator.
  81241. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  81242. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  81243. * @param light The light object generating the shadows.
  81244. * @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.
  81245. */
  81246. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  81247. private _initializeGenerator;
  81248. private _initializeShadowMap;
  81249. private _initializeBlurRTTAndPostProcesses;
  81250. private _renderForShadowMap;
  81251. private _renderSubMeshForShadowMap;
  81252. private _applyFilterValues;
  81253. /**
  81254. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  81255. * @param onCompiled Callback triggered at the and of the effects compilation
  81256. * @param options Sets of optional options forcing the compilation with different modes
  81257. */
  81258. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  81259. useInstances: boolean;
  81260. }>): void;
  81261. /**
  81262. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  81263. * @param options Sets of optional options forcing the compilation with different modes
  81264. * @returns A promise that resolves when the compilation completes
  81265. */
  81266. forceCompilationAsync(options?: Partial<{
  81267. useInstances: boolean;
  81268. }>): Promise<void>;
  81269. /**
  81270. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  81271. * @param subMesh The submesh we want to render in the shadow map
  81272. * @param useInstances Defines wether will draw in the map using instances
  81273. * @returns true if ready otherwise, false
  81274. */
  81275. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  81276. /**
  81277. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  81278. * @param defines Defines of the material we want to update
  81279. * @param lightIndex Index of the light in the enabled light list of the material
  81280. */
  81281. prepareDefines(defines: any, lightIndex: number): void;
  81282. /**
  81283. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  81284. * defined in the generator but impacting the effect).
  81285. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  81286. * @param effect The effect we are binfing the information for
  81287. */
  81288. bindShadowLight(lightIndex: string, effect: Effect): void;
  81289. /**
  81290. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  81291. * (eq to shadow prjection matrix * light transform matrix)
  81292. * @returns The transform matrix used to create the shadow map
  81293. */
  81294. getTransformMatrix(): Matrix;
  81295. /**
  81296. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  81297. * Cube and 2D textures for instance.
  81298. */
  81299. recreateShadowMap(): void;
  81300. private _disposeBlurPostProcesses;
  81301. private _disposeRTTandPostProcesses;
  81302. /**
  81303. * Disposes the ShadowGenerator.
  81304. * Returns nothing.
  81305. */
  81306. dispose(): void;
  81307. /**
  81308. * Serializes the shadow generator setup to a json object.
  81309. * @returns The serialized JSON object
  81310. */
  81311. serialize(): any;
  81312. /**
  81313. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  81314. * @param parsedShadowGenerator The JSON object to parse
  81315. * @param scene The scene to create the shadow map for
  81316. * @returns The parsed shadow generator
  81317. */
  81318. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  81319. }
  81320. }
  81321. declare module BABYLON {
  81322. /**
  81323. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  81324. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  81325. * 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.
  81326. */
  81327. export abstract class Light extends Node {
  81328. /**
  81329. * Falloff Default: light is falling off following the material specification:
  81330. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  81331. */
  81332. static readonly FALLOFF_DEFAULT: number;
  81333. /**
  81334. * Falloff Physical: light is falling off following the inverse squared distance law.
  81335. */
  81336. static readonly FALLOFF_PHYSICAL: number;
  81337. /**
  81338. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  81339. * to enhance interoperability with other engines.
  81340. */
  81341. static readonly FALLOFF_GLTF: number;
  81342. /**
  81343. * Falloff Standard: light is falling off like in the standard material
  81344. * to enhance interoperability with other materials.
  81345. */
  81346. static readonly FALLOFF_STANDARD: number;
  81347. /**
  81348. * If every light affecting the material is in this lightmapMode,
  81349. * material.lightmapTexture adds or multiplies
  81350. * (depends on material.useLightmapAsShadowmap)
  81351. * after every other light calculations.
  81352. */
  81353. static readonly LIGHTMAP_DEFAULT: number;
  81354. /**
  81355. * material.lightmapTexture as only diffuse lighting from this light
  81356. * adds only specular lighting from this light
  81357. * adds dynamic shadows
  81358. */
  81359. static readonly LIGHTMAP_SPECULAR: number;
  81360. /**
  81361. * material.lightmapTexture as only lighting
  81362. * no light calculation from this light
  81363. * only adds dynamic shadows from this light
  81364. */
  81365. static readonly LIGHTMAP_SHADOWSONLY: number;
  81366. /**
  81367. * Each light type uses the default quantity according to its type:
  81368. * point/spot lights use luminous intensity
  81369. * directional lights use illuminance
  81370. */
  81371. static readonly INTENSITYMODE_AUTOMATIC: number;
  81372. /**
  81373. * lumen (lm)
  81374. */
  81375. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  81376. /**
  81377. * candela (lm/sr)
  81378. */
  81379. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  81380. /**
  81381. * lux (lm/m^2)
  81382. */
  81383. static readonly INTENSITYMODE_ILLUMINANCE: number;
  81384. /**
  81385. * nit (cd/m^2)
  81386. */
  81387. static readonly INTENSITYMODE_LUMINANCE: number;
  81388. /**
  81389. * Light type const id of the point light.
  81390. */
  81391. static readonly LIGHTTYPEID_POINTLIGHT: number;
  81392. /**
  81393. * Light type const id of the directional light.
  81394. */
  81395. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  81396. /**
  81397. * Light type const id of the spot light.
  81398. */
  81399. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  81400. /**
  81401. * Light type const id of the hemispheric light.
  81402. */
  81403. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  81404. /**
  81405. * Diffuse gives the basic color to an object.
  81406. */
  81407. diffuse: Color3;
  81408. /**
  81409. * Specular produces a highlight color on an object.
  81410. * Note: This is note affecting PBR materials.
  81411. */
  81412. specular: Color3;
  81413. /**
  81414. * Defines the falloff type for this light. This lets overrriding how punctual light are
  81415. * falling off base on range or angle.
  81416. * This can be set to any values in Light.FALLOFF_x.
  81417. *
  81418. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  81419. * other types of materials.
  81420. */
  81421. falloffType: number;
  81422. /**
  81423. * Strength of the light.
  81424. * Note: By default it is define in the framework own unit.
  81425. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  81426. */
  81427. intensity: number;
  81428. private _range;
  81429. protected _inverseSquaredRange: number;
  81430. /**
  81431. * Defines how far from the source the light is impacting in scene units.
  81432. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  81433. */
  81434. get range(): number;
  81435. /**
  81436. * Defines how far from the source the light is impacting in scene units.
  81437. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  81438. */
  81439. set range(value: number);
  81440. /**
  81441. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  81442. * of light.
  81443. */
  81444. private _photometricScale;
  81445. private _intensityMode;
  81446. /**
  81447. * Gets the photometric scale used to interpret the intensity.
  81448. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  81449. */
  81450. get intensityMode(): number;
  81451. /**
  81452. * Sets the photometric scale used to interpret the intensity.
  81453. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  81454. */
  81455. set intensityMode(value: number);
  81456. private _radius;
  81457. /**
  81458. * Gets the light radius used by PBR Materials to simulate soft area lights.
  81459. */
  81460. get radius(): number;
  81461. /**
  81462. * sets the light radius used by PBR Materials to simulate soft area lights.
  81463. */
  81464. set radius(value: number);
  81465. private _renderPriority;
  81466. /**
  81467. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  81468. * exceeding the number allowed of the materials.
  81469. */
  81470. renderPriority: number;
  81471. private _shadowEnabled;
  81472. /**
  81473. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  81474. * the current shadow generator.
  81475. */
  81476. get shadowEnabled(): boolean;
  81477. /**
  81478. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  81479. * the current shadow generator.
  81480. */
  81481. set shadowEnabled(value: boolean);
  81482. private _includedOnlyMeshes;
  81483. /**
  81484. * Gets the only meshes impacted by this light.
  81485. */
  81486. get includedOnlyMeshes(): AbstractMesh[];
  81487. /**
  81488. * Sets the only meshes impacted by this light.
  81489. */
  81490. set includedOnlyMeshes(value: AbstractMesh[]);
  81491. private _excludedMeshes;
  81492. /**
  81493. * Gets the meshes not impacted by this light.
  81494. */
  81495. get excludedMeshes(): AbstractMesh[];
  81496. /**
  81497. * Sets the meshes not impacted by this light.
  81498. */
  81499. set excludedMeshes(value: AbstractMesh[]);
  81500. private _excludeWithLayerMask;
  81501. /**
  81502. * Gets the layer id use to find what meshes are not impacted by the light.
  81503. * Inactive if 0
  81504. */
  81505. get excludeWithLayerMask(): number;
  81506. /**
  81507. * Sets the layer id use to find what meshes are not impacted by the light.
  81508. * Inactive if 0
  81509. */
  81510. set excludeWithLayerMask(value: number);
  81511. private _includeOnlyWithLayerMask;
  81512. /**
  81513. * Gets the layer id use to find what meshes are impacted by the light.
  81514. * Inactive if 0
  81515. */
  81516. get includeOnlyWithLayerMask(): number;
  81517. /**
  81518. * Sets the layer id use to find what meshes are impacted by the light.
  81519. * Inactive if 0
  81520. */
  81521. set includeOnlyWithLayerMask(value: number);
  81522. private _lightmapMode;
  81523. /**
  81524. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  81525. */
  81526. get lightmapMode(): number;
  81527. /**
  81528. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  81529. */
  81530. set lightmapMode(value: number);
  81531. /**
  81532. * Shadow generator associted to the light.
  81533. * @hidden Internal use only.
  81534. */
  81535. _shadowGenerator: Nullable<IShadowGenerator>;
  81536. /**
  81537. * @hidden Internal use only.
  81538. */
  81539. _excludedMeshesIds: string[];
  81540. /**
  81541. * @hidden Internal use only.
  81542. */
  81543. _includedOnlyMeshesIds: string[];
  81544. /**
  81545. * The current light unifom buffer.
  81546. * @hidden Internal use only.
  81547. */
  81548. _uniformBuffer: UniformBuffer;
  81549. /** @hidden */
  81550. _renderId: number;
  81551. /**
  81552. * Creates a Light object in the scene.
  81553. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81554. * @param name The firendly name of the light
  81555. * @param scene The scene the light belongs too
  81556. */
  81557. constructor(name: string, scene: Scene);
  81558. protected abstract _buildUniformLayout(): void;
  81559. /**
  81560. * Sets the passed Effect "effect" with the Light information.
  81561. * @param effect The effect to update
  81562. * @param lightIndex The index of the light in the effect to update
  81563. * @returns The light
  81564. */
  81565. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  81566. /**
  81567. * Sets the passed Effect "effect" with the Light textures.
  81568. * @param effect The effect to update
  81569. * @param lightIndex The index of the light in the effect to update
  81570. * @returns The light
  81571. */
  81572. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  81573. /**
  81574. * Binds the lights information from the scene to the effect for the given mesh.
  81575. * @param lightIndex Light index
  81576. * @param scene The scene where the light belongs to
  81577. * @param effect The effect we are binding the data to
  81578. * @param useSpecular Defines if specular is supported
  81579. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  81580. */
  81581. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  81582. /**
  81583. * Sets the passed Effect "effect" with the Light information.
  81584. * @param effect The effect to update
  81585. * @param lightDataUniformName The uniform used to store light data (position or direction)
  81586. * @returns The light
  81587. */
  81588. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  81589. /**
  81590. * Returns the string "Light".
  81591. * @returns the class name
  81592. */
  81593. getClassName(): string;
  81594. /** @hidden */
  81595. readonly _isLight: boolean;
  81596. /**
  81597. * Converts the light information to a readable string for debug purpose.
  81598. * @param fullDetails Supports for multiple levels of logging within scene loading
  81599. * @returns the human readable light info
  81600. */
  81601. toString(fullDetails?: boolean): string;
  81602. /** @hidden */
  81603. protected _syncParentEnabledState(): void;
  81604. /**
  81605. * Set the enabled state of this node.
  81606. * @param value - the new enabled state
  81607. */
  81608. setEnabled(value: boolean): void;
  81609. /**
  81610. * Returns the Light associated shadow generator if any.
  81611. * @return the associated shadow generator.
  81612. */
  81613. getShadowGenerator(): Nullable<IShadowGenerator>;
  81614. /**
  81615. * Returns a Vector3, the absolute light position in the World.
  81616. * @returns the world space position of the light
  81617. */
  81618. getAbsolutePosition(): Vector3;
  81619. /**
  81620. * Specifies if the light will affect the passed mesh.
  81621. * @param mesh The mesh to test against the light
  81622. * @return true the mesh is affected otherwise, false.
  81623. */
  81624. canAffectMesh(mesh: AbstractMesh): boolean;
  81625. /**
  81626. * Sort function to order lights for rendering.
  81627. * @param a First Light object to compare to second.
  81628. * @param b Second Light object to compare first.
  81629. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  81630. */
  81631. static CompareLightsPriority(a: Light, b: Light): number;
  81632. /**
  81633. * Releases resources associated with this node.
  81634. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81635. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81636. */
  81637. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81638. /**
  81639. * Returns the light type ID (integer).
  81640. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81641. */
  81642. getTypeID(): number;
  81643. /**
  81644. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  81645. * @returns the scaled intensity in intensity mode unit
  81646. */
  81647. getScaledIntensity(): number;
  81648. /**
  81649. * Returns a new Light object, named "name", from the current one.
  81650. * @param name The name of the cloned light
  81651. * @returns the new created light
  81652. */
  81653. clone(name: string): Nullable<Light>;
  81654. /**
  81655. * Serializes the current light into a Serialization object.
  81656. * @returns the serialized object.
  81657. */
  81658. serialize(): any;
  81659. /**
  81660. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  81661. * This new light is named "name" and added to the passed scene.
  81662. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  81663. * @param name The friendly name of the light
  81664. * @param scene The scene the new light will belong to
  81665. * @returns the constructor function
  81666. */
  81667. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  81668. /**
  81669. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  81670. * @param parsedLight The JSON representation of the light
  81671. * @param scene The scene to create the parsed light in
  81672. * @returns the created light after parsing
  81673. */
  81674. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  81675. private _hookArrayForExcluded;
  81676. private _hookArrayForIncludedOnly;
  81677. private _resyncMeshes;
  81678. /**
  81679. * Forces the meshes to update their light related information in their rendering used effects
  81680. * @hidden Internal Use Only
  81681. */
  81682. _markMeshesAsLightDirty(): void;
  81683. /**
  81684. * Recomputes the cached photometric scale if needed.
  81685. */
  81686. private _computePhotometricScale;
  81687. /**
  81688. * Returns the Photometric Scale according to the light type and intensity mode.
  81689. */
  81690. private _getPhotometricScale;
  81691. /**
  81692. * Reorder the light in the scene according to their defined priority.
  81693. * @hidden Internal Use Only
  81694. */
  81695. _reorderLightsInScene(): void;
  81696. /**
  81697. * Prepares the list of defines specific to the light type.
  81698. * @param defines the list of defines
  81699. * @param lightIndex defines the index of the light for the effect
  81700. */
  81701. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81702. }
  81703. }
  81704. declare module BABYLON {
  81705. /**
  81706. * Interface used to define Action
  81707. */
  81708. export interface IAction {
  81709. /**
  81710. * Trigger for the action
  81711. */
  81712. trigger: number;
  81713. /** Options of the trigger */
  81714. triggerOptions: any;
  81715. /**
  81716. * Gets the trigger parameters
  81717. * @returns the trigger parameters
  81718. */
  81719. getTriggerParameter(): any;
  81720. /**
  81721. * Internal only - executes current action event
  81722. * @hidden
  81723. */
  81724. _executeCurrent(evt?: ActionEvent): void;
  81725. /**
  81726. * Serialize placeholder for child classes
  81727. * @param parent of child
  81728. * @returns the serialized object
  81729. */
  81730. serialize(parent: any): any;
  81731. /**
  81732. * Internal only
  81733. * @hidden
  81734. */
  81735. _prepare(): void;
  81736. /**
  81737. * Internal only - manager for action
  81738. * @hidden
  81739. */
  81740. _actionManager: AbstractActionManager;
  81741. /**
  81742. * Adds action to chain of actions, may be a DoNothingAction
  81743. * @param action defines the next action to execute
  81744. * @returns The action passed in
  81745. * @see https://www.babylonjs-playground.com/#1T30HR#0
  81746. */
  81747. then(action: IAction): IAction;
  81748. }
  81749. /**
  81750. * The action to be carried out following a trigger
  81751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  81752. */
  81753. export class Action implements IAction {
  81754. /** the trigger, with or without parameters, for the action */
  81755. triggerOptions: any;
  81756. /**
  81757. * Trigger for the action
  81758. */
  81759. trigger: number;
  81760. /**
  81761. * Internal only - manager for action
  81762. * @hidden
  81763. */
  81764. _actionManager: ActionManager;
  81765. private _nextActiveAction;
  81766. private _child;
  81767. private _condition?;
  81768. private _triggerParameter;
  81769. /**
  81770. * An event triggered prior to action being executed.
  81771. */
  81772. onBeforeExecuteObservable: Observable<Action>;
  81773. /**
  81774. * Creates a new Action
  81775. * @param triggerOptions the trigger, with or without parameters, for the action
  81776. * @param condition an optional determinant of action
  81777. */
  81778. constructor(
  81779. /** the trigger, with or without parameters, for the action */
  81780. triggerOptions: any, condition?: Condition);
  81781. /**
  81782. * Internal only
  81783. * @hidden
  81784. */
  81785. _prepare(): void;
  81786. /**
  81787. * Gets the trigger parameters
  81788. * @returns the trigger parameters
  81789. */
  81790. getTriggerParameter(): any;
  81791. /**
  81792. * Internal only - executes current action event
  81793. * @hidden
  81794. */
  81795. _executeCurrent(evt?: ActionEvent): void;
  81796. /**
  81797. * Execute placeholder for child classes
  81798. * @param evt optional action event
  81799. */
  81800. execute(evt?: ActionEvent): void;
  81801. /**
  81802. * Skips to next active action
  81803. */
  81804. skipToNextActiveAction(): void;
  81805. /**
  81806. * Adds action to chain of actions, may be a DoNothingAction
  81807. * @param action defines the next action to execute
  81808. * @returns The action passed in
  81809. * @see https://www.babylonjs-playground.com/#1T30HR#0
  81810. */
  81811. then(action: Action): Action;
  81812. /**
  81813. * Internal only
  81814. * @hidden
  81815. */
  81816. _getProperty(propertyPath: string): string;
  81817. /**
  81818. * Internal only
  81819. * @hidden
  81820. */
  81821. _getEffectiveTarget(target: any, propertyPath: string): any;
  81822. /**
  81823. * Serialize placeholder for child classes
  81824. * @param parent of child
  81825. * @returns the serialized object
  81826. */
  81827. serialize(parent: any): any;
  81828. /**
  81829. * Internal only called by serialize
  81830. * @hidden
  81831. */
  81832. protected _serialize(serializedAction: any, parent?: any): any;
  81833. /**
  81834. * Internal only
  81835. * @hidden
  81836. */
  81837. static _SerializeValueAsString: (value: any) => string;
  81838. /**
  81839. * Internal only
  81840. * @hidden
  81841. */
  81842. static _GetTargetProperty: (target: Node | Scene) => {
  81843. name: string;
  81844. targetType: string;
  81845. value: string;
  81846. };
  81847. }
  81848. }
  81849. declare module BABYLON {
  81850. /**
  81851. * A Condition applied to an Action
  81852. */
  81853. export class Condition {
  81854. /**
  81855. * Internal only - manager for action
  81856. * @hidden
  81857. */
  81858. _actionManager: ActionManager;
  81859. /**
  81860. * Internal only
  81861. * @hidden
  81862. */
  81863. _evaluationId: number;
  81864. /**
  81865. * Internal only
  81866. * @hidden
  81867. */
  81868. _currentResult: boolean;
  81869. /**
  81870. * Creates a new Condition
  81871. * @param actionManager the manager of the action the condition is applied to
  81872. */
  81873. constructor(actionManager: ActionManager);
  81874. /**
  81875. * Check if the current condition is valid
  81876. * @returns a boolean
  81877. */
  81878. isValid(): boolean;
  81879. /**
  81880. * Internal only
  81881. * @hidden
  81882. */
  81883. _getProperty(propertyPath: string): string;
  81884. /**
  81885. * Internal only
  81886. * @hidden
  81887. */
  81888. _getEffectiveTarget(target: any, propertyPath: string): any;
  81889. /**
  81890. * Serialize placeholder for child classes
  81891. * @returns the serialized object
  81892. */
  81893. serialize(): any;
  81894. /**
  81895. * Internal only
  81896. * @hidden
  81897. */
  81898. protected _serialize(serializedCondition: any): any;
  81899. }
  81900. /**
  81901. * Defines specific conditional operators as extensions of Condition
  81902. */
  81903. export class ValueCondition extends Condition {
  81904. /** path to specify the property of the target the conditional operator uses */
  81905. propertyPath: string;
  81906. /** the value compared by the conditional operator against the current value of the property */
  81907. value: any;
  81908. /** the conditional operator, default ValueCondition.IsEqual */
  81909. operator: number;
  81910. /**
  81911. * Internal only
  81912. * @hidden
  81913. */
  81914. private static _IsEqual;
  81915. /**
  81916. * Internal only
  81917. * @hidden
  81918. */
  81919. private static _IsDifferent;
  81920. /**
  81921. * Internal only
  81922. * @hidden
  81923. */
  81924. private static _IsGreater;
  81925. /**
  81926. * Internal only
  81927. * @hidden
  81928. */
  81929. private static _IsLesser;
  81930. /**
  81931. * returns the number for IsEqual
  81932. */
  81933. static get IsEqual(): number;
  81934. /**
  81935. * Returns the number for IsDifferent
  81936. */
  81937. static get IsDifferent(): number;
  81938. /**
  81939. * Returns the number for IsGreater
  81940. */
  81941. static get IsGreater(): number;
  81942. /**
  81943. * Returns the number for IsLesser
  81944. */
  81945. static get IsLesser(): number;
  81946. /**
  81947. * Internal only The action manager for the condition
  81948. * @hidden
  81949. */
  81950. _actionManager: ActionManager;
  81951. /**
  81952. * Internal only
  81953. * @hidden
  81954. */
  81955. private _target;
  81956. /**
  81957. * Internal only
  81958. * @hidden
  81959. */
  81960. private _effectiveTarget;
  81961. /**
  81962. * Internal only
  81963. * @hidden
  81964. */
  81965. private _property;
  81966. /**
  81967. * Creates a new ValueCondition
  81968. * @param actionManager manager for the action the condition applies to
  81969. * @param target for the action
  81970. * @param propertyPath path to specify the property of the target the conditional operator uses
  81971. * @param value the value compared by the conditional operator against the current value of the property
  81972. * @param operator the conditional operator, default ValueCondition.IsEqual
  81973. */
  81974. constructor(actionManager: ActionManager, target: any,
  81975. /** path to specify the property of the target the conditional operator uses */
  81976. propertyPath: string,
  81977. /** the value compared by the conditional operator against the current value of the property */
  81978. value: any,
  81979. /** the conditional operator, default ValueCondition.IsEqual */
  81980. operator?: number);
  81981. /**
  81982. * Compares the given value with the property value for the specified conditional operator
  81983. * @returns the result of the comparison
  81984. */
  81985. isValid(): boolean;
  81986. /**
  81987. * Serialize the ValueCondition into a JSON compatible object
  81988. * @returns serialization object
  81989. */
  81990. serialize(): any;
  81991. /**
  81992. * Gets the name of the conditional operator for the ValueCondition
  81993. * @param operator the conditional operator
  81994. * @returns the name
  81995. */
  81996. static GetOperatorName(operator: number): string;
  81997. }
  81998. /**
  81999. * Defines a predicate condition as an extension of Condition
  82000. */
  82001. export class PredicateCondition extends Condition {
  82002. /** defines the predicate function used to validate the condition */
  82003. predicate: () => boolean;
  82004. /**
  82005. * Internal only - manager for action
  82006. * @hidden
  82007. */
  82008. _actionManager: ActionManager;
  82009. /**
  82010. * Creates a new PredicateCondition
  82011. * @param actionManager manager for the action the condition applies to
  82012. * @param predicate defines the predicate function used to validate the condition
  82013. */
  82014. constructor(actionManager: ActionManager,
  82015. /** defines the predicate function used to validate the condition */
  82016. predicate: () => boolean);
  82017. /**
  82018. * @returns the validity of the predicate condition
  82019. */
  82020. isValid(): boolean;
  82021. }
  82022. /**
  82023. * Defines a state condition as an extension of Condition
  82024. */
  82025. export class StateCondition extends Condition {
  82026. /** Value to compare with target state */
  82027. value: string;
  82028. /**
  82029. * Internal only - manager for action
  82030. * @hidden
  82031. */
  82032. _actionManager: ActionManager;
  82033. /**
  82034. * Internal only
  82035. * @hidden
  82036. */
  82037. private _target;
  82038. /**
  82039. * Creates a new StateCondition
  82040. * @param actionManager manager for the action the condition applies to
  82041. * @param target of the condition
  82042. * @param value to compare with target state
  82043. */
  82044. constructor(actionManager: ActionManager, target: any,
  82045. /** Value to compare with target state */
  82046. value: string);
  82047. /**
  82048. * Gets a boolean indicating if the current condition is met
  82049. * @returns the validity of the state
  82050. */
  82051. isValid(): boolean;
  82052. /**
  82053. * Serialize the StateCondition into a JSON compatible object
  82054. * @returns serialization object
  82055. */
  82056. serialize(): any;
  82057. }
  82058. }
  82059. declare module BABYLON {
  82060. /**
  82061. * This defines an action responsible to toggle a boolean once triggered.
  82062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82063. */
  82064. export class SwitchBooleanAction extends Action {
  82065. /**
  82066. * The path to the boolean property in the target object
  82067. */
  82068. propertyPath: string;
  82069. private _target;
  82070. private _effectiveTarget;
  82071. private _property;
  82072. /**
  82073. * Instantiate the action
  82074. * @param triggerOptions defines the trigger options
  82075. * @param target defines the object containing the boolean
  82076. * @param propertyPath defines the path to the boolean property in the target object
  82077. * @param condition defines the trigger related conditions
  82078. */
  82079. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  82080. /** @hidden */
  82081. _prepare(): void;
  82082. /**
  82083. * Execute the action toggle the boolean value.
  82084. */
  82085. execute(): void;
  82086. /**
  82087. * Serializes the actions and its related information.
  82088. * @param parent defines the object to serialize in
  82089. * @returns the serialized object
  82090. */
  82091. serialize(parent: any): any;
  82092. }
  82093. /**
  82094. * This defines an action responsible to set a the state field of the target
  82095. * to a desired value once triggered.
  82096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82097. */
  82098. export class SetStateAction extends Action {
  82099. /**
  82100. * The value to store in the state field.
  82101. */
  82102. value: string;
  82103. private _target;
  82104. /**
  82105. * Instantiate the action
  82106. * @param triggerOptions defines the trigger options
  82107. * @param target defines the object containing the state property
  82108. * @param value defines the value to store in the state field
  82109. * @param condition defines the trigger related conditions
  82110. */
  82111. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  82112. /**
  82113. * Execute the action and store the value on the target state property.
  82114. */
  82115. execute(): void;
  82116. /**
  82117. * Serializes the actions and its related information.
  82118. * @param parent defines the object to serialize in
  82119. * @returns the serialized object
  82120. */
  82121. serialize(parent: any): any;
  82122. }
  82123. /**
  82124. * This defines an action responsible to set a property of the target
  82125. * to a desired value once triggered.
  82126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82127. */
  82128. export class SetValueAction extends Action {
  82129. /**
  82130. * The path of the property to set in the target.
  82131. */
  82132. propertyPath: string;
  82133. /**
  82134. * The value to set in the property
  82135. */
  82136. value: any;
  82137. private _target;
  82138. private _effectiveTarget;
  82139. private _property;
  82140. /**
  82141. * Instantiate the action
  82142. * @param triggerOptions defines the trigger options
  82143. * @param target defines the object containing the property
  82144. * @param propertyPath defines the path of the property to set in the target
  82145. * @param value defines the value to set in the property
  82146. * @param condition defines the trigger related conditions
  82147. */
  82148. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  82149. /** @hidden */
  82150. _prepare(): void;
  82151. /**
  82152. * Execute the action and set the targetted property to the desired value.
  82153. */
  82154. execute(): void;
  82155. /**
  82156. * Serializes the actions and its related information.
  82157. * @param parent defines the object to serialize in
  82158. * @returns the serialized object
  82159. */
  82160. serialize(parent: any): any;
  82161. }
  82162. /**
  82163. * This defines an action responsible to increment the target value
  82164. * to a desired value once triggered.
  82165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82166. */
  82167. export class IncrementValueAction extends Action {
  82168. /**
  82169. * The path of the property to increment in the target.
  82170. */
  82171. propertyPath: string;
  82172. /**
  82173. * The value we should increment the property by.
  82174. */
  82175. value: any;
  82176. private _target;
  82177. private _effectiveTarget;
  82178. private _property;
  82179. /**
  82180. * Instantiate the action
  82181. * @param triggerOptions defines the trigger options
  82182. * @param target defines the object containing the property
  82183. * @param propertyPath defines the path of the property to increment in the target
  82184. * @param value defines the value value we should increment the property by
  82185. * @param condition defines the trigger related conditions
  82186. */
  82187. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  82188. /** @hidden */
  82189. _prepare(): void;
  82190. /**
  82191. * Execute the action and increment the target of the value amount.
  82192. */
  82193. execute(): void;
  82194. /**
  82195. * Serializes the actions and its related information.
  82196. * @param parent defines the object to serialize in
  82197. * @returns the serialized object
  82198. */
  82199. serialize(parent: any): any;
  82200. }
  82201. /**
  82202. * This defines an action responsible to start an animation once triggered.
  82203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82204. */
  82205. export class PlayAnimationAction extends Action {
  82206. /**
  82207. * Where the animation should start (animation frame)
  82208. */
  82209. from: number;
  82210. /**
  82211. * Where the animation should stop (animation frame)
  82212. */
  82213. to: number;
  82214. /**
  82215. * Define if the animation should loop or stop after the first play.
  82216. */
  82217. loop?: boolean;
  82218. private _target;
  82219. /**
  82220. * Instantiate the action
  82221. * @param triggerOptions defines the trigger options
  82222. * @param target defines the target animation or animation name
  82223. * @param from defines from where the animation should start (animation frame)
  82224. * @param end defines where the animation should stop (animation frame)
  82225. * @param loop defines if the animation should loop or stop after the first play
  82226. * @param condition defines the trigger related conditions
  82227. */
  82228. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  82229. /** @hidden */
  82230. _prepare(): void;
  82231. /**
  82232. * Execute the action and play the animation.
  82233. */
  82234. execute(): void;
  82235. /**
  82236. * Serializes the actions and its related information.
  82237. * @param parent defines the object to serialize in
  82238. * @returns the serialized object
  82239. */
  82240. serialize(parent: any): any;
  82241. }
  82242. /**
  82243. * This defines an action responsible to stop an animation once triggered.
  82244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82245. */
  82246. export class StopAnimationAction extends Action {
  82247. private _target;
  82248. /**
  82249. * Instantiate the action
  82250. * @param triggerOptions defines the trigger options
  82251. * @param target defines the target animation or animation name
  82252. * @param condition defines the trigger related conditions
  82253. */
  82254. constructor(triggerOptions: any, target: any, condition?: Condition);
  82255. /** @hidden */
  82256. _prepare(): void;
  82257. /**
  82258. * Execute the action and stop the animation.
  82259. */
  82260. execute(): void;
  82261. /**
  82262. * Serializes the actions and its related information.
  82263. * @param parent defines the object to serialize in
  82264. * @returns the serialized object
  82265. */
  82266. serialize(parent: any): any;
  82267. }
  82268. /**
  82269. * This defines an action responsible that does nothing once triggered.
  82270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82271. */
  82272. export class DoNothingAction extends Action {
  82273. /**
  82274. * Instantiate the action
  82275. * @param triggerOptions defines the trigger options
  82276. * @param condition defines the trigger related conditions
  82277. */
  82278. constructor(triggerOptions?: any, condition?: Condition);
  82279. /**
  82280. * Execute the action and do nothing.
  82281. */
  82282. execute(): void;
  82283. /**
  82284. * Serializes the actions and its related information.
  82285. * @param parent defines the object to serialize in
  82286. * @returns the serialized object
  82287. */
  82288. serialize(parent: any): any;
  82289. }
  82290. /**
  82291. * This defines an action responsible to trigger several actions once triggered.
  82292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82293. */
  82294. export class CombineAction extends Action {
  82295. /**
  82296. * The list of aggregated animations to run.
  82297. */
  82298. children: Action[];
  82299. /**
  82300. * Instantiate the action
  82301. * @param triggerOptions defines the trigger options
  82302. * @param children defines the list of aggregated animations to run
  82303. * @param condition defines the trigger related conditions
  82304. */
  82305. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  82306. /** @hidden */
  82307. _prepare(): void;
  82308. /**
  82309. * Execute the action and executes all the aggregated actions.
  82310. */
  82311. execute(evt: ActionEvent): void;
  82312. /**
  82313. * Serializes the actions and its related information.
  82314. * @param parent defines the object to serialize in
  82315. * @returns the serialized object
  82316. */
  82317. serialize(parent: any): any;
  82318. }
  82319. /**
  82320. * This defines an action responsible to run code (external event) once triggered.
  82321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82322. */
  82323. export class ExecuteCodeAction extends Action {
  82324. /**
  82325. * The callback function to run.
  82326. */
  82327. func: (evt: ActionEvent) => void;
  82328. /**
  82329. * Instantiate the action
  82330. * @param triggerOptions defines the trigger options
  82331. * @param func defines the callback function to run
  82332. * @param condition defines the trigger related conditions
  82333. */
  82334. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  82335. /**
  82336. * Execute the action and run the attached code.
  82337. */
  82338. execute(evt: ActionEvent): void;
  82339. }
  82340. /**
  82341. * This defines an action responsible to set the parent property of the target once triggered.
  82342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82343. */
  82344. export class SetParentAction extends Action {
  82345. private _parent;
  82346. private _target;
  82347. /**
  82348. * Instantiate the action
  82349. * @param triggerOptions defines the trigger options
  82350. * @param target defines the target containing the parent property
  82351. * @param parent defines from where the animation should start (animation frame)
  82352. * @param condition defines the trigger related conditions
  82353. */
  82354. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  82355. /** @hidden */
  82356. _prepare(): void;
  82357. /**
  82358. * Execute the action and set the parent property.
  82359. */
  82360. execute(): void;
  82361. /**
  82362. * Serializes the actions and its related information.
  82363. * @param parent defines the object to serialize in
  82364. * @returns the serialized object
  82365. */
  82366. serialize(parent: any): any;
  82367. }
  82368. }
  82369. declare module BABYLON {
  82370. /**
  82371. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  82372. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  82373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  82374. */
  82375. export class ActionManager extends AbstractActionManager {
  82376. /**
  82377. * Nothing
  82378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82379. */
  82380. static readonly NothingTrigger: number;
  82381. /**
  82382. * On pick
  82383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82384. */
  82385. static readonly OnPickTrigger: number;
  82386. /**
  82387. * On left pick
  82388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82389. */
  82390. static readonly OnLeftPickTrigger: number;
  82391. /**
  82392. * On right pick
  82393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82394. */
  82395. static readonly OnRightPickTrigger: number;
  82396. /**
  82397. * On center pick
  82398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82399. */
  82400. static readonly OnCenterPickTrigger: number;
  82401. /**
  82402. * On pick down
  82403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82404. */
  82405. static readonly OnPickDownTrigger: number;
  82406. /**
  82407. * On double pick
  82408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82409. */
  82410. static readonly OnDoublePickTrigger: number;
  82411. /**
  82412. * On pick up
  82413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82414. */
  82415. static readonly OnPickUpTrigger: number;
  82416. /**
  82417. * On pick out.
  82418. * This trigger will only be raised if you also declared a OnPickDown
  82419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82420. */
  82421. static readonly OnPickOutTrigger: number;
  82422. /**
  82423. * On long press
  82424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82425. */
  82426. static readonly OnLongPressTrigger: number;
  82427. /**
  82428. * On pointer over
  82429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82430. */
  82431. static readonly OnPointerOverTrigger: number;
  82432. /**
  82433. * On pointer out
  82434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82435. */
  82436. static readonly OnPointerOutTrigger: number;
  82437. /**
  82438. * On every frame
  82439. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82440. */
  82441. static readonly OnEveryFrameTrigger: number;
  82442. /**
  82443. * On intersection enter
  82444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82445. */
  82446. static readonly OnIntersectionEnterTrigger: number;
  82447. /**
  82448. * On intersection exit
  82449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82450. */
  82451. static readonly OnIntersectionExitTrigger: number;
  82452. /**
  82453. * On key down
  82454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82455. */
  82456. static readonly OnKeyDownTrigger: number;
  82457. /**
  82458. * On key up
  82459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82460. */
  82461. static readonly OnKeyUpTrigger: number;
  82462. private _scene;
  82463. /**
  82464. * Creates a new action manager
  82465. * @param scene defines the hosting scene
  82466. */
  82467. constructor(scene: Scene);
  82468. /**
  82469. * Releases all associated resources
  82470. */
  82471. dispose(): void;
  82472. /**
  82473. * Gets hosting scene
  82474. * @returns the hosting scene
  82475. */
  82476. getScene(): Scene;
  82477. /**
  82478. * Does this action manager handles actions of any of the given triggers
  82479. * @param triggers defines the triggers to be tested
  82480. * @return a boolean indicating whether one (or more) of the triggers is handled
  82481. */
  82482. hasSpecificTriggers(triggers: number[]): boolean;
  82483. /**
  82484. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  82485. * speed.
  82486. * @param triggerA defines the trigger to be tested
  82487. * @param triggerB defines the trigger to be tested
  82488. * @return a boolean indicating whether one (or more) of the triggers is handled
  82489. */
  82490. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  82491. /**
  82492. * Does this action manager handles actions of a given trigger
  82493. * @param trigger defines the trigger to be tested
  82494. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  82495. * @return whether the trigger is handled
  82496. */
  82497. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  82498. /**
  82499. * Does this action manager has pointer triggers
  82500. */
  82501. get hasPointerTriggers(): boolean;
  82502. /**
  82503. * Does this action manager has pick triggers
  82504. */
  82505. get hasPickTriggers(): boolean;
  82506. /**
  82507. * Registers an action to this action manager
  82508. * @param action defines the action to be registered
  82509. * @return the action amended (prepared) after registration
  82510. */
  82511. registerAction(action: IAction): Nullable<IAction>;
  82512. /**
  82513. * Unregisters an action to this action manager
  82514. * @param action defines the action to be unregistered
  82515. * @return a boolean indicating whether the action has been unregistered
  82516. */
  82517. unregisterAction(action: IAction): Boolean;
  82518. /**
  82519. * Process a specific trigger
  82520. * @param trigger defines the trigger to process
  82521. * @param evt defines the event details to be processed
  82522. */
  82523. processTrigger(trigger: number, evt?: IActionEvent): void;
  82524. /** @hidden */
  82525. _getEffectiveTarget(target: any, propertyPath: string): any;
  82526. /** @hidden */
  82527. _getProperty(propertyPath: string): string;
  82528. /**
  82529. * Serialize this manager to a JSON object
  82530. * @param name defines the property name to store this manager
  82531. * @returns a JSON representation of this manager
  82532. */
  82533. serialize(name: string): any;
  82534. /**
  82535. * Creates a new ActionManager from a JSON data
  82536. * @param parsedActions defines the JSON data to read from
  82537. * @param object defines the hosting mesh
  82538. * @param scene defines the hosting scene
  82539. */
  82540. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  82541. /**
  82542. * Get a trigger name by index
  82543. * @param trigger defines the trigger index
  82544. * @returns a trigger name
  82545. */
  82546. static GetTriggerName(trigger: number): string;
  82547. }
  82548. }
  82549. declare module BABYLON {
  82550. /**
  82551. * Class representing a ray with position and direction
  82552. */
  82553. export class Ray {
  82554. /** origin point */
  82555. origin: Vector3;
  82556. /** direction */
  82557. direction: Vector3;
  82558. /** length of the ray */
  82559. length: number;
  82560. private static readonly TmpVector3;
  82561. private _tmpRay;
  82562. /**
  82563. * Creates a new ray
  82564. * @param origin origin point
  82565. * @param direction direction
  82566. * @param length length of the ray
  82567. */
  82568. constructor(
  82569. /** origin point */
  82570. origin: Vector3,
  82571. /** direction */
  82572. direction: Vector3,
  82573. /** length of the ray */
  82574. length?: number);
  82575. /**
  82576. * Checks if the ray intersects a box
  82577. * @param minimum bound of the box
  82578. * @param maximum bound of the box
  82579. * @param intersectionTreshold extra extend to be added to the box in all direction
  82580. * @returns if the box was hit
  82581. */
  82582. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82583. /**
  82584. * Checks if the ray intersects a box
  82585. * @param box the bounding box to check
  82586. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82587. * @returns if the box was hit
  82588. */
  82589. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82590. /**
  82591. * If the ray hits a sphere
  82592. * @param sphere the bounding sphere to check
  82593. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82594. * @returns true if it hits the sphere
  82595. */
  82596. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82597. /**
  82598. * If the ray hits a triange
  82599. * @param vertex0 triangle vertex
  82600. * @param vertex1 triangle vertex
  82601. * @param vertex2 triangle vertex
  82602. * @returns intersection information if hit
  82603. */
  82604. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82605. /**
  82606. * Checks if ray intersects a plane
  82607. * @param plane the plane to check
  82608. * @returns the distance away it was hit
  82609. */
  82610. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82611. /**
  82612. * Calculate the intercept of a ray on a given axis
  82613. * @param axis to check 'x' | 'y' | 'z'
  82614. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82615. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82616. */
  82617. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82618. /**
  82619. * Checks if ray intersects a mesh
  82620. * @param mesh the mesh to check
  82621. * @param fastCheck if only the bounding box should checked
  82622. * @returns picking info of the intersecton
  82623. */
  82624. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82625. /**
  82626. * Checks if ray intersects a mesh
  82627. * @param meshes the meshes to check
  82628. * @param fastCheck if only the bounding box should checked
  82629. * @param results array to store result in
  82630. * @returns Array of picking infos
  82631. */
  82632. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82633. private _comparePickingInfo;
  82634. private static smallnum;
  82635. private static rayl;
  82636. /**
  82637. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82638. * @param sega the first point of the segment to test the intersection against
  82639. * @param segb the second point of the segment to test the intersection against
  82640. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82641. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82642. */
  82643. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82644. /**
  82645. * Update the ray from viewport position
  82646. * @param x position
  82647. * @param y y position
  82648. * @param viewportWidth viewport width
  82649. * @param viewportHeight viewport height
  82650. * @param world world matrix
  82651. * @param view view matrix
  82652. * @param projection projection matrix
  82653. * @returns this ray updated
  82654. */
  82655. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82656. /**
  82657. * Creates a ray with origin and direction of 0,0,0
  82658. * @returns the new ray
  82659. */
  82660. static Zero(): Ray;
  82661. /**
  82662. * Creates a new ray from screen space and viewport
  82663. * @param x position
  82664. * @param y y position
  82665. * @param viewportWidth viewport width
  82666. * @param viewportHeight viewport height
  82667. * @param world world matrix
  82668. * @param view view matrix
  82669. * @param projection projection matrix
  82670. * @returns new ray
  82671. */
  82672. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82673. /**
  82674. * 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
  82675. * transformed to the given world matrix.
  82676. * @param origin The origin point
  82677. * @param end The end point
  82678. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82679. * @returns the new ray
  82680. */
  82681. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82682. /**
  82683. * Transforms a ray by a matrix
  82684. * @param ray ray to transform
  82685. * @param matrix matrix to apply
  82686. * @returns the resulting new ray
  82687. */
  82688. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82689. /**
  82690. * Transforms a ray by a matrix
  82691. * @param ray ray to transform
  82692. * @param matrix matrix to apply
  82693. * @param result ray to store result in
  82694. */
  82695. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82696. /**
  82697. * Unproject a ray from screen space to object space
  82698. * @param sourceX defines the screen space x coordinate to use
  82699. * @param sourceY defines the screen space y coordinate to use
  82700. * @param viewportWidth defines the current width of the viewport
  82701. * @param viewportHeight defines the current height of the viewport
  82702. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82703. * @param view defines the view matrix to use
  82704. * @param projection defines the projection matrix to use
  82705. */
  82706. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82707. }
  82708. /**
  82709. * Type used to define predicate used to select faces when a mesh intersection is detected
  82710. */
  82711. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82712. interface Scene {
  82713. /** @hidden */
  82714. _tempPickingRay: Nullable<Ray>;
  82715. /** @hidden */
  82716. _cachedRayForTransform: Ray;
  82717. /** @hidden */
  82718. _pickWithRayInverseMatrix: Matrix;
  82719. /** @hidden */
  82720. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82721. /** @hidden */
  82722. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82723. }
  82724. }
  82725. declare module BABYLON {
  82726. /**
  82727. * Groups all the scene component constants in one place to ease maintenance.
  82728. * @hidden
  82729. */
  82730. export class SceneComponentConstants {
  82731. static readonly NAME_EFFECTLAYER: string;
  82732. static readonly NAME_LAYER: string;
  82733. static readonly NAME_LENSFLARESYSTEM: string;
  82734. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82735. static readonly NAME_PARTICLESYSTEM: string;
  82736. static readonly NAME_GAMEPAD: string;
  82737. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82738. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82739. static readonly NAME_DEPTHRENDERER: string;
  82740. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82741. static readonly NAME_SPRITE: string;
  82742. static readonly NAME_OUTLINERENDERER: string;
  82743. static readonly NAME_PROCEDURALTEXTURE: string;
  82744. static readonly NAME_SHADOWGENERATOR: string;
  82745. static readonly NAME_OCTREE: string;
  82746. static readonly NAME_PHYSICSENGINE: string;
  82747. static readonly NAME_AUDIO: string;
  82748. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82749. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82750. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82751. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82752. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82753. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82754. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82755. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82756. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82757. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82758. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82759. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82760. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82761. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82762. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82763. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82764. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82765. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82766. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82767. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82768. static readonly STEP_AFTERRENDER_AUDIO: number;
  82769. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82770. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82771. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82772. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82773. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82774. static readonly STEP_POINTERMOVE_SPRITE: number;
  82775. static readonly STEP_POINTERDOWN_SPRITE: number;
  82776. static readonly STEP_POINTERUP_SPRITE: number;
  82777. }
  82778. /**
  82779. * This represents a scene component.
  82780. *
  82781. * This is used to decouple the dependency the scene is having on the different workloads like
  82782. * layers, post processes...
  82783. */
  82784. export interface ISceneComponent {
  82785. /**
  82786. * The name of the component. Each component must have a unique name.
  82787. */
  82788. name: string;
  82789. /**
  82790. * The scene the component belongs to.
  82791. */
  82792. scene: Scene;
  82793. /**
  82794. * Register the component to one instance of a scene.
  82795. */
  82796. register(): void;
  82797. /**
  82798. * Rebuilds the elements related to this component in case of
  82799. * context lost for instance.
  82800. */
  82801. rebuild(): void;
  82802. /**
  82803. * Disposes the component and the associated ressources.
  82804. */
  82805. dispose(): void;
  82806. }
  82807. /**
  82808. * This represents a SERIALIZABLE scene component.
  82809. *
  82810. * This extends Scene Component to add Serialization methods on top.
  82811. */
  82812. export interface ISceneSerializableComponent extends ISceneComponent {
  82813. /**
  82814. * Adds all the elements from the container to the scene
  82815. * @param container the container holding the elements
  82816. */
  82817. addFromContainer(container: AbstractScene): void;
  82818. /**
  82819. * Removes all the elements in the container from the scene
  82820. * @param container contains the elements to remove
  82821. * @param dispose if the removed element should be disposed (default: false)
  82822. */
  82823. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82824. /**
  82825. * Serializes the component data to the specified json object
  82826. * @param serializationObject The object to serialize to
  82827. */
  82828. serialize(serializationObject: any): void;
  82829. }
  82830. /**
  82831. * Strong typing of a Mesh related stage step action
  82832. */
  82833. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82834. /**
  82835. * Strong typing of a Evaluate Sub Mesh related stage step action
  82836. */
  82837. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82838. /**
  82839. * Strong typing of a Active Mesh related stage step action
  82840. */
  82841. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82842. /**
  82843. * Strong typing of a Camera related stage step action
  82844. */
  82845. export type CameraStageAction = (camera: Camera) => void;
  82846. /**
  82847. * Strong typing of a Camera Frame buffer related stage step action
  82848. */
  82849. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82850. /**
  82851. * Strong typing of a Render Target related stage step action
  82852. */
  82853. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82854. /**
  82855. * Strong typing of a RenderingGroup related stage step action
  82856. */
  82857. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82858. /**
  82859. * Strong typing of a Mesh Render related stage step action
  82860. */
  82861. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82862. /**
  82863. * Strong typing of a simple stage step action
  82864. */
  82865. export type SimpleStageAction = () => void;
  82866. /**
  82867. * Strong typing of a render target action.
  82868. */
  82869. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82870. /**
  82871. * Strong typing of a pointer move action.
  82872. */
  82873. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82874. /**
  82875. * Strong typing of a pointer up/down action.
  82876. */
  82877. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82878. /**
  82879. * Representation of a stage in the scene (Basically a list of ordered steps)
  82880. * @hidden
  82881. */
  82882. export class Stage<T extends Function> extends Array<{
  82883. index: number;
  82884. component: ISceneComponent;
  82885. action: T;
  82886. }> {
  82887. /**
  82888. * Hide ctor from the rest of the world.
  82889. * @param items The items to add.
  82890. */
  82891. private constructor();
  82892. /**
  82893. * Creates a new Stage.
  82894. * @returns A new instance of a Stage
  82895. */
  82896. static Create<T extends Function>(): Stage<T>;
  82897. /**
  82898. * Registers a step in an ordered way in the targeted stage.
  82899. * @param index Defines the position to register the step in
  82900. * @param component Defines the component attached to the step
  82901. * @param action Defines the action to launch during the step
  82902. */
  82903. registerStep(index: number, component: ISceneComponent, action: T): void;
  82904. /**
  82905. * Clears all the steps from the stage.
  82906. */
  82907. clear(): void;
  82908. }
  82909. }
  82910. declare module BABYLON {
  82911. interface Scene {
  82912. /** @hidden */
  82913. _pointerOverSprite: Nullable<Sprite>;
  82914. /** @hidden */
  82915. _pickedDownSprite: Nullable<Sprite>;
  82916. /** @hidden */
  82917. _tempSpritePickingRay: Nullable<Ray>;
  82918. /**
  82919. * All of the sprite managers added to this scene
  82920. * @see http://doc.babylonjs.com/babylon101/sprites
  82921. */
  82922. spriteManagers: Array<ISpriteManager>;
  82923. /**
  82924. * An event triggered when sprites rendering is about to start
  82925. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82926. */
  82927. onBeforeSpritesRenderingObservable: Observable<Scene>;
  82928. /**
  82929. * An event triggered when sprites rendering is done
  82930. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  82931. */
  82932. onAfterSpritesRenderingObservable: Observable<Scene>;
  82933. /** @hidden */
  82934. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82935. /** Launch a ray to try to pick a sprite in the scene
  82936. * @param x position on screen
  82937. * @param y position on screen
  82938. * @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
  82939. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82940. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82941. * @returns a PickingInfo
  82942. */
  82943. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82944. /** Use the given ray to pick a sprite in the scene
  82945. * @param ray The ray (in world space) to use to pick meshes
  82946. * @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
  82947. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  82948. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82949. * @returns a PickingInfo
  82950. */
  82951. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  82952. /** @hidden */
  82953. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82954. /** Launch a ray to try to pick sprites in the scene
  82955. * @param x position on screen
  82956. * @param y position on screen
  82957. * @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
  82958. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  82959. * @returns a PickingInfo array
  82960. */
  82961. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82962. /** Use the given ray to pick sprites in the scene
  82963. * @param ray The ray (in world space) to use to pick meshes
  82964. * @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
  82965. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  82966. * @returns a PickingInfo array
  82967. */
  82968. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  82969. /**
  82970. * Force the sprite under the pointer
  82971. * @param sprite defines the sprite to use
  82972. */
  82973. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  82974. /**
  82975. * Gets the sprite under the pointer
  82976. * @returns a Sprite or null if no sprite is under the pointer
  82977. */
  82978. getPointerOverSprite(): Nullable<Sprite>;
  82979. }
  82980. /**
  82981. * Defines the sprite scene component responsible to manage sprites
  82982. * in a given scene.
  82983. */
  82984. export class SpriteSceneComponent implements ISceneComponent {
  82985. /**
  82986. * The component name helpfull to identify the component in the list of scene components.
  82987. */
  82988. readonly name: string;
  82989. /**
  82990. * The scene the component belongs to.
  82991. */
  82992. scene: Scene;
  82993. /** @hidden */
  82994. private _spritePredicate;
  82995. /**
  82996. * Creates a new instance of the component for the given scene
  82997. * @param scene Defines the scene to register the component in
  82998. */
  82999. constructor(scene: Scene);
  83000. /**
  83001. * Registers the component in a given scene
  83002. */
  83003. register(): void;
  83004. /**
  83005. * Rebuilds the elements related to this component in case of
  83006. * context lost for instance.
  83007. */
  83008. rebuild(): void;
  83009. /**
  83010. * Disposes the component and the associated ressources.
  83011. */
  83012. dispose(): void;
  83013. private _pickSpriteButKeepRay;
  83014. private _pointerMove;
  83015. private _pointerDown;
  83016. private _pointerUp;
  83017. }
  83018. }
  83019. declare module BABYLON {
  83020. /** @hidden */
  83021. export var fogFragmentDeclaration: {
  83022. name: string;
  83023. shader: string;
  83024. };
  83025. }
  83026. declare module BABYLON {
  83027. /** @hidden */
  83028. export var fogFragment: {
  83029. name: string;
  83030. shader: string;
  83031. };
  83032. }
  83033. declare module BABYLON {
  83034. /** @hidden */
  83035. export var spritesPixelShader: {
  83036. name: string;
  83037. shader: string;
  83038. };
  83039. }
  83040. declare module BABYLON {
  83041. /** @hidden */
  83042. export var fogVertexDeclaration: {
  83043. name: string;
  83044. shader: string;
  83045. };
  83046. }
  83047. declare module BABYLON {
  83048. /** @hidden */
  83049. export var spritesVertexShader: {
  83050. name: string;
  83051. shader: string;
  83052. };
  83053. }
  83054. declare module BABYLON {
  83055. /**
  83056. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83057. */
  83058. export interface ISpriteManager extends IDisposable {
  83059. /**
  83060. * Restricts the camera to viewing objects with the same layerMask.
  83061. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83062. */
  83063. layerMask: number;
  83064. /**
  83065. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83066. */
  83067. isPickable: boolean;
  83068. /**
  83069. * Specifies the rendering group id for this mesh (0 by default)
  83070. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83071. */
  83072. renderingGroupId: number;
  83073. /**
  83074. * Defines the list of sprites managed by the manager.
  83075. */
  83076. sprites: Array<Sprite>;
  83077. /**
  83078. * Tests the intersection of a sprite with a specific ray.
  83079. * @param ray The ray we are sending to test the collision
  83080. * @param camera The camera space we are sending rays in
  83081. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83082. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83083. * @returns picking info or null.
  83084. */
  83085. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83086. /**
  83087. * Intersects the sprites with a ray
  83088. * @param ray defines the ray to intersect with
  83089. * @param camera defines the current active camera
  83090. * @param predicate defines a predicate used to select candidate sprites
  83091. * @returns null if no hit or a PickingInfo array
  83092. */
  83093. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83094. /**
  83095. * Renders the list of sprites on screen.
  83096. */
  83097. render(): void;
  83098. }
  83099. /**
  83100. * Class used to manage multiple sprites on the same spritesheet
  83101. * @see http://doc.babylonjs.com/babylon101/sprites
  83102. */
  83103. export class SpriteManager implements ISpriteManager {
  83104. /** defines the manager's name */
  83105. name: string;
  83106. /** Gets the list of sprites */
  83107. sprites: Sprite[];
  83108. /** Gets or sets the rendering group id (0 by default) */
  83109. renderingGroupId: number;
  83110. /** Gets or sets camera layer mask */
  83111. layerMask: number;
  83112. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83113. fogEnabled: boolean;
  83114. /** Gets or sets a boolean indicating if the sprites are pickable */
  83115. isPickable: boolean;
  83116. /** Defines the default width of a cell in the spritesheet */
  83117. cellWidth: number;
  83118. /** Defines the default height of a cell in the spritesheet */
  83119. cellHeight: number;
  83120. /** Associative array from JSON sprite data file */
  83121. private _cellData;
  83122. /** Array of sprite names from JSON sprite data file */
  83123. private _spriteMap;
  83124. /** True when packed cell data from JSON file is ready*/
  83125. private _packedAndReady;
  83126. /**
  83127. * An event triggered when the manager is disposed.
  83128. */
  83129. onDisposeObservable: Observable<SpriteManager>;
  83130. private _onDisposeObserver;
  83131. /**
  83132. * Callback called when the manager is disposed
  83133. */
  83134. set onDispose(callback: () => void);
  83135. private _capacity;
  83136. private _fromPacked;
  83137. private _spriteTexture;
  83138. private _epsilon;
  83139. private _scene;
  83140. private _vertexData;
  83141. private _buffer;
  83142. private _vertexBuffers;
  83143. private _indexBuffer;
  83144. private _effectBase;
  83145. private _effectFog;
  83146. /**
  83147. * Gets or sets the spritesheet texture
  83148. */
  83149. get texture(): Texture;
  83150. set texture(value: Texture);
  83151. /**
  83152. * Creates a new sprite manager
  83153. * @param name defines the manager's name
  83154. * @param imgUrl defines the sprite sheet url
  83155. * @param capacity defines the maximum allowed number of sprites
  83156. * @param cellSize defines the size of a sprite cell
  83157. * @param scene defines the hosting scene
  83158. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83159. * @param samplingMode defines the smapling mode to use with spritesheet
  83160. * @param fromPacked set to false; do not alter
  83161. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83162. */
  83163. constructor(
  83164. /** defines the manager's name */
  83165. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83166. private _makePacked;
  83167. private _appendSpriteVertex;
  83168. /**
  83169. * Intersects the sprites with a ray
  83170. * @param ray defines the ray to intersect with
  83171. * @param camera defines the current active camera
  83172. * @param predicate defines a predicate used to select candidate sprites
  83173. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83174. * @returns null if no hit or a PickingInfo
  83175. */
  83176. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83177. /**
  83178. * Intersects the sprites with a ray
  83179. * @param ray defines the ray to intersect with
  83180. * @param camera defines the current active camera
  83181. * @param predicate defines a predicate used to select candidate sprites
  83182. * @returns null if no hit or a PickingInfo array
  83183. */
  83184. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83185. /**
  83186. * Render all child sprites
  83187. */
  83188. render(): void;
  83189. /**
  83190. * Release associated resources
  83191. */
  83192. dispose(): void;
  83193. }
  83194. }
  83195. declare module BABYLON {
  83196. /**
  83197. * Class used to represent a sprite
  83198. * @see http://doc.babylonjs.com/babylon101/sprites
  83199. */
  83200. export class Sprite {
  83201. /** defines the name */
  83202. name: string;
  83203. /** Gets or sets the current world position */
  83204. position: Vector3;
  83205. /** Gets or sets the main color */
  83206. color: Color4;
  83207. /** Gets or sets the width */
  83208. width: number;
  83209. /** Gets or sets the height */
  83210. height: number;
  83211. /** Gets or sets rotation angle */
  83212. angle: number;
  83213. /** Gets or sets the cell index in the sprite sheet */
  83214. cellIndex: number;
  83215. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  83216. cellRef: string;
  83217. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  83218. invertU: number;
  83219. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  83220. invertV: number;
  83221. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  83222. disposeWhenFinishedAnimating: boolean;
  83223. /** Gets the list of attached animations */
  83224. animations: Animation[];
  83225. /** Gets or sets a boolean indicating if the sprite can be picked */
  83226. isPickable: boolean;
  83227. /**
  83228. * Gets or sets the associated action manager
  83229. */
  83230. actionManager: Nullable<ActionManager>;
  83231. private _animationStarted;
  83232. private _loopAnimation;
  83233. private _fromIndex;
  83234. private _toIndex;
  83235. private _delay;
  83236. private _direction;
  83237. private _manager;
  83238. private _time;
  83239. private _onAnimationEnd;
  83240. /**
  83241. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  83242. */
  83243. isVisible: boolean;
  83244. /**
  83245. * Gets or sets the sprite size
  83246. */
  83247. get size(): number;
  83248. set size(value: number);
  83249. /**
  83250. * Creates a new Sprite
  83251. * @param name defines the name
  83252. * @param manager defines the manager
  83253. */
  83254. constructor(
  83255. /** defines the name */
  83256. name: string, manager: ISpriteManager);
  83257. /**
  83258. * Starts an animation
  83259. * @param from defines the initial key
  83260. * @param to defines the end key
  83261. * @param loop defines if the animation must loop
  83262. * @param delay defines the start delay (in ms)
  83263. * @param onAnimationEnd defines a callback to call when animation ends
  83264. */
  83265. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  83266. /** Stops current animation (if any) */
  83267. stopAnimation(): void;
  83268. /** @hidden */
  83269. _animate(deltaTime: number): void;
  83270. /** Release associated resources */
  83271. dispose(): void;
  83272. }
  83273. }
  83274. declare module BABYLON {
  83275. /**
  83276. * Information about the result of picking within a scene
  83277. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  83278. */
  83279. export class PickingInfo {
  83280. /** @hidden */
  83281. _pickingUnavailable: boolean;
  83282. /**
  83283. * If the pick collided with an object
  83284. */
  83285. hit: boolean;
  83286. /**
  83287. * Distance away where the pick collided
  83288. */
  83289. distance: number;
  83290. /**
  83291. * The location of pick collision
  83292. */
  83293. pickedPoint: Nullable<Vector3>;
  83294. /**
  83295. * The mesh corresponding the the pick collision
  83296. */
  83297. pickedMesh: Nullable<AbstractMesh>;
  83298. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  83299. bu: number;
  83300. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  83301. bv: number;
  83302. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  83303. faceId: number;
  83304. /** Id of the the submesh that was picked */
  83305. subMeshId: number;
  83306. /** If a sprite was picked, this will be the sprite the pick collided with */
  83307. pickedSprite: Nullable<Sprite>;
  83308. /**
  83309. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  83310. */
  83311. originMesh: Nullable<AbstractMesh>;
  83312. /**
  83313. * The ray that was used to perform the picking.
  83314. */
  83315. ray: Nullable<Ray>;
  83316. /**
  83317. * Gets the normal correspodning to the face the pick collided with
  83318. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  83319. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  83320. * @returns The normal correspodning to the face the pick collided with
  83321. */
  83322. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  83323. /**
  83324. * Gets the texture coordinates of where the pick occured
  83325. * @returns the vector containing the coordnates of the texture
  83326. */
  83327. getTextureCoordinates(): Nullable<Vector2>;
  83328. }
  83329. }
  83330. declare module BABYLON {
  83331. /**
  83332. * Gather the list of pointer event types as constants.
  83333. */
  83334. export class PointerEventTypes {
  83335. /**
  83336. * 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.
  83337. */
  83338. static readonly POINTERDOWN: number;
  83339. /**
  83340. * The pointerup event is fired when a pointer is no longer active.
  83341. */
  83342. static readonly POINTERUP: number;
  83343. /**
  83344. * The pointermove event is fired when a pointer changes coordinates.
  83345. */
  83346. static readonly POINTERMOVE: number;
  83347. /**
  83348. * The pointerwheel event is fired when a mouse wheel has been rotated.
  83349. */
  83350. static readonly POINTERWHEEL: number;
  83351. /**
  83352. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  83353. */
  83354. static readonly POINTERPICK: number;
  83355. /**
  83356. * The pointertap event is fired when a the object has been touched and released without drag.
  83357. */
  83358. static readonly POINTERTAP: number;
  83359. /**
  83360. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  83361. */
  83362. static readonly POINTERDOUBLETAP: number;
  83363. }
  83364. /**
  83365. * Base class of pointer info types.
  83366. */
  83367. export class PointerInfoBase {
  83368. /**
  83369. * Defines the type of event (PointerEventTypes)
  83370. */
  83371. type: number;
  83372. /**
  83373. * Defines the related dom event
  83374. */
  83375. event: PointerEvent | MouseWheelEvent;
  83376. /**
  83377. * Instantiates the base class of pointers info.
  83378. * @param type Defines the type of event (PointerEventTypes)
  83379. * @param event Defines the related dom event
  83380. */
  83381. constructor(
  83382. /**
  83383. * Defines the type of event (PointerEventTypes)
  83384. */
  83385. type: number,
  83386. /**
  83387. * Defines the related dom event
  83388. */
  83389. event: PointerEvent | MouseWheelEvent);
  83390. }
  83391. /**
  83392. * This class is used to store pointer related info for the onPrePointerObservable event.
  83393. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  83394. */
  83395. export class PointerInfoPre extends PointerInfoBase {
  83396. /**
  83397. * Ray from a pointer if availible (eg. 6dof controller)
  83398. */
  83399. ray: Nullable<Ray>;
  83400. /**
  83401. * Defines the local position of the pointer on the canvas.
  83402. */
  83403. localPosition: Vector2;
  83404. /**
  83405. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  83406. */
  83407. skipOnPointerObservable: boolean;
  83408. /**
  83409. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  83410. * @param type Defines the type of event (PointerEventTypes)
  83411. * @param event Defines the related dom event
  83412. * @param localX Defines the local x coordinates of the pointer when the event occured
  83413. * @param localY Defines the local y coordinates of the pointer when the event occured
  83414. */
  83415. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  83416. }
  83417. /**
  83418. * This type contains all the data related to a pointer event in Babylon.js.
  83419. * 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.
  83420. */
  83421. export class PointerInfo extends PointerInfoBase {
  83422. /**
  83423. * Defines the picking info associated to the info (if any)\
  83424. */
  83425. pickInfo: Nullable<PickingInfo>;
  83426. /**
  83427. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  83428. * @param type Defines the type of event (PointerEventTypes)
  83429. * @param event Defines the related dom event
  83430. * @param pickInfo Defines the picking info associated to the info (if any)\
  83431. */
  83432. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  83433. /**
  83434. * Defines the picking info associated to the info (if any)\
  83435. */
  83436. pickInfo: Nullable<PickingInfo>);
  83437. }
  83438. /**
  83439. * Data relating to a touch event on the screen.
  83440. */
  83441. export interface PointerTouch {
  83442. /**
  83443. * X coordinate of touch.
  83444. */
  83445. x: number;
  83446. /**
  83447. * Y coordinate of touch.
  83448. */
  83449. y: number;
  83450. /**
  83451. * Id of touch. Unique for each finger.
  83452. */
  83453. pointerId: number;
  83454. /**
  83455. * Event type passed from DOM.
  83456. */
  83457. type: any;
  83458. }
  83459. }
  83460. declare module BABYLON {
  83461. /**
  83462. * Manage the mouse inputs to control the movement of a free camera.
  83463. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83464. */
  83465. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  83466. /**
  83467. * Define if touch is enabled in the mouse input
  83468. */
  83469. touchEnabled: boolean;
  83470. /**
  83471. * Defines the camera the input is attached to.
  83472. */
  83473. camera: FreeCamera;
  83474. /**
  83475. * Defines the buttons associated with the input to handle camera move.
  83476. */
  83477. buttons: number[];
  83478. /**
  83479. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  83480. */
  83481. angularSensibility: number;
  83482. private _pointerInput;
  83483. private _onMouseMove;
  83484. private _observer;
  83485. private previousPosition;
  83486. /**
  83487. * Observable for when a pointer move event occurs containing the move offset
  83488. */
  83489. onPointerMovedObservable: Observable<{
  83490. offsetX: number;
  83491. offsetY: number;
  83492. }>;
  83493. /**
  83494. * @hidden
  83495. * If the camera should be rotated automatically based on pointer movement
  83496. */
  83497. _allowCameraRotation: boolean;
  83498. /**
  83499. * Manage the mouse inputs to control the movement of a free camera.
  83500. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83501. * @param touchEnabled Defines if touch is enabled or not
  83502. */
  83503. constructor(
  83504. /**
  83505. * Define if touch is enabled in the mouse input
  83506. */
  83507. touchEnabled?: boolean);
  83508. /**
  83509. * Attach the input controls to a specific dom element to get the input from.
  83510. * @param element Defines the element the controls should be listened from
  83511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83512. */
  83513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83514. /**
  83515. * Called on JS contextmenu event.
  83516. * Override this method to provide functionality.
  83517. */
  83518. protected onContextMenu(evt: PointerEvent): void;
  83519. /**
  83520. * Detach the current controls from the specified dom element.
  83521. * @param element Defines the element to stop listening the inputs from
  83522. */
  83523. detachControl(element: Nullable<HTMLElement>): void;
  83524. /**
  83525. * Gets the class name of the current intput.
  83526. * @returns the class name
  83527. */
  83528. getClassName(): string;
  83529. /**
  83530. * Get the friendly name associated with the input class.
  83531. * @returns the input friendly name
  83532. */
  83533. getSimpleName(): string;
  83534. }
  83535. }
  83536. declare module BABYLON {
  83537. /**
  83538. * Manage the touch inputs to control the movement of a free camera.
  83539. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83540. */
  83541. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  83542. /**
  83543. * Defines the camera the input is attached to.
  83544. */
  83545. camera: FreeCamera;
  83546. /**
  83547. * Defines the touch sensibility for rotation.
  83548. * The higher the faster.
  83549. */
  83550. touchAngularSensibility: number;
  83551. /**
  83552. * Defines the touch sensibility for move.
  83553. * The higher the faster.
  83554. */
  83555. touchMoveSensibility: number;
  83556. private _offsetX;
  83557. private _offsetY;
  83558. private _pointerPressed;
  83559. private _pointerInput;
  83560. private _observer;
  83561. private _onLostFocus;
  83562. /**
  83563. * Attach the input controls to a specific dom element to get the input from.
  83564. * @param element Defines the element the controls should be listened from
  83565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83566. */
  83567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83568. /**
  83569. * Detach the current controls from the specified dom element.
  83570. * @param element Defines the element to stop listening the inputs from
  83571. */
  83572. detachControl(element: Nullable<HTMLElement>): void;
  83573. /**
  83574. * Update the current camera state depending on the inputs that have been used this frame.
  83575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83576. */
  83577. checkInputs(): void;
  83578. /**
  83579. * Gets the class name of the current intput.
  83580. * @returns the class name
  83581. */
  83582. getClassName(): string;
  83583. /**
  83584. * Get the friendly name associated with the input class.
  83585. * @returns the input friendly name
  83586. */
  83587. getSimpleName(): string;
  83588. }
  83589. }
  83590. declare module BABYLON {
  83591. /**
  83592. * Default Inputs manager for the FreeCamera.
  83593. * It groups all the default supported inputs for ease of use.
  83594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83595. */
  83596. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  83597. /**
  83598. * @hidden
  83599. */
  83600. _mouseInput: Nullable<FreeCameraMouseInput>;
  83601. /**
  83602. * Instantiates a new FreeCameraInputsManager.
  83603. * @param camera Defines the camera the inputs belong to
  83604. */
  83605. constructor(camera: FreeCamera);
  83606. /**
  83607. * Add keyboard input support to the input manager.
  83608. * @returns the current input manager
  83609. */
  83610. addKeyboard(): FreeCameraInputsManager;
  83611. /**
  83612. * Add mouse input support to the input manager.
  83613. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  83614. * @returns the current input manager
  83615. */
  83616. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  83617. /**
  83618. * Removes the mouse input support from the manager
  83619. * @returns the current input manager
  83620. */
  83621. removeMouse(): FreeCameraInputsManager;
  83622. /**
  83623. * Add touch input support to the input manager.
  83624. * @returns the current input manager
  83625. */
  83626. addTouch(): FreeCameraInputsManager;
  83627. /**
  83628. * Remove all attached input methods from a camera
  83629. */
  83630. clear(): void;
  83631. }
  83632. }
  83633. declare module BABYLON {
  83634. /**
  83635. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  83636. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  83637. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  83638. */
  83639. export class FreeCamera extends TargetCamera {
  83640. /**
  83641. * Define the collision ellipsoid of the camera.
  83642. * This is helpful to simulate a camera body like the player body around the camera
  83643. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  83644. */
  83645. ellipsoid: Vector3;
  83646. /**
  83647. * Define an offset for the position of the ellipsoid around the camera.
  83648. * This can be helpful to determine the center of the body near the gravity center of the body
  83649. * instead of its head.
  83650. */
  83651. ellipsoidOffset: Vector3;
  83652. /**
  83653. * Enable or disable collisions of the camera with the rest of the scene objects.
  83654. */
  83655. checkCollisions: boolean;
  83656. /**
  83657. * Enable or disable gravity on the camera.
  83658. */
  83659. applyGravity: boolean;
  83660. /**
  83661. * Define the input manager associated to the camera.
  83662. */
  83663. inputs: FreeCameraInputsManager;
  83664. /**
  83665. * Gets the input sensibility for a mouse input. (default is 2000.0)
  83666. * Higher values reduce sensitivity.
  83667. */
  83668. get angularSensibility(): number;
  83669. /**
  83670. * Sets the input sensibility for a mouse input. (default is 2000.0)
  83671. * Higher values reduce sensitivity.
  83672. */
  83673. set angularSensibility(value: number);
  83674. /**
  83675. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  83676. */
  83677. get keysUp(): number[];
  83678. set keysUp(value: number[]);
  83679. /**
  83680. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  83681. */
  83682. get keysDown(): number[];
  83683. set keysDown(value: number[]);
  83684. /**
  83685. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  83686. */
  83687. get keysLeft(): number[];
  83688. set keysLeft(value: number[]);
  83689. /**
  83690. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  83691. */
  83692. get keysRight(): number[];
  83693. set keysRight(value: number[]);
  83694. /**
  83695. * Event raised when the camera collide with a mesh in the scene.
  83696. */
  83697. onCollide: (collidedMesh: AbstractMesh) => void;
  83698. private _collider;
  83699. private _needMoveForGravity;
  83700. private _oldPosition;
  83701. private _diffPosition;
  83702. private _newPosition;
  83703. /** @hidden */
  83704. _localDirection: Vector3;
  83705. /** @hidden */
  83706. _transformedDirection: Vector3;
  83707. /**
  83708. * Instantiates a Free Camera.
  83709. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  83710. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  83711. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  83712. * @param name Define the name of the camera in the scene
  83713. * @param position Define the start position of the camera in the scene
  83714. * @param scene Define the scene the camera belongs to
  83715. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  83716. */
  83717. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  83718. /**
  83719. * Attached controls to the current camera.
  83720. * @param element Defines the element the controls should be listened from
  83721. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83722. */
  83723. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83724. /**
  83725. * Detach the current controls from the camera.
  83726. * The camera will stop reacting to inputs.
  83727. * @param element Defines the element to stop listening the inputs from
  83728. */
  83729. detachControl(element: HTMLElement): void;
  83730. private _collisionMask;
  83731. /**
  83732. * Define a collision mask to limit the list of object the camera can collide with
  83733. */
  83734. get collisionMask(): number;
  83735. set collisionMask(mask: number);
  83736. /** @hidden */
  83737. _collideWithWorld(displacement: Vector3): void;
  83738. private _onCollisionPositionChange;
  83739. /** @hidden */
  83740. _checkInputs(): void;
  83741. /** @hidden */
  83742. _decideIfNeedsToMove(): boolean;
  83743. /** @hidden */
  83744. _updatePosition(): void;
  83745. /**
  83746. * Destroy the camera and release the current resources hold by it.
  83747. */
  83748. dispose(): void;
  83749. /**
  83750. * Gets the current object class name.
  83751. * @return the class name
  83752. */
  83753. getClassName(): string;
  83754. }
  83755. }
  83756. declare module BABYLON {
  83757. /**
  83758. * Represents a gamepad control stick position
  83759. */
  83760. export class StickValues {
  83761. /**
  83762. * The x component of the control stick
  83763. */
  83764. x: number;
  83765. /**
  83766. * The y component of the control stick
  83767. */
  83768. y: number;
  83769. /**
  83770. * Initializes the gamepad x and y control stick values
  83771. * @param x The x component of the gamepad control stick value
  83772. * @param y The y component of the gamepad control stick value
  83773. */
  83774. constructor(
  83775. /**
  83776. * The x component of the control stick
  83777. */
  83778. x: number,
  83779. /**
  83780. * The y component of the control stick
  83781. */
  83782. y: number);
  83783. }
  83784. /**
  83785. * An interface which manages callbacks for gamepad button changes
  83786. */
  83787. export interface GamepadButtonChanges {
  83788. /**
  83789. * Called when a gamepad has been changed
  83790. */
  83791. changed: boolean;
  83792. /**
  83793. * Called when a gamepad press event has been triggered
  83794. */
  83795. pressChanged: boolean;
  83796. /**
  83797. * Called when a touch event has been triggered
  83798. */
  83799. touchChanged: boolean;
  83800. /**
  83801. * Called when a value has changed
  83802. */
  83803. valueChanged: boolean;
  83804. }
  83805. /**
  83806. * Represents a gamepad
  83807. */
  83808. export class Gamepad {
  83809. /**
  83810. * The id of the gamepad
  83811. */
  83812. id: string;
  83813. /**
  83814. * The index of the gamepad
  83815. */
  83816. index: number;
  83817. /**
  83818. * The browser gamepad
  83819. */
  83820. browserGamepad: any;
  83821. /**
  83822. * Specifies what type of gamepad this represents
  83823. */
  83824. type: number;
  83825. private _leftStick;
  83826. private _rightStick;
  83827. /** @hidden */
  83828. _isConnected: boolean;
  83829. private _leftStickAxisX;
  83830. private _leftStickAxisY;
  83831. private _rightStickAxisX;
  83832. private _rightStickAxisY;
  83833. /**
  83834. * Triggered when the left control stick has been changed
  83835. */
  83836. private _onleftstickchanged;
  83837. /**
  83838. * Triggered when the right control stick has been changed
  83839. */
  83840. private _onrightstickchanged;
  83841. /**
  83842. * Represents a gamepad controller
  83843. */
  83844. static GAMEPAD: number;
  83845. /**
  83846. * Represents a generic controller
  83847. */
  83848. static GENERIC: number;
  83849. /**
  83850. * Represents an XBox controller
  83851. */
  83852. static XBOX: number;
  83853. /**
  83854. * Represents a pose-enabled controller
  83855. */
  83856. static POSE_ENABLED: number;
  83857. /**
  83858. * Represents an Dual Shock controller
  83859. */
  83860. static DUALSHOCK: number;
  83861. /**
  83862. * Specifies whether the left control stick should be Y-inverted
  83863. */
  83864. protected _invertLeftStickY: boolean;
  83865. /**
  83866. * Specifies if the gamepad has been connected
  83867. */
  83868. get isConnected(): boolean;
  83869. /**
  83870. * Initializes the gamepad
  83871. * @param id The id of the gamepad
  83872. * @param index The index of the gamepad
  83873. * @param browserGamepad The browser gamepad
  83874. * @param leftStickX The x component of the left joystick
  83875. * @param leftStickY The y component of the left joystick
  83876. * @param rightStickX The x component of the right joystick
  83877. * @param rightStickY The y component of the right joystick
  83878. */
  83879. constructor(
  83880. /**
  83881. * The id of the gamepad
  83882. */
  83883. id: string,
  83884. /**
  83885. * The index of the gamepad
  83886. */
  83887. index: number,
  83888. /**
  83889. * The browser gamepad
  83890. */
  83891. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  83892. /**
  83893. * Callback triggered when the left joystick has changed
  83894. * @param callback
  83895. */
  83896. onleftstickchanged(callback: (values: StickValues) => void): void;
  83897. /**
  83898. * Callback triggered when the right joystick has changed
  83899. * @param callback
  83900. */
  83901. onrightstickchanged(callback: (values: StickValues) => void): void;
  83902. /**
  83903. * Gets the left joystick
  83904. */
  83905. get leftStick(): StickValues;
  83906. /**
  83907. * Sets the left joystick values
  83908. */
  83909. set leftStick(newValues: StickValues);
  83910. /**
  83911. * Gets the right joystick
  83912. */
  83913. get rightStick(): StickValues;
  83914. /**
  83915. * Sets the right joystick value
  83916. */
  83917. set rightStick(newValues: StickValues);
  83918. /**
  83919. * Updates the gamepad joystick positions
  83920. */
  83921. update(): void;
  83922. /**
  83923. * Disposes the gamepad
  83924. */
  83925. dispose(): void;
  83926. }
  83927. /**
  83928. * Represents a generic gamepad
  83929. */
  83930. export class GenericPad extends Gamepad {
  83931. private _buttons;
  83932. private _onbuttondown;
  83933. private _onbuttonup;
  83934. /**
  83935. * Observable triggered when a button has been pressed
  83936. */
  83937. onButtonDownObservable: Observable<number>;
  83938. /**
  83939. * Observable triggered when a button has been released
  83940. */
  83941. onButtonUpObservable: Observable<number>;
  83942. /**
  83943. * Callback triggered when a button has been pressed
  83944. * @param callback Called when a button has been pressed
  83945. */
  83946. onbuttondown(callback: (buttonPressed: number) => void): void;
  83947. /**
  83948. * Callback triggered when a button has been released
  83949. * @param callback Called when a button has been released
  83950. */
  83951. onbuttonup(callback: (buttonReleased: number) => void): void;
  83952. /**
  83953. * Initializes the generic gamepad
  83954. * @param id The id of the generic gamepad
  83955. * @param index The index of the generic gamepad
  83956. * @param browserGamepad The browser gamepad
  83957. */
  83958. constructor(id: string, index: number, browserGamepad: any);
  83959. private _setButtonValue;
  83960. /**
  83961. * Updates the generic gamepad
  83962. */
  83963. update(): void;
  83964. /**
  83965. * Disposes the generic gamepad
  83966. */
  83967. dispose(): void;
  83968. }
  83969. }
  83970. declare module BABYLON {
  83971. interface Engine {
  83972. /**
  83973. * Creates a raw texture
  83974. * @param data defines the data to store in the texture
  83975. * @param width defines the width of the texture
  83976. * @param height defines the height of the texture
  83977. * @param format defines the format of the data
  83978. * @param generateMipMaps defines if the engine should generate the mip levels
  83979. * @param invertY defines if data must be stored with Y axis inverted
  83980. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83981. * @param compression defines the compression used (null by default)
  83982. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83983. * @returns the raw texture inside an InternalTexture
  83984. */
  83985. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83986. /**
  83987. * Update a raw texture
  83988. * @param texture defines the texture to update
  83989. * @param data defines the data to store in the texture
  83990. * @param format defines the format of the data
  83991. * @param invertY defines if data must be stored with Y axis inverted
  83992. */
  83993. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83994. /**
  83995. * Update a raw texture
  83996. * @param texture defines the texture to update
  83997. * @param data defines the data to store in the texture
  83998. * @param format defines the format of the data
  83999. * @param invertY defines if data must be stored with Y axis inverted
  84000. * @param compression defines the compression used (null by default)
  84001. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84002. */
  84003. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  84004. /**
  84005. * Creates a new raw cube texture
  84006. * @param data defines the array of data to use to create each face
  84007. * @param size defines the size of the textures
  84008. * @param format defines the format of the data
  84009. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84010. * @param generateMipMaps defines if the engine should generate the mip levels
  84011. * @param invertY defines if data must be stored with Y axis inverted
  84012. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84013. * @param compression defines the compression used (null by default)
  84014. * @returns the cube texture as an InternalTexture
  84015. */
  84016. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  84017. /**
  84018. * Update a raw cube texture
  84019. * @param texture defines the texture to udpdate
  84020. * @param data defines the data to store
  84021. * @param format defines the data format
  84022. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84023. * @param invertY defines if data must be stored with Y axis inverted
  84024. */
  84025. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  84026. /**
  84027. * Update a raw cube texture
  84028. * @param texture defines the texture to udpdate
  84029. * @param data defines the data to store
  84030. * @param format defines the data format
  84031. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84032. * @param invertY defines if data must be stored with Y axis inverted
  84033. * @param compression defines the compression used (null by default)
  84034. */
  84035. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  84036. /**
  84037. * Update a raw cube texture
  84038. * @param texture defines the texture to udpdate
  84039. * @param data defines the data to store
  84040. * @param format defines the data format
  84041. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84042. * @param invertY defines if data must be stored with Y axis inverted
  84043. * @param compression defines the compression used (null by default)
  84044. * @param level defines which level of the texture to update
  84045. */
  84046. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  84047. /**
  84048. * Creates a new raw cube texture from a specified url
  84049. * @param url defines the url where the data is located
  84050. * @param scene defines the current scene
  84051. * @param size defines the size of the textures
  84052. * @param format defines the format of the data
  84053. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84054. * @param noMipmap defines if the engine should avoid generating the mip levels
  84055. * @param callback defines a callback used to extract texture data from loaded data
  84056. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84057. * @param onLoad defines a callback called when texture is loaded
  84058. * @param onError defines a callback called if there is an error
  84059. * @returns the cube texture as an InternalTexture
  84060. */
  84061. 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;
  84062. /**
  84063. * Creates a new raw cube texture from a specified url
  84064. * @param url defines the url where the data is located
  84065. * @param scene defines the current scene
  84066. * @param size defines the size of the textures
  84067. * @param format defines the format of the data
  84068. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84069. * @param noMipmap defines if the engine should avoid generating the mip levels
  84070. * @param callback defines a callback used to extract texture data from loaded data
  84071. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84072. * @param onLoad defines a callback called when texture is loaded
  84073. * @param onError defines a callback called if there is an error
  84074. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84075. * @param invertY defines if data must be stored with Y axis inverted
  84076. * @returns the cube texture as an InternalTexture
  84077. */
  84078. 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;
  84079. /**
  84080. * Creates a new raw 3D texture
  84081. * @param data defines the data used to create the texture
  84082. * @param width defines the width of the texture
  84083. * @param height defines the height of the texture
  84084. * @param depth defines the depth of the texture
  84085. * @param format defines the format of the texture
  84086. * @param generateMipMaps defines if the engine must generate mip levels
  84087. * @param invertY defines if data must be stored with Y axis inverted
  84088. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84089. * @param compression defines the compressed used (can be null)
  84090. * @param textureType defines the compressed used (can be null)
  84091. * @returns a new raw 3D texture (stored in an InternalTexture)
  84092. */
  84093. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84094. /**
  84095. * Update a raw 3D texture
  84096. * @param texture defines the texture to update
  84097. * @param data defines the data to store
  84098. * @param format defines the data format
  84099. * @param invertY defines if data must be stored with Y axis inverted
  84100. */
  84101. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84102. /**
  84103. * Update a raw 3D texture
  84104. * @param texture defines the texture to update
  84105. * @param data defines the data to store
  84106. * @param format defines the data format
  84107. * @param invertY defines if data must be stored with Y axis inverted
  84108. * @param compression defines the used compression (can be null)
  84109. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84110. */
  84111. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84112. /**
  84113. * Creates a new raw 2D array texture
  84114. * @param data defines the data used to create the texture
  84115. * @param width defines the width of the texture
  84116. * @param height defines the height of the texture
  84117. * @param depth defines the number of layers of the texture
  84118. * @param format defines the format of the texture
  84119. * @param generateMipMaps defines if the engine must generate mip levels
  84120. * @param invertY defines if data must be stored with Y axis inverted
  84121. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84122. * @param compression defines the compressed used (can be null)
  84123. * @param textureType defines the compressed used (can be null)
  84124. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84125. */
  84126. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84127. /**
  84128. * Update a raw 2D array texture
  84129. * @param texture defines the texture to update
  84130. * @param data defines the data to store
  84131. * @param format defines the data format
  84132. * @param invertY defines if data must be stored with Y axis inverted
  84133. */
  84134. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84135. /**
  84136. * Update a raw 2D array texture
  84137. * @param texture defines the texture to update
  84138. * @param data defines the data to store
  84139. * @param format defines the data format
  84140. * @param invertY defines if data must be stored with Y axis inverted
  84141. * @param compression defines the used compression (can be null)
  84142. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84143. */
  84144. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84145. }
  84146. }
  84147. declare module BABYLON {
  84148. /**
  84149. * Raw texture can help creating a texture directly from an array of data.
  84150. * This can be super useful if you either get the data from an uncompressed source or
  84151. * if you wish to create your texture pixel by pixel.
  84152. */
  84153. export class RawTexture extends Texture {
  84154. /**
  84155. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84156. */
  84157. format: number;
  84158. private _engine;
  84159. /**
  84160. * Instantiates a new RawTexture.
  84161. * Raw texture can help creating a texture directly from an array of data.
  84162. * This can be super useful if you either get the data from an uncompressed source or
  84163. * if you wish to create your texture pixel by pixel.
  84164. * @param data define the array of data to use to create the texture
  84165. * @param width define the width of the texture
  84166. * @param height define the height of the texture
  84167. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84168. * @param scene define the scene the texture belongs to
  84169. * @param generateMipMaps define whether mip maps should be generated or not
  84170. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84171. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84172. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84173. */
  84174. constructor(data: ArrayBufferView, width: number, height: number,
  84175. /**
  84176. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84177. */
  84178. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84179. /**
  84180. * Updates the texture underlying data.
  84181. * @param data Define the new data of the texture
  84182. */
  84183. update(data: ArrayBufferView): void;
  84184. /**
  84185. * Creates a luminance texture from some data.
  84186. * @param data Define the texture data
  84187. * @param width Define the width of the texture
  84188. * @param height Define the height of the texture
  84189. * @param scene Define the scene the texture belongs to
  84190. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84191. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84192. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84193. * @returns the luminance texture
  84194. */
  84195. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84196. /**
  84197. * Creates a luminance alpha texture from some data.
  84198. * @param data Define the texture data
  84199. * @param width Define the width of the texture
  84200. * @param height Define the height of the texture
  84201. * @param scene Define the scene the texture belongs to
  84202. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84203. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84204. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84205. * @returns the luminance alpha texture
  84206. */
  84207. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84208. /**
  84209. * Creates an alpha texture from some data.
  84210. * @param data Define the texture data
  84211. * @param width Define the width of the texture
  84212. * @param height Define the height of the texture
  84213. * @param scene Define the scene the texture belongs to
  84214. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84215. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84216. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84217. * @returns the alpha texture
  84218. */
  84219. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84220. /**
  84221. * Creates a RGB texture from some data.
  84222. * @param data Define the texture data
  84223. * @param width Define the width of the texture
  84224. * @param height Define the height of the texture
  84225. * @param scene Define the scene the texture belongs to
  84226. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84227. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84228. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84229. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84230. * @returns the RGB alpha texture
  84231. */
  84232. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84233. /**
  84234. * Creates a RGBA texture from some data.
  84235. * @param data Define the texture data
  84236. * @param width Define the width of the texture
  84237. * @param height Define the height of the texture
  84238. * @param scene Define the scene the texture belongs to
  84239. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84240. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84241. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84242. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84243. * @returns the RGBA texture
  84244. */
  84245. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84246. /**
  84247. * Creates a R texture from some data.
  84248. * @param data Define the texture data
  84249. * @param width Define the width of the texture
  84250. * @param height Define the height of the texture
  84251. * @param scene Define the scene the texture belongs to
  84252. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84253. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84254. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84255. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84256. * @returns the R texture
  84257. */
  84258. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  84259. }
  84260. }
  84261. declare module BABYLON {
  84262. /**
  84263. * Interface for the size containing width and height
  84264. */
  84265. export interface ISize {
  84266. /**
  84267. * Width
  84268. */
  84269. width: number;
  84270. /**
  84271. * Heighht
  84272. */
  84273. height: number;
  84274. }
  84275. /**
  84276. * Size containing widht and height
  84277. */
  84278. export class Size implements ISize {
  84279. /**
  84280. * Width
  84281. */
  84282. width: number;
  84283. /**
  84284. * Height
  84285. */
  84286. height: number;
  84287. /**
  84288. * Creates a Size object from the given width and height (floats).
  84289. * @param width width of the new size
  84290. * @param height height of the new size
  84291. */
  84292. constructor(width: number, height: number);
  84293. /**
  84294. * Returns a string with the Size width and height
  84295. * @returns a string with the Size width and height
  84296. */
  84297. toString(): string;
  84298. /**
  84299. * "Size"
  84300. * @returns the string "Size"
  84301. */
  84302. getClassName(): string;
  84303. /**
  84304. * Returns the Size hash code.
  84305. * @returns a hash code for a unique width and height
  84306. */
  84307. getHashCode(): number;
  84308. /**
  84309. * Updates the current size from the given one.
  84310. * @param src the given size
  84311. */
  84312. copyFrom(src: Size): void;
  84313. /**
  84314. * Updates in place the current Size from the given floats.
  84315. * @param width width of the new size
  84316. * @param height height of the new size
  84317. * @returns the updated Size.
  84318. */
  84319. copyFromFloats(width: number, height: number): Size;
  84320. /**
  84321. * Updates in place the current Size from the given floats.
  84322. * @param width width to set
  84323. * @param height height to set
  84324. * @returns the updated Size.
  84325. */
  84326. set(width: number, height: number): Size;
  84327. /**
  84328. * Multiplies the width and height by numbers
  84329. * @param w factor to multiple the width by
  84330. * @param h factor to multiple the height by
  84331. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  84332. */
  84333. multiplyByFloats(w: number, h: number): Size;
  84334. /**
  84335. * Clones the size
  84336. * @returns a new Size copied from the given one.
  84337. */
  84338. clone(): Size;
  84339. /**
  84340. * True if the current Size and the given one width and height are strictly equal.
  84341. * @param other the other size to compare against
  84342. * @returns True if the current Size and the given one width and height are strictly equal.
  84343. */
  84344. equals(other: Size): boolean;
  84345. /**
  84346. * The surface of the Size : width * height (float).
  84347. */
  84348. get surface(): number;
  84349. /**
  84350. * Create a new size of zero
  84351. * @returns a new Size set to (0.0, 0.0)
  84352. */
  84353. static Zero(): Size;
  84354. /**
  84355. * Sums the width and height of two sizes
  84356. * @param otherSize size to add to this size
  84357. * @returns a new Size set as the addition result of the current Size and the given one.
  84358. */
  84359. add(otherSize: Size): Size;
  84360. /**
  84361. * Subtracts the width and height of two
  84362. * @param otherSize size to subtract to this size
  84363. * @returns a new Size set as the subtraction result of the given one from the current Size.
  84364. */
  84365. subtract(otherSize: Size): Size;
  84366. /**
  84367. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  84368. * @param start starting size to lerp between
  84369. * @param end end size to lerp between
  84370. * @param amount amount to lerp between the start and end values
  84371. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  84372. */
  84373. static Lerp(start: Size, end: Size, amount: number): Size;
  84374. }
  84375. }
  84376. declare module BABYLON {
  84377. /**
  84378. * Defines a runtime animation
  84379. */
  84380. export class RuntimeAnimation {
  84381. private _events;
  84382. /**
  84383. * The current frame of the runtime animation
  84384. */
  84385. private _currentFrame;
  84386. /**
  84387. * The animation used by the runtime animation
  84388. */
  84389. private _animation;
  84390. /**
  84391. * The target of the runtime animation
  84392. */
  84393. private _target;
  84394. /**
  84395. * The initiating animatable
  84396. */
  84397. private _host;
  84398. /**
  84399. * The original value of the runtime animation
  84400. */
  84401. private _originalValue;
  84402. /**
  84403. * The original blend value of the runtime animation
  84404. */
  84405. private _originalBlendValue;
  84406. /**
  84407. * The offsets cache of the runtime animation
  84408. */
  84409. private _offsetsCache;
  84410. /**
  84411. * The high limits cache of the runtime animation
  84412. */
  84413. private _highLimitsCache;
  84414. /**
  84415. * Specifies if the runtime animation has been stopped
  84416. */
  84417. private _stopped;
  84418. /**
  84419. * The blending factor of the runtime animation
  84420. */
  84421. private _blendingFactor;
  84422. /**
  84423. * The BabylonJS scene
  84424. */
  84425. private _scene;
  84426. /**
  84427. * The current value of the runtime animation
  84428. */
  84429. private _currentValue;
  84430. /** @hidden */
  84431. _animationState: _IAnimationState;
  84432. /**
  84433. * The active target of the runtime animation
  84434. */
  84435. private _activeTargets;
  84436. private _currentActiveTarget;
  84437. private _directTarget;
  84438. /**
  84439. * The target path of the runtime animation
  84440. */
  84441. private _targetPath;
  84442. /**
  84443. * The weight of the runtime animation
  84444. */
  84445. private _weight;
  84446. /**
  84447. * The ratio offset of the runtime animation
  84448. */
  84449. private _ratioOffset;
  84450. /**
  84451. * The previous delay of the runtime animation
  84452. */
  84453. private _previousDelay;
  84454. /**
  84455. * The previous ratio of the runtime animation
  84456. */
  84457. private _previousRatio;
  84458. private _enableBlending;
  84459. private _keys;
  84460. private _minFrame;
  84461. private _maxFrame;
  84462. private _minValue;
  84463. private _maxValue;
  84464. private _targetIsArray;
  84465. /**
  84466. * Gets the current frame of the runtime animation
  84467. */
  84468. get currentFrame(): number;
  84469. /**
  84470. * Gets the weight of the runtime animation
  84471. */
  84472. get weight(): number;
  84473. /**
  84474. * Gets the current value of the runtime animation
  84475. */
  84476. get currentValue(): any;
  84477. /**
  84478. * Gets the target path of the runtime animation
  84479. */
  84480. get targetPath(): string;
  84481. /**
  84482. * Gets the actual target of the runtime animation
  84483. */
  84484. get target(): any;
  84485. /** @hidden */
  84486. _onLoop: () => void;
  84487. /**
  84488. * Create a new RuntimeAnimation object
  84489. * @param target defines the target of the animation
  84490. * @param animation defines the source animation object
  84491. * @param scene defines the hosting scene
  84492. * @param host defines the initiating Animatable
  84493. */
  84494. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  84495. private _preparePath;
  84496. /**
  84497. * Gets the animation from the runtime animation
  84498. */
  84499. get animation(): Animation;
  84500. /**
  84501. * Resets the runtime animation to the beginning
  84502. * @param restoreOriginal defines whether to restore the target property to the original value
  84503. */
  84504. reset(restoreOriginal?: boolean): void;
  84505. /**
  84506. * Specifies if the runtime animation is stopped
  84507. * @returns Boolean specifying if the runtime animation is stopped
  84508. */
  84509. isStopped(): boolean;
  84510. /**
  84511. * Disposes of the runtime animation
  84512. */
  84513. dispose(): void;
  84514. /**
  84515. * Apply the interpolated value to the target
  84516. * @param currentValue defines the value computed by the animation
  84517. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  84518. */
  84519. setValue(currentValue: any, weight: number): void;
  84520. private _getOriginalValues;
  84521. private _setValue;
  84522. /**
  84523. * Gets the loop pmode of the runtime animation
  84524. * @returns Loop Mode
  84525. */
  84526. private _getCorrectLoopMode;
  84527. /**
  84528. * Move the current animation to a given frame
  84529. * @param frame defines the frame to move to
  84530. */
  84531. goToFrame(frame: number): void;
  84532. /**
  84533. * @hidden Internal use only
  84534. */
  84535. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  84536. /**
  84537. * Execute the current animation
  84538. * @param delay defines the delay to add to the current frame
  84539. * @param from defines the lower bound of the animation range
  84540. * @param to defines the upper bound of the animation range
  84541. * @param loop defines if the current animation must loop
  84542. * @param speedRatio defines the current speed ratio
  84543. * @param weight defines the weight of the animation (default is -1 so no weight)
  84544. * @param onLoop optional callback called when animation loops
  84545. * @returns a boolean indicating if the animation is running
  84546. */
  84547. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  84548. }
  84549. }
  84550. declare module BABYLON {
  84551. /**
  84552. * Class used to store an actual running animation
  84553. */
  84554. export class Animatable {
  84555. /** defines the target object */
  84556. target: any;
  84557. /** defines the starting frame number (default is 0) */
  84558. fromFrame: number;
  84559. /** defines the ending frame number (default is 100) */
  84560. toFrame: number;
  84561. /** defines if the animation must loop (default is false) */
  84562. loopAnimation: boolean;
  84563. /** defines a callback to call when animation ends if it is not looping */
  84564. onAnimationEnd?: (() => void) | null | undefined;
  84565. /** defines a callback to call when animation loops */
  84566. onAnimationLoop?: (() => void) | null | undefined;
  84567. private _localDelayOffset;
  84568. private _pausedDelay;
  84569. private _runtimeAnimations;
  84570. private _paused;
  84571. private _scene;
  84572. private _speedRatio;
  84573. private _weight;
  84574. private _syncRoot;
  84575. /**
  84576. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  84577. * This will only apply for non looping animation (default is true)
  84578. */
  84579. disposeOnEnd: boolean;
  84580. /**
  84581. * Gets a boolean indicating if the animation has started
  84582. */
  84583. animationStarted: boolean;
  84584. /**
  84585. * Observer raised when the animation ends
  84586. */
  84587. onAnimationEndObservable: Observable<Animatable>;
  84588. /**
  84589. * Observer raised when the animation loops
  84590. */
  84591. onAnimationLoopObservable: Observable<Animatable>;
  84592. /**
  84593. * Gets the root Animatable used to synchronize and normalize animations
  84594. */
  84595. get syncRoot(): Nullable<Animatable>;
  84596. /**
  84597. * Gets the current frame of the first RuntimeAnimation
  84598. * Used to synchronize Animatables
  84599. */
  84600. get masterFrame(): number;
  84601. /**
  84602. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  84603. */
  84604. get weight(): number;
  84605. set weight(value: number);
  84606. /**
  84607. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  84608. */
  84609. get speedRatio(): number;
  84610. set speedRatio(value: number);
  84611. /**
  84612. * Creates a new Animatable
  84613. * @param scene defines the hosting scene
  84614. * @param target defines the target object
  84615. * @param fromFrame defines the starting frame number (default is 0)
  84616. * @param toFrame defines the ending frame number (default is 100)
  84617. * @param loopAnimation defines if the animation must loop (default is false)
  84618. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  84619. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  84620. * @param animations defines a group of animation to add to the new Animatable
  84621. * @param onAnimationLoop defines a callback to call when animation loops
  84622. */
  84623. constructor(scene: Scene,
  84624. /** defines the target object */
  84625. target: any,
  84626. /** defines the starting frame number (default is 0) */
  84627. fromFrame?: number,
  84628. /** defines the ending frame number (default is 100) */
  84629. toFrame?: number,
  84630. /** defines if the animation must loop (default is false) */
  84631. loopAnimation?: boolean, speedRatio?: number,
  84632. /** defines a callback to call when animation ends if it is not looping */
  84633. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  84634. /** defines a callback to call when animation loops */
  84635. onAnimationLoop?: (() => void) | null | undefined);
  84636. /**
  84637. * Synchronize and normalize current Animatable with a source Animatable
  84638. * This is useful when using animation weights and when animations are not of the same length
  84639. * @param root defines the root Animatable to synchronize with
  84640. * @returns the current Animatable
  84641. */
  84642. syncWith(root: Animatable): Animatable;
  84643. /**
  84644. * Gets the list of runtime animations
  84645. * @returns an array of RuntimeAnimation
  84646. */
  84647. getAnimations(): RuntimeAnimation[];
  84648. /**
  84649. * Adds more animations to the current animatable
  84650. * @param target defines the target of the animations
  84651. * @param animations defines the new animations to add
  84652. */
  84653. appendAnimations(target: any, animations: Animation[]): void;
  84654. /**
  84655. * Gets the source animation for a specific property
  84656. * @param property defines the propertyu to look for
  84657. * @returns null or the source animation for the given property
  84658. */
  84659. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  84660. /**
  84661. * Gets the runtime animation for a specific property
  84662. * @param property defines the propertyu to look for
  84663. * @returns null or the runtime animation for the given property
  84664. */
  84665. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  84666. /**
  84667. * Resets the animatable to its original state
  84668. */
  84669. reset(): void;
  84670. /**
  84671. * Allows the animatable to blend with current running animations
  84672. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84673. * @param blendingSpeed defines the blending speed to use
  84674. */
  84675. enableBlending(blendingSpeed: number): void;
  84676. /**
  84677. * Disable animation blending
  84678. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  84679. */
  84680. disableBlending(): void;
  84681. /**
  84682. * Jump directly to a given frame
  84683. * @param frame defines the frame to jump to
  84684. */
  84685. goToFrame(frame: number): void;
  84686. /**
  84687. * Pause the animation
  84688. */
  84689. pause(): void;
  84690. /**
  84691. * Restart the animation
  84692. */
  84693. restart(): void;
  84694. private _raiseOnAnimationEnd;
  84695. /**
  84696. * Stop and delete the current animation
  84697. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  84698. * @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)
  84699. */
  84700. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  84701. /**
  84702. * Wait asynchronously for the animation to end
  84703. * @returns a promise which will be fullfilled when the animation ends
  84704. */
  84705. waitAsync(): Promise<Animatable>;
  84706. /** @hidden */
  84707. _animate(delay: number): boolean;
  84708. }
  84709. interface Scene {
  84710. /** @hidden */
  84711. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  84712. /** @hidden */
  84713. _processLateAnimationBindingsForMatrices(holder: {
  84714. totalWeight: number;
  84715. animations: RuntimeAnimation[];
  84716. originalValue: Matrix;
  84717. }): any;
  84718. /** @hidden */
  84719. _processLateAnimationBindingsForQuaternions(holder: {
  84720. totalWeight: number;
  84721. animations: RuntimeAnimation[];
  84722. originalValue: Quaternion;
  84723. }, refQuaternion: Quaternion): Quaternion;
  84724. /** @hidden */
  84725. _processLateAnimationBindings(): void;
  84726. /**
  84727. * Will start the animation sequence of a given target
  84728. * @param target defines the target
  84729. * @param from defines from which frame should animation start
  84730. * @param to defines until which frame should animation run.
  84731. * @param weight defines the weight to apply to the animation (1.0 by default)
  84732. * @param loop defines if the animation loops
  84733. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84734. * @param onAnimationEnd defines the function to be executed when the animation ends
  84735. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84736. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  84737. * @param onAnimationLoop defines the callback to call when an animation loops
  84738. * @returns the animatable object created for this animation
  84739. */
  84740. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  84741. /**
  84742. * Will start the animation sequence of a given target
  84743. * @param target defines the target
  84744. * @param from defines from which frame should animation start
  84745. * @param to defines until which frame should animation run.
  84746. * @param loop defines if the animation loops
  84747. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84748. * @param onAnimationEnd defines the function to be executed when the animation ends
  84749. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84750. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  84751. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  84752. * @param onAnimationLoop defines the callback to call when an animation loops
  84753. * @returns the animatable object created for this animation
  84754. */
  84755. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  84756. /**
  84757. * Will start the animation sequence of a given target and its hierarchy
  84758. * @param target defines the target
  84759. * @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.
  84760. * @param from defines from which frame should animation start
  84761. * @param to defines until which frame should animation run.
  84762. * @param loop defines if the animation loops
  84763. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  84764. * @param onAnimationEnd defines the function to be executed when the animation ends
  84765. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  84766. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  84767. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  84768. * @param onAnimationLoop defines the callback to call when an animation loops
  84769. * @returns the list of created animatables
  84770. */
  84771. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  84772. /**
  84773. * Begin a new animation on a given node
  84774. * @param target defines the target where the animation will take place
  84775. * @param animations defines the list of animations to start
  84776. * @param from defines the initial value
  84777. * @param to defines the final value
  84778. * @param loop defines if you want animation to loop (off by default)
  84779. * @param speedRatio defines the speed ratio to apply to all animations
  84780. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84781. * @param onAnimationLoop defines the callback to call when an animation loops
  84782. * @returns the list of created animatables
  84783. */
  84784. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  84785. /**
  84786. * Begin a new animation on a given node and its hierarchy
  84787. * @param target defines the root node where the animation will take place
  84788. * @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.
  84789. * @param animations defines the list of animations to start
  84790. * @param from defines the initial value
  84791. * @param to defines the final value
  84792. * @param loop defines if you want animation to loop (off by default)
  84793. * @param speedRatio defines the speed ratio to apply to all animations
  84794. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84795. * @param onAnimationLoop defines the callback to call when an animation loops
  84796. * @returns the list of animatables created for all nodes
  84797. */
  84798. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  84799. /**
  84800. * Gets the animatable associated with a specific target
  84801. * @param target defines the target of the animatable
  84802. * @returns the required animatable if found
  84803. */
  84804. getAnimatableByTarget(target: any): Nullable<Animatable>;
  84805. /**
  84806. * Gets all animatables associated with a given target
  84807. * @param target defines the target to look animatables for
  84808. * @returns an array of Animatables
  84809. */
  84810. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  84811. /**
  84812. * Stops and removes all animations that have been applied to the scene
  84813. */
  84814. stopAllAnimations(): void;
  84815. /**
  84816. * Gets the current delta time used by animation engine
  84817. */
  84818. deltaTime: number;
  84819. }
  84820. interface Bone {
  84821. /**
  84822. * Copy an animation range from another bone
  84823. * @param source defines the source bone
  84824. * @param rangeName defines the range name to copy
  84825. * @param frameOffset defines the frame offset
  84826. * @param rescaleAsRequired defines if rescaling must be applied if required
  84827. * @param skelDimensionsRatio defines the scaling ratio
  84828. * @returns true if operation was successful
  84829. */
  84830. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  84831. }
  84832. }
  84833. declare module BABYLON {
  84834. /**
  84835. * Class used to override all child animations of a given target
  84836. */
  84837. export class AnimationPropertiesOverride {
  84838. /**
  84839. * Gets or sets a value indicating if animation blending must be used
  84840. */
  84841. enableBlending: boolean;
  84842. /**
  84843. * Gets or sets the blending speed to use when enableBlending is true
  84844. */
  84845. blendingSpeed: number;
  84846. /**
  84847. * Gets or sets the default loop mode to use
  84848. */
  84849. loopMode: number;
  84850. }
  84851. }
  84852. declare module BABYLON {
  84853. /**
  84854. * Class used to handle skinning animations
  84855. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  84856. */
  84857. export class Skeleton implements IAnimatable {
  84858. /** defines the skeleton name */
  84859. name: string;
  84860. /** defines the skeleton Id */
  84861. id: string;
  84862. /**
  84863. * Defines the list of child bones
  84864. */
  84865. bones: Bone[];
  84866. /**
  84867. * Defines an estimate of the dimension of the skeleton at rest
  84868. */
  84869. dimensionsAtRest: Vector3;
  84870. /**
  84871. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  84872. */
  84873. needInitialSkinMatrix: boolean;
  84874. /**
  84875. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  84876. */
  84877. overrideMesh: Nullable<AbstractMesh>;
  84878. /**
  84879. * Gets the list of animations attached to this skeleton
  84880. */
  84881. animations: Array<Animation>;
  84882. private _scene;
  84883. private _isDirty;
  84884. private _transformMatrices;
  84885. private _transformMatrixTexture;
  84886. private _meshesWithPoseMatrix;
  84887. private _animatables;
  84888. private _identity;
  84889. private _synchronizedWithMesh;
  84890. private _ranges;
  84891. private _lastAbsoluteTransformsUpdateId;
  84892. private _canUseTextureForBones;
  84893. private _uniqueId;
  84894. /** @hidden */
  84895. _numBonesWithLinkedTransformNode: number;
  84896. /** @hidden */
  84897. _hasWaitingData: Nullable<boolean>;
  84898. /**
  84899. * Specifies if the skeleton should be serialized
  84900. */
  84901. doNotSerialize: boolean;
  84902. private _useTextureToStoreBoneMatrices;
  84903. /**
  84904. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  84905. * Please note that this option is not available if the hardware does not support it
  84906. */
  84907. get useTextureToStoreBoneMatrices(): boolean;
  84908. set useTextureToStoreBoneMatrices(value: boolean);
  84909. private _animationPropertiesOverride;
  84910. /**
  84911. * Gets or sets the animation properties override
  84912. */
  84913. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  84914. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  84915. /**
  84916. * List of inspectable custom properties (used by the Inspector)
  84917. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84918. */
  84919. inspectableCustomProperties: IInspectable[];
  84920. /**
  84921. * An observable triggered before computing the skeleton's matrices
  84922. */
  84923. onBeforeComputeObservable: Observable<Skeleton>;
  84924. /**
  84925. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  84926. */
  84927. get isUsingTextureForMatrices(): boolean;
  84928. /**
  84929. * Gets the unique ID of this skeleton
  84930. */
  84931. get uniqueId(): number;
  84932. /**
  84933. * Creates a new skeleton
  84934. * @param name defines the skeleton name
  84935. * @param id defines the skeleton Id
  84936. * @param scene defines the hosting scene
  84937. */
  84938. constructor(
  84939. /** defines the skeleton name */
  84940. name: string,
  84941. /** defines the skeleton Id */
  84942. id: string, scene: Scene);
  84943. /**
  84944. * Gets the current object class name.
  84945. * @return the class name
  84946. */
  84947. getClassName(): string;
  84948. /**
  84949. * Returns an array containing the root bones
  84950. * @returns an array containing the root bones
  84951. */
  84952. getChildren(): Array<Bone>;
  84953. /**
  84954. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  84955. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84956. * @returns a Float32Array containing matrices data
  84957. */
  84958. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  84959. /**
  84960. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  84961. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  84962. * @returns a raw texture containing the data
  84963. */
  84964. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  84965. /**
  84966. * Gets the current hosting scene
  84967. * @returns a scene object
  84968. */
  84969. getScene(): Scene;
  84970. /**
  84971. * Gets a string representing the current skeleton data
  84972. * @param fullDetails defines a boolean indicating if we want a verbose version
  84973. * @returns a string representing the current skeleton data
  84974. */
  84975. toString(fullDetails?: boolean): string;
  84976. /**
  84977. * Get bone's index searching by name
  84978. * @param name defines bone's name to search for
  84979. * @return the indice of the bone. Returns -1 if not found
  84980. */
  84981. getBoneIndexByName(name: string): number;
  84982. /**
  84983. * Creater a new animation range
  84984. * @param name defines the name of the range
  84985. * @param from defines the start key
  84986. * @param to defines the end key
  84987. */
  84988. createAnimationRange(name: string, from: number, to: number): void;
  84989. /**
  84990. * Delete a specific animation range
  84991. * @param name defines the name of the range
  84992. * @param deleteFrames defines if frames must be removed as well
  84993. */
  84994. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84995. /**
  84996. * Gets a specific animation range
  84997. * @param name defines the name of the range to look for
  84998. * @returns the requested animation range or null if not found
  84999. */
  85000. getAnimationRange(name: string): Nullable<AnimationRange>;
  85001. /**
  85002. * Gets the list of all animation ranges defined on this skeleton
  85003. * @returns an array
  85004. */
  85005. getAnimationRanges(): Nullable<AnimationRange>[];
  85006. /**
  85007. * Copy animation range from a source skeleton.
  85008. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  85009. * @param source defines the source skeleton
  85010. * @param name defines the name of the range to copy
  85011. * @param rescaleAsRequired defines if rescaling must be applied if required
  85012. * @returns true if operation was successful
  85013. */
  85014. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  85015. /**
  85016. * Forces the skeleton to go to rest pose
  85017. */
  85018. returnToRest(): void;
  85019. private _getHighestAnimationFrame;
  85020. /**
  85021. * Begin a specific animation range
  85022. * @param name defines the name of the range to start
  85023. * @param loop defines if looping must be turned on (false by default)
  85024. * @param speedRatio defines the speed ratio to apply (1 by default)
  85025. * @param onAnimationEnd defines a callback which will be called when animation will end
  85026. * @returns a new animatable
  85027. */
  85028. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  85029. /** @hidden */
  85030. _markAsDirty(): void;
  85031. /** @hidden */
  85032. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  85033. /** @hidden */
  85034. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  85035. private _computeTransformMatrices;
  85036. /**
  85037. * Build all resources required to render a skeleton
  85038. */
  85039. prepare(): void;
  85040. /**
  85041. * Gets the list of animatables currently running for this skeleton
  85042. * @returns an array of animatables
  85043. */
  85044. getAnimatables(): IAnimatable[];
  85045. /**
  85046. * Clone the current skeleton
  85047. * @param name defines the name of the new skeleton
  85048. * @param id defines the id of the new skeleton
  85049. * @returns the new skeleton
  85050. */
  85051. clone(name: string, id?: string): Skeleton;
  85052. /**
  85053. * Enable animation blending for this skeleton
  85054. * @param blendingSpeed defines the blending speed to apply
  85055. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  85056. */
  85057. enableBlending(blendingSpeed?: number): void;
  85058. /**
  85059. * Releases all resources associated with the current skeleton
  85060. */
  85061. dispose(): void;
  85062. /**
  85063. * Serialize the skeleton in a JSON object
  85064. * @returns a JSON object
  85065. */
  85066. serialize(): any;
  85067. /**
  85068. * Creates a new skeleton from serialized data
  85069. * @param parsedSkeleton defines the serialized data
  85070. * @param scene defines the hosting scene
  85071. * @returns a new skeleton
  85072. */
  85073. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  85074. /**
  85075. * Compute all node absolute transforms
  85076. * @param forceUpdate defines if computation must be done even if cache is up to date
  85077. */
  85078. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  85079. /**
  85080. * Gets the root pose matrix
  85081. * @returns a matrix
  85082. */
  85083. getPoseMatrix(): Nullable<Matrix>;
  85084. /**
  85085. * Sorts bones per internal index
  85086. */
  85087. sortBones(): void;
  85088. private _sortBones;
  85089. }
  85090. }
  85091. declare module BABYLON {
  85092. /**
  85093. * Class used to store bone information
  85094. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  85095. */
  85096. export class Bone extends Node {
  85097. /**
  85098. * defines the bone name
  85099. */
  85100. name: string;
  85101. private static _tmpVecs;
  85102. private static _tmpQuat;
  85103. private static _tmpMats;
  85104. /**
  85105. * Gets the list of child bones
  85106. */
  85107. children: Bone[];
  85108. /** Gets the animations associated with this bone */
  85109. animations: Animation[];
  85110. /**
  85111. * Gets or sets bone length
  85112. */
  85113. length: number;
  85114. /**
  85115. * @hidden Internal only
  85116. * Set this value to map this bone to a different index in the transform matrices
  85117. * Set this value to -1 to exclude the bone from the transform matrices
  85118. */
  85119. _index: Nullable<number>;
  85120. private _skeleton;
  85121. private _localMatrix;
  85122. private _restPose;
  85123. private _baseMatrix;
  85124. private _absoluteTransform;
  85125. private _invertedAbsoluteTransform;
  85126. private _parent;
  85127. private _scalingDeterminant;
  85128. private _worldTransform;
  85129. private _localScaling;
  85130. private _localRotation;
  85131. private _localPosition;
  85132. private _needToDecompose;
  85133. private _needToCompose;
  85134. /** @hidden */
  85135. _linkedTransformNode: Nullable<TransformNode>;
  85136. /** @hidden */
  85137. _waitingTransformNodeId: Nullable<string>;
  85138. /** @hidden */
  85139. get _matrix(): Matrix;
  85140. /** @hidden */
  85141. set _matrix(value: Matrix);
  85142. /**
  85143. * Create a new bone
  85144. * @param name defines the bone name
  85145. * @param skeleton defines the parent skeleton
  85146. * @param parentBone defines the parent (can be null if the bone is the root)
  85147. * @param localMatrix defines the local matrix
  85148. * @param restPose defines the rest pose matrix
  85149. * @param baseMatrix defines the base matrix
  85150. * @param index defines index of the bone in the hiearchy
  85151. */
  85152. constructor(
  85153. /**
  85154. * defines the bone name
  85155. */
  85156. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  85157. /**
  85158. * Gets the current object class name.
  85159. * @return the class name
  85160. */
  85161. getClassName(): string;
  85162. /**
  85163. * Gets the parent skeleton
  85164. * @returns a skeleton
  85165. */
  85166. getSkeleton(): Skeleton;
  85167. /**
  85168. * Gets parent bone
  85169. * @returns a bone or null if the bone is the root of the bone hierarchy
  85170. */
  85171. getParent(): Nullable<Bone>;
  85172. /**
  85173. * Returns an array containing the root bones
  85174. * @returns an array containing the root bones
  85175. */
  85176. getChildren(): Array<Bone>;
  85177. /**
  85178. * Gets the node index in matrix array generated for rendering
  85179. * @returns the node index
  85180. */
  85181. getIndex(): number;
  85182. /**
  85183. * Sets the parent bone
  85184. * @param parent defines the parent (can be null if the bone is the root)
  85185. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  85186. */
  85187. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  85188. /**
  85189. * Gets the local matrix
  85190. * @returns a matrix
  85191. */
  85192. getLocalMatrix(): Matrix;
  85193. /**
  85194. * Gets the base matrix (initial matrix which remains unchanged)
  85195. * @returns a matrix
  85196. */
  85197. getBaseMatrix(): Matrix;
  85198. /**
  85199. * Gets the rest pose matrix
  85200. * @returns a matrix
  85201. */
  85202. getRestPose(): Matrix;
  85203. /**
  85204. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  85205. */
  85206. getWorldMatrix(): Matrix;
  85207. /**
  85208. * Sets the local matrix to rest pose matrix
  85209. */
  85210. returnToRest(): void;
  85211. /**
  85212. * Gets the inverse of the absolute transform matrix.
  85213. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  85214. * @returns a matrix
  85215. */
  85216. getInvertedAbsoluteTransform(): Matrix;
  85217. /**
  85218. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  85219. * @returns a matrix
  85220. */
  85221. getAbsoluteTransform(): Matrix;
  85222. /**
  85223. * Links with the given transform node.
  85224. * The local matrix of this bone is copied from the transform node every frame.
  85225. * @param transformNode defines the transform node to link to
  85226. */
  85227. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  85228. /**
  85229. * Gets the node used to drive the bone's transformation
  85230. * @returns a transform node or null
  85231. */
  85232. getTransformNode(): Nullable<TransformNode>;
  85233. /** Gets or sets current position (in local space) */
  85234. get position(): Vector3;
  85235. set position(newPosition: Vector3);
  85236. /** Gets or sets current rotation (in local space) */
  85237. get rotation(): Vector3;
  85238. set rotation(newRotation: Vector3);
  85239. /** Gets or sets current rotation quaternion (in local space) */
  85240. get rotationQuaternion(): Quaternion;
  85241. set rotationQuaternion(newRotation: Quaternion);
  85242. /** Gets or sets current scaling (in local space) */
  85243. get scaling(): Vector3;
  85244. set scaling(newScaling: Vector3);
  85245. /**
  85246. * Gets the animation properties override
  85247. */
  85248. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  85249. private _decompose;
  85250. private _compose;
  85251. /**
  85252. * Update the base and local matrices
  85253. * @param matrix defines the new base or local matrix
  85254. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  85255. * @param updateLocalMatrix defines if the local matrix should be updated
  85256. */
  85257. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  85258. /** @hidden */
  85259. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  85260. /**
  85261. * Flag the bone as dirty (Forcing it to update everything)
  85262. */
  85263. markAsDirty(): void;
  85264. /** @hidden */
  85265. _markAsDirtyAndCompose(): void;
  85266. private _markAsDirtyAndDecompose;
  85267. /**
  85268. * Translate the bone in local or world space
  85269. * @param vec The amount to translate the bone
  85270. * @param space The space that the translation is in
  85271. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85272. */
  85273. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  85274. /**
  85275. * Set the postion of the bone in local or world space
  85276. * @param position The position to set the bone
  85277. * @param space The space that the position is in
  85278. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85279. */
  85280. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  85281. /**
  85282. * Set the absolute position of the bone (world space)
  85283. * @param position The position to set the bone
  85284. * @param mesh The mesh that this bone is attached to
  85285. */
  85286. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  85287. /**
  85288. * Scale the bone on the x, y and z axes (in local space)
  85289. * @param x The amount to scale the bone on the x axis
  85290. * @param y The amount to scale the bone on the y axis
  85291. * @param z The amount to scale the bone on the z axis
  85292. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  85293. */
  85294. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  85295. /**
  85296. * Set the bone scaling in local space
  85297. * @param scale defines the scaling vector
  85298. */
  85299. setScale(scale: Vector3): void;
  85300. /**
  85301. * Gets the current scaling in local space
  85302. * @returns the current scaling vector
  85303. */
  85304. getScale(): Vector3;
  85305. /**
  85306. * Gets the current scaling in local space and stores it in a target vector
  85307. * @param result defines the target vector
  85308. */
  85309. getScaleToRef(result: Vector3): void;
  85310. /**
  85311. * Set the yaw, pitch, and roll of the bone in local or world space
  85312. * @param yaw The rotation of the bone on the y axis
  85313. * @param pitch The rotation of the bone on the x axis
  85314. * @param roll The rotation of the bone on the z axis
  85315. * @param space The space that the axes of rotation are in
  85316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85317. */
  85318. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  85319. /**
  85320. * Add a rotation to the bone on an axis in local or world space
  85321. * @param axis The axis to rotate the bone on
  85322. * @param amount The amount to rotate the bone
  85323. * @param space The space that the axis is in
  85324. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85325. */
  85326. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  85327. /**
  85328. * Set the rotation of the bone to a particular axis angle in local or world space
  85329. * @param axis The axis to rotate the bone on
  85330. * @param angle The angle that the bone should be rotated to
  85331. * @param space The space that the axis is in
  85332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85333. */
  85334. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  85335. /**
  85336. * Set the euler rotation of the bone in local of world space
  85337. * @param rotation The euler rotation that the bone should be set to
  85338. * @param space The space that the rotation is in
  85339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85340. */
  85341. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  85342. /**
  85343. * Set the quaternion rotation of the bone in local of world space
  85344. * @param quat The quaternion rotation that the bone should be set to
  85345. * @param space The space that the rotation is in
  85346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85347. */
  85348. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  85349. /**
  85350. * Set the rotation matrix of the bone in local of world space
  85351. * @param rotMat The rotation matrix that the bone should be set to
  85352. * @param space The space that the rotation is in
  85353. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85354. */
  85355. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  85356. private _rotateWithMatrix;
  85357. private _getNegativeRotationToRef;
  85358. /**
  85359. * Get the position of the bone in local or world space
  85360. * @param space The space that the returned position is in
  85361. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85362. * @returns The position of the bone
  85363. */
  85364. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  85365. /**
  85366. * Copy the position of the bone to a vector3 in local or world space
  85367. * @param space The space that the returned position is in
  85368. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85369. * @param result The vector3 to copy the position to
  85370. */
  85371. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  85372. /**
  85373. * Get the absolute position of the bone (world space)
  85374. * @param mesh The mesh that this bone is attached to
  85375. * @returns The absolute position of the bone
  85376. */
  85377. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  85378. /**
  85379. * Copy the absolute position of the bone (world space) to the result param
  85380. * @param mesh The mesh that this bone is attached to
  85381. * @param result The vector3 to copy the absolute position to
  85382. */
  85383. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  85384. /**
  85385. * Compute the absolute transforms of this bone and its children
  85386. */
  85387. computeAbsoluteTransforms(): void;
  85388. /**
  85389. * Get the world direction from an axis that is in the local space of the bone
  85390. * @param localAxis The local direction that is used to compute the world direction
  85391. * @param mesh The mesh that this bone is attached to
  85392. * @returns The world direction
  85393. */
  85394. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  85395. /**
  85396. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  85397. * @param localAxis The local direction that is used to compute the world direction
  85398. * @param mesh The mesh that this bone is attached to
  85399. * @param result The vector3 that the world direction will be copied to
  85400. */
  85401. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  85402. /**
  85403. * Get the euler rotation of the bone in local or world space
  85404. * @param space The space that the rotation should be in
  85405. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85406. * @returns The euler rotation
  85407. */
  85408. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  85409. /**
  85410. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  85411. * @param space The space that the rotation should be in
  85412. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85413. * @param result The vector3 that the rotation should be copied to
  85414. */
  85415. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  85416. /**
  85417. * Get the quaternion rotation of the bone in either local or world space
  85418. * @param space The space that the rotation should be in
  85419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85420. * @returns The quaternion rotation
  85421. */
  85422. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  85423. /**
  85424. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  85425. * @param space The space that the rotation should be in
  85426. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85427. * @param result The quaternion that the rotation should be copied to
  85428. */
  85429. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  85430. /**
  85431. * Get the rotation matrix of the bone in local or world space
  85432. * @param space The space that the rotation should be in
  85433. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85434. * @returns The rotation matrix
  85435. */
  85436. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  85437. /**
  85438. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  85439. * @param space The space that the rotation should be in
  85440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  85441. * @param result The quaternion that the rotation should be copied to
  85442. */
  85443. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  85444. /**
  85445. * Get the world position of a point that is in the local space of the bone
  85446. * @param position The local position
  85447. * @param mesh The mesh that this bone is attached to
  85448. * @returns The world position
  85449. */
  85450. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  85451. /**
  85452. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  85453. * @param position The local position
  85454. * @param mesh The mesh that this bone is attached to
  85455. * @param result The vector3 that the world position should be copied to
  85456. */
  85457. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  85458. /**
  85459. * Get the local position of a point that is in world space
  85460. * @param position The world position
  85461. * @param mesh The mesh that this bone is attached to
  85462. * @returns The local position
  85463. */
  85464. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  85465. /**
  85466. * Get the local position of a point that is in world space and copy it to the result param
  85467. * @param position The world position
  85468. * @param mesh The mesh that this bone is attached to
  85469. * @param result The vector3 that the local position should be copied to
  85470. */
  85471. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  85472. }
  85473. }
  85474. declare module BABYLON {
  85475. /**
  85476. * 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.
  85477. * @see https://doc.babylonjs.com/how_to/transformnode
  85478. */
  85479. export class TransformNode extends Node {
  85480. /**
  85481. * Object will not rotate to face the camera
  85482. */
  85483. static BILLBOARDMODE_NONE: number;
  85484. /**
  85485. * Object will rotate to face the camera but only on the x axis
  85486. */
  85487. static BILLBOARDMODE_X: number;
  85488. /**
  85489. * Object will rotate to face the camera but only on the y axis
  85490. */
  85491. static BILLBOARDMODE_Y: number;
  85492. /**
  85493. * Object will rotate to face the camera but only on the z axis
  85494. */
  85495. static BILLBOARDMODE_Z: number;
  85496. /**
  85497. * Object will rotate to face the camera
  85498. */
  85499. static BILLBOARDMODE_ALL: number;
  85500. /**
  85501. * Object will rotate to face the camera's position instead of orientation
  85502. */
  85503. static BILLBOARDMODE_USE_POSITION: number;
  85504. private _forward;
  85505. private _forwardInverted;
  85506. private _up;
  85507. private _right;
  85508. private _rightInverted;
  85509. private _position;
  85510. private _rotation;
  85511. private _rotationQuaternion;
  85512. protected _scaling: Vector3;
  85513. protected _isDirty: boolean;
  85514. private _transformToBoneReferal;
  85515. private _isAbsoluteSynced;
  85516. private _billboardMode;
  85517. /**
  85518. * Gets or sets the billboard mode. Default is 0.
  85519. *
  85520. * | Value | Type | Description |
  85521. * | --- | --- | --- |
  85522. * | 0 | BILLBOARDMODE_NONE | |
  85523. * | 1 | BILLBOARDMODE_X | |
  85524. * | 2 | BILLBOARDMODE_Y | |
  85525. * | 4 | BILLBOARDMODE_Z | |
  85526. * | 7 | BILLBOARDMODE_ALL | |
  85527. *
  85528. */
  85529. get billboardMode(): number;
  85530. set billboardMode(value: number);
  85531. private _preserveParentRotationForBillboard;
  85532. /**
  85533. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  85534. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  85535. */
  85536. get preserveParentRotationForBillboard(): boolean;
  85537. set preserveParentRotationForBillboard(value: boolean);
  85538. /**
  85539. * 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
  85540. */
  85541. scalingDeterminant: number;
  85542. private _infiniteDistance;
  85543. /**
  85544. * Gets or sets the distance of the object to max, often used by skybox
  85545. */
  85546. get infiniteDistance(): boolean;
  85547. set infiniteDistance(value: boolean);
  85548. /**
  85549. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  85550. * By default the system will update normals to compensate
  85551. */
  85552. ignoreNonUniformScaling: boolean;
  85553. /**
  85554. * 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
  85555. */
  85556. reIntegrateRotationIntoRotationQuaternion: boolean;
  85557. /** @hidden */
  85558. _poseMatrix: Nullable<Matrix>;
  85559. /** @hidden */
  85560. _localMatrix: Matrix;
  85561. private _usePivotMatrix;
  85562. private _absolutePosition;
  85563. private _absoluteScaling;
  85564. private _absoluteRotationQuaternion;
  85565. private _pivotMatrix;
  85566. private _pivotMatrixInverse;
  85567. protected _postMultiplyPivotMatrix: boolean;
  85568. protected _isWorldMatrixFrozen: boolean;
  85569. /** @hidden */
  85570. _indexInSceneTransformNodesArray: number;
  85571. /**
  85572. * An event triggered after the world matrix is updated
  85573. */
  85574. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  85575. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  85576. /**
  85577. * Gets a string identifying the name of the class
  85578. * @returns "TransformNode" string
  85579. */
  85580. getClassName(): string;
  85581. /**
  85582. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  85583. */
  85584. get position(): Vector3;
  85585. set position(newPosition: Vector3);
  85586. /**
  85587. * 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)).
  85588. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  85589. */
  85590. get rotation(): Vector3;
  85591. set rotation(newRotation: Vector3);
  85592. /**
  85593. * 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)).
  85594. */
  85595. get scaling(): Vector3;
  85596. set scaling(newScaling: Vector3);
  85597. /**
  85598. * 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).
  85599. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  85600. */
  85601. get rotationQuaternion(): Nullable<Quaternion>;
  85602. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  85603. /**
  85604. * The forward direction of that transform in world space.
  85605. */
  85606. get forward(): Vector3;
  85607. /**
  85608. * The up direction of that transform in world space.
  85609. */
  85610. get up(): Vector3;
  85611. /**
  85612. * The right direction of that transform in world space.
  85613. */
  85614. get right(): Vector3;
  85615. /**
  85616. * Copies the parameter passed Matrix into the mesh Pose matrix.
  85617. * @param matrix the matrix to copy the pose from
  85618. * @returns this TransformNode.
  85619. */
  85620. updatePoseMatrix(matrix: Matrix): TransformNode;
  85621. /**
  85622. * Returns the mesh Pose matrix.
  85623. * @returns the pose matrix
  85624. */
  85625. getPoseMatrix(): Matrix;
  85626. /** @hidden */
  85627. _isSynchronized(): boolean;
  85628. /** @hidden */
  85629. _initCache(): void;
  85630. /**
  85631. * Flag the transform node as dirty (Forcing it to update everything)
  85632. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  85633. * @returns this transform node
  85634. */
  85635. markAsDirty(property: string): TransformNode;
  85636. /**
  85637. * Returns the current mesh absolute position.
  85638. * Returns a Vector3.
  85639. */
  85640. get absolutePosition(): Vector3;
  85641. /**
  85642. * Returns the current mesh absolute scaling.
  85643. * Returns a Vector3.
  85644. */
  85645. get absoluteScaling(): Vector3;
  85646. /**
  85647. * Returns the current mesh absolute rotation.
  85648. * Returns a Quaternion.
  85649. */
  85650. get absoluteRotationQuaternion(): Quaternion;
  85651. /**
  85652. * Sets a new matrix to apply before all other transformation
  85653. * @param matrix defines the transform matrix
  85654. * @returns the current TransformNode
  85655. */
  85656. setPreTransformMatrix(matrix: Matrix): TransformNode;
  85657. /**
  85658. * Sets a new pivot matrix to the current node
  85659. * @param matrix defines the new pivot matrix to use
  85660. * @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
  85661. * @returns the current TransformNode
  85662. */
  85663. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  85664. /**
  85665. * Returns the mesh pivot matrix.
  85666. * Default : Identity.
  85667. * @returns the matrix
  85668. */
  85669. getPivotMatrix(): Matrix;
  85670. /**
  85671. * Instantiate (when possible) or clone that node with its hierarchy
  85672. * @param newParent defines the new parent to use for the instance (or clone)
  85673. * @param options defines options to configure how copy is done
  85674. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  85675. * @returns an instance (or a clone) of the current node with its hiearchy
  85676. */
  85677. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  85678. doNotInstantiate: boolean;
  85679. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  85680. /**
  85681. * Prevents the World matrix to be computed any longer
  85682. * @param newWorldMatrix defines an optional matrix to use as world matrix
  85683. * @returns the TransformNode.
  85684. */
  85685. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  85686. /**
  85687. * Allows back the World matrix computation.
  85688. * @returns the TransformNode.
  85689. */
  85690. unfreezeWorldMatrix(): this;
  85691. /**
  85692. * True if the World matrix has been frozen.
  85693. */
  85694. get isWorldMatrixFrozen(): boolean;
  85695. /**
  85696. * Retuns the mesh absolute position in the World.
  85697. * @returns a Vector3.
  85698. */
  85699. getAbsolutePosition(): Vector3;
  85700. /**
  85701. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  85702. * @param absolutePosition the absolute position to set
  85703. * @returns the TransformNode.
  85704. */
  85705. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  85706. /**
  85707. * Sets the mesh position in its local space.
  85708. * @param vector3 the position to set in localspace
  85709. * @returns the TransformNode.
  85710. */
  85711. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  85712. /**
  85713. * Returns the mesh position in the local space from the current World matrix values.
  85714. * @returns a new Vector3.
  85715. */
  85716. getPositionExpressedInLocalSpace(): Vector3;
  85717. /**
  85718. * Translates the mesh along the passed Vector3 in its local space.
  85719. * @param vector3 the distance to translate in localspace
  85720. * @returns the TransformNode.
  85721. */
  85722. locallyTranslate(vector3: Vector3): TransformNode;
  85723. private static _lookAtVectorCache;
  85724. /**
  85725. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  85726. * @param targetPoint the position (must be in same space as current mesh) to look at
  85727. * @param yawCor optional yaw (y-axis) correction in radians
  85728. * @param pitchCor optional pitch (x-axis) correction in radians
  85729. * @param rollCor optional roll (z-axis) correction in radians
  85730. * @param space the choosen space of the target
  85731. * @returns the TransformNode.
  85732. */
  85733. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  85734. /**
  85735. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  85736. * This Vector3 is expressed in the World space.
  85737. * @param localAxis axis to rotate
  85738. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  85739. */
  85740. getDirection(localAxis: Vector3): Vector3;
  85741. /**
  85742. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  85743. * localAxis is expressed in the mesh local space.
  85744. * result is computed in the Wordl space from the mesh World matrix.
  85745. * @param localAxis axis to rotate
  85746. * @param result the resulting transformnode
  85747. * @returns this TransformNode.
  85748. */
  85749. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  85750. /**
  85751. * Sets this transform node rotation to the given local axis.
  85752. * @param localAxis the axis in local space
  85753. * @param yawCor optional yaw (y-axis) correction in radians
  85754. * @param pitchCor optional pitch (x-axis) correction in radians
  85755. * @param rollCor optional roll (z-axis) correction in radians
  85756. * @returns this TransformNode
  85757. */
  85758. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  85759. /**
  85760. * Sets a new pivot point to the current node
  85761. * @param point defines the new pivot point to use
  85762. * @param space defines if the point is in world or local space (local by default)
  85763. * @returns the current TransformNode
  85764. */
  85765. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  85766. /**
  85767. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  85768. * @returns the pivot point
  85769. */
  85770. getPivotPoint(): Vector3;
  85771. /**
  85772. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  85773. * @param result the vector3 to store the result
  85774. * @returns this TransformNode.
  85775. */
  85776. getPivotPointToRef(result: Vector3): TransformNode;
  85777. /**
  85778. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  85779. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  85780. */
  85781. getAbsolutePivotPoint(): Vector3;
  85782. /**
  85783. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  85784. * @param result vector3 to store the result
  85785. * @returns this TransformNode.
  85786. */
  85787. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  85788. /**
  85789. * Defines the passed node as the parent of the current node.
  85790. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  85791. * @see https://doc.babylonjs.com/how_to/parenting
  85792. * @param node the node ot set as the parent
  85793. * @returns this TransformNode.
  85794. */
  85795. setParent(node: Nullable<Node>): TransformNode;
  85796. private _nonUniformScaling;
  85797. /**
  85798. * True if the scaling property of this object is non uniform eg. (1,2,1)
  85799. */
  85800. get nonUniformScaling(): boolean;
  85801. /** @hidden */
  85802. _updateNonUniformScalingState(value: boolean): boolean;
  85803. /**
  85804. * Attach the current TransformNode to another TransformNode associated with a bone
  85805. * @param bone Bone affecting the TransformNode
  85806. * @param affectedTransformNode TransformNode associated with the bone
  85807. * @returns this object
  85808. */
  85809. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  85810. /**
  85811. * Detach the transform node if its associated with a bone
  85812. * @returns this object
  85813. */
  85814. detachFromBone(): TransformNode;
  85815. private static _rotationAxisCache;
  85816. /**
  85817. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  85818. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85819. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85820. * The passed axis is also normalized.
  85821. * @param axis the axis to rotate around
  85822. * @param amount the amount to rotate in radians
  85823. * @param space Space to rotate in (Default: local)
  85824. * @returns the TransformNode.
  85825. */
  85826. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  85827. /**
  85828. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  85829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  85830. * The passed axis is also normalized. .
  85831. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  85832. * @param point the point to rotate around
  85833. * @param axis the axis to rotate around
  85834. * @param amount the amount to rotate in radians
  85835. * @returns the TransformNode
  85836. */
  85837. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  85838. /**
  85839. * Translates the mesh along the axis vector for the passed distance in the given space.
  85840. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  85841. * @param axis the axis to translate in
  85842. * @param distance the distance to translate
  85843. * @param space Space to rotate in (Default: local)
  85844. * @returns the TransformNode.
  85845. */
  85846. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  85847. /**
  85848. * Adds a rotation step to the mesh current rotation.
  85849. * x, y, z are Euler angles expressed in radians.
  85850. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  85851. * This means this rotation is made in the mesh local space only.
  85852. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  85853. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  85854. * ```javascript
  85855. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  85856. * ```
  85857. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  85858. * 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.
  85859. * @param x Rotation to add
  85860. * @param y Rotation to add
  85861. * @param z Rotation to add
  85862. * @returns the TransformNode.
  85863. */
  85864. addRotation(x: number, y: number, z: number): TransformNode;
  85865. /**
  85866. * @hidden
  85867. */
  85868. protected _getEffectiveParent(): Nullable<Node>;
  85869. /**
  85870. * Computes the world matrix of the node
  85871. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  85872. * @returns the world matrix
  85873. */
  85874. computeWorldMatrix(force?: boolean): Matrix;
  85875. protected _afterComputeWorldMatrix(): void;
  85876. /**
  85877. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  85878. * @param func callback function to add
  85879. *
  85880. * @returns the TransformNode.
  85881. */
  85882. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85883. /**
  85884. * Removes a registered callback function.
  85885. * @param func callback function to remove
  85886. * @returns the TransformNode.
  85887. */
  85888. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  85889. /**
  85890. * Gets the position of the current mesh in camera space
  85891. * @param camera defines the camera to use
  85892. * @returns a position
  85893. */
  85894. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  85895. /**
  85896. * Returns the distance from the mesh to the active camera
  85897. * @param camera defines the camera to use
  85898. * @returns the distance
  85899. */
  85900. getDistanceToCamera(camera?: Nullable<Camera>): number;
  85901. /**
  85902. * Clone the current transform node
  85903. * @param name Name of the new clone
  85904. * @param newParent New parent for the clone
  85905. * @param doNotCloneChildren Do not clone children hierarchy
  85906. * @returns the new transform node
  85907. */
  85908. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  85909. /**
  85910. * Serializes the objects information.
  85911. * @param currentSerializationObject defines the object to serialize in
  85912. * @returns the serialized object
  85913. */
  85914. serialize(currentSerializationObject?: any): any;
  85915. /**
  85916. * Returns a new TransformNode object parsed from the source provided.
  85917. * @param parsedTransformNode is the source.
  85918. * @param scene the scne the object belongs to
  85919. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  85920. * @returns a new TransformNode object parsed from the source provided.
  85921. */
  85922. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  85923. /**
  85924. * Get all child-transformNodes of this node
  85925. * @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
  85926. * @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
  85927. * @returns an array of TransformNode
  85928. */
  85929. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  85930. /**
  85931. * Releases resources associated with this transform node.
  85932. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85933. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85934. */
  85935. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85936. /**
  85937. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  85938. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  85939. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  85940. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  85941. * @returns the current mesh
  85942. */
  85943. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  85944. private _syncAbsoluteScalingAndRotation;
  85945. }
  85946. }
  85947. declare module BABYLON {
  85948. /**
  85949. * Defines the types of pose enabled controllers that are supported
  85950. */
  85951. export enum PoseEnabledControllerType {
  85952. /**
  85953. * HTC Vive
  85954. */
  85955. VIVE = 0,
  85956. /**
  85957. * Oculus Rift
  85958. */
  85959. OCULUS = 1,
  85960. /**
  85961. * Windows mixed reality
  85962. */
  85963. WINDOWS = 2,
  85964. /**
  85965. * Samsung gear VR
  85966. */
  85967. GEAR_VR = 3,
  85968. /**
  85969. * Google Daydream
  85970. */
  85971. DAYDREAM = 4,
  85972. /**
  85973. * Generic
  85974. */
  85975. GENERIC = 5
  85976. }
  85977. /**
  85978. * Defines the MutableGamepadButton interface for the state of a gamepad button
  85979. */
  85980. export interface MutableGamepadButton {
  85981. /**
  85982. * Value of the button/trigger
  85983. */
  85984. value: number;
  85985. /**
  85986. * If the button/trigger is currently touched
  85987. */
  85988. touched: boolean;
  85989. /**
  85990. * If the button/trigger is currently pressed
  85991. */
  85992. pressed: boolean;
  85993. }
  85994. /**
  85995. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  85996. * @hidden
  85997. */
  85998. export interface ExtendedGamepadButton extends GamepadButton {
  85999. /**
  86000. * If the button/trigger is currently pressed
  86001. */
  86002. readonly pressed: boolean;
  86003. /**
  86004. * If the button/trigger is currently touched
  86005. */
  86006. readonly touched: boolean;
  86007. /**
  86008. * Value of the button/trigger
  86009. */
  86010. readonly value: number;
  86011. }
  86012. /** @hidden */
  86013. export interface _GamePadFactory {
  86014. /**
  86015. * Returns wether or not the current gamepad can be created for this type of controller.
  86016. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  86017. * @returns true if it can be created, otherwise false
  86018. */
  86019. canCreate(gamepadInfo: any): boolean;
  86020. /**
  86021. * Creates a new instance of the Gamepad.
  86022. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  86023. * @returns the new gamepad instance
  86024. */
  86025. create(gamepadInfo: any): Gamepad;
  86026. }
  86027. /**
  86028. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  86029. */
  86030. export class PoseEnabledControllerHelper {
  86031. /** @hidden */
  86032. static _ControllerFactories: _GamePadFactory[];
  86033. /** @hidden */
  86034. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  86035. /**
  86036. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  86037. * @param vrGamepad the gamepad to initialized
  86038. * @returns a vr controller of the type the gamepad identified as
  86039. */
  86040. static InitiateController(vrGamepad: any): Gamepad;
  86041. }
  86042. /**
  86043. * Defines the PoseEnabledController object that contains state of a vr capable controller
  86044. */
  86045. export class PoseEnabledController extends Gamepad implements PoseControlled {
  86046. /**
  86047. * If the controller is used in a webXR session
  86048. */
  86049. isXR: boolean;
  86050. private _deviceRoomPosition;
  86051. private _deviceRoomRotationQuaternion;
  86052. /**
  86053. * The device position in babylon space
  86054. */
  86055. devicePosition: Vector3;
  86056. /**
  86057. * The device rotation in babylon space
  86058. */
  86059. deviceRotationQuaternion: Quaternion;
  86060. /**
  86061. * The scale factor of the device in babylon space
  86062. */
  86063. deviceScaleFactor: number;
  86064. /**
  86065. * (Likely devicePosition should be used instead) The device position in its room space
  86066. */
  86067. position: Vector3;
  86068. /**
  86069. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  86070. */
  86071. rotationQuaternion: Quaternion;
  86072. /**
  86073. * The type of controller (Eg. Windows mixed reality)
  86074. */
  86075. controllerType: PoseEnabledControllerType;
  86076. protected _calculatedPosition: Vector3;
  86077. private _calculatedRotation;
  86078. /**
  86079. * The raw pose from the device
  86080. */
  86081. rawPose: DevicePose;
  86082. private _trackPosition;
  86083. private _maxRotationDistFromHeadset;
  86084. private _draggedRoomRotation;
  86085. /**
  86086. * @hidden
  86087. */
  86088. _disableTrackPosition(fixedPosition: Vector3): void;
  86089. /**
  86090. * Internal, the mesh attached to the controller
  86091. * @hidden
  86092. */
  86093. _mesh: Nullable<AbstractMesh>;
  86094. private _poseControlledCamera;
  86095. private _leftHandSystemQuaternion;
  86096. /**
  86097. * Internal, matrix used to convert room space to babylon space
  86098. * @hidden
  86099. */
  86100. _deviceToWorld: Matrix;
  86101. /**
  86102. * Node to be used when casting a ray from the controller
  86103. * @hidden
  86104. */
  86105. _pointingPoseNode: Nullable<TransformNode>;
  86106. /**
  86107. * Name of the child mesh that can be used to cast a ray from the controller
  86108. */
  86109. static readonly POINTING_POSE: string;
  86110. /**
  86111. * Creates a new PoseEnabledController from a gamepad
  86112. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  86113. */
  86114. constructor(browserGamepad: any);
  86115. private _workingMatrix;
  86116. /**
  86117. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  86118. */
  86119. update(): void;
  86120. /**
  86121. * Updates only the pose device and mesh without doing any button event checking
  86122. */
  86123. protected _updatePoseAndMesh(): void;
  86124. /**
  86125. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  86126. * @param poseData raw pose fromthe device
  86127. */
  86128. updateFromDevice(poseData: DevicePose): void;
  86129. /**
  86130. * @hidden
  86131. */
  86132. _meshAttachedObservable: Observable<AbstractMesh>;
  86133. /**
  86134. * Attaches a mesh to the controller
  86135. * @param mesh the mesh to be attached
  86136. */
  86137. attachToMesh(mesh: AbstractMesh): void;
  86138. /**
  86139. * Attaches the controllers mesh to a camera
  86140. * @param camera the camera the mesh should be attached to
  86141. */
  86142. attachToPoseControlledCamera(camera: TargetCamera): void;
  86143. /**
  86144. * Disposes of the controller
  86145. */
  86146. dispose(): void;
  86147. /**
  86148. * The mesh that is attached to the controller
  86149. */
  86150. get mesh(): Nullable<AbstractMesh>;
  86151. /**
  86152. * Gets the ray of the controller in the direction the controller is pointing
  86153. * @param length the length the resulting ray should be
  86154. * @returns a ray in the direction the controller is pointing
  86155. */
  86156. getForwardRay(length?: number): Ray;
  86157. }
  86158. }
  86159. declare module BABYLON {
  86160. /**
  86161. * Defines the WebVRController object that represents controllers tracked in 3D space
  86162. */
  86163. export abstract class WebVRController extends PoseEnabledController {
  86164. /**
  86165. * Internal, the default controller model for the controller
  86166. */
  86167. protected _defaultModel: Nullable<AbstractMesh>;
  86168. /**
  86169. * Fired when the trigger state has changed
  86170. */
  86171. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  86172. /**
  86173. * Fired when the main button state has changed
  86174. */
  86175. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  86176. /**
  86177. * Fired when the secondary button state has changed
  86178. */
  86179. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  86180. /**
  86181. * Fired when the pad state has changed
  86182. */
  86183. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  86184. /**
  86185. * Fired when controllers stick values have changed
  86186. */
  86187. onPadValuesChangedObservable: Observable<StickValues>;
  86188. /**
  86189. * Array of button availible on the controller
  86190. */
  86191. protected _buttons: Array<MutableGamepadButton>;
  86192. private _onButtonStateChange;
  86193. /**
  86194. * Fired when a controller button's state has changed
  86195. * @param callback the callback containing the button that was modified
  86196. */
  86197. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  86198. /**
  86199. * X and Y axis corresponding to the controllers joystick
  86200. */
  86201. pad: StickValues;
  86202. /**
  86203. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  86204. */
  86205. hand: string;
  86206. /**
  86207. * The default controller model for the controller
  86208. */
  86209. get defaultModel(): Nullable<AbstractMesh>;
  86210. /**
  86211. * Creates a new WebVRController from a gamepad
  86212. * @param vrGamepad the gamepad that the WebVRController should be created from
  86213. */
  86214. constructor(vrGamepad: any);
  86215. /**
  86216. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  86217. */
  86218. update(): void;
  86219. /**
  86220. * Function to be called when a button is modified
  86221. */
  86222. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  86223. /**
  86224. * Loads a mesh and attaches it to the controller
  86225. * @param scene the scene the mesh should be added to
  86226. * @param meshLoaded callback for when the mesh has been loaded
  86227. */
  86228. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  86229. private _setButtonValue;
  86230. private _changes;
  86231. private _checkChanges;
  86232. /**
  86233. * Disposes of th webVRCOntroller
  86234. */
  86235. dispose(): void;
  86236. }
  86237. }
  86238. declare module BABYLON {
  86239. /**
  86240. * The HemisphericLight simulates the ambient environment light,
  86241. * so the passed direction is the light reflection direction, not the incoming direction.
  86242. */
  86243. export class HemisphericLight extends Light {
  86244. /**
  86245. * The groundColor is the light in the opposite direction to the one specified during creation.
  86246. * 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.
  86247. */
  86248. groundColor: Color3;
  86249. /**
  86250. * The light reflection direction, not the incoming direction.
  86251. */
  86252. direction: Vector3;
  86253. /**
  86254. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  86255. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  86256. * The HemisphericLight can't cast shadows.
  86257. * Documentation : https://doc.babylonjs.com/babylon101/lights
  86258. * @param name The friendly name of the light
  86259. * @param direction The direction of the light reflection
  86260. * @param scene The scene the light belongs to
  86261. */
  86262. constructor(name: string, direction: Vector3, scene: Scene);
  86263. protected _buildUniformLayout(): void;
  86264. /**
  86265. * Returns the string "HemisphericLight".
  86266. * @return The class name
  86267. */
  86268. getClassName(): string;
  86269. /**
  86270. * Sets the HemisphericLight direction towards the passed target (Vector3).
  86271. * Returns the updated direction.
  86272. * @param target The target the direction should point to
  86273. * @return The computed direction
  86274. */
  86275. setDirectionToTarget(target: Vector3): Vector3;
  86276. /**
  86277. * Returns the shadow generator associated to the light.
  86278. * @returns Always null for hemispheric lights because it does not support shadows.
  86279. */
  86280. getShadowGenerator(): Nullable<IShadowGenerator>;
  86281. /**
  86282. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  86283. * @param effect The effect to update
  86284. * @param lightIndex The index of the light in the effect to update
  86285. * @returns The hemispheric light
  86286. */
  86287. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  86288. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  86289. /**
  86290. * Computes the world matrix of the node
  86291. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  86292. * @param useWasUpdatedFlag defines a reserved property
  86293. * @returns the world matrix
  86294. */
  86295. computeWorldMatrix(): Matrix;
  86296. /**
  86297. * Returns the integer 3.
  86298. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  86299. */
  86300. getTypeID(): number;
  86301. /**
  86302. * Prepares the list of defines specific to the light type.
  86303. * @param defines the list of defines
  86304. * @param lightIndex defines the index of the light for the effect
  86305. */
  86306. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  86307. }
  86308. }
  86309. declare module BABYLON {
  86310. /** @hidden */
  86311. export var vrMultiviewToSingleviewPixelShader: {
  86312. name: string;
  86313. shader: string;
  86314. };
  86315. }
  86316. declare module BABYLON {
  86317. /**
  86318. * Renders to multiple views with a single draw call
  86319. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  86320. */
  86321. export class MultiviewRenderTarget extends RenderTargetTexture {
  86322. /**
  86323. * Creates a multiview render target
  86324. * @param scene scene used with the render target
  86325. * @param size the size of the render target (used for each view)
  86326. */
  86327. constructor(scene: Scene, size?: number | {
  86328. width: number;
  86329. height: number;
  86330. } | {
  86331. ratio: number;
  86332. });
  86333. /**
  86334. * @hidden
  86335. * @param faceIndex the face index, if its a cube texture
  86336. */
  86337. _bindFrameBuffer(faceIndex?: number): void;
  86338. /**
  86339. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86340. * @returns the view count
  86341. */
  86342. getViewCount(): number;
  86343. }
  86344. }
  86345. declare module BABYLON {
  86346. /**
  86347. * Represents a camera frustum
  86348. */
  86349. export class Frustum {
  86350. /**
  86351. * Gets the planes representing the frustum
  86352. * @param transform matrix to be applied to the returned planes
  86353. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  86354. */
  86355. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  86356. /**
  86357. * Gets the near frustum plane transformed by the transform matrix
  86358. * @param transform transformation matrix to be applied to the resulting frustum plane
  86359. * @param frustumPlane the resuling frustum plane
  86360. */
  86361. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86362. /**
  86363. * Gets the far frustum plane transformed by the transform matrix
  86364. * @param transform transformation matrix to be applied to the resulting frustum plane
  86365. * @param frustumPlane the resuling frustum plane
  86366. */
  86367. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86368. /**
  86369. * Gets the left frustum plane transformed by the transform matrix
  86370. * @param transform transformation matrix to be applied to the resulting frustum plane
  86371. * @param frustumPlane the resuling frustum plane
  86372. */
  86373. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86374. /**
  86375. * Gets the right frustum plane transformed by the transform matrix
  86376. * @param transform transformation matrix to be applied to the resulting frustum plane
  86377. * @param frustumPlane the resuling frustum plane
  86378. */
  86379. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86380. /**
  86381. * Gets the top frustum plane transformed by the transform matrix
  86382. * @param transform transformation matrix to be applied to the resulting frustum plane
  86383. * @param frustumPlane the resuling frustum plane
  86384. */
  86385. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86386. /**
  86387. * Gets the bottom frustum plane transformed by the transform matrix
  86388. * @param transform transformation matrix to be applied to the resulting frustum plane
  86389. * @param frustumPlane the resuling frustum plane
  86390. */
  86391. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  86392. /**
  86393. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  86394. * @param transform transformation matrix to be applied to the resulting frustum planes
  86395. * @param frustumPlanes the resuling frustum planes
  86396. */
  86397. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  86398. }
  86399. }
  86400. declare module BABYLON {
  86401. interface Engine {
  86402. /**
  86403. * Creates a new multiview render target
  86404. * @param width defines the width of the texture
  86405. * @param height defines the height of the texture
  86406. * @returns the created multiview texture
  86407. */
  86408. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  86409. /**
  86410. * Binds a multiview framebuffer to be drawn to
  86411. * @param multiviewTexture texture to bind
  86412. */
  86413. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  86414. }
  86415. interface Camera {
  86416. /**
  86417. * @hidden
  86418. * 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)
  86419. */
  86420. _useMultiviewToSingleView: boolean;
  86421. /**
  86422. * @hidden
  86423. * 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)
  86424. */
  86425. _multiviewTexture: Nullable<RenderTargetTexture>;
  86426. /**
  86427. * @hidden
  86428. * ensures the multiview texture of the camera exists and has the specified width/height
  86429. * @param width height to set on the multiview texture
  86430. * @param height width to set on the multiview texture
  86431. */
  86432. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  86433. }
  86434. interface Scene {
  86435. /** @hidden */
  86436. _transformMatrixR: Matrix;
  86437. /** @hidden */
  86438. _multiviewSceneUbo: Nullable<UniformBuffer>;
  86439. /** @hidden */
  86440. _createMultiviewUbo(): void;
  86441. /** @hidden */
  86442. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  86443. /** @hidden */
  86444. _renderMultiviewToSingleView(camera: Camera): void;
  86445. }
  86446. }
  86447. declare module BABYLON {
  86448. /**
  86449. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  86450. * This will not be used for webXR as it supports displaying texture arrays directly
  86451. */
  86452. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  86453. /**
  86454. * Initializes a VRMultiviewToSingleview
  86455. * @param name name of the post process
  86456. * @param camera camera to be applied to
  86457. * @param scaleFactor scaling factor to the size of the output texture
  86458. */
  86459. constructor(name: string, camera: Camera, scaleFactor: number);
  86460. }
  86461. }
  86462. declare module BABYLON {
  86463. /**
  86464. * Interface used to define additional presentation attributes
  86465. */
  86466. export interface IVRPresentationAttributes {
  86467. /**
  86468. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  86469. */
  86470. highRefreshRate: boolean;
  86471. /**
  86472. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  86473. */
  86474. foveationLevel: number;
  86475. }
  86476. interface Engine {
  86477. /** @hidden */
  86478. _vrDisplay: any;
  86479. /** @hidden */
  86480. _vrSupported: boolean;
  86481. /** @hidden */
  86482. _oldSize: Size;
  86483. /** @hidden */
  86484. _oldHardwareScaleFactor: number;
  86485. /** @hidden */
  86486. _vrExclusivePointerMode: boolean;
  86487. /** @hidden */
  86488. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  86489. /** @hidden */
  86490. _onVRDisplayPointerRestricted: () => void;
  86491. /** @hidden */
  86492. _onVRDisplayPointerUnrestricted: () => void;
  86493. /** @hidden */
  86494. _onVrDisplayConnect: Nullable<(display: any) => void>;
  86495. /** @hidden */
  86496. _onVrDisplayDisconnect: Nullable<() => void>;
  86497. /** @hidden */
  86498. _onVrDisplayPresentChange: Nullable<() => void>;
  86499. /**
  86500. * Observable signaled when VR display mode changes
  86501. */
  86502. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  86503. /**
  86504. * Observable signaled when VR request present is complete
  86505. */
  86506. onVRRequestPresentComplete: Observable<boolean>;
  86507. /**
  86508. * Observable signaled when VR request present starts
  86509. */
  86510. onVRRequestPresentStart: Observable<Engine>;
  86511. /**
  86512. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86513. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86514. */
  86515. isInVRExclusivePointerMode: boolean;
  86516. /**
  86517. * Gets a boolean indicating if a webVR device was detected
  86518. * @returns true if a webVR device was detected
  86519. */
  86520. isVRDevicePresent(): boolean;
  86521. /**
  86522. * Gets the current webVR device
  86523. * @returns the current webVR device (or null)
  86524. */
  86525. getVRDevice(): any;
  86526. /**
  86527. * Initializes a webVR display and starts listening to display change events
  86528. * The onVRDisplayChangedObservable will be notified upon these changes
  86529. * @returns A promise containing a VRDisplay and if vr is supported
  86530. */
  86531. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  86532. /** @hidden */
  86533. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  86534. /**
  86535. * Gets or sets the presentation attributes used to configure VR rendering
  86536. */
  86537. vrPresentationAttributes?: IVRPresentationAttributes;
  86538. /**
  86539. * Call this function to switch to webVR mode
  86540. * Will do nothing if webVR is not supported or if there is no webVR device
  86541. * @param options the webvr options provided to the camera. mainly used for multiview
  86542. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86543. */
  86544. enableVR(options: WebVROptions): void;
  86545. /** @hidden */
  86546. _onVRFullScreenTriggered(): void;
  86547. }
  86548. }
  86549. declare module BABYLON {
  86550. /**
  86551. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  86552. * IMPORTANT!! The data is right-hand data.
  86553. * @export
  86554. * @interface DevicePose
  86555. */
  86556. export interface DevicePose {
  86557. /**
  86558. * The position of the device, values in array are [x,y,z].
  86559. */
  86560. readonly position: Nullable<Float32Array>;
  86561. /**
  86562. * The linearVelocity of the device, values in array are [x,y,z].
  86563. */
  86564. readonly linearVelocity: Nullable<Float32Array>;
  86565. /**
  86566. * The linearAcceleration of the device, values in array are [x,y,z].
  86567. */
  86568. readonly linearAcceleration: Nullable<Float32Array>;
  86569. /**
  86570. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  86571. */
  86572. readonly orientation: Nullable<Float32Array>;
  86573. /**
  86574. * The angularVelocity of the device, values in array are [x,y,z].
  86575. */
  86576. readonly angularVelocity: Nullable<Float32Array>;
  86577. /**
  86578. * The angularAcceleration of the device, values in array are [x,y,z].
  86579. */
  86580. readonly angularAcceleration: Nullable<Float32Array>;
  86581. }
  86582. /**
  86583. * Interface representing a pose controlled object in Babylon.
  86584. * A pose controlled object has both regular pose values as well as pose values
  86585. * from an external device such as a VR head mounted display
  86586. */
  86587. export interface PoseControlled {
  86588. /**
  86589. * The position of the object in babylon space.
  86590. */
  86591. position: Vector3;
  86592. /**
  86593. * The rotation quaternion of the object in babylon space.
  86594. */
  86595. rotationQuaternion: Quaternion;
  86596. /**
  86597. * The position of the device in babylon space.
  86598. */
  86599. devicePosition?: Vector3;
  86600. /**
  86601. * The rotation quaternion of the device in babylon space.
  86602. */
  86603. deviceRotationQuaternion: Quaternion;
  86604. /**
  86605. * The raw pose coming from the device.
  86606. */
  86607. rawPose: Nullable<DevicePose>;
  86608. /**
  86609. * The scale of the device to be used when translating from device space to babylon space.
  86610. */
  86611. deviceScaleFactor: number;
  86612. /**
  86613. * Updates the poseControlled values based on the input device pose.
  86614. * @param poseData the pose data to update the object with
  86615. */
  86616. updateFromDevice(poseData: DevicePose): void;
  86617. }
  86618. /**
  86619. * Set of options to customize the webVRCamera
  86620. */
  86621. export interface WebVROptions {
  86622. /**
  86623. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  86624. */
  86625. trackPosition?: boolean;
  86626. /**
  86627. * Sets the scale of the vrDevice in babylon space. (default: 1)
  86628. */
  86629. positionScale?: number;
  86630. /**
  86631. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  86632. */
  86633. displayName?: string;
  86634. /**
  86635. * Should the native controller meshes be initialized. (default: true)
  86636. */
  86637. controllerMeshes?: boolean;
  86638. /**
  86639. * Creating a default HemiLight only on controllers. (default: true)
  86640. */
  86641. defaultLightingOnControllers?: boolean;
  86642. /**
  86643. * If you don't want to use the default VR button of the helper. (default: false)
  86644. */
  86645. useCustomVRButton?: boolean;
  86646. /**
  86647. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  86648. */
  86649. customVRButton?: HTMLButtonElement;
  86650. /**
  86651. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  86652. */
  86653. rayLength?: number;
  86654. /**
  86655. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  86656. */
  86657. defaultHeight?: number;
  86658. /**
  86659. * If multiview should be used if availible (default: false)
  86660. */
  86661. useMultiview?: boolean;
  86662. }
  86663. /**
  86664. * This represents a WebVR camera.
  86665. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  86666. * @example http://doc.babylonjs.com/how_to/webvr_camera
  86667. */
  86668. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  86669. private webVROptions;
  86670. /**
  86671. * @hidden
  86672. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  86673. */
  86674. _vrDevice: any;
  86675. /**
  86676. * The rawPose of the vrDevice.
  86677. */
  86678. rawPose: Nullable<DevicePose>;
  86679. private _onVREnabled;
  86680. private _specsVersion;
  86681. private _attached;
  86682. private _frameData;
  86683. protected _descendants: Array<Node>;
  86684. private _deviceRoomPosition;
  86685. /** @hidden */
  86686. _deviceRoomRotationQuaternion: Quaternion;
  86687. private _standingMatrix;
  86688. /**
  86689. * Represents device position in babylon space.
  86690. */
  86691. devicePosition: Vector3;
  86692. /**
  86693. * Represents device rotation in babylon space.
  86694. */
  86695. deviceRotationQuaternion: Quaternion;
  86696. /**
  86697. * The scale of the device to be used when translating from device space to babylon space.
  86698. */
  86699. deviceScaleFactor: number;
  86700. private _deviceToWorld;
  86701. private _worldToDevice;
  86702. /**
  86703. * References to the webVR controllers for the vrDevice.
  86704. */
  86705. controllers: Array<WebVRController>;
  86706. /**
  86707. * Emits an event when a controller is attached.
  86708. */
  86709. onControllersAttachedObservable: Observable<WebVRController[]>;
  86710. /**
  86711. * Emits an event when a controller's mesh has been loaded;
  86712. */
  86713. onControllerMeshLoadedObservable: Observable<WebVRController>;
  86714. /**
  86715. * Emits an event when the HMD's pose has been updated.
  86716. */
  86717. onPoseUpdatedFromDeviceObservable: Observable<any>;
  86718. private _poseSet;
  86719. /**
  86720. * If the rig cameras be used as parent instead of this camera.
  86721. */
  86722. rigParenting: boolean;
  86723. private _lightOnControllers;
  86724. private _defaultHeight?;
  86725. /**
  86726. * Instantiates a WebVRFreeCamera.
  86727. * @param name The name of the WebVRFreeCamera
  86728. * @param position The starting anchor position for the camera
  86729. * @param scene The scene the camera belongs to
  86730. * @param webVROptions a set of customizable options for the webVRCamera
  86731. */
  86732. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  86733. /**
  86734. * Gets the device distance from the ground in meters.
  86735. * @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.
  86736. */
  86737. deviceDistanceToRoomGround(): number;
  86738. /**
  86739. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  86740. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  86741. */
  86742. useStandingMatrix(callback?: (bool: boolean) => void): void;
  86743. /**
  86744. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  86745. * @returns A promise with a boolean set to if the standing matrix is supported.
  86746. */
  86747. useStandingMatrixAsync(): Promise<boolean>;
  86748. /**
  86749. * Disposes the camera
  86750. */
  86751. dispose(): void;
  86752. /**
  86753. * Gets a vrController by name.
  86754. * @param name The name of the controller to retreive
  86755. * @returns the controller matching the name specified or null if not found
  86756. */
  86757. getControllerByName(name: string): Nullable<WebVRController>;
  86758. private _leftController;
  86759. /**
  86760. * The controller corresponding to the users left hand.
  86761. */
  86762. get leftController(): Nullable<WebVRController>;
  86763. private _rightController;
  86764. /**
  86765. * The controller corresponding to the users right hand.
  86766. */
  86767. get rightController(): Nullable<WebVRController>;
  86768. /**
  86769. * Casts a ray forward from the vrCamera's gaze.
  86770. * @param length Length of the ray (default: 100)
  86771. * @returns the ray corresponding to the gaze
  86772. */
  86773. getForwardRay(length?: number): Ray;
  86774. /**
  86775. * @hidden
  86776. * Updates the camera based on device's frame data
  86777. */
  86778. _checkInputs(): void;
  86779. /**
  86780. * Updates the poseControlled values based on the input device pose.
  86781. * @param poseData Pose coming from the device
  86782. */
  86783. updateFromDevice(poseData: DevicePose): void;
  86784. private _htmlElementAttached;
  86785. private _detachIfAttached;
  86786. /**
  86787. * WebVR's attach control will start broadcasting frames to the device.
  86788. * Note that in certain browsers (chrome for example) this function must be called
  86789. * within a user-interaction callback. Example:
  86790. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  86791. *
  86792. * @param element html element to attach the vrDevice to
  86793. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  86794. */
  86795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86796. /**
  86797. * Detaches the camera from the html element and disables VR
  86798. *
  86799. * @param element html element to detach from
  86800. */
  86801. detachControl(element: HTMLElement): void;
  86802. /**
  86803. * @returns the name of this class
  86804. */
  86805. getClassName(): string;
  86806. /**
  86807. * Calls resetPose on the vrDisplay
  86808. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  86809. */
  86810. resetToCurrentRotation(): void;
  86811. /**
  86812. * @hidden
  86813. * Updates the rig cameras (left and right eye)
  86814. */
  86815. _updateRigCameras(): void;
  86816. private _workingVector;
  86817. private _oneVector;
  86818. private _workingMatrix;
  86819. private updateCacheCalled;
  86820. private _correctPositionIfNotTrackPosition;
  86821. /**
  86822. * @hidden
  86823. * Updates the cached values of the camera
  86824. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  86825. */
  86826. _updateCache(ignoreParentClass?: boolean): void;
  86827. /**
  86828. * @hidden
  86829. * Get current device position in babylon world
  86830. */
  86831. _computeDevicePosition(): void;
  86832. /**
  86833. * Updates the current device position and rotation in the babylon world
  86834. */
  86835. update(): void;
  86836. /**
  86837. * @hidden
  86838. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  86839. * @returns an identity matrix
  86840. */
  86841. _getViewMatrix(): Matrix;
  86842. private _tmpMatrix;
  86843. /**
  86844. * This function is called by the two RIG cameras.
  86845. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  86846. * @hidden
  86847. */
  86848. _getWebVRViewMatrix(): Matrix;
  86849. /** @hidden */
  86850. _getWebVRProjectionMatrix(): Matrix;
  86851. private _onGamepadConnectedObserver;
  86852. private _onGamepadDisconnectedObserver;
  86853. private _updateCacheWhenTrackingDisabledObserver;
  86854. /**
  86855. * Initializes the controllers and their meshes
  86856. */
  86857. initControllers(): void;
  86858. }
  86859. }
  86860. declare module BABYLON {
  86861. /**
  86862. * Size options for a post process
  86863. */
  86864. export type PostProcessOptions = {
  86865. width: number;
  86866. height: number;
  86867. };
  86868. /**
  86869. * PostProcess can be used to apply a shader to a texture after it has been rendered
  86870. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  86871. */
  86872. export class PostProcess {
  86873. /** Name of the PostProcess. */
  86874. name: string;
  86875. /**
  86876. * Gets or sets the unique id of the post process
  86877. */
  86878. uniqueId: number;
  86879. /**
  86880. * Width of the texture to apply the post process on
  86881. */
  86882. width: number;
  86883. /**
  86884. * Height of the texture to apply the post process on
  86885. */
  86886. height: number;
  86887. /**
  86888. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  86889. * @hidden
  86890. */
  86891. _outputTexture: Nullable<InternalTexture>;
  86892. /**
  86893. * Sampling mode used by the shader
  86894. * See https://doc.babylonjs.com/classes/3.1/texture
  86895. */
  86896. renderTargetSamplingMode: number;
  86897. /**
  86898. * Clear color to use when screen clearing
  86899. */
  86900. clearColor: Color4;
  86901. /**
  86902. * If the buffer needs to be cleared before applying the post process. (default: true)
  86903. * Should be set to false if shader will overwrite all previous pixels.
  86904. */
  86905. autoClear: boolean;
  86906. /**
  86907. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  86908. */
  86909. alphaMode: number;
  86910. /**
  86911. * Sets the setAlphaBlendConstants of the babylon engine
  86912. */
  86913. alphaConstants: Color4;
  86914. /**
  86915. * Animations to be used for the post processing
  86916. */
  86917. animations: Animation[];
  86918. /**
  86919. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  86920. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  86921. */
  86922. enablePixelPerfectMode: boolean;
  86923. /**
  86924. * Force the postprocess to be applied without taking in account viewport
  86925. */
  86926. forceFullscreenViewport: boolean;
  86927. /**
  86928. * List of inspectable custom properties (used by the Inspector)
  86929. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86930. */
  86931. inspectableCustomProperties: IInspectable[];
  86932. /**
  86933. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  86934. *
  86935. * | Value | Type | Description |
  86936. * | ----- | ----------------------------------- | ----------- |
  86937. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  86938. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  86939. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  86940. *
  86941. */
  86942. scaleMode: number;
  86943. /**
  86944. * Force textures to be a power of two (default: false)
  86945. */
  86946. alwaysForcePOT: boolean;
  86947. private _samples;
  86948. /**
  86949. * Number of sample textures (default: 1)
  86950. */
  86951. get samples(): number;
  86952. set samples(n: number);
  86953. /**
  86954. * Modify the scale of the post process to be the same as the viewport (default: false)
  86955. */
  86956. adaptScaleToCurrentViewport: boolean;
  86957. private _camera;
  86958. private _scene;
  86959. private _engine;
  86960. private _options;
  86961. private _reusable;
  86962. private _textureType;
  86963. /**
  86964. * Smart array of input and output textures for the post process.
  86965. * @hidden
  86966. */
  86967. _textures: SmartArray<InternalTexture>;
  86968. /**
  86969. * The index in _textures that corresponds to the output texture.
  86970. * @hidden
  86971. */
  86972. _currentRenderTextureInd: number;
  86973. private _effect;
  86974. private _samplers;
  86975. private _fragmentUrl;
  86976. private _vertexUrl;
  86977. private _parameters;
  86978. private _scaleRatio;
  86979. protected _indexParameters: any;
  86980. private _shareOutputWithPostProcess;
  86981. private _texelSize;
  86982. private _forcedOutputTexture;
  86983. /**
  86984. * Returns the fragment url or shader name used in the post process.
  86985. * @returns the fragment url or name in the shader store.
  86986. */
  86987. getEffectName(): string;
  86988. /**
  86989. * An event triggered when the postprocess is activated.
  86990. */
  86991. onActivateObservable: Observable<Camera>;
  86992. private _onActivateObserver;
  86993. /**
  86994. * A function that is added to the onActivateObservable
  86995. */
  86996. set onActivate(callback: Nullable<(camera: Camera) => void>);
  86997. /**
  86998. * An event triggered when the postprocess changes its size.
  86999. */
  87000. onSizeChangedObservable: Observable<PostProcess>;
  87001. private _onSizeChangedObserver;
  87002. /**
  87003. * A function that is added to the onSizeChangedObservable
  87004. */
  87005. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  87006. /**
  87007. * An event triggered when the postprocess applies its effect.
  87008. */
  87009. onApplyObservable: Observable<Effect>;
  87010. private _onApplyObserver;
  87011. /**
  87012. * A function that is added to the onApplyObservable
  87013. */
  87014. set onApply(callback: (effect: Effect) => void);
  87015. /**
  87016. * An event triggered before rendering the postprocess
  87017. */
  87018. onBeforeRenderObservable: Observable<Effect>;
  87019. private _onBeforeRenderObserver;
  87020. /**
  87021. * A function that is added to the onBeforeRenderObservable
  87022. */
  87023. set onBeforeRender(callback: (effect: Effect) => void);
  87024. /**
  87025. * An event triggered after rendering the postprocess
  87026. */
  87027. onAfterRenderObservable: Observable<Effect>;
  87028. private _onAfterRenderObserver;
  87029. /**
  87030. * A function that is added to the onAfterRenderObservable
  87031. */
  87032. set onAfterRender(callback: (efect: Effect) => void);
  87033. /**
  87034. * 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
  87035. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  87036. */
  87037. get inputTexture(): InternalTexture;
  87038. set inputTexture(value: InternalTexture);
  87039. /**
  87040. * Gets the camera which post process is applied to.
  87041. * @returns The camera the post process is applied to.
  87042. */
  87043. getCamera(): Camera;
  87044. /**
  87045. * Gets the texel size of the postprocess.
  87046. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  87047. */
  87048. get texelSize(): Vector2;
  87049. /**
  87050. * Creates a new instance PostProcess
  87051. * @param name The name of the PostProcess.
  87052. * @param fragmentUrl The url of the fragment shader to be used.
  87053. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  87054. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  87055. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  87056. * @param camera The camera to apply the render pass to.
  87057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  87058. * @param engine The engine which the post process will be applied. (default: current engine)
  87059. * @param reusable If the post process can be reused on the same frame. (default: false)
  87060. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  87061. * @param textureType Type of textures used when performing the post process. (default: 0)
  87062. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  87063. * @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
  87064. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  87065. */
  87066. constructor(
  87067. /** Name of the PostProcess. */
  87068. 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);
  87069. /**
  87070. * Gets a string idenfifying the name of the class
  87071. * @returns "PostProcess" string
  87072. */
  87073. getClassName(): string;
  87074. /**
  87075. * Gets the engine which this post process belongs to.
  87076. * @returns The engine the post process was enabled with.
  87077. */
  87078. getEngine(): Engine;
  87079. /**
  87080. * The effect that is created when initializing the post process.
  87081. * @returns The created effect corresponding the the postprocess.
  87082. */
  87083. getEffect(): Effect;
  87084. /**
  87085. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  87086. * @param postProcess The post process to share the output with.
  87087. * @returns This post process.
  87088. */
  87089. shareOutputWith(postProcess: PostProcess): PostProcess;
  87090. /**
  87091. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  87092. * This should be called if the post process that shares output with this post process is disabled/disposed.
  87093. */
  87094. useOwnOutput(): void;
  87095. /**
  87096. * Updates the effect with the current post process compile time values and recompiles the shader.
  87097. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  87098. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  87099. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  87100. * @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
  87101. * @param onCompiled Called when the shader has been compiled.
  87102. * @param onError Called if there is an error when compiling a shader.
  87103. */
  87104. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  87105. /**
  87106. * The post process is reusable if it can be used multiple times within one frame.
  87107. * @returns If the post process is reusable
  87108. */
  87109. isReusable(): boolean;
  87110. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  87111. markTextureDirty(): void;
  87112. /**
  87113. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  87114. * 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.
  87115. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  87116. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  87117. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  87118. * @returns The target texture that was bound to be written to.
  87119. */
  87120. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  87121. /**
  87122. * If the post process is supported.
  87123. */
  87124. get isSupported(): boolean;
  87125. /**
  87126. * The aspect ratio of the output texture.
  87127. */
  87128. get aspectRatio(): number;
  87129. /**
  87130. * Get a value indicating if the post-process is ready to be used
  87131. * @returns true if the post-process is ready (shader is compiled)
  87132. */
  87133. isReady(): boolean;
  87134. /**
  87135. * Binds all textures and uniforms to the shader, this will be run on every pass.
  87136. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  87137. */
  87138. apply(): Nullable<Effect>;
  87139. private _disposeTextures;
  87140. /**
  87141. * Disposes the post process.
  87142. * @param camera The camera to dispose the post process on.
  87143. */
  87144. dispose(camera?: Camera): void;
  87145. }
  87146. }
  87147. declare module BABYLON {
  87148. /** @hidden */
  87149. export var kernelBlurVaryingDeclaration: {
  87150. name: string;
  87151. shader: string;
  87152. };
  87153. }
  87154. declare module BABYLON {
  87155. /** @hidden */
  87156. export var kernelBlurFragment: {
  87157. name: string;
  87158. shader: string;
  87159. };
  87160. }
  87161. declare module BABYLON {
  87162. /** @hidden */
  87163. export var kernelBlurFragment2: {
  87164. name: string;
  87165. shader: string;
  87166. };
  87167. }
  87168. declare module BABYLON {
  87169. /** @hidden */
  87170. export var kernelBlurPixelShader: {
  87171. name: string;
  87172. shader: string;
  87173. };
  87174. }
  87175. declare module BABYLON {
  87176. /** @hidden */
  87177. export var kernelBlurVertex: {
  87178. name: string;
  87179. shader: string;
  87180. };
  87181. }
  87182. declare module BABYLON {
  87183. /** @hidden */
  87184. export var kernelBlurVertexShader: {
  87185. name: string;
  87186. shader: string;
  87187. };
  87188. }
  87189. declare module BABYLON {
  87190. /**
  87191. * The Blur Post Process which blurs an image based on a kernel and direction.
  87192. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  87193. */
  87194. export class BlurPostProcess extends PostProcess {
  87195. /** The direction in which to blur the image. */
  87196. direction: Vector2;
  87197. private blockCompilation;
  87198. protected _kernel: number;
  87199. protected _idealKernel: number;
  87200. protected _packedFloat: boolean;
  87201. private _staticDefines;
  87202. /**
  87203. * Sets the length in pixels of the blur sample region
  87204. */
  87205. set kernel(v: number);
  87206. /**
  87207. * Gets the length in pixels of the blur sample region
  87208. */
  87209. get kernel(): number;
  87210. /**
  87211. * Sets wether or not the blur needs to unpack/repack floats
  87212. */
  87213. set packedFloat(v: boolean);
  87214. /**
  87215. * Gets wether or not the blur is unpacking/repacking floats
  87216. */
  87217. get packedFloat(): boolean;
  87218. /**
  87219. * Creates a new instance BlurPostProcess
  87220. * @param name The name of the effect.
  87221. * @param direction The direction in which to blur the image.
  87222. * @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.
  87223. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  87224. * @param camera The camera to apply the render pass to.
  87225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  87226. * @param engine The engine which the post process will be applied. (default: current engine)
  87227. * @param reusable If the post process can be reused on the same frame. (default: false)
  87228. * @param textureType Type of textures used when performing the post process. (default: 0)
  87229. * @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)
  87230. */
  87231. constructor(name: string,
  87232. /** The direction in which to blur the image. */
  87233. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  87234. /**
  87235. * Updates the effect with the current post process compile time values and recompiles the shader.
  87236. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  87237. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  87238. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  87239. * @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
  87240. * @param onCompiled Called when the shader has been compiled.
  87241. * @param onError Called if there is an error when compiling a shader.
  87242. */
  87243. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  87244. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  87245. /**
  87246. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  87247. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  87248. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  87249. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  87250. * The gaps between physical kernels are compensated for in the weighting of the samples
  87251. * @param idealKernel Ideal blur kernel.
  87252. * @return Nearest best kernel.
  87253. */
  87254. protected _nearestBestKernel(idealKernel: number): number;
  87255. /**
  87256. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  87257. * @param x The point on the Gaussian distribution to sample.
  87258. * @return the value of the Gaussian function at x.
  87259. */
  87260. protected _gaussianWeight(x: number): number;
  87261. /**
  87262. * Generates a string that can be used as a floating point number in GLSL.
  87263. * @param x Value to print.
  87264. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  87265. * @return GLSL float string.
  87266. */
  87267. protected _glslFloat(x: number, decimalFigures?: number): string;
  87268. }
  87269. }
  87270. declare module BABYLON {
  87271. /**
  87272. * Mirror texture can be used to simulate the view from a mirror in a scene.
  87273. * It will dynamically be rendered every frame to adapt to the camera point of view.
  87274. * You can then easily use it as a reflectionTexture on a flat surface.
  87275. * In case the surface is not a plane, please consider relying on reflection probes.
  87276. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  87277. */
  87278. export class MirrorTexture extends RenderTargetTexture {
  87279. private scene;
  87280. /**
  87281. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  87282. * 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.
  87283. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  87284. */
  87285. mirrorPlane: Plane;
  87286. /**
  87287. * Define the blur ratio used to blur the reflection if needed.
  87288. */
  87289. set blurRatio(value: number);
  87290. get blurRatio(): number;
  87291. /**
  87292. * Define the adaptive blur kernel used to blur the reflection if needed.
  87293. * This will autocompute the closest best match for the `blurKernel`
  87294. */
  87295. set adaptiveBlurKernel(value: number);
  87296. /**
  87297. * Define the blur kernel used to blur the reflection if needed.
  87298. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  87299. */
  87300. set blurKernel(value: number);
  87301. /**
  87302. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  87303. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  87304. */
  87305. set blurKernelX(value: number);
  87306. get blurKernelX(): number;
  87307. /**
  87308. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  87309. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  87310. */
  87311. set blurKernelY(value: number);
  87312. get blurKernelY(): number;
  87313. private _autoComputeBlurKernel;
  87314. protected _onRatioRescale(): void;
  87315. private _updateGammaSpace;
  87316. private _imageProcessingConfigChangeObserver;
  87317. private _transformMatrix;
  87318. private _mirrorMatrix;
  87319. private _savedViewMatrix;
  87320. private _blurX;
  87321. private _blurY;
  87322. private _adaptiveBlurKernel;
  87323. private _blurKernelX;
  87324. private _blurKernelY;
  87325. private _blurRatio;
  87326. /**
  87327. * Instantiates a Mirror Texture.
  87328. * Mirror texture can be used to simulate the view from a mirror in a scene.
  87329. * It will dynamically be rendered every frame to adapt to the camera point of view.
  87330. * You can then easily use it as a reflectionTexture on a flat surface.
  87331. * In case the surface is not a plane, please consider relying on reflection probes.
  87332. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  87333. * @param name
  87334. * @param size
  87335. * @param scene
  87336. * @param generateMipMaps
  87337. * @param type
  87338. * @param samplingMode
  87339. * @param generateDepthBuffer
  87340. */
  87341. constructor(name: string, size: number | {
  87342. width: number;
  87343. height: number;
  87344. } | {
  87345. ratio: number;
  87346. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  87347. private _preparePostProcesses;
  87348. /**
  87349. * Clone the mirror texture.
  87350. * @returns the cloned texture
  87351. */
  87352. clone(): MirrorTexture;
  87353. /**
  87354. * Serialize the texture to a JSON representation you could use in Parse later on
  87355. * @returns the serialized JSON representation
  87356. */
  87357. serialize(): any;
  87358. /**
  87359. * Dispose the texture and release its associated resources.
  87360. */
  87361. dispose(): void;
  87362. }
  87363. }
  87364. declare module BABYLON {
  87365. /**
  87366. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  87367. * @see http://doc.babylonjs.com/babylon101/materials#texture
  87368. */
  87369. export class Texture extends BaseTexture {
  87370. /**
  87371. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  87372. */
  87373. static SerializeBuffers: boolean;
  87374. /** @hidden */
  87375. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  87376. /** @hidden */
  87377. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  87378. /** @hidden */
  87379. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  87380. /** nearest is mag = nearest and min = nearest and mip = linear */
  87381. static readonly NEAREST_SAMPLINGMODE: number;
  87382. /** nearest is mag = nearest and min = nearest and mip = linear */
  87383. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  87384. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87385. static readonly BILINEAR_SAMPLINGMODE: number;
  87386. /** Bilinear is mag = linear and min = linear and mip = nearest */
  87387. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  87388. /** Trilinear is mag = linear and min = linear and mip = linear */
  87389. static readonly TRILINEAR_SAMPLINGMODE: number;
  87390. /** Trilinear is mag = linear and min = linear and mip = linear */
  87391. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  87392. /** mag = nearest and min = nearest and mip = nearest */
  87393. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  87394. /** mag = nearest and min = linear and mip = nearest */
  87395. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  87396. /** mag = nearest and min = linear and mip = linear */
  87397. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  87398. /** mag = nearest and min = linear and mip = none */
  87399. static readonly NEAREST_LINEAR: number;
  87400. /** mag = nearest and min = nearest and mip = none */
  87401. static readonly NEAREST_NEAREST: number;
  87402. /** mag = linear and min = nearest and mip = nearest */
  87403. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  87404. /** mag = linear and min = nearest and mip = linear */
  87405. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  87406. /** mag = linear and min = linear and mip = none */
  87407. static readonly LINEAR_LINEAR: number;
  87408. /** mag = linear and min = nearest and mip = none */
  87409. static readonly LINEAR_NEAREST: number;
  87410. /** Explicit coordinates mode */
  87411. static readonly EXPLICIT_MODE: number;
  87412. /** Spherical coordinates mode */
  87413. static readonly SPHERICAL_MODE: number;
  87414. /** Planar coordinates mode */
  87415. static readonly PLANAR_MODE: number;
  87416. /** Cubic coordinates mode */
  87417. static readonly CUBIC_MODE: number;
  87418. /** Projection coordinates mode */
  87419. static readonly PROJECTION_MODE: number;
  87420. /** Inverse Cubic coordinates mode */
  87421. static readonly SKYBOX_MODE: number;
  87422. /** Inverse Cubic coordinates mode */
  87423. static readonly INVCUBIC_MODE: number;
  87424. /** Equirectangular coordinates mode */
  87425. static readonly EQUIRECTANGULAR_MODE: number;
  87426. /** Equirectangular Fixed coordinates mode */
  87427. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  87428. /** Equirectangular Fixed Mirrored coordinates mode */
  87429. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  87430. /** Texture is not repeating outside of 0..1 UVs */
  87431. static readonly CLAMP_ADDRESSMODE: number;
  87432. /** Texture is repeating outside of 0..1 UVs */
  87433. static readonly WRAP_ADDRESSMODE: number;
  87434. /** Texture is repeating and mirrored */
  87435. static readonly MIRROR_ADDRESSMODE: number;
  87436. /**
  87437. * 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
  87438. */
  87439. static UseSerializedUrlIfAny: boolean;
  87440. /**
  87441. * Define the url of the texture.
  87442. */
  87443. url: Nullable<string>;
  87444. /**
  87445. * Define an offset on the texture to offset the u coordinates of the UVs
  87446. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  87447. */
  87448. uOffset: number;
  87449. /**
  87450. * Define an offset on the texture to offset the v coordinates of the UVs
  87451. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  87452. */
  87453. vOffset: number;
  87454. /**
  87455. * Define an offset on the texture to scale the u coordinates of the UVs
  87456. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  87457. */
  87458. uScale: number;
  87459. /**
  87460. * Define an offset on the texture to scale the v coordinates of the UVs
  87461. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  87462. */
  87463. vScale: number;
  87464. /**
  87465. * Define an offset on the texture to rotate around the u coordinates of the UVs
  87466. * @see http://doc.babylonjs.com/how_to/more_materials
  87467. */
  87468. uAng: number;
  87469. /**
  87470. * Define an offset on the texture to rotate around the v coordinates of the UVs
  87471. * @see http://doc.babylonjs.com/how_to/more_materials
  87472. */
  87473. vAng: number;
  87474. /**
  87475. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  87476. * @see http://doc.babylonjs.com/how_to/more_materials
  87477. */
  87478. wAng: number;
  87479. /**
  87480. * Defines the center of rotation (U)
  87481. */
  87482. uRotationCenter: number;
  87483. /**
  87484. * Defines the center of rotation (V)
  87485. */
  87486. vRotationCenter: number;
  87487. /**
  87488. * Defines the center of rotation (W)
  87489. */
  87490. wRotationCenter: number;
  87491. /**
  87492. * Are mip maps generated for this texture or not.
  87493. */
  87494. get noMipmap(): boolean;
  87495. /**
  87496. * List of inspectable custom properties (used by the Inspector)
  87497. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87498. */
  87499. inspectableCustomProperties: Nullable<IInspectable[]>;
  87500. private _noMipmap;
  87501. /** @hidden */
  87502. _invertY: boolean;
  87503. private _rowGenerationMatrix;
  87504. private _cachedTextureMatrix;
  87505. private _projectionModeMatrix;
  87506. private _t0;
  87507. private _t1;
  87508. private _t2;
  87509. private _cachedUOffset;
  87510. private _cachedVOffset;
  87511. private _cachedUScale;
  87512. private _cachedVScale;
  87513. private _cachedUAng;
  87514. private _cachedVAng;
  87515. private _cachedWAng;
  87516. private _cachedProjectionMatrixId;
  87517. private _cachedCoordinatesMode;
  87518. /** @hidden */
  87519. protected _initialSamplingMode: number;
  87520. /** @hidden */
  87521. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  87522. private _deleteBuffer;
  87523. protected _format: Nullable<number>;
  87524. private _delayedOnLoad;
  87525. private _delayedOnError;
  87526. private _mimeType?;
  87527. /**
  87528. * Observable triggered once the texture has been loaded.
  87529. */
  87530. onLoadObservable: Observable<Texture>;
  87531. protected _isBlocking: boolean;
  87532. /**
  87533. * Is the texture preventing material to render while loading.
  87534. * If false, a default texture will be used instead of the loading one during the preparation step.
  87535. */
  87536. set isBlocking(value: boolean);
  87537. get isBlocking(): boolean;
  87538. /**
  87539. * Get the current sampling mode associated with the texture.
  87540. */
  87541. get samplingMode(): number;
  87542. /**
  87543. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  87544. */
  87545. get invertY(): boolean;
  87546. /**
  87547. * Instantiates a new texture.
  87548. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  87549. * @see http://doc.babylonjs.com/babylon101/materials#texture
  87550. * @param url defines the url of the picture to load as a texture
  87551. * @param scene defines the scene or engine the texture will belong to
  87552. * @param noMipmap defines if the texture will require mip maps or not
  87553. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  87554. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  87555. * @param onLoad defines a callback triggered when the texture has been loaded
  87556. * @param onError defines a callback triggered when an error occurred during the loading session
  87557. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  87558. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  87559. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  87560. * @param mimeType defines an optional mime type information
  87561. */
  87562. 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);
  87563. /**
  87564. * Update the url (and optional buffer) of this texture if url was null during construction.
  87565. * @param url the url of the texture
  87566. * @param buffer the buffer of the texture (defaults to null)
  87567. * @param onLoad callback called when the texture is loaded (defaults to null)
  87568. */
  87569. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  87570. /**
  87571. * Finish the loading sequence of a texture flagged as delayed load.
  87572. * @hidden
  87573. */
  87574. delayLoad(): void;
  87575. private _prepareRowForTextureGeneration;
  87576. /**
  87577. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  87578. * @returns the transform matrix of the texture.
  87579. */
  87580. getTextureMatrix(uBase?: number): Matrix;
  87581. /**
  87582. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  87583. * @returns The reflection texture transform
  87584. */
  87585. getReflectionTextureMatrix(): Matrix;
  87586. /**
  87587. * Clones the texture.
  87588. * @returns the cloned texture
  87589. */
  87590. clone(): Texture;
  87591. /**
  87592. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  87593. * @returns The JSON representation of the texture
  87594. */
  87595. serialize(): any;
  87596. /**
  87597. * Get the current class name of the texture useful for serialization or dynamic coding.
  87598. * @returns "Texture"
  87599. */
  87600. getClassName(): string;
  87601. /**
  87602. * Dispose the texture and release its associated resources.
  87603. */
  87604. dispose(): void;
  87605. /**
  87606. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  87607. * @param parsedTexture Define the JSON representation of the texture
  87608. * @param scene Define the scene the parsed texture should be instantiated in
  87609. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  87610. * @returns The parsed texture if successful
  87611. */
  87612. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  87613. /**
  87614. * Creates a texture from its base 64 representation.
  87615. * @param data Define the base64 payload without the data: prefix
  87616. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  87617. * @param scene Define the scene the texture should belong to
  87618. * @param noMipmap Forces the texture to not create mip map information if true
  87619. * @param invertY define if the texture needs to be inverted on the y axis during loading
  87620. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  87621. * @param onLoad define a callback triggered when the texture has been loaded
  87622. * @param onError define a callback triggered when an error occurred during the loading session
  87623. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  87624. * @returns the created texture
  87625. */
  87626. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  87627. /**
  87628. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  87629. * @param data Define the base64 payload without the data: prefix
  87630. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  87631. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  87632. * @param scene Define the scene the texture should belong to
  87633. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  87634. * @param noMipmap Forces the texture to not create mip map information if true
  87635. * @param invertY define if the texture needs to be inverted on the y axis during loading
  87636. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  87637. * @param onLoad define a callback triggered when the texture has been loaded
  87638. * @param onError define a callback triggered when an error occurred during the loading session
  87639. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  87640. * @returns the created texture
  87641. */
  87642. 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;
  87643. }
  87644. }
  87645. declare module BABYLON {
  87646. /**
  87647. * PostProcessManager is used to manage one or more post processes or post process pipelines
  87648. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  87649. */
  87650. export class PostProcessManager {
  87651. private _scene;
  87652. private _indexBuffer;
  87653. private _vertexBuffers;
  87654. /**
  87655. * Creates a new instance PostProcess
  87656. * @param scene The scene that the post process is associated with.
  87657. */
  87658. constructor(scene: Scene);
  87659. private _prepareBuffers;
  87660. private _buildIndexBuffer;
  87661. /**
  87662. * Rebuilds the vertex buffers of the manager.
  87663. * @hidden
  87664. */
  87665. _rebuild(): void;
  87666. /**
  87667. * Prepares a frame to be run through a post process.
  87668. * @param sourceTexture The input texture to the post procesess. (default: null)
  87669. * @param postProcesses An array of post processes to be run. (default: null)
  87670. * @returns True if the post processes were able to be run.
  87671. * @hidden
  87672. */
  87673. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  87674. /**
  87675. * Manually render a set of post processes to a texture.
  87676. * @param postProcesses An array of post processes to be run.
  87677. * @param targetTexture The target texture to render to.
  87678. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  87679. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  87680. * @param lodLevel defines which lod of the texture to render to
  87681. */
  87682. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  87683. /**
  87684. * Finalize the result of the output of the postprocesses.
  87685. * @param doNotPresent If true the result will not be displayed to the screen.
  87686. * @param targetTexture The target texture to render to.
  87687. * @param faceIndex The index of the face to bind the target texture to.
  87688. * @param postProcesses The array of post processes to render.
  87689. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  87690. * @hidden
  87691. */
  87692. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  87693. /**
  87694. * Disposes of the post process manager.
  87695. */
  87696. dispose(): void;
  87697. }
  87698. }
  87699. declare module BABYLON {
  87700. /** Interface used by value gradients (color, factor, ...) */
  87701. export interface IValueGradient {
  87702. /**
  87703. * Gets or sets the gradient value (between 0 and 1)
  87704. */
  87705. gradient: number;
  87706. }
  87707. /** Class used to store color4 gradient */
  87708. export class ColorGradient implements IValueGradient {
  87709. /**
  87710. * Gets or sets the gradient value (between 0 and 1)
  87711. */
  87712. gradient: number;
  87713. /**
  87714. * Gets or sets first associated color
  87715. */
  87716. color1: Color4;
  87717. /**
  87718. * Gets or sets second associated color
  87719. */
  87720. color2?: Color4;
  87721. /**
  87722. * Will get a color picked randomly between color1 and color2.
  87723. * If color2 is undefined then color1 will be used
  87724. * @param result defines the target Color4 to store the result in
  87725. */
  87726. getColorToRef(result: Color4): void;
  87727. }
  87728. /** Class used to store color 3 gradient */
  87729. export class Color3Gradient implements IValueGradient {
  87730. /**
  87731. * Gets or sets the gradient value (between 0 and 1)
  87732. */
  87733. gradient: number;
  87734. /**
  87735. * Gets or sets the associated color
  87736. */
  87737. color: Color3;
  87738. }
  87739. /** Class used to store factor gradient */
  87740. export class FactorGradient implements IValueGradient {
  87741. /**
  87742. * Gets or sets the gradient value (between 0 and 1)
  87743. */
  87744. gradient: number;
  87745. /**
  87746. * Gets or sets first associated factor
  87747. */
  87748. factor1: number;
  87749. /**
  87750. * Gets or sets second associated factor
  87751. */
  87752. factor2?: number;
  87753. /**
  87754. * Will get a number picked randomly between factor1 and factor2.
  87755. * If factor2 is undefined then factor1 will be used
  87756. * @returns the picked number
  87757. */
  87758. getFactor(): number;
  87759. }
  87760. /**
  87761. * Helper used to simplify some generic gradient tasks
  87762. */
  87763. export class GradientHelper {
  87764. /**
  87765. * Gets the current gradient from an array of IValueGradient
  87766. * @param ratio defines the current ratio to get
  87767. * @param gradients defines the array of IValueGradient
  87768. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  87769. */
  87770. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  87771. }
  87772. }
  87773. declare module BABYLON {
  87774. interface ThinEngine {
  87775. /**
  87776. * Creates a dynamic texture
  87777. * @param width defines the width of the texture
  87778. * @param height defines the height of the texture
  87779. * @param generateMipMaps defines if the engine should generate the mip levels
  87780. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87781. * @returns the dynamic texture inside an InternalTexture
  87782. */
  87783. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87784. /**
  87785. * Update the content of a dynamic texture
  87786. * @param texture defines the texture to update
  87787. * @param canvas defines the canvas containing the source
  87788. * @param invertY defines if data must be stored with Y axis inverted
  87789. * @param premulAlpha defines if alpha is stored as premultiplied
  87790. * @param format defines the format of the data
  87791. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87792. */
  87793. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87794. }
  87795. }
  87796. declare module BABYLON {
  87797. /**
  87798. * Helper class used to generate a canvas to manipulate images
  87799. */
  87800. export class CanvasGenerator {
  87801. /**
  87802. * Create a new canvas (or offscreen canvas depending on the context)
  87803. * @param width defines the expected width
  87804. * @param height defines the expected height
  87805. * @return a new canvas or offscreen canvas
  87806. */
  87807. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  87808. }
  87809. }
  87810. declare module BABYLON {
  87811. /**
  87812. * A class extending Texture allowing drawing on a texture
  87813. * @see http://doc.babylonjs.com/how_to/dynamictexture
  87814. */
  87815. export class DynamicTexture extends Texture {
  87816. private _generateMipMaps;
  87817. private _canvas;
  87818. private _context;
  87819. private _engine;
  87820. /**
  87821. * Creates a DynamicTexture
  87822. * @param name defines the name of the texture
  87823. * @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
  87824. * @param scene defines the scene where you want the texture
  87825. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  87826. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  87827. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  87828. */
  87829. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  87830. /**
  87831. * Get the current class name of the texture useful for serialization or dynamic coding.
  87832. * @returns "DynamicTexture"
  87833. */
  87834. getClassName(): string;
  87835. /**
  87836. * Gets the current state of canRescale
  87837. */
  87838. get canRescale(): boolean;
  87839. private _recreate;
  87840. /**
  87841. * Scales the texture
  87842. * @param ratio the scale factor to apply to both width and height
  87843. */
  87844. scale(ratio: number): void;
  87845. /**
  87846. * Resizes the texture
  87847. * @param width the new width
  87848. * @param height the new height
  87849. */
  87850. scaleTo(width: number, height: number): void;
  87851. /**
  87852. * Gets the context of the canvas used by the texture
  87853. * @returns the canvas context of the dynamic texture
  87854. */
  87855. getContext(): CanvasRenderingContext2D;
  87856. /**
  87857. * Clears the texture
  87858. */
  87859. clear(): void;
  87860. /**
  87861. * Updates the texture
  87862. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87863. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  87864. */
  87865. update(invertY?: boolean, premulAlpha?: boolean): void;
  87866. /**
  87867. * Draws text onto the texture
  87868. * @param text defines the text to be drawn
  87869. * @param x defines the placement of the text from the left
  87870. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  87871. * @param font defines the font to be used with font-style, font-size, font-name
  87872. * @param color defines the color used for the text
  87873. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  87874. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  87875. * @param update defines whether texture is immediately update (default is true)
  87876. */
  87877. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  87878. /**
  87879. * Clones the texture
  87880. * @returns the clone of the texture.
  87881. */
  87882. clone(): DynamicTexture;
  87883. /**
  87884. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  87885. * @returns a serialized dynamic texture object
  87886. */
  87887. serialize(): any;
  87888. /** @hidden */
  87889. _rebuild(): void;
  87890. }
  87891. }
  87892. declare module BABYLON {
  87893. interface AbstractScene {
  87894. /**
  87895. * The list of procedural textures added to the scene
  87896. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87897. */
  87898. proceduralTextures: Array<ProceduralTexture>;
  87899. }
  87900. /**
  87901. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  87902. * in a given scene.
  87903. */
  87904. export class ProceduralTextureSceneComponent implements ISceneComponent {
  87905. /**
  87906. * The component name helpfull to identify the component in the list of scene components.
  87907. */
  87908. readonly name: string;
  87909. /**
  87910. * The scene the component belongs to.
  87911. */
  87912. scene: Scene;
  87913. /**
  87914. * Creates a new instance of the component for the given scene
  87915. * @param scene Defines the scene to register the component in
  87916. */
  87917. constructor(scene: Scene);
  87918. /**
  87919. * Registers the component in a given scene
  87920. */
  87921. register(): void;
  87922. /**
  87923. * Rebuilds the elements related to this component in case of
  87924. * context lost for instance.
  87925. */
  87926. rebuild(): void;
  87927. /**
  87928. * Disposes the component and the associated ressources.
  87929. */
  87930. dispose(): void;
  87931. private _beforeClear;
  87932. }
  87933. }
  87934. declare module BABYLON {
  87935. interface ThinEngine {
  87936. /**
  87937. * Creates a new render target cube texture
  87938. * @param size defines the size of the texture
  87939. * @param options defines the options used to create the texture
  87940. * @returns a new render target cube texture stored in an InternalTexture
  87941. */
  87942. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87943. }
  87944. }
  87945. declare module BABYLON {
  87946. /** @hidden */
  87947. export var proceduralVertexShader: {
  87948. name: string;
  87949. shader: string;
  87950. };
  87951. }
  87952. declare module BABYLON {
  87953. /**
  87954. * 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.
  87955. * This is the base class of any Procedural texture and contains most of the shareable code.
  87956. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  87957. */
  87958. export class ProceduralTexture extends Texture {
  87959. isCube: boolean;
  87960. /**
  87961. * Define if the texture is enabled or not (disabled texture will not render)
  87962. */
  87963. isEnabled: boolean;
  87964. /**
  87965. * Define if the texture must be cleared before rendering (default is true)
  87966. */
  87967. autoClear: boolean;
  87968. /**
  87969. * Callback called when the texture is generated
  87970. */
  87971. onGenerated: () => void;
  87972. /**
  87973. * Event raised when the texture is generated
  87974. */
  87975. onGeneratedObservable: Observable<ProceduralTexture>;
  87976. /** @hidden */
  87977. _generateMipMaps: boolean;
  87978. /** @hidden **/
  87979. _effect: Effect;
  87980. /** @hidden */
  87981. _textures: {
  87982. [key: string]: Texture;
  87983. };
  87984. private _size;
  87985. private _currentRefreshId;
  87986. private _frameId;
  87987. private _refreshRate;
  87988. private _vertexBuffers;
  87989. private _indexBuffer;
  87990. private _uniforms;
  87991. private _samplers;
  87992. private _fragment;
  87993. private _floats;
  87994. private _ints;
  87995. private _floatsArrays;
  87996. private _colors3;
  87997. private _colors4;
  87998. private _vectors2;
  87999. private _vectors3;
  88000. private _matrices;
  88001. private _fallbackTexture;
  88002. private _fallbackTextureUsed;
  88003. private _engine;
  88004. private _cachedDefines;
  88005. private _contentUpdateId;
  88006. private _contentData;
  88007. /**
  88008. * Instantiates a new procedural texture.
  88009. * 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.
  88010. * This is the base class of any Procedural texture and contains most of the shareable code.
  88011. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  88012. * @param name Define the name of the texture
  88013. * @param size Define the size of the texture to create
  88014. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  88015. * @param scene Define the scene the texture belongs to
  88016. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  88017. * @param generateMipMaps Define if the texture should creates mip maps or not
  88018. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  88019. */
  88020. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  88021. /**
  88022. * The effect that is created when initializing the post process.
  88023. * @returns The created effect corresponding the the postprocess.
  88024. */
  88025. getEffect(): Effect;
  88026. /**
  88027. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  88028. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  88029. */
  88030. getContent(): Nullable<ArrayBufferView>;
  88031. private _createIndexBuffer;
  88032. /** @hidden */
  88033. _rebuild(): void;
  88034. /**
  88035. * Resets the texture in order to recreate its associated resources.
  88036. * This can be called in case of context loss
  88037. */
  88038. reset(): void;
  88039. protected _getDefines(): string;
  88040. /**
  88041. * Is the texture ready to be used ? (rendered at least once)
  88042. * @returns true if ready, otherwise, false.
  88043. */
  88044. isReady(): boolean;
  88045. /**
  88046. * Resets the refresh counter of the texture and start bak from scratch.
  88047. * Could be useful to regenerate the texture if it is setup to render only once.
  88048. */
  88049. resetRefreshCounter(): void;
  88050. /**
  88051. * Set the fragment shader to use in order to render the texture.
  88052. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  88053. */
  88054. setFragment(fragment: any): void;
  88055. /**
  88056. * Define the refresh rate of the texture or the rendering frequency.
  88057. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  88058. */
  88059. get refreshRate(): number;
  88060. set refreshRate(value: number);
  88061. /** @hidden */
  88062. _shouldRender(): boolean;
  88063. /**
  88064. * Get the size the texture is rendering at.
  88065. * @returns the size (texture is always squared)
  88066. */
  88067. getRenderSize(): number;
  88068. /**
  88069. * Resize the texture to new value.
  88070. * @param size Define the new size the texture should have
  88071. * @param generateMipMaps Define whether the new texture should create mip maps
  88072. */
  88073. resize(size: number, generateMipMaps: boolean): void;
  88074. private _checkUniform;
  88075. /**
  88076. * Set a texture in the shader program used to render.
  88077. * @param name Define the name of the uniform samplers as defined in the shader
  88078. * @param texture Define the texture to bind to this sampler
  88079. * @return the texture itself allowing "fluent" like uniform updates
  88080. */
  88081. setTexture(name: string, texture: Texture): ProceduralTexture;
  88082. /**
  88083. * Set a float in the shader.
  88084. * @param name Define the name of the uniform as defined in the shader
  88085. * @param value Define the value to give to the uniform
  88086. * @return the texture itself allowing "fluent" like uniform updates
  88087. */
  88088. setFloat(name: string, value: number): ProceduralTexture;
  88089. /**
  88090. * Set a int in the shader.
  88091. * @param name Define the name of the uniform as defined in the shader
  88092. * @param value Define the value to give to the uniform
  88093. * @return the texture itself allowing "fluent" like uniform updates
  88094. */
  88095. setInt(name: string, value: number): ProceduralTexture;
  88096. /**
  88097. * Set an array of floats in the shader.
  88098. * @param name Define the name of the uniform as defined in the shader
  88099. * @param value Define the value to give to the uniform
  88100. * @return the texture itself allowing "fluent" like uniform updates
  88101. */
  88102. setFloats(name: string, value: number[]): ProceduralTexture;
  88103. /**
  88104. * Set a vec3 in the shader from a Color3.
  88105. * @param name Define the name of the uniform as defined in the shader
  88106. * @param value Define the value to give to the uniform
  88107. * @return the texture itself allowing "fluent" like uniform updates
  88108. */
  88109. setColor3(name: string, value: Color3): ProceduralTexture;
  88110. /**
  88111. * Set a vec4 in the shader from a Color4.
  88112. * @param name Define the name of the uniform as defined in the shader
  88113. * @param value Define the value to give to the uniform
  88114. * @return the texture itself allowing "fluent" like uniform updates
  88115. */
  88116. setColor4(name: string, value: Color4): ProceduralTexture;
  88117. /**
  88118. * Set a vec2 in the shader from a Vector2.
  88119. * @param name Define the name of the uniform as defined in the shader
  88120. * @param value Define the value to give to the uniform
  88121. * @return the texture itself allowing "fluent" like uniform updates
  88122. */
  88123. setVector2(name: string, value: Vector2): ProceduralTexture;
  88124. /**
  88125. * Set a vec3 in the shader from a Vector3.
  88126. * @param name Define the name of the uniform as defined in the shader
  88127. * @param value Define the value to give to the uniform
  88128. * @return the texture itself allowing "fluent" like uniform updates
  88129. */
  88130. setVector3(name: string, value: Vector3): ProceduralTexture;
  88131. /**
  88132. * Set a mat4 in the shader from a MAtrix.
  88133. * @param name Define the name of the uniform as defined in the shader
  88134. * @param value Define the value to give to the uniform
  88135. * @return the texture itself allowing "fluent" like uniform updates
  88136. */
  88137. setMatrix(name: string, value: Matrix): ProceduralTexture;
  88138. /**
  88139. * Render the texture to its associated render target.
  88140. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  88141. */
  88142. render(useCameraPostProcess?: boolean): void;
  88143. /**
  88144. * Clone the texture.
  88145. * @returns the cloned texture
  88146. */
  88147. clone(): ProceduralTexture;
  88148. /**
  88149. * Dispose the texture and release its asoociated resources.
  88150. */
  88151. dispose(): void;
  88152. }
  88153. }
  88154. declare module BABYLON {
  88155. /**
  88156. * This represents the base class for particle system in Babylon.
  88157. * 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.
  88158. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  88159. * @example https://doc.babylonjs.com/babylon101/particles
  88160. */
  88161. export class BaseParticleSystem {
  88162. /**
  88163. * Source color is added to the destination color without alpha affecting the result
  88164. */
  88165. static BLENDMODE_ONEONE: number;
  88166. /**
  88167. * Blend current color and particle color using particle’s alpha
  88168. */
  88169. static BLENDMODE_STANDARD: number;
  88170. /**
  88171. * Add current color and particle color multiplied by particle’s alpha
  88172. */
  88173. static BLENDMODE_ADD: number;
  88174. /**
  88175. * Multiply current color with particle color
  88176. */
  88177. static BLENDMODE_MULTIPLY: number;
  88178. /**
  88179. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  88180. */
  88181. static BLENDMODE_MULTIPLYADD: number;
  88182. /**
  88183. * List of animations used by the particle system.
  88184. */
  88185. animations: Animation[];
  88186. /**
  88187. * The id of the Particle system.
  88188. */
  88189. id: string;
  88190. /**
  88191. * The friendly name of the Particle system.
  88192. */
  88193. name: string;
  88194. /**
  88195. * The rendering group used by the Particle system to chose when to render.
  88196. */
  88197. renderingGroupId: number;
  88198. /**
  88199. * The emitter represents the Mesh or position we are attaching the particle system to.
  88200. */
  88201. emitter: Nullable<AbstractMesh | Vector3>;
  88202. /**
  88203. * The maximum number of particles to emit per frame
  88204. */
  88205. emitRate: number;
  88206. /**
  88207. * If you want to launch only a few particles at once, that can be done, as well.
  88208. */
  88209. manualEmitCount: number;
  88210. /**
  88211. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  88212. */
  88213. updateSpeed: number;
  88214. /**
  88215. * The amount of time the particle system is running (depends of the overall update speed).
  88216. */
  88217. targetStopDuration: number;
  88218. /**
  88219. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  88220. */
  88221. disposeOnStop: boolean;
  88222. /**
  88223. * Minimum power of emitting particles.
  88224. */
  88225. minEmitPower: number;
  88226. /**
  88227. * Maximum power of emitting particles.
  88228. */
  88229. maxEmitPower: number;
  88230. /**
  88231. * Minimum life time of emitting particles.
  88232. */
  88233. minLifeTime: number;
  88234. /**
  88235. * Maximum life time of emitting particles.
  88236. */
  88237. maxLifeTime: number;
  88238. /**
  88239. * Minimum Size of emitting particles.
  88240. */
  88241. minSize: number;
  88242. /**
  88243. * Maximum Size of emitting particles.
  88244. */
  88245. maxSize: number;
  88246. /**
  88247. * Minimum scale of emitting particles on X axis.
  88248. */
  88249. minScaleX: number;
  88250. /**
  88251. * Maximum scale of emitting particles on X axis.
  88252. */
  88253. maxScaleX: number;
  88254. /**
  88255. * Minimum scale of emitting particles on Y axis.
  88256. */
  88257. minScaleY: number;
  88258. /**
  88259. * Maximum scale of emitting particles on Y axis.
  88260. */
  88261. maxScaleY: number;
  88262. /**
  88263. * Gets or sets the minimal initial rotation in radians.
  88264. */
  88265. minInitialRotation: number;
  88266. /**
  88267. * Gets or sets the maximal initial rotation in radians.
  88268. */
  88269. maxInitialRotation: number;
  88270. /**
  88271. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  88272. */
  88273. minAngularSpeed: number;
  88274. /**
  88275. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  88276. */
  88277. maxAngularSpeed: number;
  88278. /**
  88279. * The texture used to render each particle. (this can be a spritesheet)
  88280. */
  88281. particleTexture: Nullable<Texture>;
  88282. /**
  88283. * The layer mask we are rendering the particles through.
  88284. */
  88285. layerMask: number;
  88286. /**
  88287. * This can help using your own shader to render the particle system.
  88288. * The according effect will be created
  88289. */
  88290. customShader: any;
  88291. /**
  88292. * By default particle system starts as soon as they are created. This prevents the
  88293. * automatic start to happen and let you decide when to start emitting particles.
  88294. */
  88295. preventAutoStart: boolean;
  88296. private _noiseTexture;
  88297. /**
  88298. * Gets or sets a texture used to add random noise to particle positions
  88299. */
  88300. get noiseTexture(): Nullable<ProceduralTexture>;
  88301. set noiseTexture(value: Nullable<ProceduralTexture>);
  88302. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  88303. noiseStrength: Vector3;
  88304. /**
  88305. * Callback triggered when the particle animation is ending.
  88306. */
  88307. onAnimationEnd: Nullable<() => void>;
  88308. /**
  88309. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  88310. */
  88311. blendMode: number;
  88312. /**
  88313. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  88314. * to override the particles.
  88315. */
  88316. forceDepthWrite: boolean;
  88317. /** 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 */
  88318. preWarmCycles: number;
  88319. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  88320. preWarmStepOffset: number;
  88321. /**
  88322. * 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)
  88323. */
  88324. spriteCellChangeSpeed: number;
  88325. /**
  88326. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  88327. */
  88328. startSpriteCellID: number;
  88329. /**
  88330. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  88331. */
  88332. endSpriteCellID: number;
  88333. /**
  88334. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  88335. */
  88336. spriteCellWidth: number;
  88337. /**
  88338. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  88339. */
  88340. spriteCellHeight: number;
  88341. /**
  88342. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  88343. */
  88344. spriteRandomStartCell: boolean;
  88345. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  88346. translationPivot: Vector2;
  88347. /** @hidden */
  88348. protected _isAnimationSheetEnabled: boolean;
  88349. /**
  88350. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  88351. */
  88352. beginAnimationOnStart: boolean;
  88353. /**
  88354. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  88355. */
  88356. beginAnimationFrom: number;
  88357. /**
  88358. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  88359. */
  88360. beginAnimationTo: number;
  88361. /**
  88362. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  88363. */
  88364. beginAnimationLoop: boolean;
  88365. /**
  88366. * Gets or sets a world offset applied to all particles
  88367. */
  88368. worldOffset: Vector3;
  88369. /**
  88370. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  88371. */
  88372. get isAnimationSheetEnabled(): boolean;
  88373. set isAnimationSheetEnabled(value: boolean);
  88374. /**
  88375. * Get hosting scene
  88376. * @returns the scene
  88377. */
  88378. getScene(): Scene;
  88379. /**
  88380. * You can use gravity if you want to give an orientation to your particles.
  88381. */
  88382. gravity: Vector3;
  88383. protected _colorGradients: Nullable<Array<ColorGradient>>;
  88384. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  88385. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  88386. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  88387. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  88388. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  88389. protected _dragGradients: Nullable<Array<FactorGradient>>;
  88390. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  88391. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  88392. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  88393. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  88394. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  88395. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  88396. /**
  88397. * Defines the delay in milliseconds before starting the system (0 by default)
  88398. */
  88399. startDelay: number;
  88400. /**
  88401. * Gets the current list of drag gradients.
  88402. * You must use addDragGradient and removeDragGradient to udpate this list
  88403. * @returns the list of drag gradients
  88404. */
  88405. getDragGradients(): Nullable<Array<FactorGradient>>;
  88406. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  88407. limitVelocityDamping: number;
  88408. /**
  88409. * Gets the current list of limit velocity gradients.
  88410. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  88411. * @returns the list of limit velocity gradients
  88412. */
  88413. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  88414. /**
  88415. * Gets the current list of color gradients.
  88416. * You must use addColorGradient and removeColorGradient to udpate this list
  88417. * @returns the list of color gradients
  88418. */
  88419. getColorGradients(): Nullable<Array<ColorGradient>>;
  88420. /**
  88421. * Gets the current list of size gradients.
  88422. * You must use addSizeGradient and removeSizeGradient to udpate this list
  88423. * @returns the list of size gradients
  88424. */
  88425. getSizeGradients(): Nullable<Array<FactorGradient>>;
  88426. /**
  88427. * Gets the current list of color remap gradients.
  88428. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  88429. * @returns the list of color remap gradients
  88430. */
  88431. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  88432. /**
  88433. * Gets the current list of alpha remap gradients.
  88434. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  88435. * @returns the list of alpha remap gradients
  88436. */
  88437. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  88438. /**
  88439. * Gets the current list of life time gradients.
  88440. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  88441. * @returns the list of life time gradients
  88442. */
  88443. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  88444. /**
  88445. * Gets the current list of angular speed gradients.
  88446. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  88447. * @returns the list of angular speed gradients
  88448. */
  88449. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  88450. /**
  88451. * Gets the current list of velocity gradients.
  88452. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  88453. * @returns the list of velocity gradients
  88454. */
  88455. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  88456. /**
  88457. * Gets the current list of start size gradients.
  88458. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  88459. * @returns the list of start size gradients
  88460. */
  88461. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  88462. /**
  88463. * Gets the current list of emit rate gradients.
  88464. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  88465. * @returns the list of emit rate gradients
  88466. */
  88467. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  88468. /**
  88469. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88470. * This only works when particleEmitterTyps is a BoxParticleEmitter
  88471. */
  88472. get direction1(): Vector3;
  88473. set direction1(value: Vector3);
  88474. /**
  88475. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  88476. * This only works when particleEmitterTyps is a BoxParticleEmitter
  88477. */
  88478. get direction2(): Vector3;
  88479. set direction2(value: Vector3);
  88480. /**
  88481. * 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.
  88482. * This only works when particleEmitterTyps is a BoxParticleEmitter
  88483. */
  88484. get minEmitBox(): Vector3;
  88485. set minEmitBox(value: Vector3);
  88486. /**
  88487. * 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.
  88488. * This only works when particleEmitterTyps is a BoxParticleEmitter
  88489. */
  88490. get maxEmitBox(): Vector3;
  88491. set maxEmitBox(value: Vector3);
  88492. /**
  88493. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  88494. */
  88495. color1: Color4;
  88496. /**
  88497. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  88498. */
  88499. color2: Color4;
  88500. /**
  88501. * Color the particle will have at the end of its lifetime
  88502. */
  88503. colorDead: Color4;
  88504. /**
  88505. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  88506. */
  88507. textureMask: Color4;
  88508. /**
  88509. * The particle emitter type defines the emitter used by the particle system.
  88510. * It can be for example box, sphere, or cone...
  88511. */
  88512. particleEmitterType: IParticleEmitterType;
  88513. /** @hidden */
  88514. _isSubEmitter: boolean;
  88515. /**
  88516. * Gets or sets the billboard mode to use when isBillboardBased = true.
  88517. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  88518. */
  88519. billboardMode: number;
  88520. protected _isBillboardBased: boolean;
  88521. /**
  88522. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  88523. */
  88524. get isBillboardBased(): boolean;
  88525. set isBillboardBased(value: boolean);
  88526. /**
  88527. * The scene the particle system belongs to.
  88528. */
  88529. protected _scene: Scene;
  88530. /**
  88531. * Local cache of defines for image processing.
  88532. */
  88533. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  88534. /**
  88535. * Default configuration related to image processing available in the standard Material.
  88536. */
  88537. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  88538. /**
  88539. * Gets the image processing configuration used either in this material.
  88540. */
  88541. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  88542. /**
  88543. * Sets the Default image processing configuration used either in the this material.
  88544. *
  88545. * If sets to null, the scene one is in use.
  88546. */
  88547. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  88548. /**
  88549. * Attaches a new image processing configuration to the Standard Material.
  88550. * @param configuration
  88551. */
  88552. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  88553. /** @hidden */
  88554. protected _reset(): void;
  88555. /** @hidden */
  88556. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  88557. /**
  88558. * Instantiates a particle system.
  88559. * 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.
  88560. * @param name The name of the particle system
  88561. */
  88562. constructor(name: string);
  88563. /**
  88564. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  88565. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88566. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88567. * @returns the emitter
  88568. */
  88569. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  88570. /**
  88571. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  88572. * @param radius The radius of the hemisphere to emit from
  88573. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88574. * @returns the emitter
  88575. */
  88576. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  88577. /**
  88578. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  88579. * @param radius The radius of the sphere to emit from
  88580. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  88581. * @returns the emitter
  88582. */
  88583. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  88584. /**
  88585. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  88586. * @param radius The radius of the sphere to emit from
  88587. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  88588. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  88589. * @returns the emitter
  88590. */
  88591. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  88592. /**
  88593. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  88594. * @param radius The radius of the emission cylinder
  88595. * @param height The height of the emission cylinder
  88596. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  88597. * @param directionRandomizer How much to randomize the particle direction [0-1]
  88598. * @returns the emitter
  88599. */
  88600. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  88601. /**
  88602. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  88603. * @param radius The radius of the cylinder to emit from
  88604. * @param height The height of the emission cylinder
  88605. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  88606. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  88607. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  88608. * @returns the emitter
  88609. */
  88610. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  88611. /**
  88612. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  88613. * @param radius The radius of the cone to emit from
  88614. * @param angle The base angle of the cone
  88615. * @returns the emitter
  88616. */
  88617. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  88618. /**
  88619. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  88620. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  88621. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  88622. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88623. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  88624. * @returns the emitter
  88625. */
  88626. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  88627. }
  88628. }
  88629. declare module BABYLON {
  88630. /**
  88631. * Type of sub emitter
  88632. */
  88633. export enum SubEmitterType {
  88634. /**
  88635. * Attached to the particle over it's lifetime
  88636. */
  88637. ATTACHED = 0,
  88638. /**
  88639. * Created when the particle dies
  88640. */
  88641. END = 1
  88642. }
  88643. /**
  88644. * Sub emitter class used to emit particles from an existing particle
  88645. */
  88646. export class SubEmitter {
  88647. /**
  88648. * the particle system to be used by the sub emitter
  88649. */
  88650. particleSystem: ParticleSystem;
  88651. /**
  88652. * Type of the submitter (Default: END)
  88653. */
  88654. type: SubEmitterType;
  88655. /**
  88656. * 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)
  88657. * Note: This only is supported when using an emitter of type Mesh
  88658. */
  88659. inheritDirection: boolean;
  88660. /**
  88661. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  88662. */
  88663. inheritedVelocityAmount: number;
  88664. /**
  88665. * Creates a sub emitter
  88666. * @param particleSystem the particle system to be used by the sub emitter
  88667. */
  88668. constructor(
  88669. /**
  88670. * the particle system to be used by the sub emitter
  88671. */
  88672. particleSystem: ParticleSystem);
  88673. /**
  88674. * Clones the sub emitter
  88675. * @returns the cloned sub emitter
  88676. */
  88677. clone(): SubEmitter;
  88678. /**
  88679. * Serialize current object to a JSON object
  88680. * @returns the serialized object
  88681. */
  88682. serialize(): any;
  88683. /** @hidden */
  88684. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  88685. /**
  88686. * Creates a new SubEmitter from a serialized JSON version
  88687. * @param serializationObject defines the JSON object to read from
  88688. * @param scene defines the hosting scene
  88689. * @param rootUrl defines the rootUrl for data loading
  88690. * @returns a new SubEmitter
  88691. */
  88692. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  88693. /** Release associated resources */
  88694. dispose(): void;
  88695. }
  88696. }
  88697. declare module BABYLON {
  88698. /** @hidden */
  88699. export var clipPlaneFragmentDeclaration: {
  88700. name: string;
  88701. shader: string;
  88702. };
  88703. }
  88704. declare module BABYLON {
  88705. /** @hidden */
  88706. export var imageProcessingDeclaration: {
  88707. name: string;
  88708. shader: string;
  88709. };
  88710. }
  88711. declare module BABYLON {
  88712. /** @hidden */
  88713. export var imageProcessingFunctions: {
  88714. name: string;
  88715. shader: string;
  88716. };
  88717. }
  88718. declare module BABYLON {
  88719. /** @hidden */
  88720. export var clipPlaneFragment: {
  88721. name: string;
  88722. shader: string;
  88723. };
  88724. }
  88725. declare module BABYLON {
  88726. /** @hidden */
  88727. export var particlesPixelShader: {
  88728. name: string;
  88729. shader: string;
  88730. };
  88731. }
  88732. declare module BABYLON {
  88733. /** @hidden */
  88734. export var clipPlaneVertexDeclaration: {
  88735. name: string;
  88736. shader: string;
  88737. };
  88738. }
  88739. declare module BABYLON {
  88740. /** @hidden */
  88741. export var clipPlaneVertex: {
  88742. name: string;
  88743. shader: string;
  88744. };
  88745. }
  88746. declare module BABYLON {
  88747. /** @hidden */
  88748. export var particlesVertexShader: {
  88749. name: string;
  88750. shader: string;
  88751. };
  88752. }
  88753. declare module BABYLON {
  88754. /**
  88755. * This represents a particle system in Babylon.
  88756. * 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.
  88757. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  88758. * @example https://doc.babylonjs.com/babylon101/particles
  88759. */
  88760. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  88761. /**
  88762. * Billboard mode will only apply to Y axis
  88763. */
  88764. static readonly BILLBOARDMODE_Y: number;
  88765. /**
  88766. * Billboard mode will apply to all axes
  88767. */
  88768. static readonly BILLBOARDMODE_ALL: number;
  88769. /**
  88770. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  88771. */
  88772. static readonly BILLBOARDMODE_STRETCHED: number;
  88773. /**
  88774. * This function can be defined to provide custom update for active particles.
  88775. * This function will be called instead of regular update (age, position, color, etc.).
  88776. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  88777. */
  88778. updateFunction: (particles: Particle[]) => void;
  88779. private _emitterWorldMatrix;
  88780. /**
  88781. * This function can be defined to specify initial direction for every new particle.
  88782. * It by default use the emitterType defined function
  88783. */
  88784. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  88785. /**
  88786. * This function can be defined to specify initial position for every new particle.
  88787. * It by default use the emitterType defined function
  88788. */
  88789. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  88790. /**
  88791. * @hidden
  88792. */
  88793. _inheritedVelocityOffset: Vector3;
  88794. /**
  88795. * An event triggered when the system is disposed
  88796. */
  88797. onDisposeObservable: Observable<ParticleSystem>;
  88798. private _onDisposeObserver;
  88799. /**
  88800. * Sets a callback that will be triggered when the system is disposed
  88801. */
  88802. set onDispose(callback: () => void);
  88803. private _particles;
  88804. private _epsilon;
  88805. private _capacity;
  88806. private _stockParticles;
  88807. private _newPartsExcess;
  88808. private _vertexData;
  88809. private _vertexBuffer;
  88810. private _vertexBuffers;
  88811. private _spriteBuffer;
  88812. private _indexBuffer;
  88813. private _effect;
  88814. private _customEffect;
  88815. private _cachedDefines;
  88816. private _scaledColorStep;
  88817. private _colorDiff;
  88818. private _scaledDirection;
  88819. private _scaledGravity;
  88820. private _currentRenderId;
  88821. private _alive;
  88822. private _useInstancing;
  88823. private _started;
  88824. private _stopped;
  88825. private _actualFrame;
  88826. private _scaledUpdateSpeed;
  88827. private _vertexBufferSize;
  88828. /** @hidden */
  88829. _currentEmitRateGradient: Nullable<FactorGradient>;
  88830. /** @hidden */
  88831. _currentEmitRate1: number;
  88832. /** @hidden */
  88833. _currentEmitRate2: number;
  88834. /** @hidden */
  88835. _currentStartSizeGradient: Nullable<FactorGradient>;
  88836. /** @hidden */
  88837. _currentStartSize1: number;
  88838. /** @hidden */
  88839. _currentStartSize2: number;
  88840. private readonly _rawTextureWidth;
  88841. private _rampGradientsTexture;
  88842. private _useRampGradients;
  88843. /** Gets or sets a boolean indicating that ramp gradients must be used
  88844. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  88845. */
  88846. get useRampGradients(): boolean;
  88847. set useRampGradients(value: boolean);
  88848. /**
  88849. * 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.
  88850. * 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: [])
  88851. */
  88852. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  88853. private _subEmitters;
  88854. /**
  88855. * @hidden
  88856. * If the particle systems emitter should be disposed when the particle system is disposed
  88857. */
  88858. _disposeEmitterOnDispose: boolean;
  88859. /**
  88860. * The current active Sub-systems, this property is used by the root particle system only.
  88861. */
  88862. activeSubSystems: Array<ParticleSystem>;
  88863. private _rootParticleSystem;
  88864. /**
  88865. * Gets the current list of active particles
  88866. */
  88867. get particles(): Particle[];
  88868. /**
  88869. * Returns the string "ParticleSystem"
  88870. * @returns a string containing the class name
  88871. */
  88872. getClassName(): string;
  88873. /**
  88874. * Instantiates a particle system.
  88875. * 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.
  88876. * @param name The name of the particle system
  88877. * @param capacity The max number of particles alive at the same time
  88878. * @param scene The scene the particle system belongs to
  88879. * @param customEffect a custom effect used to change the way particles are rendered by default
  88880. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  88881. * @param epsilon Offset used to render the particles
  88882. */
  88883. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  88884. private _addFactorGradient;
  88885. private _removeFactorGradient;
  88886. /**
  88887. * Adds a new life time gradient
  88888. * @param gradient defines the gradient to use (between 0 and 1)
  88889. * @param factor defines the life time factor to affect to the specified gradient
  88890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88891. * @returns the current particle system
  88892. */
  88893. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88894. /**
  88895. * Remove a specific life time gradient
  88896. * @param gradient defines the gradient to remove
  88897. * @returns the current particle system
  88898. */
  88899. removeLifeTimeGradient(gradient: number): IParticleSystem;
  88900. /**
  88901. * Adds a new size gradient
  88902. * @param gradient defines the gradient to use (between 0 and 1)
  88903. * @param factor defines the size factor to affect to the specified gradient
  88904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88905. * @returns the current particle system
  88906. */
  88907. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88908. /**
  88909. * Remove a specific size gradient
  88910. * @param gradient defines the gradient to remove
  88911. * @returns the current particle system
  88912. */
  88913. removeSizeGradient(gradient: number): IParticleSystem;
  88914. /**
  88915. * Adds a new color remap gradient
  88916. * @param gradient defines the gradient to use (between 0 and 1)
  88917. * @param min defines the color remap minimal range
  88918. * @param max defines the color remap maximal range
  88919. * @returns the current particle system
  88920. */
  88921. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88922. /**
  88923. * Remove a specific color remap gradient
  88924. * @param gradient defines the gradient to remove
  88925. * @returns the current particle system
  88926. */
  88927. removeColorRemapGradient(gradient: number): IParticleSystem;
  88928. /**
  88929. * Adds a new alpha remap gradient
  88930. * @param gradient defines the gradient to use (between 0 and 1)
  88931. * @param min defines the alpha remap minimal range
  88932. * @param max defines the alpha remap maximal range
  88933. * @returns the current particle system
  88934. */
  88935. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  88936. /**
  88937. * Remove a specific alpha remap gradient
  88938. * @param gradient defines the gradient to remove
  88939. * @returns the current particle system
  88940. */
  88941. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  88942. /**
  88943. * Adds a new angular speed gradient
  88944. * @param gradient defines the gradient to use (between 0 and 1)
  88945. * @param factor defines the angular speed 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. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88950. /**
  88951. * Remove a specific angular speed gradient
  88952. * @param gradient defines the gradient to remove
  88953. * @returns the current particle system
  88954. */
  88955. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  88956. /**
  88957. * Adds a new velocity gradient
  88958. * @param gradient defines the gradient to use (between 0 and 1)
  88959. * @param factor defines the velocity to affect to the specified gradient
  88960. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88961. * @returns the current particle system
  88962. */
  88963. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88964. /**
  88965. * Remove a specific velocity gradient
  88966. * @param gradient defines the gradient to remove
  88967. * @returns the current particle system
  88968. */
  88969. removeVelocityGradient(gradient: number): IParticleSystem;
  88970. /**
  88971. * Adds a new limit velocity gradient
  88972. * @param gradient defines the gradient to use (between 0 and 1)
  88973. * @param factor defines the limit velocity value to affect to the specified gradient
  88974. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88975. * @returns the current particle system
  88976. */
  88977. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88978. /**
  88979. * Remove a specific limit velocity gradient
  88980. * @param gradient defines the gradient to remove
  88981. * @returns the current particle system
  88982. */
  88983. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  88984. /**
  88985. * Adds a new drag gradient
  88986. * @param gradient defines the gradient to use (between 0 and 1)
  88987. * @param factor defines the drag value to affect to the specified gradient
  88988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  88989. * @returns the current particle system
  88990. */
  88991. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  88992. /**
  88993. * Remove a specific drag gradient
  88994. * @param gradient defines the gradient to remove
  88995. * @returns the current particle system
  88996. */
  88997. removeDragGradient(gradient: number): IParticleSystem;
  88998. /**
  88999. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  89000. * @param gradient defines the gradient to use (between 0 and 1)
  89001. * @param factor defines the emit rate value to affect to the specified gradient
  89002. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89003. * @returns the current particle system
  89004. */
  89005. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89006. /**
  89007. * Remove a specific emit rate gradient
  89008. * @param gradient defines the gradient to remove
  89009. * @returns the current particle system
  89010. */
  89011. removeEmitRateGradient(gradient: number): IParticleSystem;
  89012. /**
  89013. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  89014. * @param gradient defines the gradient to use (between 0 and 1)
  89015. * @param factor defines the start size value to affect to the specified gradient
  89016. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  89017. * @returns the current particle system
  89018. */
  89019. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  89020. /**
  89021. * Remove a specific start size gradient
  89022. * @param gradient defines the gradient to remove
  89023. * @returns the current particle system
  89024. */
  89025. removeStartSizeGradient(gradient: number): IParticleSystem;
  89026. private _createRampGradientTexture;
  89027. /**
  89028. * Gets the current list of ramp gradients.
  89029. * You must use addRampGradient and removeRampGradient to udpate this list
  89030. * @returns the list of ramp gradients
  89031. */
  89032. getRampGradients(): Nullable<Array<Color3Gradient>>;
  89033. /**
  89034. * Adds a new ramp gradient used to remap particle colors
  89035. * @param gradient defines the gradient to use (between 0 and 1)
  89036. * @param color defines the color to affect to the specified gradient
  89037. * @returns the current particle system
  89038. */
  89039. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  89040. /**
  89041. * Remove a specific ramp gradient
  89042. * @param gradient defines the gradient to remove
  89043. * @returns the current particle system
  89044. */
  89045. removeRampGradient(gradient: number): ParticleSystem;
  89046. /**
  89047. * Adds a new color gradient
  89048. * @param gradient defines the gradient to use (between 0 and 1)
  89049. * @param color1 defines the color to affect to the specified gradient
  89050. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  89051. * @returns this particle system
  89052. */
  89053. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  89054. /**
  89055. * Remove a specific color gradient
  89056. * @param gradient defines the gradient to remove
  89057. * @returns this particle system
  89058. */
  89059. removeColorGradient(gradient: number): IParticleSystem;
  89060. private _fetchR;
  89061. protected _reset(): void;
  89062. private _resetEffect;
  89063. private _createVertexBuffers;
  89064. private _createIndexBuffer;
  89065. /**
  89066. * Gets the maximum number of particles active at the same time.
  89067. * @returns The max number of active particles.
  89068. */
  89069. getCapacity(): number;
  89070. /**
  89071. * Gets whether there are still active particles in the system.
  89072. * @returns True if it is alive, otherwise false.
  89073. */
  89074. isAlive(): boolean;
  89075. /**
  89076. * Gets if the system has been started. (Note: this will still be true after stop is called)
  89077. * @returns True if it has been started, otherwise false.
  89078. */
  89079. isStarted(): boolean;
  89080. private _prepareSubEmitterInternalArray;
  89081. /**
  89082. * Starts the particle system and begins to emit
  89083. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  89084. */
  89085. start(delay?: number): void;
  89086. /**
  89087. * Stops the particle system.
  89088. * @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.
  89089. */
  89090. stop(stopSubEmitters?: boolean): void;
  89091. /**
  89092. * Remove all active particles
  89093. */
  89094. reset(): void;
  89095. /**
  89096. * @hidden (for internal use only)
  89097. */
  89098. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  89099. /**
  89100. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  89101. * Its lifetime will start back at 0.
  89102. */
  89103. recycleParticle: (particle: Particle) => void;
  89104. private _stopSubEmitters;
  89105. private _createParticle;
  89106. private _removeFromRoot;
  89107. private _emitFromParticle;
  89108. private _update;
  89109. /** @hidden */
  89110. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  89111. /** @hidden */
  89112. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  89113. /** @hidden */
  89114. private _getEffect;
  89115. /**
  89116. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  89117. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  89118. */
  89119. animate(preWarmOnly?: boolean): void;
  89120. private _appendParticleVertices;
  89121. /**
  89122. * Rebuilds the particle system.
  89123. */
  89124. rebuild(): void;
  89125. /**
  89126. * Is this system ready to be used/rendered
  89127. * @return true if the system is ready
  89128. */
  89129. isReady(): boolean;
  89130. private _render;
  89131. /**
  89132. * Renders the particle system in its current state.
  89133. * @returns the current number of particles
  89134. */
  89135. render(): number;
  89136. /**
  89137. * Disposes the particle system and free the associated resources
  89138. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  89139. */
  89140. dispose(disposeTexture?: boolean): void;
  89141. /**
  89142. * Clones the particle system.
  89143. * @param name The name of the cloned object
  89144. * @param newEmitter The new emitter to use
  89145. * @returns the cloned particle system
  89146. */
  89147. clone(name: string, newEmitter: any): ParticleSystem;
  89148. /**
  89149. * Serializes the particle system to a JSON object.
  89150. * @returns the JSON object
  89151. */
  89152. serialize(): any;
  89153. /** @hidden */
  89154. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  89155. /** @hidden */
  89156. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  89157. /**
  89158. * Parses a JSON object to create a particle system.
  89159. * @param parsedParticleSystem The JSON object to parse
  89160. * @param scene The scene to create the particle system in
  89161. * @param rootUrl The root url to use to load external dependencies like texture
  89162. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  89163. * @returns the Parsed particle system
  89164. */
  89165. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  89166. }
  89167. }
  89168. declare module BABYLON {
  89169. /**
  89170. * A particle represents one of the element emitted by a particle system.
  89171. * This is mainly define by its coordinates, direction, velocity and age.
  89172. */
  89173. export class Particle {
  89174. /**
  89175. * The particle system the particle belongs to.
  89176. */
  89177. particleSystem: ParticleSystem;
  89178. private static _Count;
  89179. /**
  89180. * Unique ID of the particle
  89181. */
  89182. id: number;
  89183. /**
  89184. * The world position of the particle in the scene.
  89185. */
  89186. position: Vector3;
  89187. /**
  89188. * The world direction of the particle in the scene.
  89189. */
  89190. direction: Vector3;
  89191. /**
  89192. * The color of the particle.
  89193. */
  89194. color: Color4;
  89195. /**
  89196. * The color change of the particle per step.
  89197. */
  89198. colorStep: Color4;
  89199. /**
  89200. * Defines how long will the life of the particle be.
  89201. */
  89202. lifeTime: number;
  89203. /**
  89204. * The current age of the particle.
  89205. */
  89206. age: number;
  89207. /**
  89208. * The current size of the particle.
  89209. */
  89210. size: number;
  89211. /**
  89212. * The current scale of the particle.
  89213. */
  89214. scale: Vector2;
  89215. /**
  89216. * The current angle of the particle.
  89217. */
  89218. angle: number;
  89219. /**
  89220. * Defines how fast is the angle changing.
  89221. */
  89222. angularSpeed: number;
  89223. /**
  89224. * Defines the cell index used by the particle to be rendered from a sprite.
  89225. */
  89226. cellIndex: number;
  89227. /**
  89228. * The information required to support color remapping
  89229. */
  89230. remapData: Vector4;
  89231. /** @hidden */
  89232. _randomCellOffset?: number;
  89233. /** @hidden */
  89234. _initialDirection: Nullable<Vector3>;
  89235. /** @hidden */
  89236. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  89237. /** @hidden */
  89238. _initialStartSpriteCellID: number;
  89239. /** @hidden */
  89240. _initialEndSpriteCellID: number;
  89241. /** @hidden */
  89242. _currentColorGradient: Nullable<ColorGradient>;
  89243. /** @hidden */
  89244. _currentColor1: Color4;
  89245. /** @hidden */
  89246. _currentColor2: Color4;
  89247. /** @hidden */
  89248. _currentSizeGradient: Nullable<FactorGradient>;
  89249. /** @hidden */
  89250. _currentSize1: number;
  89251. /** @hidden */
  89252. _currentSize2: number;
  89253. /** @hidden */
  89254. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  89255. /** @hidden */
  89256. _currentAngularSpeed1: number;
  89257. /** @hidden */
  89258. _currentAngularSpeed2: number;
  89259. /** @hidden */
  89260. _currentVelocityGradient: Nullable<FactorGradient>;
  89261. /** @hidden */
  89262. _currentVelocity1: number;
  89263. /** @hidden */
  89264. _currentVelocity2: number;
  89265. /** @hidden */
  89266. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  89267. /** @hidden */
  89268. _currentLimitVelocity1: number;
  89269. /** @hidden */
  89270. _currentLimitVelocity2: number;
  89271. /** @hidden */
  89272. _currentDragGradient: Nullable<FactorGradient>;
  89273. /** @hidden */
  89274. _currentDrag1: number;
  89275. /** @hidden */
  89276. _currentDrag2: number;
  89277. /** @hidden */
  89278. _randomNoiseCoordinates1: Vector3;
  89279. /** @hidden */
  89280. _randomNoiseCoordinates2: Vector3;
  89281. /**
  89282. * Creates a new instance Particle
  89283. * @param particleSystem the particle system the particle belongs to
  89284. */
  89285. constructor(
  89286. /**
  89287. * The particle system the particle belongs to.
  89288. */
  89289. particleSystem: ParticleSystem);
  89290. private updateCellInfoFromSystem;
  89291. /**
  89292. * Defines how the sprite cell index is updated for the particle
  89293. */
  89294. updateCellIndex(): void;
  89295. /** @hidden */
  89296. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  89297. /** @hidden */
  89298. _inheritParticleInfoToSubEmitters(): void;
  89299. /** @hidden */
  89300. _reset(): void;
  89301. /**
  89302. * Copy the properties of particle to another one.
  89303. * @param other the particle to copy the information to.
  89304. */
  89305. copyTo(other: Particle): void;
  89306. }
  89307. }
  89308. declare module BABYLON {
  89309. /**
  89310. * Particle emitter represents a volume emitting particles.
  89311. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  89312. */
  89313. export interface IParticleEmitterType {
  89314. /**
  89315. * Called by the particle System when the direction is computed for the created particle.
  89316. * @param worldMatrix is the world matrix of the particle system
  89317. * @param directionToUpdate is the direction vector to update with the result
  89318. * @param particle is the particle we are computed the direction for
  89319. */
  89320. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89321. /**
  89322. * Called by the particle System when the position is computed for the created particle.
  89323. * @param worldMatrix is the world matrix of the particle system
  89324. * @param positionToUpdate is the position vector to update with the result
  89325. * @param particle is the particle we are computed the position for
  89326. */
  89327. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89328. /**
  89329. * Clones the current emitter and returns a copy of it
  89330. * @returns the new emitter
  89331. */
  89332. clone(): IParticleEmitterType;
  89333. /**
  89334. * Called by the GPUParticleSystem to setup the update shader
  89335. * @param effect defines the update shader
  89336. */
  89337. applyToShader(effect: Effect): void;
  89338. /**
  89339. * Returns a string to use to update the GPU particles update shader
  89340. * @returns the effect defines string
  89341. */
  89342. getEffectDefines(): string;
  89343. /**
  89344. * Returns a string representing the class name
  89345. * @returns a string containing the class name
  89346. */
  89347. getClassName(): string;
  89348. /**
  89349. * Serializes the particle system to a JSON object.
  89350. * @returns the JSON object
  89351. */
  89352. serialize(): any;
  89353. /**
  89354. * Parse properties from a JSON object
  89355. * @param serializationObject defines the JSON object
  89356. */
  89357. parse(serializationObject: any): void;
  89358. }
  89359. }
  89360. declare module BABYLON {
  89361. /**
  89362. * Particle emitter emitting particles from the inside of a box.
  89363. * It emits the particles randomly between 2 given directions.
  89364. */
  89365. export class BoxParticleEmitter implements IParticleEmitterType {
  89366. /**
  89367. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89368. */
  89369. direction1: Vector3;
  89370. /**
  89371. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89372. */
  89373. direction2: Vector3;
  89374. /**
  89375. * 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.
  89376. */
  89377. minEmitBox: Vector3;
  89378. /**
  89379. * 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.
  89380. */
  89381. maxEmitBox: Vector3;
  89382. /**
  89383. * Creates a new instance BoxParticleEmitter
  89384. */
  89385. constructor();
  89386. /**
  89387. * Called by the particle System when the direction is computed for the created particle.
  89388. * @param worldMatrix is the world matrix of the particle system
  89389. * @param directionToUpdate is the direction vector to update with the result
  89390. * @param particle is the particle we are computed the direction for
  89391. */
  89392. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89393. /**
  89394. * Called by the particle System when the position is computed for the created particle.
  89395. * @param worldMatrix is the world matrix of the particle system
  89396. * @param positionToUpdate is the position vector to update with the result
  89397. * @param particle is the particle we are computed the position for
  89398. */
  89399. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89400. /**
  89401. * Clones the current emitter and returns a copy of it
  89402. * @returns the new emitter
  89403. */
  89404. clone(): BoxParticleEmitter;
  89405. /**
  89406. * Called by the GPUParticleSystem to setup the update shader
  89407. * @param effect defines the update shader
  89408. */
  89409. applyToShader(effect: Effect): void;
  89410. /**
  89411. * Returns a string to use to update the GPU particles update shader
  89412. * @returns a string containng the defines string
  89413. */
  89414. getEffectDefines(): string;
  89415. /**
  89416. * Returns the string "BoxParticleEmitter"
  89417. * @returns a string containing the class name
  89418. */
  89419. getClassName(): string;
  89420. /**
  89421. * Serializes the particle system to a JSON object.
  89422. * @returns the JSON object
  89423. */
  89424. serialize(): any;
  89425. /**
  89426. * Parse properties from a JSON object
  89427. * @param serializationObject defines the JSON object
  89428. */
  89429. parse(serializationObject: any): void;
  89430. }
  89431. }
  89432. declare module BABYLON {
  89433. /**
  89434. * Particle emitter emitting particles from the inside of a cone.
  89435. * It emits the particles alongside the cone volume from the base to the particle.
  89436. * The emission direction might be randomized.
  89437. */
  89438. export class ConeParticleEmitter implements IParticleEmitterType {
  89439. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  89440. directionRandomizer: number;
  89441. private _radius;
  89442. private _angle;
  89443. private _height;
  89444. /**
  89445. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  89446. */
  89447. radiusRange: number;
  89448. /**
  89449. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  89450. */
  89451. heightRange: number;
  89452. /**
  89453. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  89454. */
  89455. emitFromSpawnPointOnly: boolean;
  89456. /**
  89457. * Gets or sets the radius of the emission cone
  89458. */
  89459. get radius(): number;
  89460. set radius(value: number);
  89461. /**
  89462. * Gets or sets the angle of the emission cone
  89463. */
  89464. get angle(): number;
  89465. set angle(value: number);
  89466. private _buildHeight;
  89467. /**
  89468. * Creates a new instance ConeParticleEmitter
  89469. * @param radius the radius of the emission cone (1 by default)
  89470. * @param angle the cone base angle (PI by default)
  89471. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  89472. */
  89473. constructor(radius?: number, angle?: number,
  89474. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  89475. directionRandomizer?: number);
  89476. /**
  89477. * Called by the particle System when the direction is computed for the created particle.
  89478. * @param worldMatrix is the world matrix of the particle system
  89479. * @param directionToUpdate is the direction vector to update with the result
  89480. * @param particle is the particle we are computed the direction for
  89481. */
  89482. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89483. /**
  89484. * Called by the particle System when the position is computed for the created particle.
  89485. * @param worldMatrix is the world matrix of the particle system
  89486. * @param positionToUpdate is the position vector to update with the result
  89487. * @param particle is the particle we are computed the position for
  89488. */
  89489. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89490. /**
  89491. * Clones the current emitter and returns a copy of it
  89492. * @returns the new emitter
  89493. */
  89494. clone(): ConeParticleEmitter;
  89495. /**
  89496. * Called by the GPUParticleSystem to setup the update shader
  89497. * @param effect defines the update shader
  89498. */
  89499. applyToShader(effect: Effect): void;
  89500. /**
  89501. * Returns a string to use to update the GPU particles update shader
  89502. * @returns a string containng the defines string
  89503. */
  89504. getEffectDefines(): string;
  89505. /**
  89506. * Returns the string "ConeParticleEmitter"
  89507. * @returns a string containing the class name
  89508. */
  89509. getClassName(): string;
  89510. /**
  89511. * Serializes the particle system to a JSON object.
  89512. * @returns the JSON object
  89513. */
  89514. serialize(): any;
  89515. /**
  89516. * Parse properties from a JSON object
  89517. * @param serializationObject defines the JSON object
  89518. */
  89519. parse(serializationObject: any): void;
  89520. }
  89521. }
  89522. declare module BABYLON {
  89523. /**
  89524. * Particle emitter emitting particles from the inside of a cylinder.
  89525. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  89526. */
  89527. export class CylinderParticleEmitter implements IParticleEmitterType {
  89528. /**
  89529. * The radius of the emission cylinder.
  89530. */
  89531. radius: number;
  89532. /**
  89533. * The height of the emission cylinder.
  89534. */
  89535. height: number;
  89536. /**
  89537. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89538. */
  89539. radiusRange: number;
  89540. /**
  89541. * How much to randomize the particle direction [0-1].
  89542. */
  89543. directionRandomizer: number;
  89544. /**
  89545. * Creates a new instance CylinderParticleEmitter
  89546. * @param radius the radius of the emission cylinder (1 by default)
  89547. * @param height the height of the emission cylinder (1 by default)
  89548. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89549. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89550. */
  89551. constructor(
  89552. /**
  89553. * The radius of the emission cylinder.
  89554. */
  89555. radius?: number,
  89556. /**
  89557. * The height of the emission cylinder.
  89558. */
  89559. height?: number,
  89560. /**
  89561. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89562. */
  89563. radiusRange?: number,
  89564. /**
  89565. * How much to randomize the particle direction [0-1].
  89566. */
  89567. directionRandomizer?: number);
  89568. /**
  89569. * Called by the particle System when the direction is computed for the created particle.
  89570. * @param worldMatrix is the world matrix of the particle system
  89571. * @param directionToUpdate is the direction vector to update with the result
  89572. * @param particle is the particle we are computed the direction for
  89573. */
  89574. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89575. /**
  89576. * Called by the particle System when the position is computed for the created particle.
  89577. * @param worldMatrix is the world matrix of the particle system
  89578. * @param positionToUpdate is the position vector to update with the result
  89579. * @param particle is the particle we are computed the position for
  89580. */
  89581. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89582. /**
  89583. * Clones the current emitter and returns a copy of it
  89584. * @returns the new emitter
  89585. */
  89586. clone(): CylinderParticleEmitter;
  89587. /**
  89588. * Called by the GPUParticleSystem to setup the update shader
  89589. * @param effect defines the update shader
  89590. */
  89591. applyToShader(effect: Effect): void;
  89592. /**
  89593. * Returns a string to use to update the GPU particles update shader
  89594. * @returns a string containng the defines string
  89595. */
  89596. getEffectDefines(): string;
  89597. /**
  89598. * Returns the string "CylinderParticleEmitter"
  89599. * @returns a string containing the class name
  89600. */
  89601. getClassName(): string;
  89602. /**
  89603. * Serializes the particle system to a JSON object.
  89604. * @returns the JSON object
  89605. */
  89606. serialize(): any;
  89607. /**
  89608. * Parse properties from a JSON object
  89609. * @param serializationObject defines the JSON object
  89610. */
  89611. parse(serializationObject: any): void;
  89612. }
  89613. /**
  89614. * Particle emitter emitting particles from the inside of a cylinder.
  89615. * It emits the particles randomly between two vectors.
  89616. */
  89617. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  89618. /**
  89619. * The min limit of the emission direction.
  89620. */
  89621. direction1: Vector3;
  89622. /**
  89623. * The max limit of the emission direction.
  89624. */
  89625. direction2: Vector3;
  89626. /**
  89627. * Creates a new instance CylinderDirectedParticleEmitter
  89628. * @param radius the radius of the emission cylinder (1 by default)
  89629. * @param height the height of the emission cylinder (1 by default)
  89630. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89631. * @param direction1 the min limit of the emission direction (up vector by default)
  89632. * @param direction2 the max limit of the emission direction (up vector by default)
  89633. */
  89634. constructor(radius?: number, height?: number, radiusRange?: number,
  89635. /**
  89636. * The min limit of the emission direction.
  89637. */
  89638. direction1?: Vector3,
  89639. /**
  89640. * The max limit of the emission direction.
  89641. */
  89642. direction2?: Vector3);
  89643. /**
  89644. * Called by the particle System when the direction is computed for the created particle.
  89645. * @param worldMatrix is the world matrix of the particle system
  89646. * @param directionToUpdate is the direction vector to update with the result
  89647. * @param particle is the particle we are computed the direction for
  89648. */
  89649. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89650. /**
  89651. * Clones the current emitter and returns a copy of it
  89652. * @returns the new emitter
  89653. */
  89654. clone(): CylinderDirectedParticleEmitter;
  89655. /**
  89656. * Called by the GPUParticleSystem to setup the update shader
  89657. * @param effect defines the update shader
  89658. */
  89659. applyToShader(effect: Effect): void;
  89660. /**
  89661. * Returns a string to use to update the GPU particles update shader
  89662. * @returns a string containng the defines string
  89663. */
  89664. getEffectDefines(): string;
  89665. /**
  89666. * Returns the string "CylinderDirectedParticleEmitter"
  89667. * @returns a string containing the class name
  89668. */
  89669. getClassName(): string;
  89670. /**
  89671. * Serializes the particle system to a JSON object.
  89672. * @returns the JSON object
  89673. */
  89674. serialize(): any;
  89675. /**
  89676. * Parse properties from a JSON object
  89677. * @param serializationObject defines the JSON object
  89678. */
  89679. parse(serializationObject: any): void;
  89680. }
  89681. }
  89682. declare module BABYLON {
  89683. /**
  89684. * Particle emitter emitting particles from the inside of a hemisphere.
  89685. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  89686. */
  89687. export class HemisphericParticleEmitter implements IParticleEmitterType {
  89688. /**
  89689. * The radius of the emission hemisphere.
  89690. */
  89691. radius: number;
  89692. /**
  89693. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89694. */
  89695. radiusRange: number;
  89696. /**
  89697. * How much to randomize the particle direction [0-1].
  89698. */
  89699. directionRandomizer: number;
  89700. /**
  89701. * Creates a new instance HemisphericParticleEmitter
  89702. * @param radius the radius of the emission hemisphere (1 by default)
  89703. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89704. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89705. */
  89706. constructor(
  89707. /**
  89708. * The radius of the emission hemisphere.
  89709. */
  89710. radius?: number,
  89711. /**
  89712. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89713. */
  89714. radiusRange?: number,
  89715. /**
  89716. * How much to randomize the particle direction [0-1].
  89717. */
  89718. directionRandomizer?: number);
  89719. /**
  89720. * Called by the particle System when the direction is computed for the created particle.
  89721. * @param worldMatrix is the world matrix of the particle system
  89722. * @param directionToUpdate is the direction vector to update with the result
  89723. * @param particle is the particle we are computed the direction for
  89724. */
  89725. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89726. /**
  89727. * Called by the particle System when the position is computed for the created particle.
  89728. * @param worldMatrix is the world matrix of the particle system
  89729. * @param positionToUpdate is the position vector to update with the result
  89730. * @param particle is the particle we are computed the position for
  89731. */
  89732. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89733. /**
  89734. * Clones the current emitter and returns a copy of it
  89735. * @returns the new emitter
  89736. */
  89737. clone(): HemisphericParticleEmitter;
  89738. /**
  89739. * Called by the GPUParticleSystem to setup the update shader
  89740. * @param effect defines the update shader
  89741. */
  89742. applyToShader(effect: Effect): void;
  89743. /**
  89744. * Returns a string to use to update the GPU particles update shader
  89745. * @returns a string containng the defines string
  89746. */
  89747. getEffectDefines(): string;
  89748. /**
  89749. * Returns the string "HemisphericParticleEmitter"
  89750. * @returns a string containing the class name
  89751. */
  89752. getClassName(): string;
  89753. /**
  89754. * Serializes the particle system to a JSON object.
  89755. * @returns the JSON object
  89756. */
  89757. serialize(): any;
  89758. /**
  89759. * Parse properties from a JSON object
  89760. * @param serializationObject defines the JSON object
  89761. */
  89762. parse(serializationObject: any): void;
  89763. }
  89764. }
  89765. declare module BABYLON {
  89766. /**
  89767. * Particle emitter emitting particles from a point.
  89768. * It emits the particles randomly between 2 given directions.
  89769. */
  89770. export class PointParticleEmitter implements IParticleEmitterType {
  89771. /**
  89772. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89773. */
  89774. direction1: Vector3;
  89775. /**
  89776. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  89777. */
  89778. direction2: Vector3;
  89779. /**
  89780. * Creates a new instance PointParticleEmitter
  89781. */
  89782. constructor();
  89783. /**
  89784. * Called by the particle System when the direction is computed for the created particle.
  89785. * @param worldMatrix is the world matrix of the particle system
  89786. * @param directionToUpdate is the direction vector to update with the result
  89787. * @param particle is the particle we are computed the direction for
  89788. */
  89789. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89790. /**
  89791. * Called by the particle System when the position is computed for the created particle.
  89792. * @param worldMatrix is the world matrix of the particle system
  89793. * @param positionToUpdate is the position vector to update with the result
  89794. * @param particle is the particle we are computed the position for
  89795. */
  89796. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89797. /**
  89798. * Clones the current emitter and returns a copy of it
  89799. * @returns the new emitter
  89800. */
  89801. clone(): PointParticleEmitter;
  89802. /**
  89803. * Called by the GPUParticleSystem to setup the update shader
  89804. * @param effect defines the update shader
  89805. */
  89806. applyToShader(effect: Effect): void;
  89807. /**
  89808. * Returns a string to use to update the GPU particles update shader
  89809. * @returns a string containng the defines string
  89810. */
  89811. getEffectDefines(): string;
  89812. /**
  89813. * Returns the string "PointParticleEmitter"
  89814. * @returns a string containing the class name
  89815. */
  89816. getClassName(): string;
  89817. /**
  89818. * Serializes the particle system to a JSON object.
  89819. * @returns the JSON object
  89820. */
  89821. serialize(): any;
  89822. /**
  89823. * Parse properties from a JSON object
  89824. * @param serializationObject defines the JSON object
  89825. */
  89826. parse(serializationObject: any): void;
  89827. }
  89828. }
  89829. declare module BABYLON {
  89830. /**
  89831. * Particle emitter emitting particles from the inside of a sphere.
  89832. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  89833. */
  89834. export class SphereParticleEmitter implements IParticleEmitterType {
  89835. /**
  89836. * The radius of the emission sphere.
  89837. */
  89838. radius: number;
  89839. /**
  89840. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89841. */
  89842. radiusRange: number;
  89843. /**
  89844. * How much to randomize the particle direction [0-1].
  89845. */
  89846. directionRandomizer: number;
  89847. /**
  89848. * Creates a new instance SphereParticleEmitter
  89849. * @param radius the radius of the emission sphere (1 by default)
  89850. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  89851. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  89852. */
  89853. constructor(
  89854. /**
  89855. * The radius of the emission sphere.
  89856. */
  89857. radius?: number,
  89858. /**
  89859. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  89860. */
  89861. radiusRange?: number,
  89862. /**
  89863. * How much to randomize the particle direction [0-1].
  89864. */
  89865. directionRandomizer?: number);
  89866. /**
  89867. * Called by the particle System when the direction is computed for the created particle.
  89868. * @param worldMatrix is the world matrix of the particle system
  89869. * @param directionToUpdate is the direction vector to update with the result
  89870. * @param particle is the particle we are computed the direction for
  89871. */
  89872. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89873. /**
  89874. * Called by the particle System when the position is computed for the created particle.
  89875. * @param worldMatrix is the world matrix of the particle system
  89876. * @param positionToUpdate is the position vector to update with the result
  89877. * @param particle is the particle we are computed the position for
  89878. */
  89879. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  89880. /**
  89881. * Clones the current emitter and returns a copy of it
  89882. * @returns the new emitter
  89883. */
  89884. clone(): SphereParticleEmitter;
  89885. /**
  89886. * Called by the GPUParticleSystem to setup the update shader
  89887. * @param effect defines the update shader
  89888. */
  89889. applyToShader(effect: Effect): void;
  89890. /**
  89891. * Returns a string to use to update the GPU particles update shader
  89892. * @returns a string containng the defines string
  89893. */
  89894. getEffectDefines(): string;
  89895. /**
  89896. * Returns the string "SphereParticleEmitter"
  89897. * @returns a string containing the class name
  89898. */
  89899. getClassName(): string;
  89900. /**
  89901. * Serializes the particle system to a JSON object.
  89902. * @returns the JSON object
  89903. */
  89904. serialize(): any;
  89905. /**
  89906. * Parse properties from a JSON object
  89907. * @param serializationObject defines the JSON object
  89908. */
  89909. parse(serializationObject: any): void;
  89910. }
  89911. /**
  89912. * Particle emitter emitting particles from the inside of a sphere.
  89913. * It emits the particles randomly between two vectors.
  89914. */
  89915. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  89916. /**
  89917. * The min limit of the emission direction.
  89918. */
  89919. direction1: Vector3;
  89920. /**
  89921. * The max limit of the emission direction.
  89922. */
  89923. direction2: Vector3;
  89924. /**
  89925. * Creates a new instance SphereDirectedParticleEmitter
  89926. * @param radius the radius of the emission sphere (1 by default)
  89927. * @param direction1 the min limit of the emission direction (up vector by default)
  89928. * @param direction2 the max limit of the emission direction (up vector by default)
  89929. */
  89930. constructor(radius?: number,
  89931. /**
  89932. * The min limit of the emission direction.
  89933. */
  89934. direction1?: Vector3,
  89935. /**
  89936. * The max limit of the emission direction.
  89937. */
  89938. direction2?: Vector3);
  89939. /**
  89940. * Called by the particle System when the direction is computed for the created particle.
  89941. * @param worldMatrix is the world matrix of the particle system
  89942. * @param directionToUpdate is the direction vector to update with the result
  89943. * @param particle is the particle we are computed the direction for
  89944. */
  89945. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  89946. /**
  89947. * Clones the current emitter and returns a copy of it
  89948. * @returns the new emitter
  89949. */
  89950. clone(): SphereDirectedParticleEmitter;
  89951. /**
  89952. * Called by the GPUParticleSystem to setup the update shader
  89953. * @param effect defines the update shader
  89954. */
  89955. applyToShader(effect: Effect): void;
  89956. /**
  89957. * Returns a string to use to update the GPU particles update shader
  89958. * @returns a string containng the defines string
  89959. */
  89960. getEffectDefines(): string;
  89961. /**
  89962. * Returns the string "SphereDirectedParticleEmitter"
  89963. * @returns a string containing the class name
  89964. */
  89965. getClassName(): string;
  89966. /**
  89967. * Serializes the particle system to a JSON object.
  89968. * @returns the JSON object
  89969. */
  89970. serialize(): any;
  89971. /**
  89972. * Parse properties from a JSON object
  89973. * @param serializationObject defines the JSON object
  89974. */
  89975. parse(serializationObject: any): void;
  89976. }
  89977. }
  89978. declare module BABYLON {
  89979. /**
  89980. * Interface representing a particle system in Babylon.js.
  89981. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  89982. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  89983. */
  89984. export interface IParticleSystem {
  89985. /**
  89986. * List of animations used by the particle system.
  89987. */
  89988. animations: Animation[];
  89989. /**
  89990. * The id of the Particle system.
  89991. */
  89992. id: string;
  89993. /**
  89994. * The name of the Particle system.
  89995. */
  89996. name: string;
  89997. /**
  89998. * The emitter represents the Mesh or position we are attaching the particle system to.
  89999. */
  90000. emitter: Nullable<AbstractMesh | Vector3>;
  90001. /**
  90002. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90003. */
  90004. isBillboardBased: boolean;
  90005. /**
  90006. * The rendering group used by the Particle system to chose when to render.
  90007. */
  90008. renderingGroupId: number;
  90009. /**
  90010. * The layer mask we are rendering the particles through.
  90011. */
  90012. layerMask: number;
  90013. /**
  90014. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90015. */
  90016. updateSpeed: number;
  90017. /**
  90018. * The amount of time the particle system is running (depends of the overall update speed).
  90019. */
  90020. targetStopDuration: number;
  90021. /**
  90022. * The texture used to render each particle. (this can be a spritesheet)
  90023. */
  90024. particleTexture: Nullable<Texture>;
  90025. /**
  90026. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  90027. */
  90028. blendMode: number;
  90029. /**
  90030. * Minimum life time of emitting particles.
  90031. */
  90032. minLifeTime: number;
  90033. /**
  90034. * Maximum life time of emitting particles.
  90035. */
  90036. maxLifeTime: number;
  90037. /**
  90038. * Minimum Size of emitting particles.
  90039. */
  90040. minSize: number;
  90041. /**
  90042. * Maximum Size of emitting particles.
  90043. */
  90044. maxSize: number;
  90045. /**
  90046. * Minimum scale of emitting particles on X axis.
  90047. */
  90048. minScaleX: number;
  90049. /**
  90050. * Maximum scale of emitting particles on X axis.
  90051. */
  90052. maxScaleX: number;
  90053. /**
  90054. * Minimum scale of emitting particles on Y axis.
  90055. */
  90056. minScaleY: number;
  90057. /**
  90058. * Maximum scale of emitting particles on Y axis.
  90059. */
  90060. maxScaleY: number;
  90061. /**
  90062. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  90063. */
  90064. color1: Color4;
  90065. /**
  90066. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  90067. */
  90068. color2: Color4;
  90069. /**
  90070. * Color the particle will have at the end of its lifetime.
  90071. */
  90072. colorDead: Color4;
  90073. /**
  90074. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  90075. */
  90076. emitRate: number;
  90077. /**
  90078. * You can use gravity if you want to give an orientation to your particles.
  90079. */
  90080. gravity: Vector3;
  90081. /**
  90082. * Minimum power of emitting particles.
  90083. */
  90084. minEmitPower: number;
  90085. /**
  90086. * Maximum power of emitting particles.
  90087. */
  90088. maxEmitPower: number;
  90089. /**
  90090. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90091. */
  90092. minAngularSpeed: number;
  90093. /**
  90094. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90095. */
  90096. maxAngularSpeed: number;
  90097. /**
  90098. * Gets or sets the minimal initial rotation in radians.
  90099. */
  90100. minInitialRotation: number;
  90101. /**
  90102. * Gets or sets the maximal initial rotation in radians.
  90103. */
  90104. maxInitialRotation: number;
  90105. /**
  90106. * The particle emitter type defines the emitter used by the particle system.
  90107. * It can be for example box, sphere, or cone...
  90108. */
  90109. particleEmitterType: Nullable<IParticleEmitterType>;
  90110. /**
  90111. * Defines the delay in milliseconds before starting the system (0 by default)
  90112. */
  90113. startDelay: number;
  90114. /**
  90115. * 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
  90116. */
  90117. preWarmCycles: number;
  90118. /**
  90119. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  90120. */
  90121. preWarmStepOffset: number;
  90122. /**
  90123. * 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)
  90124. */
  90125. spriteCellChangeSpeed: number;
  90126. /**
  90127. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90128. */
  90129. startSpriteCellID: number;
  90130. /**
  90131. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90132. */
  90133. endSpriteCellID: number;
  90134. /**
  90135. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90136. */
  90137. spriteCellWidth: number;
  90138. /**
  90139. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90140. */
  90141. spriteCellHeight: number;
  90142. /**
  90143. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90144. */
  90145. spriteRandomStartCell: boolean;
  90146. /**
  90147. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  90148. */
  90149. isAnimationSheetEnabled: boolean;
  90150. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90151. translationPivot: Vector2;
  90152. /**
  90153. * Gets or sets a texture used to add random noise to particle positions
  90154. */
  90155. noiseTexture: Nullable<BaseTexture>;
  90156. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90157. noiseStrength: Vector3;
  90158. /**
  90159. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90160. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90161. */
  90162. billboardMode: number;
  90163. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90164. limitVelocityDamping: number;
  90165. /**
  90166. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90167. */
  90168. beginAnimationOnStart: boolean;
  90169. /**
  90170. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90171. */
  90172. beginAnimationFrom: number;
  90173. /**
  90174. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90175. */
  90176. beginAnimationTo: number;
  90177. /**
  90178. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90179. */
  90180. beginAnimationLoop: boolean;
  90181. /**
  90182. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90183. */
  90184. disposeOnStop: boolean;
  90185. /**
  90186. * Gets the maximum number of particles active at the same time.
  90187. * @returns The max number of active particles.
  90188. */
  90189. getCapacity(): number;
  90190. /**
  90191. * Gets if the system has been started. (Note: this will still be true after stop is called)
  90192. * @returns True if it has been started, otherwise false.
  90193. */
  90194. isStarted(): boolean;
  90195. /**
  90196. * Animates the particle system for this frame.
  90197. */
  90198. animate(): void;
  90199. /**
  90200. * Renders the particle system in its current state.
  90201. * @returns the current number of particles
  90202. */
  90203. render(): number;
  90204. /**
  90205. * Dispose the particle system and frees its associated resources.
  90206. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  90207. */
  90208. dispose(disposeTexture?: boolean): void;
  90209. /**
  90210. * Clones the particle system.
  90211. * @param name The name of the cloned object
  90212. * @param newEmitter The new emitter to use
  90213. * @returns the cloned particle system
  90214. */
  90215. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  90216. /**
  90217. * Serializes the particle system to a JSON object.
  90218. * @returns the JSON object
  90219. */
  90220. serialize(): any;
  90221. /**
  90222. * Rebuild the particle system
  90223. */
  90224. rebuild(): void;
  90225. /**
  90226. * Starts the particle system and begins to emit
  90227. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  90228. */
  90229. start(delay?: number): void;
  90230. /**
  90231. * Stops the particle system.
  90232. */
  90233. stop(): void;
  90234. /**
  90235. * Remove all active particles
  90236. */
  90237. reset(): void;
  90238. /**
  90239. * Is this system ready to be used/rendered
  90240. * @return true if the system is ready
  90241. */
  90242. isReady(): boolean;
  90243. /**
  90244. * Adds a new color gradient
  90245. * @param gradient defines the gradient to use (between 0 and 1)
  90246. * @param color1 defines the color to affect to the specified gradient
  90247. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  90248. * @returns the current particle system
  90249. */
  90250. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  90251. /**
  90252. * Remove a specific color gradient
  90253. * @param gradient defines the gradient to remove
  90254. * @returns the current particle system
  90255. */
  90256. removeColorGradient(gradient: number): IParticleSystem;
  90257. /**
  90258. * Adds a new size gradient
  90259. * @param gradient defines the gradient to use (between 0 and 1)
  90260. * @param factor defines the size factor to affect to the specified gradient
  90261. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90262. * @returns the current particle system
  90263. */
  90264. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90265. /**
  90266. * Remove a specific size gradient
  90267. * @param gradient defines the gradient to remove
  90268. * @returns the current particle system
  90269. */
  90270. removeSizeGradient(gradient: number): IParticleSystem;
  90271. /**
  90272. * Gets the current list of color gradients.
  90273. * You must use addColorGradient and removeColorGradient to udpate this list
  90274. * @returns the list of color gradients
  90275. */
  90276. getColorGradients(): Nullable<Array<ColorGradient>>;
  90277. /**
  90278. * Gets the current list of size gradients.
  90279. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90280. * @returns the list of size gradients
  90281. */
  90282. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90283. /**
  90284. * Gets the current list of angular speed gradients.
  90285. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90286. * @returns the list of angular speed gradients
  90287. */
  90288. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90289. /**
  90290. * Adds a new angular speed gradient
  90291. * @param gradient defines the gradient to use (between 0 and 1)
  90292. * @param factor defines the angular speed to affect to the specified gradient
  90293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90294. * @returns the current particle system
  90295. */
  90296. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90297. /**
  90298. * Remove a specific angular speed gradient
  90299. * @param gradient defines the gradient to remove
  90300. * @returns the current particle system
  90301. */
  90302. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90303. /**
  90304. * Gets the current list of velocity gradients.
  90305. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90306. * @returns the list of velocity gradients
  90307. */
  90308. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90309. /**
  90310. * Adds a new velocity gradient
  90311. * @param gradient defines the gradient to use (between 0 and 1)
  90312. * @param factor defines the velocity to affect to the specified gradient
  90313. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90314. * @returns the current particle system
  90315. */
  90316. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90317. /**
  90318. * Remove a specific velocity gradient
  90319. * @param gradient defines the gradient to remove
  90320. * @returns the current particle system
  90321. */
  90322. removeVelocityGradient(gradient: number): IParticleSystem;
  90323. /**
  90324. * Gets the current list of limit velocity gradients.
  90325. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90326. * @returns the list of limit velocity gradients
  90327. */
  90328. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90329. /**
  90330. * Adds a new limit velocity gradient
  90331. * @param gradient defines the gradient to use (between 0 and 1)
  90332. * @param factor defines the limit velocity to affect to the specified gradient
  90333. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90334. * @returns the current particle system
  90335. */
  90336. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90337. /**
  90338. * Remove a specific limit velocity gradient
  90339. * @param gradient defines the gradient to remove
  90340. * @returns the current particle system
  90341. */
  90342. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90343. /**
  90344. * Adds a new drag gradient
  90345. * @param gradient defines the gradient to use (between 0 and 1)
  90346. * @param factor defines the drag to affect to the specified gradient
  90347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90348. * @returns the current particle system
  90349. */
  90350. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90351. /**
  90352. * Remove a specific drag gradient
  90353. * @param gradient defines the gradient to remove
  90354. * @returns the current particle system
  90355. */
  90356. removeDragGradient(gradient: number): IParticleSystem;
  90357. /**
  90358. * Gets the current list of drag gradients.
  90359. * You must use addDragGradient and removeDragGradient to udpate this list
  90360. * @returns the list of drag gradients
  90361. */
  90362. getDragGradients(): Nullable<Array<FactorGradient>>;
  90363. /**
  90364. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90365. * @param gradient defines the gradient to use (between 0 and 1)
  90366. * @param factor defines the emit rate to affect to the specified gradient
  90367. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90368. * @returns the current particle system
  90369. */
  90370. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90371. /**
  90372. * Remove a specific emit rate gradient
  90373. * @param gradient defines the gradient to remove
  90374. * @returns the current particle system
  90375. */
  90376. removeEmitRateGradient(gradient: number): IParticleSystem;
  90377. /**
  90378. * Gets the current list of emit rate gradients.
  90379. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  90380. * @returns the list of emit rate gradients
  90381. */
  90382. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  90383. /**
  90384. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  90385. * @param gradient defines the gradient to use (between 0 and 1)
  90386. * @param factor defines the start size to affect to the specified gradient
  90387. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90388. * @returns the current particle system
  90389. */
  90390. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90391. /**
  90392. * Remove a specific start size gradient
  90393. * @param gradient defines the gradient to remove
  90394. * @returns the current particle system
  90395. */
  90396. removeStartSizeGradient(gradient: number): IParticleSystem;
  90397. /**
  90398. * Gets the current list of start size gradients.
  90399. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90400. * @returns the list of start size gradients
  90401. */
  90402. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90403. /**
  90404. * Adds a new life time gradient
  90405. * @param gradient defines the gradient to use (between 0 and 1)
  90406. * @param factor defines the life time factor to affect to the specified gradient
  90407. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90408. * @returns the current particle system
  90409. */
  90410. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90411. /**
  90412. * Remove a specific life time gradient
  90413. * @param gradient defines the gradient to remove
  90414. * @returns the current particle system
  90415. */
  90416. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90417. /**
  90418. * Gets the current list of life time gradients.
  90419. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90420. * @returns the list of life time gradients
  90421. */
  90422. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90423. /**
  90424. * Gets the current list of color gradients.
  90425. * You must use addColorGradient and removeColorGradient to udpate this list
  90426. * @returns the list of color gradients
  90427. */
  90428. getColorGradients(): Nullable<Array<ColorGradient>>;
  90429. /**
  90430. * Adds a new ramp gradient used to remap particle colors
  90431. * @param gradient defines the gradient to use (between 0 and 1)
  90432. * @param color defines the color to affect to the specified gradient
  90433. * @returns the current particle system
  90434. */
  90435. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  90436. /**
  90437. * Gets the current list of ramp gradients.
  90438. * You must use addRampGradient and removeRampGradient to udpate this list
  90439. * @returns the list of ramp gradients
  90440. */
  90441. getRampGradients(): Nullable<Array<Color3Gradient>>;
  90442. /** Gets or sets a boolean indicating that ramp gradients must be used
  90443. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90444. */
  90445. useRampGradients: boolean;
  90446. /**
  90447. * Adds a new color remap gradient
  90448. * @param gradient defines the gradient to use (between 0 and 1)
  90449. * @param min defines the color remap minimal range
  90450. * @param max defines the color remap maximal range
  90451. * @returns the current particle system
  90452. */
  90453. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90454. /**
  90455. * Gets the current list of color remap gradients.
  90456. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90457. * @returns the list of color remap gradients
  90458. */
  90459. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90460. /**
  90461. * Adds a new alpha remap gradient
  90462. * @param gradient defines the gradient to use (between 0 and 1)
  90463. * @param min defines the alpha remap minimal range
  90464. * @param max defines the alpha remap maximal range
  90465. * @returns the current particle system
  90466. */
  90467. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90468. /**
  90469. * Gets the current list of alpha remap gradients.
  90470. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90471. * @returns the list of alpha remap gradients
  90472. */
  90473. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90474. /**
  90475. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90476. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90477. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90478. * @returns the emitter
  90479. */
  90480. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90481. /**
  90482. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90483. * @param radius The radius of the hemisphere to emit from
  90484. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90485. * @returns the emitter
  90486. */
  90487. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  90488. /**
  90489. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90490. * @param radius The radius of the sphere to emit from
  90491. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90492. * @returns the emitter
  90493. */
  90494. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  90495. /**
  90496. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90497. * @param radius The radius of the sphere to emit from
  90498. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90499. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90500. * @returns the emitter
  90501. */
  90502. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  90503. /**
  90504. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90505. * @param radius The radius of the emission cylinder
  90506. * @param height The height of the emission cylinder
  90507. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90508. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90509. * @returns the emitter
  90510. */
  90511. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  90512. /**
  90513. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90514. * @param radius The radius of the cylinder to emit from
  90515. * @param height The height of the emission cylinder
  90516. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90517. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90518. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90519. * @returns the emitter
  90520. */
  90521. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  90522. /**
  90523. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90524. * @param radius The radius of the cone to emit from
  90525. * @param angle The base angle of the cone
  90526. * @returns the emitter
  90527. */
  90528. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  90529. /**
  90530. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90531. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90532. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90533. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90534. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90535. * @returns the emitter
  90536. */
  90537. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90538. /**
  90539. * Get hosting scene
  90540. * @returns the scene
  90541. */
  90542. getScene(): Scene;
  90543. }
  90544. }
  90545. declare module BABYLON {
  90546. /**
  90547. * Creates an instance based on a source mesh.
  90548. */
  90549. export class InstancedMesh extends AbstractMesh {
  90550. private _sourceMesh;
  90551. private _currentLOD;
  90552. /** @hidden */
  90553. _indexInSourceMeshInstanceArray: number;
  90554. constructor(name: string, source: Mesh);
  90555. /**
  90556. * Returns the string "InstancedMesh".
  90557. */
  90558. getClassName(): string;
  90559. /** Gets the list of lights affecting that mesh */
  90560. get lightSources(): Light[];
  90561. _resyncLightSources(): void;
  90562. _resyncLightSource(light: Light): void;
  90563. _removeLightSource(light: Light, dispose: boolean): void;
  90564. /**
  90565. * If the source mesh receives shadows
  90566. */
  90567. get receiveShadows(): boolean;
  90568. /**
  90569. * The material of the source mesh
  90570. */
  90571. get material(): Nullable<Material>;
  90572. /**
  90573. * Visibility of the source mesh
  90574. */
  90575. get visibility(): number;
  90576. /**
  90577. * Skeleton of the source mesh
  90578. */
  90579. get skeleton(): Nullable<Skeleton>;
  90580. /**
  90581. * Rendering ground id of the source mesh
  90582. */
  90583. get renderingGroupId(): number;
  90584. set renderingGroupId(value: number);
  90585. /**
  90586. * Returns the total number of vertices (integer).
  90587. */
  90588. getTotalVertices(): number;
  90589. /**
  90590. * Returns a positive integer : the total number of indices in this mesh geometry.
  90591. * @returns the numner of indices or zero if the mesh has no geometry.
  90592. */
  90593. getTotalIndices(): number;
  90594. /**
  90595. * The source mesh of the instance
  90596. */
  90597. get sourceMesh(): Mesh;
  90598. /**
  90599. * Is this node ready to be used/rendered
  90600. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90601. * @return {boolean} is it ready
  90602. */
  90603. isReady(completeCheck?: boolean): boolean;
  90604. /**
  90605. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90606. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  90607. * @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.
  90608. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  90609. */
  90610. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  90611. /**
  90612. * Sets the vertex data of the mesh geometry for the requested `kind`.
  90613. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  90614. * The `data` are either a numeric array either a Float32Array.
  90615. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  90616. * 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).
  90617. * Note that a new underlying VertexBuffer object is created each call.
  90618. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  90619. *
  90620. * Possible `kind` values :
  90621. * - VertexBuffer.PositionKind
  90622. * - VertexBuffer.UVKind
  90623. * - VertexBuffer.UV2Kind
  90624. * - VertexBuffer.UV3Kind
  90625. * - VertexBuffer.UV4Kind
  90626. * - VertexBuffer.UV5Kind
  90627. * - VertexBuffer.UV6Kind
  90628. * - VertexBuffer.ColorKind
  90629. * - VertexBuffer.MatricesIndicesKind
  90630. * - VertexBuffer.MatricesIndicesExtraKind
  90631. * - VertexBuffer.MatricesWeightsKind
  90632. * - VertexBuffer.MatricesWeightsExtraKind
  90633. *
  90634. * Returns the Mesh.
  90635. */
  90636. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90637. /**
  90638. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  90639. * If the mesh has no geometry, it is simply returned as it is.
  90640. * The `data` are either a numeric array either a Float32Array.
  90641. * No new underlying VertexBuffer object is created.
  90642. * 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.
  90643. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  90644. *
  90645. * Possible `kind` values :
  90646. * - VertexBuffer.PositionKind
  90647. * - VertexBuffer.UVKind
  90648. * - VertexBuffer.UV2Kind
  90649. * - VertexBuffer.UV3Kind
  90650. * - VertexBuffer.UV4Kind
  90651. * - VertexBuffer.UV5Kind
  90652. * - VertexBuffer.UV6Kind
  90653. * - VertexBuffer.ColorKind
  90654. * - VertexBuffer.MatricesIndicesKind
  90655. * - VertexBuffer.MatricesIndicesExtraKind
  90656. * - VertexBuffer.MatricesWeightsKind
  90657. * - VertexBuffer.MatricesWeightsExtraKind
  90658. *
  90659. * Returns the Mesh.
  90660. */
  90661. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  90662. /**
  90663. * Sets the mesh indices.
  90664. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  90665. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  90666. * This method creates a new index buffer each call.
  90667. * Returns the Mesh.
  90668. */
  90669. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  90670. /**
  90671. * Boolean : True if the mesh owns the requested kind of data.
  90672. */
  90673. isVerticesDataPresent(kind: string): boolean;
  90674. /**
  90675. * Returns an array of indices (IndicesArray).
  90676. */
  90677. getIndices(): Nullable<IndicesArray>;
  90678. get _positions(): Nullable<Vector3[]>;
  90679. /**
  90680. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90681. * This means the mesh underlying bounding box and sphere are recomputed.
  90682. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90683. * @returns the current mesh
  90684. */
  90685. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  90686. /** @hidden */
  90687. _preActivate(): InstancedMesh;
  90688. /** @hidden */
  90689. _activate(renderId: number, intermediateRendering: boolean): boolean;
  90690. /** @hidden */
  90691. _postActivate(): void;
  90692. getWorldMatrix(): Matrix;
  90693. get isAnInstance(): boolean;
  90694. /**
  90695. * Returns the current associated LOD AbstractMesh.
  90696. */
  90697. getLOD(camera: Camera): AbstractMesh;
  90698. /** @hidden */
  90699. _syncSubMeshes(): InstancedMesh;
  90700. /** @hidden */
  90701. _generatePointsArray(): boolean;
  90702. /**
  90703. * Creates a new InstancedMesh from the current mesh.
  90704. * - name (string) : the cloned mesh name
  90705. * - newParent (optional Node) : the optional Node to parent the clone to.
  90706. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  90707. *
  90708. * Returns the clone.
  90709. */
  90710. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  90711. /**
  90712. * Disposes the InstancedMesh.
  90713. * Returns nothing.
  90714. */
  90715. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90716. }
  90717. interface Mesh {
  90718. /**
  90719. * Register a custom buffer that will be instanced
  90720. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  90721. * @param kind defines the buffer kind
  90722. * @param stride defines the stride in floats
  90723. */
  90724. registerInstancedBuffer(kind: string, stride: number): void;
  90725. /** @hidden */
  90726. _userInstancedBuffersStorage: {
  90727. data: {
  90728. [key: string]: Float32Array;
  90729. };
  90730. sizes: {
  90731. [key: string]: number;
  90732. };
  90733. vertexBuffers: {
  90734. [key: string]: Nullable<VertexBuffer>;
  90735. };
  90736. strides: {
  90737. [key: string]: number;
  90738. };
  90739. };
  90740. }
  90741. interface AbstractMesh {
  90742. /**
  90743. * Object used to store instanced buffers defined by user
  90744. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  90745. */
  90746. instancedBuffers: {
  90747. [key: string]: any;
  90748. };
  90749. }
  90750. }
  90751. declare module BABYLON {
  90752. /**
  90753. * Defines the options associated with the creation of a shader material.
  90754. */
  90755. export interface IShaderMaterialOptions {
  90756. /**
  90757. * Does the material work in alpha blend mode
  90758. */
  90759. needAlphaBlending: boolean;
  90760. /**
  90761. * Does the material work in alpha test mode
  90762. */
  90763. needAlphaTesting: boolean;
  90764. /**
  90765. * The list of attribute names used in the shader
  90766. */
  90767. attributes: string[];
  90768. /**
  90769. * The list of unifrom names used in the shader
  90770. */
  90771. uniforms: string[];
  90772. /**
  90773. * The list of UBO names used in the shader
  90774. */
  90775. uniformBuffers: string[];
  90776. /**
  90777. * The list of sampler names used in the shader
  90778. */
  90779. samplers: string[];
  90780. /**
  90781. * The list of defines used in the shader
  90782. */
  90783. defines: string[];
  90784. }
  90785. /**
  90786. * 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.
  90787. *
  90788. * This returned material effects how the mesh will look based on the code in the shaders.
  90789. *
  90790. * @see http://doc.babylonjs.com/how_to/shader_material
  90791. */
  90792. export class ShaderMaterial extends Material {
  90793. private _shaderPath;
  90794. private _options;
  90795. private _textures;
  90796. private _textureArrays;
  90797. private _floats;
  90798. private _ints;
  90799. private _floatsArrays;
  90800. private _colors3;
  90801. private _colors3Arrays;
  90802. private _colors4;
  90803. private _colors4Arrays;
  90804. private _vectors2;
  90805. private _vectors3;
  90806. private _vectors4;
  90807. private _matrices;
  90808. private _matrixArrays;
  90809. private _matrices3x3;
  90810. private _matrices2x2;
  90811. private _vectors2Arrays;
  90812. private _vectors3Arrays;
  90813. private _vectors4Arrays;
  90814. private _cachedWorldViewMatrix;
  90815. private _cachedWorldViewProjectionMatrix;
  90816. private _renderId;
  90817. private _multiview;
  90818. /**
  90819. * Instantiate a new shader material.
  90820. * 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.
  90821. * This returned material effects how the mesh will look based on the code in the shaders.
  90822. * @see http://doc.babylonjs.com/how_to/shader_material
  90823. * @param name Define the name of the material in the scene
  90824. * @param scene Define the scene the material belongs to
  90825. * @param shaderPath Defines the route to the shader code in one of three ways:
  90826. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  90827. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  90828. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  90829. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  90830. * @param options Define the options used to create the shader
  90831. */
  90832. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  90833. /**
  90834. * Gets the shader path used to define the shader code
  90835. * It can be modified to trigger a new compilation
  90836. */
  90837. get shaderPath(): any;
  90838. /**
  90839. * Sets the shader path used to define the shader code
  90840. * It can be modified to trigger a new compilation
  90841. */
  90842. set shaderPath(shaderPath: any);
  90843. /**
  90844. * Gets the options used to compile the shader.
  90845. * They can be modified to trigger a new compilation
  90846. */
  90847. get options(): IShaderMaterialOptions;
  90848. /**
  90849. * Gets the current class name of the material e.g. "ShaderMaterial"
  90850. * Mainly use in serialization.
  90851. * @returns the class name
  90852. */
  90853. getClassName(): string;
  90854. /**
  90855. * Specifies if the material will require alpha blending
  90856. * @returns a boolean specifying if alpha blending is needed
  90857. */
  90858. needAlphaBlending(): boolean;
  90859. /**
  90860. * Specifies if this material should be rendered in alpha test mode
  90861. * @returns a boolean specifying if an alpha test is needed.
  90862. */
  90863. needAlphaTesting(): boolean;
  90864. private _checkUniform;
  90865. /**
  90866. * Set a texture in the shader.
  90867. * @param name Define the name of the uniform samplers as defined in the shader
  90868. * @param texture Define the texture to bind to this sampler
  90869. * @return the material itself allowing "fluent" like uniform updates
  90870. */
  90871. setTexture(name: string, texture: Texture): ShaderMaterial;
  90872. /**
  90873. * Set a texture array in the shader.
  90874. * @param name Define the name of the uniform sampler array as defined in the shader
  90875. * @param textures Define the list of textures to bind to this sampler
  90876. * @return the material itself allowing "fluent" like uniform updates
  90877. */
  90878. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  90879. /**
  90880. * Set a float in the shader.
  90881. * @param name Define the name of the uniform as defined in the shader
  90882. * @param value Define the value to give to the uniform
  90883. * @return the material itself allowing "fluent" like uniform updates
  90884. */
  90885. setFloat(name: string, value: number): ShaderMaterial;
  90886. /**
  90887. * Set a int in the shader.
  90888. * @param name Define the name of the uniform as defined in the shader
  90889. * @param value Define the value to give to the uniform
  90890. * @return the material itself allowing "fluent" like uniform updates
  90891. */
  90892. setInt(name: string, value: number): ShaderMaterial;
  90893. /**
  90894. * Set an array of floats in the shader.
  90895. * @param name Define the name of the uniform as defined in the shader
  90896. * @param value Define the value to give to the uniform
  90897. * @return the material itself allowing "fluent" like uniform updates
  90898. */
  90899. setFloats(name: string, value: number[]): ShaderMaterial;
  90900. /**
  90901. * Set a vec3 in the shader from a Color3.
  90902. * @param name Define the name of the uniform as defined in the shader
  90903. * @param value Define the value to give to the uniform
  90904. * @return the material itself allowing "fluent" like uniform updates
  90905. */
  90906. setColor3(name: string, value: Color3): ShaderMaterial;
  90907. /**
  90908. * Set a vec3 array in the shader from a Color3 array.
  90909. * @param name Define the name of the uniform as defined in the shader
  90910. * @param value Define the value to give to the uniform
  90911. * @return the material itself allowing "fluent" like uniform updates
  90912. */
  90913. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  90914. /**
  90915. * Set a vec4 in the shader from a Color4.
  90916. * @param name Define the name of the uniform as defined in the shader
  90917. * @param value Define the value to give to the uniform
  90918. * @return the material itself allowing "fluent" like uniform updates
  90919. */
  90920. setColor4(name: string, value: Color4): ShaderMaterial;
  90921. /**
  90922. * Set a vec4 array in the shader from a Color4 array.
  90923. * @param name Define the name of the uniform as defined in the shader
  90924. * @param value Define the value to give to the uniform
  90925. * @return the material itself allowing "fluent" like uniform updates
  90926. */
  90927. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  90928. /**
  90929. * Set a vec2 in the shader from a Vector2.
  90930. * @param name Define the name of the uniform as defined in the shader
  90931. * @param value Define the value to give to the uniform
  90932. * @return the material itself allowing "fluent" like uniform updates
  90933. */
  90934. setVector2(name: string, value: Vector2): ShaderMaterial;
  90935. /**
  90936. * Set a vec3 in the shader from a Vector3.
  90937. * @param name Define the name of the uniform as defined in the shader
  90938. * @param value Define the value to give to the uniform
  90939. * @return the material itself allowing "fluent" like uniform updates
  90940. */
  90941. setVector3(name: string, value: Vector3): ShaderMaterial;
  90942. /**
  90943. * Set a vec4 in the shader from a Vector4.
  90944. * @param name Define the name of the uniform as defined in the shader
  90945. * @param value Define the value to give to the uniform
  90946. * @return the material itself allowing "fluent" like uniform updates
  90947. */
  90948. setVector4(name: string, value: Vector4): ShaderMaterial;
  90949. /**
  90950. * Set a mat4 in the shader from a Matrix.
  90951. * @param name Define the name of the uniform as defined in the shader
  90952. * @param value Define the value to give to the uniform
  90953. * @return the material itself allowing "fluent" like uniform updates
  90954. */
  90955. setMatrix(name: string, value: Matrix): ShaderMaterial;
  90956. /**
  90957. * Set a float32Array in the shader from a matrix array.
  90958. * @param name Define the name of the uniform as defined in the shader
  90959. * @param value Define the value to give to the uniform
  90960. * @return the material itself allowing "fluent" like uniform updates
  90961. */
  90962. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  90963. /**
  90964. * Set a mat3 in the shader from a Float32Array.
  90965. * @param name Define the name of the uniform as defined in the shader
  90966. * @param value Define the value to give to the uniform
  90967. * @return the material itself allowing "fluent" like uniform updates
  90968. */
  90969. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  90970. /**
  90971. * Set a mat2 in the shader from a Float32Array.
  90972. * @param name Define the name of the uniform as defined in the shader
  90973. * @param value Define the value to give to the uniform
  90974. * @return the material itself allowing "fluent" like uniform updates
  90975. */
  90976. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  90977. /**
  90978. * Set a vec2 array in the shader from a number array.
  90979. * @param name Define the name of the uniform as defined in the shader
  90980. * @param value Define the value to give to the uniform
  90981. * @return the material itself allowing "fluent" like uniform updates
  90982. */
  90983. setArray2(name: string, value: number[]): ShaderMaterial;
  90984. /**
  90985. * Set a vec3 array in the shader from a number array.
  90986. * @param name Define the name of the uniform as defined in the shader
  90987. * @param value Define the value to give to the uniform
  90988. * @return the material itself allowing "fluent" like uniform updates
  90989. */
  90990. setArray3(name: string, value: number[]): ShaderMaterial;
  90991. /**
  90992. * Set a vec4 array in the shader from a number array.
  90993. * @param name Define the name of the uniform as defined in the shader
  90994. * @param value Define the value to give to the uniform
  90995. * @return the material itself allowing "fluent" like uniform updates
  90996. */
  90997. setArray4(name: string, value: number[]): ShaderMaterial;
  90998. private _checkCache;
  90999. /**
  91000. * Specifies that the submesh is ready to be used
  91001. * @param mesh defines the mesh to check
  91002. * @param subMesh defines which submesh to check
  91003. * @param useInstances specifies that instances should be used
  91004. * @returns a boolean indicating that the submesh is ready or not
  91005. */
  91006. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  91007. /**
  91008. * Checks if the material is ready to render the requested mesh
  91009. * @param mesh Define the mesh to render
  91010. * @param useInstances Define whether or not the material is used with instances
  91011. * @returns true if ready, otherwise false
  91012. */
  91013. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  91014. /**
  91015. * Binds the world matrix to the material
  91016. * @param world defines the world transformation matrix
  91017. */
  91018. bindOnlyWorldMatrix(world: Matrix): void;
  91019. /**
  91020. * Binds the material to the mesh
  91021. * @param world defines the world transformation matrix
  91022. * @param mesh defines the mesh to bind the material to
  91023. */
  91024. bind(world: Matrix, mesh?: Mesh): void;
  91025. /**
  91026. * Gets the active textures from the material
  91027. * @returns an array of textures
  91028. */
  91029. getActiveTextures(): BaseTexture[];
  91030. /**
  91031. * Specifies if the material uses a texture
  91032. * @param texture defines the texture to check against the material
  91033. * @returns a boolean specifying if the material uses the texture
  91034. */
  91035. hasTexture(texture: BaseTexture): boolean;
  91036. /**
  91037. * Makes a duplicate of the material, and gives it a new name
  91038. * @param name defines the new name for the duplicated material
  91039. * @returns the cloned material
  91040. */
  91041. clone(name: string): ShaderMaterial;
  91042. /**
  91043. * Disposes the material
  91044. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  91045. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  91046. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  91047. */
  91048. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  91049. /**
  91050. * Serializes this material in a JSON representation
  91051. * @returns the serialized material object
  91052. */
  91053. serialize(): any;
  91054. /**
  91055. * Creates a shader material from parsed shader material data
  91056. * @param source defines the JSON represnetation of the material
  91057. * @param scene defines the hosting scene
  91058. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91059. * @returns a new material
  91060. */
  91061. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  91062. }
  91063. }
  91064. declare module BABYLON {
  91065. /** @hidden */
  91066. export var colorPixelShader: {
  91067. name: string;
  91068. shader: string;
  91069. };
  91070. }
  91071. declare module BABYLON {
  91072. /** @hidden */
  91073. export var colorVertexShader: {
  91074. name: string;
  91075. shader: string;
  91076. };
  91077. }
  91078. declare module BABYLON {
  91079. /**
  91080. * Line mesh
  91081. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  91082. */
  91083. export class LinesMesh extends Mesh {
  91084. /**
  91085. * If vertex color should be applied to the mesh
  91086. */
  91087. readonly useVertexColor?: boolean | undefined;
  91088. /**
  91089. * If vertex alpha should be applied to the mesh
  91090. */
  91091. readonly useVertexAlpha?: boolean | undefined;
  91092. /**
  91093. * Color of the line (Default: White)
  91094. */
  91095. color: Color3;
  91096. /**
  91097. * Alpha of the line (Default: 1)
  91098. */
  91099. alpha: number;
  91100. /**
  91101. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91102. * This margin is expressed in world space coordinates, so its value may vary.
  91103. * Default value is 0.1
  91104. */
  91105. intersectionThreshold: number;
  91106. private _colorShader;
  91107. private color4;
  91108. /**
  91109. * Creates a new LinesMesh
  91110. * @param name defines the name
  91111. * @param scene defines the hosting scene
  91112. * @param parent defines the parent mesh if any
  91113. * @param source defines the optional source LinesMesh used to clone data from
  91114. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  91115. * When false, achieved by calling a clone(), also passing False.
  91116. * This will make creation of children, recursive.
  91117. * @param useVertexColor defines if this LinesMesh supports vertex color
  91118. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  91119. */
  91120. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  91121. /**
  91122. * If vertex color should be applied to the mesh
  91123. */
  91124. useVertexColor?: boolean | undefined,
  91125. /**
  91126. * If vertex alpha should be applied to the mesh
  91127. */
  91128. useVertexAlpha?: boolean | undefined);
  91129. private _addClipPlaneDefine;
  91130. private _removeClipPlaneDefine;
  91131. isReady(): boolean;
  91132. /**
  91133. * Returns the string "LineMesh"
  91134. */
  91135. getClassName(): string;
  91136. /**
  91137. * @hidden
  91138. */
  91139. get material(): Material;
  91140. /**
  91141. * @hidden
  91142. */
  91143. set material(value: Material);
  91144. /**
  91145. * @hidden
  91146. */
  91147. get checkCollisions(): boolean;
  91148. /** @hidden */
  91149. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  91150. /** @hidden */
  91151. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  91152. /**
  91153. * Disposes of the line mesh
  91154. * @param doNotRecurse If children should be disposed
  91155. */
  91156. dispose(doNotRecurse?: boolean): void;
  91157. /**
  91158. * Returns a new LineMesh object cloned from the current one.
  91159. */
  91160. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  91161. /**
  91162. * Creates a new InstancedLinesMesh object from the mesh model.
  91163. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91164. * @param name defines the name of the new instance
  91165. * @returns a new InstancedLinesMesh
  91166. */
  91167. createInstance(name: string): InstancedLinesMesh;
  91168. }
  91169. /**
  91170. * Creates an instance based on a source LinesMesh
  91171. */
  91172. export class InstancedLinesMesh extends InstancedMesh {
  91173. /**
  91174. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  91175. * This margin is expressed in world space coordinates, so its value may vary.
  91176. * Initilized with the intersectionThreshold value of the source LinesMesh
  91177. */
  91178. intersectionThreshold: number;
  91179. constructor(name: string, source: LinesMesh);
  91180. /**
  91181. * Returns the string "InstancedLinesMesh".
  91182. */
  91183. getClassName(): string;
  91184. }
  91185. }
  91186. declare module BABYLON {
  91187. /** @hidden */
  91188. export var linePixelShader: {
  91189. name: string;
  91190. shader: string;
  91191. };
  91192. }
  91193. declare module BABYLON {
  91194. /** @hidden */
  91195. export var lineVertexShader: {
  91196. name: string;
  91197. shader: string;
  91198. };
  91199. }
  91200. declare module BABYLON {
  91201. interface AbstractMesh {
  91202. /**
  91203. * Gets the edgesRenderer associated with the mesh
  91204. */
  91205. edgesRenderer: Nullable<EdgesRenderer>;
  91206. }
  91207. interface LinesMesh {
  91208. /**
  91209. * Enables the edge rendering mode on the mesh.
  91210. * This mode makes the mesh edges visible
  91211. * @param epsilon defines the maximal distance between two angles to detect a face
  91212. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91213. * @returns the currentAbstractMesh
  91214. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91215. */
  91216. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  91217. }
  91218. interface InstancedLinesMesh {
  91219. /**
  91220. * Enables the edge rendering mode on the mesh.
  91221. * This mode makes the mesh edges visible
  91222. * @param epsilon defines the maximal distance between two angles to detect a face
  91223. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  91224. * @returns the current InstancedLinesMesh
  91225. * @see https://www.babylonjs-playground.com/#19O9TU#0
  91226. */
  91227. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  91228. }
  91229. /**
  91230. * Defines the minimum contract an Edges renderer should follow.
  91231. */
  91232. export interface IEdgesRenderer extends IDisposable {
  91233. /**
  91234. * Gets or sets a boolean indicating if the edgesRenderer is active
  91235. */
  91236. isEnabled: boolean;
  91237. /**
  91238. * Renders the edges of the attached mesh,
  91239. */
  91240. render(): void;
  91241. /**
  91242. * Checks wether or not the edges renderer is ready to render.
  91243. * @return true if ready, otherwise false.
  91244. */
  91245. isReady(): boolean;
  91246. }
  91247. /**
  91248. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  91249. */
  91250. export class EdgesRenderer implements IEdgesRenderer {
  91251. /**
  91252. * Define the size of the edges with an orthographic camera
  91253. */
  91254. edgesWidthScalerForOrthographic: number;
  91255. /**
  91256. * Define the size of the edges with a perspective camera
  91257. */
  91258. edgesWidthScalerForPerspective: number;
  91259. protected _source: AbstractMesh;
  91260. protected _linesPositions: number[];
  91261. protected _linesNormals: number[];
  91262. protected _linesIndices: number[];
  91263. protected _epsilon: number;
  91264. protected _indicesCount: number;
  91265. protected _lineShader: ShaderMaterial;
  91266. protected _ib: DataBuffer;
  91267. protected _buffers: {
  91268. [key: string]: Nullable<VertexBuffer>;
  91269. };
  91270. protected _checkVerticesInsteadOfIndices: boolean;
  91271. private _meshRebuildObserver;
  91272. private _meshDisposeObserver;
  91273. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  91274. isEnabled: boolean;
  91275. /**
  91276. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  91277. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  91278. * @param source Mesh used to create edges
  91279. * @param epsilon sum of angles in adjacency to check for edge
  91280. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  91281. * @param generateEdgesLines - should generate Lines or only prepare resources.
  91282. */
  91283. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  91284. protected _prepareRessources(): void;
  91285. /** @hidden */
  91286. _rebuild(): void;
  91287. /**
  91288. * Releases the required resources for the edges renderer
  91289. */
  91290. dispose(): void;
  91291. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  91292. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  91293. /**
  91294. * Checks if the pair of p0 and p1 is en edge
  91295. * @param faceIndex
  91296. * @param edge
  91297. * @param faceNormals
  91298. * @param p0
  91299. * @param p1
  91300. * @private
  91301. */
  91302. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  91303. /**
  91304. * push line into the position, normal and index buffer
  91305. * @protected
  91306. */
  91307. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  91308. /**
  91309. * Generates lines edges from adjacencjes
  91310. * @private
  91311. */
  91312. _generateEdgesLines(): void;
  91313. /**
  91314. * Checks wether or not the edges renderer is ready to render.
  91315. * @return true if ready, otherwise false.
  91316. */
  91317. isReady(): boolean;
  91318. /**
  91319. * Renders the edges of the attached mesh,
  91320. */
  91321. render(): void;
  91322. }
  91323. /**
  91324. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  91325. */
  91326. export class LineEdgesRenderer extends EdgesRenderer {
  91327. /**
  91328. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  91329. * @param source LineMesh used to generate edges
  91330. * @param epsilon not important (specified angle for edge detection)
  91331. * @param checkVerticesInsteadOfIndices not important for LineMesh
  91332. */
  91333. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  91334. /**
  91335. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  91336. */
  91337. _generateEdgesLines(): void;
  91338. }
  91339. }
  91340. declare module BABYLON {
  91341. /**
  91342. * This represents the object necessary to create a rendering group.
  91343. * This is exclusively used and created by the rendering manager.
  91344. * To modify the behavior, you use the available helpers in your scene or meshes.
  91345. * @hidden
  91346. */
  91347. export class RenderingGroup {
  91348. index: number;
  91349. private static _zeroVector;
  91350. private _scene;
  91351. private _opaqueSubMeshes;
  91352. private _transparentSubMeshes;
  91353. private _alphaTestSubMeshes;
  91354. private _depthOnlySubMeshes;
  91355. private _particleSystems;
  91356. private _spriteManagers;
  91357. private _opaqueSortCompareFn;
  91358. private _alphaTestSortCompareFn;
  91359. private _transparentSortCompareFn;
  91360. private _renderOpaque;
  91361. private _renderAlphaTest;
  91362. private _renderTransparent;
  91363. /** @hidden */
  91364. _edgesRenderers: SmartArray<IEdgesRenderer>;
  91365. onBeforeTransparentRendering: () => void;
  91366. /**
  91367. * Set the opaque sort comparison function.
  91368. * If null the sub meshes will be render in the order they were created
  91369. */
  91370. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91371. /**
  91372. * Set the alpha test sort comparison function.
  91373. * If null the sub meshes will be render in the order they were created
  91374. */
  91375. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91376. /**
  91377. * Set the transparent sort comparison function.
  91378. * If null the sub meshes will be render in the order they were created
  91379. */
  91380. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  91381. /**
  91382. * Creates a new rendering group.
  91383. * @param index The rendering group index
  91384. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  91385. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  91386. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  91387. */
  91388. 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>);
  91389. /**
  91390. * Render all the sub meshes contained in the group.
  91391. * @param customRenderFunction Used to override the default render behaviour of the group.
  91392. * @returns true if rendered some submeshes.
  91393. */
  91394. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  91395. /**
  91396. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  91397. * @param subMeshes The submeshes to render
  91398. */
  91399. private renderOpaqueSorted;
  91400. /**
  91401. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  91402. * @param subMeshes The submeshes to render
  91403. */
  91404. private renderAlphaTestSorted;
  91405. /**
  91406. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  91407. * @param subMeshes The submeshes to render
  91408. */
  91409. private renderTransparentSorted;
  91410. /**
  91411. * Renders the submeshes in a specified order.
  91412. * @param subMeshes The submeshes to sort before render
  91413. * @param sortCompareFn The comparison function use to sort
  91414. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  91415. * @param transparent Specifies to activate blending if true
  91416. */
  91417. private static renderSorted;
  91418. /**
  91419. * Renders the submeshes in the order they were dispatched (no sort applied).
  91420. * @param subMeshes The submeshes to render
  91421. */
  91422. private static renderUnsorted;
  91423. /**
  91424. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91425. * are rendered back to front if in the same alpha index.
  91426. *
  91427. * @param a The first submesh
  91428. * @param b The second submesh
  91429. * @returns The result of the comparison
  91430. */
  91431. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  91432. /**
  91433. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91434. * are rendered back to front.
  91435. *
  91436. * @param a The first submesh
  91437. * @param b The second submesh
  91438. * @returns The result of the comparison
  91439. */
  91440. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  91441. /**
  91442. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  91443. * are rendered front to back (prevent overdraw).
  91444. *
  91445. * @param a The first submesh
  91446. * @param b The second submesh
  91447. * @returns The result of the comparison
  91448. */
  91449. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  91450. /**
  91451. * Resets the different lists of submeshes to prepare a new frame.
  91452. */
  91453. prepare(): void;
  91454. dispose(): void;
  91455. /**
  91456. * Inserts the submesh in its correct queue depending on its material.
  91457. * @param subMesh The submesh to dispatch
  91458. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  91459. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  91460. */
  91461. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  91462. dispatchSprites(spriteManager: ISpriteManager): void;
  91463. dispatchParticles(particleSystem: IParticleSystem): void;
  91464. private _renderParticles;
  91465. private _renderSprites;
  91466. }
  91467. }
  91468. declare module BABYLON {
  91469. /**
  91470. * Interface describing the different options available in the rendering manager
  91471. * regarding Auto Clear between groups.
  91472. */
  91473. export interface IRenderingManagerAutoClearSetup {
  91474. /**
  91475. * Defines whether or not autoclear is enable.
  91476. */
  91477. autoClear: boolean;
  91478. /**
  91479. * Defines whether or not to autoclear the depth buffer.
  91480. */
  91481. depth: boolean;
  91482. /**
  91483. * Defines whether or not to autoclear the stencil buffer.
  91484. */
  91485. stencil: boolean;
  91486. }
  91487. /**
  91488. * This class is used by the onRenderingGroupObservable
  91489. */
  91490. export class RenderingGroupInfo {
  91491. /**
  91492. * The Scene that being rendered
  91493. */
  91494. scene: Scene;
  91495. /**
  91496. * The camera currently used for the rendering pass
  91497. */
  91498. camera: Nullable<Camera>;
  91499. /**
  91500. * The ID of the renderingGroup being processed
  91501. */
  91502. renderingGroupId: number;
  91503. }
  91504. /**
  91505. * This is the manager responsible of all the rendering for meshes sprites and particles.
  91506. * It is enable to manage the different groups as well as the different necessary sort functions.
  91507. * This should not be used directly aside of the few static configurations
  91508. */
  91509. export class RenderingManager {
  91510. /**
  91511. * The max id used for rendering groups (not included)
  91512. */
  91513. static MAX_RENDERINGGROUPS: number;
  91514. /**
  91515. * The min id used for rendering groups (included)
  91516. */
  91517. static MIN_RENDERINGGROUPS: number;
  91518. /**
  91519. * Used to globally prevent autoclearing scenes.
  91520. */
  91521. static AUTOCLEAR: boolean;
  91522. /**
  91523. * @hidden
  91524. */
  91525. _useSceneAutoClearSetup: boolean;
  91526. private _scene;
  91527. private _renderingGroups;
  91528. private _depthStencilBufferAlreadyCleaned;
  91529. private _autoClearDepthStencil;
  91530. private _customOpaqueSortCompareFn;
  91531. private _customAlphaTestSortCompareFn;
  91532. private _customTransparentSortCompareFn;
  91533. private _renderingGroupInfo;
  91534. /**
  91535. * Instantiates a new rendering group for a particular scene
  91536. * @param scene Defines the scene the groups belongs to
  91537. */
  91538. constructor(scene: Scene);
  91539. private _clearDepthStencilBuffer;
  91540. /**
  91541. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  91542. * @hidden
  91543. */
  91544. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  91545. /**
  91546. * Resets the different information of the group to prepare a new frame
  91547. * @hidden
  91548. */
  91549. reset(): void;
  91550. /**
  91551. * Dispose and release the group and its associated resources.
  91552. * @hidden
  91553. */
  91554. dispose(): void;
  91555. /**
  91556. * Clear the info related to rendering groups preventing retention points during dispose.
  91557. */
  91558. freeRenderingGroups(): void;
  91559. private _prepareRenderingGroup;
  91560. /**
  91561. * Add a sprite manager to the rendering manager in order to render it this frame.
  91562. * @param spriteManager Define the sprite manager to render
  91563. */
  91564. dispatchSprites(spriteManager: ISpriteManager): void;
  91565. /**
  91566. * Add a particle system to the rendering manager in order to render it this frame.
  91567. * @param particleSystem Define the particle system to render
  91568. */
  91569. dispatchParticles(particleSystem: IParticleSystem): void;
  91570. /**
  91571. * Add a submesh to the manager in order to render it this frame
  91572. * @param subMesh The submesh to dispatch
  91573. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  91574. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  91575. */
  91576. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  91577. /**
  91578. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91579. * This allowed control for front to back rendering or reversly depending of the special needs.
  91580. *
  91581. * @param renderingGroupId The rendering group id corresponding to its index
  91582. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91583. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91584. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91585. */
  91586. 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;
  91587. /**
  91588. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91589. *
  91590. * @param renderingGroupId The rendering group id corresponding to its index
  91591. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91592. * @param depth Automatically clears depth between groups if true and autoClear is true.
  91593. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  91594. */
  91595. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  91596. /**
  91597. * Gets the current auto clear configuration for one rendering group of the rendering
  91598. * manager.
  91599. * @param index the rendering group index to get the information for
  91600. * @returns The auto clear setup for the requested rendering group
  91601. */
  91602. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  91603. }
  91604. }
  91605. declare module BABYLON {
  91606. /**
  91607. * This Helps creating a texture that will be created from a camera in your scene.
  91608. * It is basically a dynamic texture that could be used to create special effects for instance.
  91609. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  91610. */
  91611. export class RenderTargetTexture extends Texture {
  91612. isCube: boolean;
  91613. /**
  91614. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  91615. */
  91616. static readonly REFRESHRATE_RENDER_ONCE: number;
  91617. /**
  91618. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  91619. */
  91620. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  91621. /**
  91622. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  91623. * the central point of your effect and can save a lot of performances.
  91624. */
  91625. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  91626. /**
  91627. * Use this predicate to dynamically define the list of mesh you want to render.
  91628. * If set, the renderList property will be overwritten.
  91629. */
  91630. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  91631. private _renderList;
  91632. /**
  91633. * Use this list to define the list of mesh you want to render.
  91634. */
  91635. get renderList(): Nullable<Array<AbstractMesh>>;
  91636. set renderList(value: Nullable<Array<AbstractMesh>>);
  91637. private _hookArray;
  91638. /**
  91639. * Define if particles should be rendered in your texture.
  91640. */
  91641. renderParticles: boolean;
  91642. /**
  91643. * Define if sprites should be rendered in your texture.
  91644. */
  91645. renderSprites: boolean;
  91646. /**
  91647. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  91648. */
  91649. coordinatesMode: number;
  91650. /**
  91651. * Define the camera used to render the texture.
  91652. */
  91653. activeCamera: Nullable<Camera>;
  91654. /**
  91655. * Override the render function of the texture with your own one.
  91656. */
  91657. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  91658. /**
  91659. * Define if camera post processes should be use while rendering the texture.
  91660. */
  91661. useCameraPostProcesses: boolean;
  91662. /**
  91663. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  91664. */
  91665. ignoreCameraViewport: boolean;
  91666. private _postProcessManager;
  91667. private _postProcesses;
  91668. private _resizeObserver;
  91669. /**
  91670. * An event triggered when the texture is unbind.
  91671. */
  91672. onBeforeBindObservable: Observable<RenderTargetTexture>;
  91673. /**
  91674. * An event triggered when the texture is unbind.
  91675. */
  91676. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  91677. private _onAfterUnbindObserver;
  91678. /**
  91679. * Set a after unbind callback in the texture.
  91680. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  91681. */
  91682. set onAfterUnbind(callback: () => void);
  91683. /**
  91684. * An event triggered before rendering the texture
  91685. */
  91686. onBeforeRenderObservable: Observable<number>;
  91687. private _onBeforeRenderObserver;
  91688. /**
  91689. * Set a before render callback in the texture.
  91690. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  91691. */
  91692. set onBeforeRender(callback: (faceIndex: number) => void);
  91693. /**
  91694. * An event triggered after rendering the texture
  91695. */
  91696. onAfterRenderObservable: Observable<number>;
  91697. private _onAfterRenderObserver;
  91698. /**
  91699. * Set a after render callback in the texture.
  91700. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  91701. */
  91702. set onAfterRender(callback: (faceIndex: number) => void);
  91703. /**
  91704. * An event triggered after the texture clear
  91705. */
  91706. onClearObservable: Observable<Engine>;
  91707. private _onClearObserver;
  91708. /**
  91709. * Set a clear callback in the texture.
  91710. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  91711. */
  91712. set onClear(callback: (Engine: Engine) => void);
  91713. /**
  91714. * An event triggered when the texture is resized.
  91715. */
  91716. onResizeObservable: Observable<RenderTargetTexture>;
  91717. /**
  91718. * Define the clear color of the Render Target if it should be different from the scene.
  91719. */
  91720. clearColor: Color4;
  91721. protected _size: number | {
  91722. width: number;
  91723. height: number;
  91724. };
  91725. protected _initialSizeParameter: number | {
  91726. width: number;
  91727. height: number;
  91728. } | {
  91729. ratio: number;
  91730. };
  91731. protected _sizeRatio: Nullable<number>;
  91732. /** @hidden */
  91733. _generateMipMaps: boolean;
  91734. protected _renderingManager: RenderingManager;
  91735. /** @hidden */
  91736. _waitingRenderList: string[];
  91737. protected _doNotChangeAspectRatio: boolean;
  91738. protected _currentRefreshId: number;
  91739. protected _refreshRate: number;
  91740. protected _textureMatrix: Matrix;
  91741. protected _samples: number;
  91742. protected _renderTargetOptions: RenderTargetCreationOptions;
  91743. /**
  91744. * Gets render target creation options that were used.
  91745. */
  91746. get renderTargetOptions(): RenderTargetCreationOptions;
  91747. protected _engine: Engine;
  91748. protected _onRatioRescale(): void;
  91749. /**
  91750. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  91751. * It must define where the camera used to render the texture is set
  91752. */
  91753. boundingBoxPosition: Vector3;
  91754. private _boundingBoxSize;
  91755. /**
  91756. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  91757. * When defined, the cubemap will switch to local mode
  91758. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  91759. * @example https://www.babylonjs-playground.com/#RNASML
  91760. */
  91761. set boundingBoxSize(value: Vector3);
  91762. get boundingBoxSize(): Vector3;
  91763. /**
  91764. * In case the RTT has been created with a depth texture, get the associated
  91765. * depth texture.
  91766. * Otherwise, return null.
  91767. */
  91768. depthStencilTexture: Nullable<InternalTexture>;
  91769. /**
  91770. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  91771. * or used a shadow, depth texture...
  91772. * @param name The friendly name of the texture
  91773. * @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)
  91774. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  91775. * @param generateMipMaps True if mip maps need to be generated after render.
  91776. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  91777. * @param type The type of the buffer in the RTT (int, half float, float...)
  91778. * @param isCube True if a cube texture needs to be created
  91779. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  91780. * @param generateDepthBuffer True to generate a depth buffer
  91781. * @param generateStencilBuffer True to generate a stencil buffer
  91782. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  91783. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  91784. * @param delayAllocation if the texture allocation should be delayed (default: false)
  91785. */
  91786. constructor(name: string, size: number | {
  91787. width: number;
  91788. height: number;
  91789. } | {
  91790. ratio: number;
  91791. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  91792. /**
  91793. * Creates a depth stencil texture.
  91794. * This is only available in WebGL 2 or with the depth texture extension available.
  91795. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  91796. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  91797. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  91798. */
  91799. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  91800. private _processSizeParameter;
  91801. /**
  91802. * Define the number of samples to use in case of MSAA.
  91803. * It defaults to one meaning no MSAA has been enabled.
  91804. */
  91805. get samples(): number;
  91806. set samples(value: number);
  91807. /**
  91808. * Resets the refresh counter of the texture and start bak from scratch.
  91809. * Could be useful to regenerate the texture if it is setup to render only once.
  91810. */
  91811. resetRefreshCounter(): void;
  91812. /**
  91813. * Define the refresh rate of the texture or the rendering frequency.
  91814. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  91815. */
  91816. get refreshRate(): number;
  91817. set refreshRate(value: number);
  91818. /**
  91819. * Adds a post process to the render target rendering passes.
  91820. * @param postProcess define the post process to add
  91821. */
  91822. addPostProcess(postProcess: PostProcess): void;
  91823. /**
  91824. * Clear all the post processes attached to the render target
  91825. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  91826. */
  91827. clearPostProcesses(dispose?: boolean): void;
  91828. /**
  91829. * Remove one of the post process from the list of attached post processes to the texture
  91830. * @param postProcess define the post process to remove from the list
  91831. */
  91832. removePostProcess(postProcess: PostProcess): void;
  91833. /** @hidden */
  91834. _shouldRender(): boolean;
  91835. /**
  91836. * Gets the actual render size of the texture.
  91837. * @returns the width of the render size
  91838. */
  91839. getRenderSize(): number;
  91840. /**
  91841. * Gets the actual render width of the texture.
  91842. * @returns the width of the render size
  91843. */
  91844. getRenderWidth(): number;
  91845. /**
  91846. * Gets the actual render height of the texture.
  91847. * @returns the height of the render size
  91848. */
  91849. getRenderHeight(): number;
  91850. /**
  91851. * Get if the texture can be rescaled or not.
  91852. */
  91853. get canRescale(): boolean;
  91854. /**
  91855. * Resize the texture using a ratio.
  91856. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  91857. */
  91858. scale(ratio: number): void;
  91859. /**
  91860. * Get the texture reflection matrix used to rotate/transform the reflection.
  91861. * @returns the reflection matrix
  91862. */
  91863. getReflectionTextureMatrix(): Matrix;
  91864. /**
  91865. * Resize the texture to a new desired size.
  91866. * Be carrefull as it will recreate all the data in the new texture.
  91867. * @param size Define the new size. It can be:
  91868. * - a number for squared texture,
  91869. * - an object containing { width: number, height: number }
  91870. * - or an object containing a ratio { ratio: number }
  91871. */
  91872. resize(size: number | {
  91873. width: number;
  91874. height: number;
  91875. } | {
  91876. ratio: number;
  91877. }): void;
  91878. /**
  91879. * Renders all the objects from the render list into the texture.
  91880. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  91881. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  91882. */
  91883. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  91884. private _bestReflectionRenderTargetDimension;
  91885. /**
  91886. * @hidden
  91887. * @param faceIndex face index to bind to if this is a cubetexture
  91888. */
  91889. _bindFrameBuffer(faceIndex?: number): void;
  91890. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  91891. private renderToTarget;
  91892. /**
  91893. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  91894. * This allowed control for front to back rendering or reversly depending of the special needs.
  91895. *
  91896. * @param renderingGroupId The rendering group id corresponding to its index
  91897. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  91898. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  91899. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  91900. */
  91901. 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;
  91902. /**
  91903. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  91904. *
  91905. * @param renderingGroupId The rendering group id corresponding to its index
  91906. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  91907. */
  91908. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  91909. /**
  91910. * Clones the texture.
  91911. * @returns the cloned texture
  91912. */
  91913. clone(): RenderTargetTexture;
  91914. /**
  91915. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  91916. * @returns The JSON representation of the texture
  91917. */
  91918. serialize(): any;
  91919. /**
  91920. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  91921. */
  91922. disposeFramebufferObjects(): void;
  91923. /**
  91924. * Dispose the texture and release its associated resources.
  91925. */
  91926. dispose(): void;
  91927. /** @hidden */
  91928. _rebuild(): void;
  91929. /**
  91930. * Clear the info related to rendering groups preventing retention point in material dispose.
  91931. */
  91932. freeRenderingGroups(): void;
  91933. /**
  91934. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  91935. * @returns the view count
  91936. */
  91937. getViewCount(): number;
  91938. }
  91939. }
  91940. declare module BABYLON {
  91941. /**
  91942. * Options for compiling materials.
  91943. */
  91944. export interface IMaterialCompilationOptions {
  91945. /**
  91946. * Defines whether clip planes are enabled.
  91947. */
  91948. clipPlane: boolean;
  91949. /**
  91950. * Defines whether instances are enabled.
  91951. */
  91952. useInstances: boolean;
  91953. }
  91954. /**
  91955. * Base class for the main features of a material in Babylon.js
  91956. */
  91957. export class Material implements IAnimatable {
  91958. /**
  91959. * Returns the triangle fill mode
  91960. */
  91961. static readonly TriangleFillMode: number;
  91962. /**
  91963. * Returns the wireframe mode
  91964. */
  91965. static readonly WireFrameFillMode: number;
  91966. /**
  91967. * Returns the point fill mode
  91968. */
  91969. static readonly PointFillMode: number;
  91970. /**
  91971. * Returns the point list draw mode
  91972. */
  91973. static readonly PointListDrawMode: number;
  91974. /**
  91975. * Returns the line list draw mode
  91976. */
  91977. static readonly LineListDrawMode: number;
  91978. /**
  91979. * Returns the line loop draw mode
  91980. */
  91981. static readonly LineLoopDrawMode: number;
  91982. /**
  91983. * Returns the line strip draw mode
  91984. */
  91985. static readonly LineStripDrawMode: number;
  91986. /**
  91987. * Returns the triangle strip draw mode
  91988. */
  91989. static readonly TriangleStripDrawMode: number;
  91990. /**
  91991. * Returns the triangle fan draw mode
  91992. */
  91993. static readonly TriangleFanDrawMode: number;
  91994. /**
  91995. * Stores the clock-wise side orientation
  91996. */
  91997. static readonly ClockWiseSideOrientation: number;
  91998. /**
  91999. * Stores the counter clock-wise side orientation
  92000. */
  92001. static readonly CounterClockWiseSideOrientation: number;
  92002. /**
  92003. * The dirty texture flag value
  92004. */
  92005. static readonly TextureDirtyFlag: number;
  92006. /**
  92007. * The dirty light flag value
  92008. */
  92009. static readonly LightDirtyFlag: number;
  92010. /**
  92011. * The dirty fresnel flag value
  92012. */
  92013. static readonly FresnelDirtyFlag: number;
  92014. /**
  92015. * The dirty attribute flag value
  92016. */
  92017. static readonly AttributesDirtyFlag: number;
  92018. /**
  92019. * The dirty misc flag value
  92020. */
  92021. static readonly MiscDirtyFlag: number;
  92022. /**
  92023. * The all dirty flag value
  92024. */
  92025. static readonly AllDirtyFlag: number;
  92026. /**
  92027. * The ID of the material
  92028. */
  92029. id: string;
  92030. /**
  92031. * Gets or sets the unique id of the material
  92032. */
  92033. uniqueId: number;
  92034. /**
  92035. * The name of the material
  92036. */
  92037. name: string;
  92038. /**
  92039. * Gets or sets user defined metadata
  92040. */
  92041. metadata: any;
  92042. /**
  92043. * For internal use only. Please do not use.
  92044. */
  92045. reservedDataStore: any;
  92046. /**
  92047. * Specifies if the ready state should be checked on each call
  92048. */
  92049. checkReadyOnEveryCall: boolean;
  92050. /**
  92051. * Specifies if the ready state should be checked once
  92052. */
  92053. checkReadyOnlyOnce: boolean;
  92054. /**
  92055. * The state of the material
  92056. */
  92057. state: string;
  92058. /**
  92059. * The alpha value of the material
  92060. */
  92061. protected _alpha: number;
  92062. /**
  92063. * List of inspectable custom properties (used by the Inspector)
  92064. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92065. */
  92066. inspectableCustomProperties: IInspectable[];
  92067. /**
  92068. * Sets the alpha value of the material
  92069. */
  92070. set alpha(value: number);
  92071. /**
  92072. * Gets the alpha value of the material
  92073. */
  92074. get alpha(): number;
  92075. /**
  92076. * Specifies if back face culling is enabled
  92077. */
  92078. protected _backFaceCulling: boolean;
  92079. /**
  92080. * Sets the back-face culling state
  92081. */
  92082. set backFaceCulling(value: boolean);
  92083. /**
  92084. * Gets the back-face culling state
  92085. */
  92086. get backFaceCulling(): boolean;
  92087. /**
  92088. * Stores the value for side orientation
  92089. */
  92090. sideOrientation: number;
  92091. /**
  92092. * Callback triggered when the material is compiled
  92093. */
  92094. onCompiled: Nullable<(effect: Effect) => void>;
  92095. /**
  92096. * Callback triggered when an error occurs
  92097. */
  92098. onError: Nullable<(effect: Effect, errors: string) => void>;
  92099. /**
  92100. * Callback triggered to get the render target textures
  92101. */
  92102. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  92103. /**
  92104. * Gets a boolean indicating that current material needs to register RTT
  92105. */
  92106. get hasRenderTargetTextures(): boolean;
  92107. /**
  92108. * Specifies if the material should be serialized
  92109. */
  92110. doNotSerialize: boolean;
  92111. /**
  92112. * @hidden
  92113. */
  92114. _storeEffectOnSubMeshes: boolean;
  92115. /**
  92116. * Stores the animations for the material
  92117. */
  92118. animations: Nullable<Array<Animation>>;
  92119. /**
  92120. * An event triggered when the material is disposed
  92121. */
  92122. onDisposeObservable: Observable<Material>;
  92123. /**
  92124. * An observer which watches for dispose events
  92125. */
  92126. private _onDisposeObserver;
  92127. private _onUnBindObservable;
  92128. /**
  92129. * Called during a dispose event
  92130. */
  92131. set onDispose(callback: () => void);
  92132. private _onBindObservable;
  92133. /**
  92134. * An event triggered when the material is bound
  92135. */
  92136. get onBindObservable(): Observable<AbstractMesh>;
  92137. /**
  92138. * An observer which watches for bind events
  92139. */
  92140. private _onBindObserver;
  92141. /**
  92142. * Called during a bind event
  92143. */
  92144. set onBind(callback: (Mesh: AbstractMesh) => void);
  92145. /**
  92146. * An event triggered when the material is unbound
  92147. */
  92148. get onUnBindObservable(): Observable<Material>;
  92149. /**
  92150. * Stores the value of the alpha mode
  92151. */
  92152. private _alphaMode;
  92153. /**
  92154. * Sets the value of the alpha mode.
  92155. *
  92156. * | Value | Type | Description |
  92157. * | --- | --- | --- |
  92158. * | 0 | ALPHA_DISABLE | |
  92159. * | 1 | ALPHA_ADD | |
  92160. * | 2 | ALPHA_COMBINE | |
  92161. * | 3 | ALPHA_SUBTRACT | |
  92162. * | 4 | ALPHA_MULTIPLY | |
  92163. * | 5 | ALPHA_MAXIMIZED | |
  92164. * | 6 | ALPHA_ONEONE | |
  92165. * | 7 | ALPHA_PREMULTIPLIED | |
  92166. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  92167. * | 9 | ALPHA_INTERPOLATE | |
  92168. * | 10 | ALPHA_SCREENMODE | |
  92169. *
  92170. */
  92171. set alphaMode(value: number);
  92172. /**
  92173. * Gets the value of the alpha mode
  92174. */
  92175. get alphaMode(): number;
  92176. /**
  92177. * Stores the state of the need depth pre-pass value
  92178. */
  92179. private _needDepthPrePass;
  92180. /**
  92181. * Sets the need depth pre-pass value
  92182. */
  92183. set needDepthPrePass(value: boolean);
  92184. /**
  92185. * Gets the depth pre-pass value
  92186. */
  92187. get needDepthPrePass(): boolean;
  92188. /**
  92189. * Specifies if depth writing should be disabled
  92190. */
  92191. disableDepthWrite: boolean;
  92192. /**
  92193. * Specifies if depth writing should be forced
  92194. */
  92195. forceDepthWrite: boolean;
  92196. /**
  92197. * Specifies the depth function that should be used. 0 means the default engine function
  92198. */
  92199. depthFunction: number;
  92200. /**
  92201. * Specifies if there should be a separate pass for culling
  92202. */
  92203. separateCullingPass: boolean;
  92204. /**
  92205. * Stores the state specifing if fog should be enabled
  92206. */
  92207. private _fogEnabled;
  92208. /**
  92209. * Sets the state for enabling fog
  92210. */
  92211. set fogEnabled(value: boolean);
  92212. /**
  92213. * Gets the value of the fog enabled state
  92214. */
  92215. get fogEnabled(): boolean;
  92216. /**
  92217. * Stores the size of points
  92218. */
  92219. pointSize: number;
  92220. /**
  92221. * Stores the z offset value
  92222. */
  92223. zOffset: number;
  92224. /**
  92225. * Gets a value specifying if wireframe mode is enabled
  92226. */
  92227. get wireframe(): boolean;
  92228. /**
  92229. * Sets the state of wireframe mode
  92230. */
  92231. set wireframe(value: boolean);
  92232. /**
  92233. * Gets the value specifying if point clouds are enabled
  92234. */
  92235. get pointsCloud(): boolean;
  92236. /**
  92237. * Sets the state of point cloud mode
  92238. */
  92239. set pointsCloud(value: boolean);
  92240. /**
  92241. * Gets the material fill mode
  92242. */
  92243. get fillMode(): number;
  92244. /**
  92245. * Sets the material fill mode
  92246. */
  92247. set fillMode(value: number);
  92248. /**
  92249. * @hidden
  92250. * Stores the effects for the material
  92251. */
  92252. _effect: Nullable<Effect>;
  92253. /**
  92254. * Specifies if uniform buffers should be used
  92255. */
  92256. private _useUBO;
  92257. /**
  92258. * Stores a reference to the scene
  92259. */
  92260. private _scene;
  92261. /**
  92262. * Stores the fill mode state
  92263. */
  92264. private _fillMode;
  92265. /**
  92266. * Specifies if the depth write state should be cached
  92267. */
  92268. private _cachedDepthWriteState;
  92269. /**
  92270. * Specifies if the depth function state should be cached
  92271. */
  92272. private _cachedDepthFunctionState;
  92273. /**
  92274. * Stores the uniform buffer
  92275. */
  92276. protected _uniformBuffer: UniformBuffer;
  92277. /** @hidden */
  92278. _indexInSceneMaterialArray: number;
  92279. /** @hidden */
  92280. meshMap: Nullable<{
  92281. [id: string]: AbstractMesh | undefined;
  92282. }>;
  92283. /**
  92284. * Creates a material instance
  92285. * @param name defines the name of the material
  92286. * @param scene defines the scene to reference
  92287. * @param doNotAdd specifies if the material should be added to the scene
  92288. */
  92289. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  92290. /**
  92291. * Returns a string representation of the current material
  92292. * @param fullDetails defines a boolean indicating which levels of logging is desired
  92293. * @returns a string with material information
  92294. */
  92295. toString(fullDetails?: boolean): string;
  92296. /**
  92297. * Gets the class name of the material
  92298. * @returns a string with the class name of the material
  92299. */
  92300. getClassName(): string;
  92301. /**
  92302. * Specifies if updates for the material been locked
  92303. */
  92304. get isFrozen(): boolean;
  92305. /**
  92306. * Locks updates for the material
  92307. */
  92308. freeze(): void;
  92309. /**
  92310. * Unlocks updates for the material
  92311. */
  92312. unfreeze(): void;
  92313. /**
  92314. * Specifies if the material is ready to be used
  92315. * @param mesh defines the mesh to check
  92316. * @param useInstances specifies if instances should be used
  92317. * @returns a boolean indicating if the material is ready to be used
  92318. */
  92319. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  92320. /**
  92321. * Specifies that the submesh is ready to be used
  92322. * @param mesh defines the mesh to check
  92323. * @param subMesh defines which submesh to check
  92324. * @param useInstances specifies that instances should be used
  92325. * @returns a boolean indicating that the submesh is ready or not
  92326. */
  92327. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  92328. /**
  92329. * Returns the material effect
  92330. * @returns the effect associated with the material
  92331. */
  92332. getEffect(): Nullable<Effect>;
  92333. /**
  92334. * Returns the current scene
  92335. * @returns a Scene
  92336. */
  92337. getScene(): Scene;
  92338. /**
  92339. * Specifies if the material will require alpha blending
  92340. * @returns a boolean specifying if alpha blending is needed
  92341. */
  92342. needAlphaBlending(): boolean;
  92343. /**
  92344. * Specifies if the mesh will require alpha blending
  92345. * @param mesh defines the mesh to check
  92346. * @returns a boolean specifying if alpha blending is needed for the mesh
  92347. */
  92348. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  92349. /**
  92350. * Specifies if this material should be rendered in alpha test mode
  92351. * @returns a boolean specifying if an alpha test is needed.
  92352. */
  92353. needAlphaTesting(): boolean;
  92354. /**
  92355. * Gets the texture used for the alpha test
  92356. * @returns the texture to use for alpha testing
  92357. */
  92358. getAlphaTestTexture(): Nullable<BaseTexture>;
  92359. /**
  92360. * Marks the material to indicate that it needs to be re-calculated
  92361. */
  92362. markDirty(): void;
  92363. /** @hidden */
  92364. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  92365. /**
  92366. * Binds the material to the mesh
  92367. * @param world defines the world transformation matrix
  92368. * @param mesh defines the mesh to bind the material to
  92369. */
  92370. bind(world: Matrix, mesh?: Mesh): void;
  92371. /**
  92372. * Binds the submesh to the material
  92373. * @param world defines the world transformation matrix
  92374. * @param mesh defines the mesh containing the submesh
  92375. * @param subMesh defines the submesh to bind the material to
  92376. */
  92377. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  92378. /**
  92379. * Binds the world matrix to the material
  92380. * @param world defines the world transformation matrix
  92381. */
  92382. bindOnlyWorldMatrix(world: Matrix): void;
  92383. /**
  92384. * Binds the scene's uniform buffer to the effect.
  92385. * @param effect defines the effect to bind to the scene uniform buffer
  92386. * @param sceneUbo defines the uniform buffer storing scene data
  92387. */
  92388. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  92389. /**
  92390. * Binds the view matrix to the effect
  92391. * @param effect defines the effect to bind the view matrix to
  92392. */
  92393. bindView(effect: Effect): void;
  92394. /**
  92395. * Binds the view projection matrix to the effect
  92396. * @param effect defines the effect to bind the view projection matrix to
  92397. */
  92398. bindViewProjection(effect: Effect): void;
  92399. /**
  92400. * Specifies if material alpha testing should be turned on for the mesh
  92401. * @param mesh defines the mesh to check
  92402. */
  92403. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  92404. /**
  92405. * Processes to execute after binding the material to a mesh
  92406. * @param mesh defines the rendered mesh
  92407. */
  92408. protected _afterBind(mesh?: Mesh): void;
  92409. /**
  92410. * Unbinds the material from the mesh
  92411. */
  92412. unbind(): void;
  92413. /**
  92414. * Gets the active textures from the material
  92415. * @returns an array of textures
  92416. */
  92417. getActiveTextures(): BaseTexture[];
  92418. /**
  92419. * Specifies if the material uses a texture
  92420. * @param texture defines the texture to check against the material
  92421. * @returns a boolean specifying if the material uses the texture
  92422. */
  92423. hasTexture(texture: BaseTexture): boolean;
  92424. /**
  92425. * Makes a duplicate of the material, and gives it a new name
  92426. * @param name defines the new name for the duplicated material
  92427. * @returns the cloned material
  92428. */
  92429. clone(name: string): Nullable<Material>;
  92430. /**
  92431. * Gets the meshes bound to the material
  92432. * @returns an array of meshes bound to the material
  92433. */
  92434. getBindedMeshes(): AbstractMesh[];
  92435. /**
  92436. * Force shader compilation
  92437. * @param mesh defines the mesh associated with this material
  92438. * @param onCompiled defines a function to execute once the material is compiled
  92439. * @param options defines the options to configure the compilation
  92440. * @param onError defines a function to execute if the material fails compiling
  92441. */
  92442. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  92443. /**
  92444. * Force shader compilation
  92445. * @param mesh defines the mesh that will use this material
  92446. * @param options defines additional options for compiling the shaders
  92447. * @returns a promise that resolves when the compilation completes
  92448. */
  92449. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  92450. private static readonly _AllDirtyCallBack;
  92451. private static readonly _ImageProcessingDirtyCallBack;
  92452. private static readonly _TextureDirtyCallBack;
  92453. private static readonly _FresnelDirtyCallBack;
  92454. private static readonly _MiscDirtyCallBack;
  92455. private static readonly _LightsDirtyCallBack;
  92456. private static readonly _AttributeDirtyCallBack;
  92457. private static _FresnelAndMiscDirtyCallBack;
  92458. private static _TextureAndMiscDirtyCallBack;
  92459. private static readonly _DirtyCallbackArray;
  92460. private static readonly _RunDirtyCallBacks;
  92461. /**
  92462. * Marks a define in the material to indicate that it needs to be re-computed
  92463. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  92464. */
  92465. markAsDirty(flag: number): void;
  92466. /**
  92467. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  92468. * @param func defines a function which checks material defines against the submeshes
  92469. */
  92470. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  92471. /**
  92472. * Indicates that we need to re-calculated for all submeshes
  92473. */
  92474. protected _markAllSubMeshesAsAllDirty(): void;
  92475. /**
  92476. * Indicates that image processing needs to be re-calculated for all submeshes
  92477. */
  92478. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  92479. /**
  92480. * Indicates that textures need to be re-calculated for all submeshes
  92481. */
  92482. protected _markAllSubMeshesAsTexturesDirty(): void;
  92483. /**
  92484. * Indicates that fresnel needs to be re-calculated for all submeshes
  92485. */
  92486. protected _markAllSubMeshesAsFresnelDirty(): void;
  92487. /**
  92488. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  92489. */
  92490. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  92491. /**
  92492. * Indicates that lights need to be re-calculated for all submeshes
  92493. */
  92494. protected _markAllSubMeshesAsLightsDirty(): void;
  92495. /**
  92496. * Indicates that attributes need to be re-calculated for all submeshes
  92497. */
  92498. protected _markAllSubMeshesAsAttributesDirty(): void;
  92499. /**
  92500. * Indicates that misc needs to be re-calculated for all submeshes
  92501. */
  92502. protected _markAllSubMeshesAsMiscDirty(): void;
  92503. /**
  92504. * Indicates that textures and misc need to be re-calculated for all submeshes
  92505. */
  92506. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  92507. /**
  92508. * Disposes the material
  92509. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92510. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  92511. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  92512. */
  92513. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  92514. /** @hidden */
  92515. private releaseVertexArrayObject;
  92516. /**
  92517. * Serializes this material
  92518. * @returns the serialized material object
  92519. */
  92520. serialize(): any;
  92521. /**
  92522. * Creates a material from parsed material data
  92523. * @param parsedMaterial defines parsed material data
  92524. * @param scene defines the hosting scene
  92525. * @param rootUrl defines the root URL to use to load textures
  92526. * @returns a new material
  92527. */
  92528. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  92529. }
  92530. }
  92531. declare module BABYLON {
  92532. /**
  92533. * A multi-material is used to apply different materials to different parts of the same object without the need of
  92534. * separate meshes. This can be use to improve performances.
  92535. * @see http://doc.babylonjs.com/how_to/multi_materials
  92536. */
  92537. export class MultiMaterial extends Material {
  92538. private _subMaterials;
  92539. /**
  92540. * Gets or Sets the list of Materials used within the multi material.
  92541. * They need to be ordered according to the submeshes order in the associated mesh
  92542. */
  92543. get subMaterials(): Nullable<Material>[];
  92544. set subMaterials(value: Nullable<Material>[]);
  92545. /**
  92546. * Function used to align with Node.getChildren()
  92547. * @returns the list of Materials used within the multi material
  92548. */
  92549. getChildren(): Nullable<Material>[];
  92550. /**
  92551. * Instantiates a new Multi Material
  92552. * A multi-material is used to apply different materials to different parts of the same object without the need of
  92553. * separate meshes. This can be use to improve performances.
  92554. * @see http://doc.babylonjs.com/how_to/multi_materials
  92555. * @param name Define the name in the scene
  92556. * @param scene Define the scene the material belongs to
  92557. */
  92558. constructor(name: string, scene: Scene);
  92559. private _hookArray;
  92560. /**
  92561. * Get one of the submaterial by its index in the submaterials array
  92562. * @param index The index to look the sub material at
  92563. * @returns The Material if the index has been defined
  92564. */
  92565. getSubMaterial(index: number): Nullable<Material>;
  92566. /**
  92567. * Get the list of active textures for the whole sub materials list.
  92568. * @returns All the textures that will be used during the rendering
  92569. */
  92570. getActiveTextures(): BaseTexture[];
  92571. /**
  92572. * Gets the current class name of the material e.g. "MultiMaterial"
  92573. * Mainly use in serialization.
  92574. * @returns the class name
  92575. */
  92576. getClassName(): string;
  92577. /**
  92578. * Checks if the material is ready to render the requested sub mesh
  92579. * @param mesh Define the mesh the submesh belongs to
  92580. * @param subMesh Define the sub mesh to look readyness for
  92581. * @param useInstances Define whether or not the material is used with instances
  92582. * @returns true if ready, otherwise false
  92583. */
  92584. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  92585. /**
  92586. * Clones the current material and its related sub materials
  92587. * @param name Define the name of the newly cloned material
  92588. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  92589. * @returns the cloned material
  92590. */
  92591. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  92592. /**
  92593. * Serializes the materials into a JSON representation.
  92594. * @returns the JSON representation
  92595. */
  92596. serialize(): any;
  92597. /**
  92598. * Dispose the material and release its associated resources
  92599. * @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)
  92600. * @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)
  92601. * @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)
  92602. */
  92603. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  92604. /**
  92605. * Creates a MultiMaterial from parsed MultiMaterial data.
  92606. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  92607. * @param scene defines the hosting scene
  92608. * @returns a new MultiMaterial
  92609. */
  92610. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  92611. }
  92612. }
  92613. declare module BABYLON {
  92614. /**
  92615. * Base class for submeshes
  92616. */
  92617. export class BaseSubMesh {
  92618. /** @hidden */
  92619. _materialDefines: Nullable<MaterialDefines>;
  92620. /** @hidden */
  92621. _materialEffect: Nullable<Effect>;
  92622. /**
  92623. * Gets material defines used by the effect associated to the sub mesh
  92624. */
  92625. get materialDefines(): Nullable<MaterialDefines>;
  92626. /**
  92627. * Sets material defines used by the effect associated to the sub mesh
  92628. */
  92629. set materialDefines(defines: Nullable<MaterialDefines>);
  92630. /**
  92631. * Gets associated effect
  92632. */
  92633. get effect(): Nullable<Effect>;
  92634. /**
  92635. * Sets associated effect (effect used to render this submesh)
  92636. * @param effect defines the effect to associate with
  92637. * @param defines defines the set of defines used to compile this effect
  92638. */
  92639. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  92640. }
  92641. /**
  92642. * Defines a subdivision inside a mesh
  92643. */
  92644. export class SubMesh extends BaseSubMesh implements ICullable {
  92645. /** the material index to use */
  92646. materialIndex: number;
  92647. /** vertex index start */
  92648. verticesStart: number;
  92649. /** vertices count */
  92650. verticesCount: number;
  92651. /** index start */
  92652. indexStart: number;
  92653. /** indices count */
  92654. indexCount: number;
  92655. /** @hidden */
  92656. _linesIndexCount: number;
  92657. private _mesh;
  92658. private _renderingMesh;
  92659. private _boundingInfo;
  92660. private _linesIndexBuffer;
  92661. /** @hidden */
  92662. _lastColliderWorldVertices: Nullable<Vector3[]>;
  92663. /** @hidden */
  92664. _trianglePlanes: Plane[];
  92665. /** @hidden */
  92666. _lastColliderTransformMatrix: Nullable<Matrix>;
  92667. /** @hidden */
  92668. _renderId: number;
  92669. /** @hidden */
  92670. _alphaIndex: number;
  92671. /** @hidden */
  92672. _distanceToCamera: number;
  92673. /** @hidden */
  92674. _id: number;
  92675. private _currentMaterial;
  92676. /**
  92677. * Add a new submesh to a mesh
  92678. * @param materialIndex defines the material index to use
  92679. * @param verticesStart defines vertex index start
  92680. * @param verticesCount defines vertices count
  92681. * @param indexStart defines index start
  92682. * @param indexCount defines indices count
  92683. * @param mesh defines the parent mesh
  92684. * @param renderingMesh defines an optional rendering mesh
  92685. * @param createBoundingBox defines if bounding box should be created for this submesh
  92686. * @returns the new submesh
  92687. */
  92688. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  92689. /**
  92690. * Creates a new submesh
  92691. * @param materialIndex defines the material index to use
  92692. * @param verticesStart defines vertex index start
  92693. * @param verticesCount defines vertices count
  92694. * @param indexStart defines index start
  92695. * @param indexCount defines indices count
  92696. * @param mesh defines the parent mesh
  92697. * @param renderingMesh defines an optional rendering mesh
  92698. * @param createBoundingBox defines if bounding box should be created for this submesh
  92699. */
  92700. constructor(
  92701. /** the material index to use */
  92702. materialIndex: number,
  92703. /** vertex index start */
  92704. verticesStart: number,
  92705. /** vertices count */
  92706. verticesCount: number,
  92707. /** index start */
  92708. indexStart: number,
  92709. /** indices count */
  92710. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  92711. /**
  92712. * Returns true if this submesh covers the entire parent mesh
  92713. * @ignorenaming
  92714. */
  92715. get IsGlobal(): boolean;
  92716. /**
  92717. * Returns the submesh BoudingInfo object
  92718. * @returns current bounding info (or mesh's one if the submesh is global)
  92719. */
  92720. getBoundingInfo(): BoundingInfo;
  92721. /**
  92722. * Sets the submesh BoundingInfo
  92723. * @param boundingInfo defines the new bounding info to use
  92724. * @returns the SubMesh
  92725. */
  92726. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  92727. /**
  92728. * Returns the mesh of the current submesh
  92729. * @return the parent mesh
  92730. */
  92731. getMesh(): AbstractMesh;
  92732. /**
  92733. * Returns the rendering mesh of the submesh
  92734. * @returns the rendering mesh (could be different from parent mesh)
  92735. */
  92736. getRenderingMesh(): Mesh;
  92737. /**
  92738. * Returns the submesh material
  92739. * @returns null or the current material
  92740. */
  92741. getMaterial(): Nullable<Material>;
  92742. /**
  92743. * Sets a new updated BoundingInfo object to the submesh
  92744. * @param data defines an optional position array to use to determine the bounding info
  92745. * @returns the SubMesh
  92746. */
  92747. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  92748. /** @hidden */
  92749. _checkCollision(collider: Collider): boolean;
  92750. /**
  92751. * Updates the submesh BoundingInfo
  92752. * @param world defines the world matrix to use to update the bounding info
  92753. * @returns the submesh
  92754. */
  92755. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  92756. /**
  92757. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  92758. * @param frustumPlanes defines the frustum planes
  92759. * @returns true if the submesh is intersecting with the frustum
  92760. */
  92761. isInFrustum(frustumPlanes: Plane[]): boolean;
  92762. /**
  92763. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  92764. * @param frustumPlanes defines the frustum planes
  92765. * @returns true if the submesh is inside the frustum
  92766. */
  92767. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  92768. /**
  92769. * Renders the submesh
  92770. * @param enableAlphaMode defines if alpha needs to be used
  92771. * @returns the submesh
  92772. */
  92773. render(enableAlphaMode: boolean): SubMesh;
  92774. /**
  92775. * @hidden
  92776. */
  92777. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  92778. /**
  92779. * Checks if the submesh intersects with a ray
  92780. * @param ray defines the ray to test
  92781. * @returns true is the passed ray intersects the submesh bounding box
  92782. */
  92783. canIntersects(ray: Ray): boolean;
  92784. /**
  92785. * Intersects current submesh with a ray
  92786. * @param ray defines the ray to test
  92787. * @param positions defines mesh's positions array
  92788. * @param indices defines mesh's indices array
  92789. * @param fastCheck defines if only bounding info should be used
  92790. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92791. * @returns intersection info or null if no intersection
  92792. */
  92793. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  92794. /** @hidden */
  92795. private _intersectLines;
  92796. /** @hidden */
  92797. private _intersectUnIndexedLines;
  92798. /** @hidden */
  92799. private _intersectTriangles;
  92800. /** @hidden */
  92801. private _intersectUnIndexedTriangles;
  92802. /** @hidden */
  92803. _rebuild(): void;
  92804. /**
  92805. * Creates a new submesh from the passed mesh
  92806. * @param newMesh defines the new hosting mesh
  92807. * @param newRenderingMesh defines an optional rendering mesh
  92808. * @returns the new submesh
  92809. */
  92810. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  92811. /**
  92812. * Release associated resources
  92813. */
  92814. dispose(): void;
  92815. /**
  92816. * Gets the class name
  92817. * @returns the string "SubMesh".
  92818. */
  92819. getClassName(): string;
  92820. /**
  92821. * Creates a new submesh from indices data
  92822. * @param materialIndex the index of the main mesh material
  92823. * @param startIndex the index where to start the copy in the mesh indices array
  92824. * @param indexCount the number of indices to copy then from the startIndex
  92825. * @param mesh the main mesh to create the submesh from
  92826. * @param renderingMesh the optional rendering mesh
  92827. * @returns a new submesh
  92828. */
  92829. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  92830. }
  92831. }
  92832. declare module BABYLON {
  92833. /**
  92834. * Class used to represent data loading progression
  92835. */
  92836. export class SceneLoaderFlags {
  92837. private static _ForceFullSceneLoadingForIncremental;
  92838. private static _ShowLoadingScreen;
  92839. private static _CleanBoneMatrixWeights;
  92840. private static _loggingLevel;
  92841. /**
  92842. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  92843. */
  92844. static get ForceFullSceneLoadingForIncremental(): boolean;
  92845. static set ForceFullSceneLoadingForIncremental(value: boolean);
  92846. /**
  92847. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  92848. */
  92849. static get ShowLoadingScreen(): boolean;
  92850. static set ShowLoadingScreen(value: boolean);
  92851. /**
  92852. * Defines the current logging level (while loading the scene)
  92853. * @ignorenaming
  92854. */
  92855. static get loggingLevel(): number;
  92856. static set loggingLevel(value: number);
  92857. /**
  92858. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  92859. */
  92860. static get CleanBoneMatrixWeights(): boolean;
  92861. static set CleanBoneMatrixWeights(value: boolean);
  92862. }
  92863. }
  92864. declare module BABYLON {
  92865. /**
  92866. * Class used to store geometry data (vertex buffers + index buffer)
  92867. */
  92868. export class Geometry implements IGetSetVerticesData {
  92869. /**
  92870. * Gets or sets the ID of the geometry
  92871. */
  92872. id: string;
  92873. /**
  92874. * Gets or sets the unique ID of the geometry
  92875. */
  92876. uniqueId: number;
  92877. /**
  92878. * Gets the delay loading state of the geometry (none by default which means not delayed)
  92879. */
  92880. delayLoadState: number;
  92881. /**
  92882. * Gets the file containing the data to load when running in delay load state
  92883. */
  92884. delayLoadingFile: Nullable<string>;
  92885. /**
  92886. * Callback called when the geometry is updated
  92887. */
  92888. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  92889. private _scene;
  92890. private _engine;
  92891. private _meshes;
  92892. private _totalVertices;
  92893. /** @hidden */
  92894. _indices: IndicesArray;
  92895. /** @hidden */
  92896. _vertexBuffers: {
  92897. [key: string]: VertexBuffer;
  92898. };
  92899. private _isDisposed;
  92900. private _extend;
  92901. private _boundingBias;
  92902. /** @hidden */
  92903. _delayInfo: Array<string>;
  92904. private _indexBuffer;
  92905. private _indexBufferIsUpdatable;
  92906. /** @hidden */
  92907. _boundingInfo: Nullable<BoundingInfo>;
  92908. /** @hidden */
  92909. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  92910. /** @hidden */
  92911. _softwareSkinningFrameId: number;
  92912. private _vertexArrayObjects;
  92913. private _updatable;
  92914. /** @hidden */
  92915. _positions: Nullable<Vector3[]>;
  92916. /**
  92917. * 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
  92918. */
  92919. get boundingBias(): Vector2;
  92920. /**
  92921. * 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
  92922. */
  92923. set boundingBias(value: Vector2);
  92924. /**
  92925. * Static function used to attach a new empty geometry to a mesh
  92926. * @param mesh defines the mesh to attach the geometry to
  92927. * @returns the new Geometry
  92928. */
  92929. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  92930. /**
  92931. * Creates a new geometry
  92932. * @param id defines the unique ID
  92933. * @param scene defines the hosting scene
  92934. * @param vertexData defines the VertexData used to get geometry data
  92935. * @param updatable defines if geometry must be updatable (false by default)
  92936. * @param mesh defines the mesh that will be associated with the geometry
  92937. */
  92938. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  92939. /**
  92940. * Gets the current extend of the geometry
  92941. */
  92942. get extend(): {
  92943. minimum: Vector3;
  92944. maximum: Vector3;
  92945. };
  92946. /**
  92947. * Gets the hosting scene
  92948. * @returns the hosting Scene
  92949. */
  92950. getScene(): Scene;
  92951. /**
  92952. * Gets the hosting engine
  92953. * @returns the hosting Engine
  92954. */
  92955. getEngine(): Engine;
  92956. /**
  92957. * Defines if the geometry is ready to use
  92958. * @returns true if the geometry is ready to be used
  92959. */
  92960. isReady(): boolean;
  92961. /**
  92962. * Gets a value indicating that the geometry should not be serialized
  92963. */
  92964. get doNotSerialize(): boolean;
  92965. /** @hidden */
  92966. _rebuild(): void;
  92967. /**
  92968. * Affects all geometry data in one call
  92969. * @param vertexData defines the geometry data
  92970. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  92971. */
  92972. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  92973. /**
  92974. * Set specific vertex data
  92975. * @param kind defines the data kind (Position, normal, etc...)
  92976. * @param data defines the vertex data to use
  92977. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  92978. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  92979. */
  92980. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  92981. /**
  92982. * Removes a specific vertex data
  92983. * @param kind defines the data kind (Position, normal, etc...)
  92984. */
  92985. removeVerticesData(kind: string): void;
  92986. /**
  92987. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  92988. * @param buffer defines the vertex buffer to use
  92989. * @param totalVertices defines the total number of vertices for position kind (could be null)
  92990. */
  92991. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  92992. /**
  92993. * Update a specific vertex buffer
  92994. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  92995. * It will do nothing if the buffer is not updatable
  92996. * @param kind defines the data kind (Position, normal, etc...)
  92997. * @param data defines the data to use
  92998. * @param offset defines the offset in the target buffer where to store the data
  92999. * @param useBytes set to true if the offset is in bytes
  93000. */
  93001. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  93002. /**
  93003. * Update a specific vertex buffer
  93004. * This function will create a new buffer if the current one is not updatable
  93005. * @param kind defines the data kind (Position, normal, etc...)
  93006. * @param data defines the data to use
  93007. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  93008. */
  93009. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  93010. private _updateBoundingInfo;
  93011. /** @hidden */
  93012. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  93013. /**
  93014. * Gets total number of vertices
  93015. * @returns the total number of vertices
  93016. */
  93017. getTotalVertices(): number;
  93018. /**
  93019. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  93020. * @param kind defines the data kind (Position, normal, etc...)
  93021. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  93022. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93023. * @returns a float array containing vertex data
  93024. */
  93025. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  93026. /**
  93027. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  93028. * @param kind defines the data kind (Position, normal, etc...)
  93029. * @returns true if the vertex buffer with the specified kind is updatable
  93030. */
  93031. isVertexBufferUpdatable(kind: string): boolean;
  93032. /**
  93033. * Gets a specific vertex buffer
  93034. * @param kind defines the data kind (Position, normal, etc...)
  93035. * @returns a VertexBuffer
  93036. */
  93037. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  93038. /**
  93039. * Returns all vertex buffers
  93040. * @return an object holding all vertex buffers indexed by kind
  93041. */
  93042. getVertexBuffers(): Nullable<{
  93043. [key: string]: VertexBuffer;
  93044. }>;
  93045. /**
  93046. * Gets a boolean indicating if specific vertex buffer is present
  93047. * @param kind defines the data kind (Position, normal, etc...)
  93048. * @returns true if data is present
  93049. */
  93050. isVerticesDataPresent(kind: string): boolean;
  93051. /**
  93052. * Gets a list of all attached data kinds (Position, normal, etc...)
  93053. * @returns a list of string containing all kinds
  93054. */
  93055. getVerticesDataKinds(): string[];
  93056. /**
  93057. * Update index buffer
  93058. * @param indices defines the indices to store in the index buffer
  93059. * @param offset defines the offset in the target buffer where to store the data
  93060. * @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)
  93061. */
  93062. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  93063. /**
  93064. * Creates a new index buffer
  93065. * @param indices defines the indices to store in the index buffer
  93066. * @param totalVertices defines the total number of vertices (could be null)
  93067. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  93068. */
  93069. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  93070. /**
  93071. * Return the total number of indices
  93072. * @returns the total number of indices
  93073. */
  93074. getTotalIndices(): number;
  93075. /**
  93076. * Gets the index buffer array
  93077. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  93078. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93079. * @returns the index buffer array
  93080. */
  93081. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93082. /**
  93083. * Gets the index buffer
  93084. * @return the index buffer
  93085. */
  93086. getIndexBuffer(): Nullable<DataBuffer>;
  93087. /** @hidden */
  93088. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  93089. /**
  93090. * Release the associated resources for a specific mesh
  93091. * @param mesh defines the source mesh
  93092. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  93093. */
  93094. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  93095. /**
  93096. * Apply current geometry to a given mesh
  93097. * @param mesh defines the mesh to apply geometry to
  93098. */
  93099. applyToMesh(mesh: Mesh): void;
  93100. private _updateExtend;
  93101. private _applyToMesh;
  93102. private notifyUpdate;
  93103. /**
  93104. * Load the geometry if it was flagged as delay loaded
  93105. * @param scene defines the hosting scene
  93106. * @param onLoaded defines a callback called when the geometry is loaded
  93107. */
  93108. load(scene: Scene, onLoaded?: () => void): void;
  93109. private _queueLoad;
  93110. /**
  93111. * Invert the geometry to move from a right handed system to a left handed one.
  93112. */
  93113. toLeftHanded(): void;
  93114. /** @hidden */
  93115. _resetPointsArrayCache(): void;
  93116. /** @hidden */
  93117. _generatePointsArray(): boolean;
  93118. /**
  93119. * Gets a value indicating if the geometry is disposed
  93120. * @returns true if the geometry was disposed
  93121. */
  93122. isDisposed(): boolean;
  93123. private _disposeVertexArrayObjects;
  93124. /**
  93125. * Free all associated resources
  93126. */
  93127. dispose(): void;
  93128. /**
  93129. * Clone the current geometry into a new geometry
  93130. * @param id defines the unique ID of the new geometry
  93131. * @returns a new geometry object
  93132. */
  93133. copy(id: string): Geometry;
  93134. /**
  93135. * Serialize the current geometry info (and not the vertices data) into a JSON object
  93136. * @return a JSON representation of the current geometry data (without the vertices data)
  93137. */
  93138. serialize(): any;
  93139. private toNumberArray;
  93140. /**
  93141. * Serialize all vertices data into a JSON oject
  93142. * @returns a JSON representation of the current geometry data
  93143. */
  93144. serializeVerticeData(): any;
  93145. /**
  93146. * Extracts a clone of a mesh geometry
  93147. * @param mesh defines the source mesh
  93148. * @param id defines the unique ID of the new geometry object
  93149. * @returns the new geometry object
  93150. */
  93151. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  93152. /**
  93153. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  93154. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93155. * Be aware Math.random() could cause collisions, but:
  93156. * "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"
  93157. * @returns a string containing a new GUID
  93158. */
  93159. static RandomId(): string;
  93160. /** @hidden */
  93161. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  93162. private static _CleanMatricesWeights;
  93163. /**
  93164. * Create a new geometry from persisted data (Using .babylon file format)
  93165. * @param parsedVertexData defines the persisted data
  93166. * @param scene defines the hosting scene
  93167. * @param rootUrl defines the root url to use to load assets (like delayed data)
  93168. * @returns the new geometry object
  93169. */
  93170. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  93171. }
  93172. }
  93173. declare module BABYLON {
  93174. /**
  93175. * Define an interface for all classes that will get and set the data on vertices
  93176. */
  93177. export interface IGetSetVerticesData {
  93178. /**
  93179. * Gets a boolean indicating if specific vertex data is present
  93180. * @param kind defines the vertex data kind to use
  93181. * @returns true is data kind is present
  93182. */
  93183. isVerticesDataPresent(kind: string): boolean;
  93184. /**
  93185. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  93186. * @param kind defines the data kind (Position, normal, etc...)
  93187. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  93188. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93189. * @returns a float array containing vertex data
  93190. */
  93191. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  93192. /**
  93193. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  93194. * @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.
  93195. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  93196. * @returns the indices array or an empty array if the mesh has no geometry
  93197. */
  93198. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  93199. /**
  93200. * Set specific vertex data
  93201. * @param kind defines the data kind (Position, normal, etc...)
  93202. * @param data defines the vertex data to use
  93203. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  93204. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  93205. */
  93206. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  93207. /**
  93208. * Update a specific associated vertex buffer
  93209. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  93210. * - VertexBuffer.PositionKind
  93211. * - VertexBuffer.UVKind
  93212. * - VertexBuffer.UV2Kind
  93213. * - VertexBuffer.UV3Kind
  93214. * - VertexBuffer.UV4Kind
  93215. * - VertexBuffer.UV5Kind
  93216. * - VertexBuffer.UV6Kind
  93217. * - VertexBuffer.ColorKind
  93218. * - VertexBuffer.MatricesIndicesKind
  93219. * - VertexBuffer.MatricesIndicesExtraKind
  93220. * - VertexBuffer.MatricesWeightsKind
  93221. * - VertexBuffer.MatricesWeightsExtraKind
  93222. * @param data defines the data source
  93223. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  93224. * @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)
  93225. */
  93226. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  93227. /**
  93228. * Creates a new index buffer
  93229. * @param indices defines the indices to store in the index buffer
  93230. * @param totalVertices defines the total number of vertices (could be null)
  93231. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  93232. */
  93233. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  93234. }
  93235. /**
  93236. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  93237. */
  93238. export class VertexData {
  93239. /**
  93240. * Mesh side orientation : usually the external or front surface
  93241. */
  93242. static readonly FRONTSIDE: number;
  93243. /**
  93244. * Mesh side orientation : usually the internal or back surface
  93245. */
  93246. static readonly BACKSIDE: number;
  93247. /**
  93248. * Mesh side orientation : both internal and external or front and back surfaces
  93249. */
  93250. static readonly DOUBLESIDE: number;
  93251. /**
  93252. * Mesh side orientation : by default, `FRONTSIDE`
  93253. */
  93254. static readonly DEFAULTSIDE: number;
  93255. /**
  93256. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  93257. */
  93258. positions: Nullable<FloatArray>;
  93259. /**
  93260. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  93261. */
  93262. normals: Nullable<FloatArray>;
  93263. /**
  93264. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  93265. */
  93266. tangents: Nullable<FloatArray>;
  93267. /**
  93268. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93269. */
  93270. uvs: Nullable<FloatArray>;
  93271. /**
  93272. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93273. */
  93274. uvs2: Nullable<FloatArray>;
  93275. /**
  93276. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93277. */
  93278. uvs3: Nullable<FloatArray>;
  93279. /**
  93280. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93281. */
  93282. uvs4: Nullable<FloatArray>;
  93283. /**
  93284. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93285. */
  93286. uvs5: Nullable<FloatArray>;
  93287. /**
  93288. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  93289. */
  93290. uvs6: Nullable<FloatArray>;
  93291. /**
  93292. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  93293. */
  93294. colors: Nullable<FloatArray>;
  93295. /**
  93296. * 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).
  93297. */
  93298. matricesIndices: Nullable<FloatArray>;
  93299. /**
  93300. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  93301. */
  93302. matricesWeights: Nullable<FloatArray>;
  93303. /**
  93304. * An array extending the number of possible indices
  93305. */
  93306. matricesIndicesExtra: Nullable<FloatArray>;
  93307. /**
  93308. * An array extending the number of possible weights when the number of indices is extended
  93309. */
  93310. matricesWeightsExtra: Nullable<FloatArray>;
  93311. /**
  93312. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  93313. */
  93314. indices: Nullable<IndicesArray>;
  93315. /**
  93316. * Uses the passed data array to set the set the values for the specified kind of data
  93317. * @param data a linear array of floating numbers
  93318. * @param kind the type of data that is being set, eg positions, colors etc
  93319. */
  93320. set(data: FloatArray, kind: string): void;
  93321. /**
  93322. * Associates the vertexData to the passed Mesh.
  93323. * Sets it as updatable or not (default `false`)
  93324. * @param mesh the mesh the vertexData is applied to
  93325. * @param updatable when used and having the value true allows new data to update the vertexData
  93326. * @returns the VertexData
  93327. */
  93328. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  93329. /**
  93330. * Associates the vertexData to the passed Geometry.
  93331. * Sets it as updatable or not (default `false`)
  93332. * @param geometry the geometry the vertexData is applied to
  93333. * @param updatable when used and having the value true allows new data to update the vertexData
  93334. * @returns VertexData
  93335. */
  93336. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  93337. /**
  93338. * Updates the associated mesh
  93339. * @param mesh the mesh to be updated
  93340. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  93341. * @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
  93342. * @returns VertexData
  93343. */
  93344. updateMesh(mesh: Mesh): VertexData;
  93345. /**
  93346. * Updates the associated geometry
  93347. * @param geometry the geometry to be updated
  93348. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  93349. * @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
  93350. * @returns VertexData.
  93351. */
  93352. updateGeometry(geometry: Geometry): VertexData;
  93353. private _applyTo;
  93354. private _update;
  93355. /**
  93356. * Transforms each position and each normal of the vertexData according to the passed Matrix
  93357. * @param matrix the transforming matrix
  93358. * @returns the VertexData
  93359. */
  93360. transform(matrix: Matrix): VertexData;
  93361. /**
  93362. * Merges the passed VertexData into the current one
  93363. * @param other the VertexData to be merged into the current one
  93364. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  93365. * @returns the modified VertexData
  93366. */
  93367. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  93368. private _mergeElement;
  93369. private _validate;
  93370. /**
  93371. * Serializes the VertexData
  93372. * @returns a serialized object
  93373. */
  93374. serialize(): any;
  93375. /**
  93376. * Extracts the vertexData from a mesh
  93377. * @param mesh the mesh from which to extract the VertexData
  93378. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  93379. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  93380. * @returns the object VertexData associated to the passed mesh
  93381. */
  93382. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  93383. /**
  93384. * Extracts the vertexData from the geometry
  93385. * @param geometry the geometry from which to extract the VertexData
  93386. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  93387. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  93388. * @returns the object VertexData associated to the passed mesh
  93389. */
  93390. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  93391. private static _ExtractFrom;
  93392. /**
  93393. * Creates the VertexData for a Ribbon
  93394. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  93395. * * pathArray array of paths, each of which an array of successive Vector3
  93396. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  93397. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  93398. * * 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
  93399. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93400. * * 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)
  93401. * * 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)
  93402. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  93403. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  93404. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  93405. * @returns the VertexData of the ribbon
  93406. */
  93407. static CreateRibbon(options: {
  93408. pathArray: Vector3[][];
  93409. closeArray?: boolean;
  93410. closePath?: boolean;
  93411. offset?: number;
  93412. sideOrientation?: number;
  93413. frontUVs?: Vector4;
  93414. backUVs?: Vector4;
  93415. invertUV?: boolean;
  93416. uvs?: Vector2[];
  93417. colors?: Color4[];
  93418. }): VertexData;
  93419. /**
  93420. * Creates the VertexData for a box
  93421. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93422. * * size sets the width, height and depth of the box to the value of size, optional default 1
  93423. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  93424. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  93425. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  93426. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  93427. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  93428. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93429. * * 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)
  93430. * * 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)
  93431. * @returns the VertexData of the box
  93432. */
  93433. static CreateBox(options: {
  93434. size?: number;
  93435. width?: number;
  93436. height?: number;
  93437. depth?: number;
  93438. faceUV?: Vector4[];
  93439. faceColors?: Color4[];
  93440. sideOrientation?: number;
  93441. frontUVs?: Vector4;
  93442. backUVs?: Vector4;
  93443. }): VertexData;
  93444. /**
  93445. * Creates the VertexData for a tiled box
  93446. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93447. * * faceTiles sets the pattern, tile size and number of tiles for a face
  93448. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  93449. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  93450. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93451. * @returns the VertexData of the box
  93452. */
  93453. static CreateTiledBox(options: {
  93454. pattern?: number;
  93455. width?: number;
  93456. height?: number;
  93457. depth?: number;
  93458. tileSize?: number;
  93459. tileWidth?: number;
  93460. tileHeight?: number;
  93461. alignHorizontal?: number;
  93462. alignVertical?: number;
  93463. faceUV?: Vector4[];
  93464. faceColors?: Color4[];
  93465. sideOrientation?: number;
  93466. }): VertexData;
  93467. /**
  93468. * Creates the VertexData for a tiled plane
  93469. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93470. * * pattern a limited pattern arrangement depending on the number
  93471. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  93472. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  93473. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  93474. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93475. * * 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)
  93476. * * 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)
  93477. * @returns the VertexData of the tiled plane
  93478. */
  93479. static CreateTiledPlane(options: {
  93480. pattern?: number;
  93481. tileSize?: number;
  93482. tileWidth?: number;
  93483. tileHeight?: number;
  93484. size?: number;
  93485. width?: number;
  93486. height?: number;
  93487. alignHorizontal?: number;
  93488. alignVertical?: number;
  93489. sideOrientation?: number;
  93490. frontUVs?: Vector4;
  93491. backUVs?: Vector4;
  93492. }): VertexData;
  93493. /**
  93494. * Creates the VertexData for an ellipsoid, defaults to a sphere
  93495. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93496. * * segments sets the number of horizontal strips optional, default 32
  93497. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  93498. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  93499. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  93500. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  93501. * * 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
  93502. * * 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
  93503. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93504. * * 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)
  93505. * * 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)
  93506. * @returns the VertexData of the ellipsoid
  93507. */
  93508. static CreateSphere(options: {
  93509. segments?: number;
  93510. diameter?: number;
  93511. diameterX?: number;
  93512. diameterY?: number;
  93513. diameterZ?: number;
  93514. arc?: number;
  93515. slice?: number;
  93516. sideOrientation?: number;
  93517. frontUVs?: Vector4;
  93518. backUVs?: Vector4;
  93519. }): VertexData;
  93520. /**
  93521. * Creates the VertexData for a cylinder, cone or prism
  93522. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93523. * * height sets the height (y direction) of the cylinder, optional, default 2
  93524. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  93525. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  93526. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  93527. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  93528. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  93529. * * 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
  93530. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93531. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93532. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  93533. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  93534. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93535. * * 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)
  93536. * * 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)
  93537. * @returns the VertexData of the cylinder, cone or prism
  93538. */
  93539. static CreateCylinder(options: {
  93540. height?: number;
  93541. diameterTop?: number;
  93542. diameterBottom?: number;
  93543. diameter?: number;
  93544. tessellation?: number;
  93545. subdivisions?: number;
  93546. arc?: number;
  93547. faceColors?: Color4[];
  93548. faceUV?: Vector4[];
  93549. hasRings?: boolean;
  93550. enclose?: boolean;
  93551. sideOrientation?: number;
  93552. frontUVs?: Vector4;
  93553. backUVs?: Vector4;
  93554. }): VertexData;
  93555. /**
  93556. * Creates the VertexData for a torus
  93557. * @param options an object used to set the following optional parameters for the box, required but can be empty
  93558. * * diameter the diameter of the torus, optional default 1
  93559. * * thickness the diameter of the tube forming the torus, optional default 0.5
  93560. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  93561. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93562. * * 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)
  93563. * * 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)
  93564. * @returns the VertexData of the torus
  93565. */
  93566. static CreateTorus(options: {
  93567. diameter?: number;
  93568. thickness?: number;
  93569. tessellation?: number;
  93570. sideOrientation?: number;
  93571. frontUVs?: Vector4;
  93572. backUVs?: Vector4;
  93573. }): VertexData;
  93574. /**
  93575. * Creates the VertexData of the LineSystem
  93576. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  93577. * - lines an array of lines, each line being an array of successive Vector3
  93578. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  93579. * @returns the VertexData of the LineSystem
  93580. */
  93581. static CreateLineSystem(options: {
  93582. lines: Vector3[][];
  93583. colors?: Nullable<Color4[][]>;
  93584. }): VertexData;
  93585. /**
  93586. * Create the VertexData for a DashedLines
  93587. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  93588. * - points an array successive Vector3
  93589. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  93590. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  93591. * - dashNb the intended total number of dashes, optional, default 200
  93592. * @returns the VertexData for the DashedLines
  93593. */
  93594. static CreateDashedLines(options: {
  93595. points: Vector3[];
  93596. dashSize?: number;
  93597. gapSize?: number;
  93598. dashNb?: number;
  93599. }): VertexData;
  93600. /**
  93601. * Creates the VertexData for a Ground
  93602. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  93603. * - width the width (x direction) of the ground, optional, default 1
  93604. * - height the height (z direction) of the ground, optional, default 1
  93605. * - subdivisions the number of subdivisions per side, optional, default 1
  93606. * @returns the VertexData of the Ground
  93607. */
  93608. static CreateGround(options: {
  93609. width?: number;
  93610. height?: number;
  93611. subdivisions?: number;
  93612. subdivisionsX?: number;
  93613. subdivisionsY?: number;
  93614. }): VertexData;
  93615. /**
  93616. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  93617. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  93618. * * xmin the ground minimum X coordinate, optional, default -1
  93619. * * zmin the ground minimum Z coordinate, optional, default -1
  93620. * * xmax the ground maximum X coordinate, optional, default 1
  93621. * * zmax the ground maximum Z coordinate, optional, default 1
  93622. * * 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}
  93623. * * 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}
  93624. * @returns the VertexData of the TiledGround
  93625. */
  93626. static CreateTiledGround(options: {
  93627. xmin: number;
  93628. zmin: number;
  93629. xmax: number;
  93630. zmax: number;
  93631. subdivisions?: {
  93632. w: number;
  93633. h: number;
  93634. };
  93635. precision?: {
  93636. w: number;
  93637. h: number;
  93638. };
  93639. }): VertexData;
  93640. /**
  93641. * Creates the VertexData of the Ground designed from a heightmap
  93642. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  93643. * * width the width (x direction) of the ground
  93644. * * height the height (z direction) of the ground
  93645. * * subdivisions the number of subdivisions per side
  93646. * * minHeight the minimum altitude on the ground, optional, default 0
  93647. * * maxHeight the maximum altitude on the ground, optional default 1
  93648. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  93649. * * buffer the array holding the image color data
  93650. * * bufferWidth the width of image
  93651. * * bufferHeight the height of image
  93652. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  93653. * @returns the VertexData of the Ground designed from a heightmap
  93654. */
  93655. static CreateGroundFromHeightMap(options: {
  93656. width: number;
  93657. height: number;
  93658. subdivisions: number;
  93659. minHeight: number;
  93660. maxHeight: number;
  93661. colorFilter: Color3;
  93662. buffer: Uint8Array;
  93663. bufferWidth: number;
  93664. bufferHeight: number;
  93665. alphaFilter: number;
  93666. }): VertexData;
  93667. /**
  93668. * Creates the VertexData for a Plane
  93669. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  93670. * * size sets the width and height of the plane to the value of size, optional default 1
  93671. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  93672. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  93673. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93674. * * 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)
  93675. * * 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)
  93676. * @returns the VertexData of the box
  93677. */
  93678. static CreatePlane(options: {
  93679. size?: number;
  93680. width?: number;
  93681. height?: number;
  93682. sideOrientation?: number;
  93683. frontUVs?: Vector4;
  93684. backUVs?: Vector4;
  93685. }): VertexData;
  93686. /**
  93687. * Creates the VertexData of the Disc or regular Polygon
  93688. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  93689. * * radius the radius of the disc, optional default 0.5
  93690. * * tessellation the number of polygon sides, optional, default 64
  93691. * * 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
  93692. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93693. * * 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)
  93694. * * 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)
  93695. * @returns the VertexData of the box
  93696. */
  93697. static CreateDisc(options: {
  93698. radius?: number;
  93699. tessellation?: number;
  93700. arc?: number;
  93701. sideOrientation?: number;
  93702. frontUVs?: Vector4;
  93703. backUVs?: Vector4;
  93704. }): VertexData;
  93705. /**
  93706. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  93707. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  93708. * @param polygon a mesh built from polygonTriangulation.build()
  93709. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93710. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93711. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93712. * @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)
  93713. * @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)
  93714. * @returns the VertexData of the Polygon
  93715. */
  93716. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  93717. /**
  93718. * Creates the VertexData of the IcoSphere
  93719. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  93720. * * radius the radius of the IcoSphere, optional default 1
  93721. * * radiusX allows stretching in the x direction, optional, default radius
  93722. * * radiusY allows stretching in the y direction, optional, default radius
  93723. * * radiusZ allows stretching in the z direction, optional, default radius
  93724. * * flat when true creates a flat shaded mesh, optional, default true
  93725. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93726. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93727. * * 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)
  93728. * * 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)
  93729. * @returns the VertexData of the IcoSphere
  93730. */
  93731. static CreateIcoSphere(options: {
  93732. radius?: number;
  93733. radiusX?: number;
  93734. radiusY?: number;
  93735. radiusZ?: number;
  93736. flat?: boolean;
  93737. subdivisions?: number;
  93738. sideOrientation?: number;
  93739. frontUVs?: Vector4;
  93740. backUVs?: Vector4;
  93741. }): VertexData;
  93742. /**
  93743. * Creates the VertexData for a Polyhedron
  93744. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  93745. * * type provided types are:
  93746. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  93747. * * 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)
  93748. * * size the size of the IcoSphere, optional default 1
  93749. * * sizeX allows stretching in the x direction, optional, default size
  93750. * * sizeY allows stretching in the y direction, optional, default size
  93751. * * sizeZ allows stretching in the z direction, optional, default size
  93752. * * 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
  93753. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  93754. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  93755. * * flat when true creates a flat shaded mesh, optional, default true
  93756. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  93757. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93758. * * 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)
  93759. * * 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)
  93760. * @returns the VertexData of the Polyhedron
  93761. */
  93762. static CreatePolyhedron(options: {
  93763. type?: number;
  93764. size?: number;
  93765. sizeX?: number;
  93766. sizeY?: number;
  93767. sizeZ?: number;
  93768. custom?: any;
  93769. faceUV?: Vector4[];
  93770. faceColors?: Color4[];
  93771. flat?: boolean;
  93772. sideOrientation?: number;
  93773. frontUVs?: Vector4;
  93774. backUVs?: Vector4;
  93775. }): VertexData;
  93776. /**
  93777. * Creates the VertexData for a TorusKnot
  93778. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  93779. * * radius the radius of the torus knot, optional, default 2
  93780. * * tube the thickness of the tube, optional, default 0.5
  93781. * * radialSegments the number of sides on each tube segments, optional, default 32
  93782. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  93783. * * p the number of windings around the z axis, optional, default 2
  93784. * * q the number of windings around the x axis, optional, default 3
  93785. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  93786. * * 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)
  93787. * * 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)
  93788. * @returns the VertexData of the Torus Knot
  93789. */
  93790. static CreateTorusKnot(options: {
  93791. radius?: number;
  93792. tube?: number;
  93793. radialSegments?: number;
  93794. tubularSegments?: number;
  93795. p?: number;
  93796. q?: number;
  93797. sideOrientation?: number;
  93798. frontUVs?: Vector4;
  93799. backUVs?: Vector4;
  93800. }): VertexData;
  93801. /**
  93802. * Compute normals for given positions and indices
  93803. * @param positions an array of vertex positions, [...., x, y, z, ......]
  93804. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  93805. * @param normals an array of vertex normals, [...., x, y, z, ......]
  93806. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  93807. * * facetNormals : optional array of facet normals (vector3)
  93808. * * facetPositions : optional array of facet positions (vector3)
  93809. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  93810. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  93811. * * bInfo : optional bounding info, required for facetPartitioning computation
  93812. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  93813. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  93814. * * useRightHandedSystem: optional boolean to for right handed system computation
  93815. * * depthSort : optional boolean to enable the facet depth sort computation
  93816. * * distanceTo : optional Vector3 to compute the facet depth from this location
  93817. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  93818. */
  93819. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  93820. facetNormals?: any;
  93821. facetPositions?: any;
  93822. facetPartitioning?: any;
  93823. ratio?: number;
  93824. bInfo?: any;
  93825. bbSize?: Vector3;
  93826. subDiv?: any;
  93827. useRightHandedSystem?: boolean;
  93828. depthSort?: boolean;
  93829. distanceTo?: Vector3;
  93830. depthSortedFacets?: any;
  93831. }): void;
  93832. /** @hidden */
  93833. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  93834. /**
  93835. * Applies VertexData created from the imported parameters to the geometry
  93836. * @param parsedVertexData the parsed data from an imported file
  93837. * @param geometry the geometry to apply the VertexData to
  93838. */
  93839. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  93840. }
  93841. }
  93842. declare module BABYLON {
  93843. /**
  93844. * Defines a target to use with MorphTargetManager
  93845. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93846. */
  93847. export class MorphTarget implements IAnimatable {
  93848. /** defines the name of the target */
  93849. name: string;
  93850. /**
  93851. * Gets or sets the list of animations
  93852. */
  93853. animations: Animation[];
  93854. private _scene;
  93855. private _positions;
  93856. private _normals;
  93857. private _tangents;
  93858. private _uvs;
  93859. private _influence;
  93860. private _uniqueId;
  93861. /**
  93862. * Observable raised when the influence changes
  93863. */
  93864. onInfluenceChanged: Observable<boolean>;
  93865. /** @hidden */
  93866. _onDataLayoutChanged: Observable<void>;
  93867. /**
  93868. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  93869. */
  93870. get influence(): number;
  93871. set influence(influence: number);
  93872. /**
  93873. * Gets or sets the id of the morph Target
  93874. */
  93875. id: string;
  93876. private _animationPropertiesOverride;
  93877. /**
  93878. * Gets or sets the animation properties override
  93879. */
  93880. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93881. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  93882. /**
  93883. * Creates a new MorphTarget
  93884. * @param name defines the name of the target
  93885. * @param influence defines the influence to use
  93886. * @param scene defines the scene the morphtarget belongs to
  93887. */
  93888. constructor(
  93889. /** defines the name of the target */
  93890. name: string, influence?: number, scene?: Nullable<Scene>);
  93891. /**
  93892. * Gets the unique ID of this manager
  93893. */
  93894. get uniqueId(): number;
  93895. /**
  93896. * Gets a boolean defining if the target contains position data
  93897. */
  93898. get hasPositions(): boolean;
  93899. /**
  93900. * Gets a boolean defining if the target contains normal data
  93901. */
  93902. get hasNormals(): boolean;
  93903. /**
  93904. * Gets a boolean defining if the target contains tangent data
  93905. */
  93906. get hasTangents(): boolean;
  93907. /**
  93908. * Gets a boolean defining if the target contains texture coordinates data
  93909. */
  93910. get hasUVs(): boolean;
  93911. /**
  93912. * Affects position data to this target
  93913. * @param data defines the position data to use
  93914. */
  93915. setPositions(data: Nullable<FloatArray>): void;
  93916. /**
  93917. * Gets the position data stored in this target
  93918. * @returns a FloatArray containing the position data (or null if not present)
  93919. */
  93920. getPositions(): Nullable<FloatArray>;
  93921. /**
  93922. * Affects normal data to this target
  93923. * @param data defines the normal data to use
  93924. */
  93925. setNormals(data: Nullable<FloatArray>): void;
  93926. /**
  93927. * Gets the normal data stored in this target
  93928. * @returns a FloatArray containing the normal data (or null if not present)
  93929. */
  93930. getNormals(): Nullable<FloatArray>;
  93931. /**
  93932. * Affects tangent data to this target
  93933. * @param data defines the tangent data to use
  93934. */
  93935. setTangents(data: Nullable<FloatArray>): void;
  93936. /**
  93937. * Gets the tangent data stored in this target
  93938. * @returns a FloatArray containing the tangent data (or null if not present)
  93939. */
  93940. getTangents(): Nullable<FloatArray>;
  93941. /**
  93942. * Affects texture coordinates data to this target
  93943. * @param data defines the texture coordinates data to use
  93944. */
  93945. setUVs(data: Nullable<FloatArray>): void;
  93946. /**
  93947. * Gets the texture coordinates data stored in this target
  93948. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  93949. */
  93950. getUVs(): Nullable<FloatArray>;
  93951. /**
  93952. * Clone the current target
  93953. * @returns a new MorphTarget
  93954. */
  93955. clone(): MorphTarget;
  93956. /**
  93957. * Serializes the current target into a Serialization object
  93958. * @returns the serialized object
  93959. */
  93960. serialize(): any;
  93961. /**
  93962. * Returns the string "MorphTarget"
  93963. * @returns "MorphTarget"
  93964. */
  93965. getClassName(): string;
  93966. /**
  93967. * Creates a new target from serialized data
  93968. * @param serializationObject defines the serialized data to use
  93969. * @returns a new MorphTarget
  93970. */
  93971. static Parse(serializationObject: any): MorphTarget;
  93972. /**
  93973. * Creates a MorphTarget from mesh data
  93974. * @param mesh defines the source mesh
  93975. * @param name defines the name to use for the new target
  93976. * @param influence defines the influence to attach to the target
  93977. * @returns a new MorphTarget
  93978. */
  93979. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  93980. }
  93981. }
  93982. declare module BABYLON {
  93983. /**
  93984. * This class is used to deform meshes using morphing between different targets
  93985. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  93986. */
  93987. export class MorphTargetManager {
  93988. private _targets;
  93989. private _targetInfluenceChangedObservers;
  93990. private _targetDataLayoutChangedObservers;
  93991. private _activeTargets;
  93992. private _scene;
  93993. private _influences;
  93994. private _supportsNormals;
  93995. private _supportsTangents;
  93996. private _supportsUVs;
  93997. private _vertexCount;
  93998. private _uniqueId;
  93999. private _tempInfluences;
  94000. /**
  94001. * Gets or sets a boolean indicating if normals must be morphed
  94002. */
  94003. enableNormalMorphing: boolean;
  94004. /**
  94005. * Gets or sets a boolean indicating if tangents must be morphed
  94006. */
  94007. enableTangentMorphing: boolean;
  94008. /**
  94009. * Gets or sets a boolean indicating if UV must be morphed
  94010. */
  94011. enableUVMorphing: boolean;
  94012. /**
  94013. * Creates a new MorphTargetManager
  94014. * @param scene defines the current scene
  94015. */
  94016. constructor(scene?: Nullable<Scene>);
  94017. /**
  94018. * Gets the unique ID of this manager
  94019. */
  94020. get uniqueId(): number;
  94021. /**
  94022. * Gets the number of vertices handled by this manager
  94023. */
  94024. get vertexCount(): number;
  94025. /**
  94026. * Gets a boolean indicating if this manager supports morphing of normals
  94027. */
  94028. get supportsNormals(): boolean;
  94029. /**
  94030. * Gets a boolean indicating if this manager supports morphing of tangents
  94031. */
  94032. get supportsTangents(): boolean;
  94033. /**
  94034. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  94035. */
  94036. get supportsUVs(): boolean;
  94037. /**
  94038. * Gets the number of targets stored in this manager
  94039. */
  94040. get numTargets(): number;
  94041. /**
  94042. * Gets the number of influencers (ie. the number of targets with influences > 0)
  94043. */
  94044. get numInfluencers(): number;
  94045. /**
  94046. * Gets the list of influences (one per target)
  94047. */
  94048. get influences(): Float32Array;
  94049. /**
  94050. * Gets the active target at specified index. An active target is a target with an influence > 0
  94051. * @param index defines the index to check
  94052. * @returns the requested target
  94053. */
  94054. getActiveTarget(index: number): MorphTarget;
  94055. /**
  94056. * Gets the target at specified index
  94057. * @param index defines the index to check
  94058. * @returns the requested target
  94059. */
  94060. getTarget(index: number): MorphTarget;
  94061. /**
  94062. * Add a new target to this manager
  94063. * @param target defines the target to add
  94064. */
  94065. addTarget(target: MorphTarget): void;
  94066. /**
  94067. * Removes a target from the manager
  94068. * @param target defines the target to remove
  94069. */
  94070. removeTarget(target: MorphTarget): void;
  94071. /**
  94072. * Clone the current manager
  94073. * @returns a new MorphTargetManager
  94074. */
  94075. clone(): MorphTargetManager;
  94076. /**
  94077. * Serializes the current manager into a Serialization object
  94078. * @returns the serialized object
  94079. */
  94080. serialize(): any;
  94081. private _syncActiveTargets;
  94082. /**
  94083. * Syncrhonize the targets with all the meshes using this morph target manager
  94084. */
  94085. synchronize(): void;
  94086. /**
  94087. * Creates a new MorphTargetManager from serialized data
  94088. * @param serializationObject defines the serialized data
  94089. * @param scene defines the hosting scene
  94090. * @returns the new MorphTargetManager
  94091. */
  94092. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  94093. }
  94094. }
  94095. declare module BABYLON {
  94096. /**
  94097. * Class used to represent a specific level of detail of a mesh
  94098. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  94099. */
  94100. export class MeshLODLevel {
  94101. /** Defines the distance where this level should start being displayed */
  94102. distance: number;
  94103. /** Defines the mesh to use to render this level */
  94104. mesh: Nullable<Mesh>;
  94105. /**
  94106. * Creates a new LOD level
  94107. * @param distance defines the distance where this level should star being displayed
  94108. * @param mesh defines the mesh to use to render this level
  94109. */
  94110. constructor(
  94111. /** Defines the distance where this level should start being displayed */
  94112. distance: number,
  94113. /** Defines the mesh to use to render this level */
  94114. mesh: Nullable<Mesh>);
  94115. }
  94116. }
  94117. declare module BABYLON {
  94118. /**
  94119. * Mesh representing the gorund
  94120. */
  94121. export class GroundMesh extends Mesh {
  94122. /** If octree should be generated */
  94123. generateOctree: boolean;
  94124. private _heightQuads;
  94125. /** @hidden */
  94126. _subdivisionsX: number;
  94127. /** @hidden */
  94128. _subdivisionsY: number;
  94129. /** @hidden */
  94130. _width: number;
  94131. /** @hidden */
  94132. _height: number;
  94133. /** @hidden */
  94134. _minX: number;
  94135. /** @hidden */
  94136. _maxX: number;
  94137. /** @hidden */
  94138. _minZ: number;
  94139. /** @hidden */
  94140. _maxZ: number;
  94141. constructor(name: string, scene: Scene);
  94142. /**
  94143. * "GroundMesh"
  94144. * @returns "GroundMesh"
  94145. */
  94146. getClassName(): string;
  94147. /**
  94148. * The minimum of x and y subdivisions
  94149. */
  94150. get subdivisions(): number;
  94151. /**
  94152. * X subdivisions
  94153. */
  94154. get subdivisionsX(): number;
  94155. /**
  94156. * Y subdivisions
  94157. */
  94158. get subdivisionsY(): number;
  94159. /**
  94160. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  94161. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  94162. * @param chunksCount the number of subdivisions for x and y
  94163. * @param octreeBlocksSize (Default: 32)
  94164. */
  94165. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  94166. /**
  94167. * Returns a height (y) value in the Worl system :
  94168. * the ground altitude at the coordinates (x, z) expressed in the World system.
  94169. * @param x x coordinate
  94170. * @param z z coordinate
  94171. * @returns the ground y position if (x, z) are outside the ground surface.
  94172. */
  94173. getHeightAtCoordinates(x: number, z: number): number;
  94174. /**
  94175. * Returns a normalized vector (Vector3) orthogonal to the ground
  94176. * at the ground coordinates (x, z) expressed in the World system.
  94177. * @param x x coordinate
  94178. * @param z z coordinate
  94179. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  94180. */
  94181. getNormalAtCoordinates(x: number, z: number): Vector3;
  94182. /**
  94183. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  94184. * at the ground coordinates (x, z) expressed in the World system.
  94185. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  94186. * @param x x coordinate
  94187. * @param z z coordinate
  94188. * @param ref vector to store the result
  94189. * @returns the GroundMesh.
  94190. */
  94191. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  94192. /**
  94193. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  94194. * if the ground has been updated.
  94195. * This can be used in the render loop.
  94196. * @returns the GroundMesh.
  94197. */
  94198. updateCoordinateHeights(): GroundMesh;
  94199. private _getFacetAt;
  94200. private _initHeightQuads;
  94201. private _computeHeightQuads;
  94202. /**
  94203. * Serializes this ground mesh
  94204. * @param serializationObject object to write serialization to
  94205. */
  94206. serialize(serializationObject: any): void;
  94207. /**
  94208. * Parses a serialized ground mesh
  94209. * @param parsedMesh the serialized mesh
  94210. * @param scene the scene to create the ground mesh in
  94211. * @returns the created ground mesh
  94212. */
  94213. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  94214. }
  94215. }
  94216. declare module BABYLON {
  94217. /**
  94218. * Interface for Physics-Joint data
  94219. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94220. */
  94221. export interface PhysicsJointData {
  94222. /**
  94223. * The main pivot of the joint
  94224. */
  94225. mainPivot?: Vector3;
  94226. /**
  94227. * The connected pivot of the joint
  94228. */
  94229. connectedPivot?: Vector3;
  94230. /**
  94231. * The main axis of the joint
  94232. */
  94233. mainAxis?: Vector3;
  94234. /**
  94235. * The connected axis of the joint
  94236. */
  94237. connectedAxis?: Vector3;
  94238. /**
  94239. * The collision of the joint
  94240. */
  94241. collision?: boolean;
  94242. /**
  94243. * Native Oimo/Cannon/Energy data
  94244. */
  94245. nativeParams?: any;
  94246. }
  94247. /**
  94248. * This is a holder class for the physics joint created by the physics plugin
  94249. * It holds a set of functions to control the underlying joint
  94250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94251. */
  94252. export class PhysicsJoint {
  94253. /**
  94254. * The type of the physics joint
  94255. */
  94256. type: number;
  94257. /**
  94258. * The data for the physics joint
  94259. */
  94260. jointData: PhysicsJointData;
  94261. private _physicsJoint;
  94262. protected _physicsPlugin: IPhysicsEnginePlugin;
  94263. /**
  94264. * Initializes the physics joint
  94265. * @param type The type of the physics joint
  94266. * @param jointData The data for the physics joint
  94267. */
  94268. constructor(
  94269. /**
  94270. * The type of the physics joint
  94271. */
  94272. type: number,
  94273. /**
  94274. * The data for the physics joint
  94275. */
  94276. jointData: PhysicsJointData);
  94277. /**
  94278. * Gets the physics joint
  94279. */
  94280. get physicsJoint(): any;
  94281. /**
  94282. * Sets the physics joint
  94283. */
  94284. set physicsJoint(newJoint: any);
  94285. /**
  94286. * Sets the physics plugin
  94287. */
  94288. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  94289. /**
  94290. * Execute a function that is physics-plugin specific.
  94291. * @param {Function} func the function that will be executed.
  94292. * It accepts two parameters: the physics world and the physics joint
  94293. */
  94294. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  94295. /**
  94296. * Distance-Joint type
  94297. */
  94298. static DistanceJoint: number;
  94299. /**
  94300. * Hinge-Joint type
  94301. */
  94302. static HingeJoint: number;
  94303. /**
  94304. * Ball-and-Socket joint type
  94305. */
  94306. static BallAndSocketJoint: number;
  94307. /**
  94308. * Wheel-Joint type
  94309. */
  94310. static WheelJoint: number;
  94311. /**
  94312. * Slider-Joint type
  94313. */
  94314. static SliderJoint: number;
  94315. /**
  94316. * Prismatic-Joint type
  94317. */
  94318. static PrismaticJoint: number;
  94319. /**
  94320. * Universal-Joint type
  94321. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  94322. */
  94323. static UniversalJoint: number;
  94324. /**
  94325. * Hinge-Joint 2 type
  94326. */
  94327. static Hinge2Joint: number;
  94328. /**
  94329. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  94330. */
  94331. static PointToPointJoint: number;
  94332. /**
  94333. * Spring-Joint type
  94334. */
  94335. static SpringJoint: number;
  94336. /**
  94337. * Lock-Joint type
  94338. */
  94339. static LockJoint: number;
  94340. }
  94341. /**
  94342. * A class representing a physics distance joint
  94343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94344. */
  94345. export class DistanceJoint extends PhysicsJoint {
  94346. /**
  94347. *
  94348. * @param jointData The data for the Distance-Joint
  94349. */
  94350. constructor(jointData: DistanceJointData);
  94351. /**
  94352. * Update the predefined distance.
  94353. * @param maxDistance The maximum preferred distance
  94354. * @param minDistance The minimum preferred distance
  94355. */
  94356. updateDistance(maxDistance: number, minDistance?: number): void;
  94357. }
  94358. /**
  94359. * Represents a Motor-Enabled Joint
  94360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94361. */
  94362. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  94363. /**
  94364. * Initializes the Motor-Enabled Joint
  94365. * @param type The type of the joint
  94366. * @param jointData The physica joint data for the joint
  94367. */
  94368. constructor(type: number, jointData: PhysicsJointData);
  94369. /**
  94370. * Set the motor values.
  94371. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94372. * @param force the force to apply
  94373. * @param maxForce max force for this motor.
  94374. */
  94375. setMotor(force?: number, maxForce?: number): void;
  94376. /**
  94377. * Set the motor's limits.
  94378. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94379. * @param upperLimit The upper limit of the motor
  94380. * @param lowerLimit The lower limit of the motor
  94381. */
  94382. setLimit(upperLimit: number, lowerLimit?: number): void;
  94383. }
  94384. /**
  94385. * This class represents a single physics Hinge-Joint
  94386. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94387. */
  94388. export class HingeJoint extends MotorEnabledJoint {
  94389. /**
  94390. * Initializes the Hinge-Joint
  94391. * @param jointData The joint data for the Hinge-Joint
  94392. */
  94393. constructor(jointData: PhysicsJointData);
  94394. /**
  94395. * Set the motor values.
  94396. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94397. * @param {number} force the force to apply
  94398. * @param {number} maxForce max force for this motor.
  94399. */
  94400. setMotor(force?: number, maxForce?: number): void;
  94401. /**
  94402. * Set the motor's limits.
  94403. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94404. * @param upperLimit The upper limit of the motor
  94405. * @param lowerLimit The lower limit of the motor
  94406. */
  94407. setLimit(upperLimit: number, lowerLimit?: number): void;
  94408. }
  94409. /**
  94410. * This class represents a dual hinge physics joint (same as wheel joint)
  94411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94412. */
  94413. export class Hinge2Joint extends MotorEnabledJoint {
  94414. /**
  94415. * Initializes the Hinge2-Joint
  94416. * @param jointData The joint data for the Hinge2-Joint
  94417. */
  94418. constructor(jointData: PhysicsJointData);
  94419. /**
  94420. * Set the motor values.
  94421. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94422. * @param {number} targetSpeed the speed the motor is to reach
  94423. * @param {number} maxForce max force for this motor.
  94424. * @param {motorIndex} the motor's index, 0 or 1.
  94425. */
  94426. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  94427. /**
  94428. * Set the motor limits.
  94429. * Attention, this function is plugin specific. Engines won't react 100% the same.
  94430. * @param {number} upperLimit the upper limit
  94431. * @param {number} lowerLimit lower limit
  94432. * @param {motorIndex} the motor's index, 0 or 1.
  94433. */
  94434. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  94435. }
  94436. /**
  94437. * Interface for a motor enabled joint
  94438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94439. */
  94440. export interface IMotorEnabledJoint {
  94441. /**
  94442. * Physics joint
  94443. */
  94444. physicsJoint: any;
  94445. /**
  94446. * Sets the motor of the motor-enabled joint
  94447. * @param force The force of the motor
  94448. * @param maxForce The maximum force of the motor
  94449. * @param motorIndex The index of the motor
  94450. */
  94451. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  94452. /**
  94453. * Sets the limit of the motor
  94454. * @param upperLimit The upper limit of the motor
  94455. * @param lowerLimit The lower limit of the motor
  94456. * @param motorIndex The index of the motor
  94457. */
  94458. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  94459. }
  94460. /**
  94461. * Joint data for a Distance-Joint
  94462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94463. */
  94464. export interface DistanceJointData extends PhysicsJointData {
  94465. /**
  94466. * Max distance the 2 joint objects can be apart
  94467. */
  94468. maxDistance: number;
  94469. }
  94470. /**
  94471. * Joint data from a spring joint
  94472. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94473. */
  94474. export interface SpringJointData extends PhysicsJointData {
  94475. /**
  94476. * Length of the spring
  94477. */
  94478. length: number;
  94479. /**
  94480. * Stiffness of the spring
  94481. */
  94482. stiffness: number;
  94483. /**
  94484. * Damping of the spring
  94485. */
  94486. damping: number;
  94487. /** this callback will be called when applying the force to the impostors. */
  94488. forceApplicationCallback: () => void;
  94489. }
  94490. }
  94491. declare module BABYLON {
  94492. /**
  94493. * Holds the data for the raycast result
  94494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94495. */
  94496. export class PhysicsRaycastResult {
  94497. private _hasHit;
  94498. private _hitDistance;
  94499. private _hitNormalWorld;
  94500. private _hitPointWorld;
  94501. private _rayFromWorld;
  94502. private _rayToWorld;
  94503. /**
  94504. * Gets if there was a hit
  94505. */
  94506. get hasHit(): boolean;
  94507. /**
  94508. * Gets the distance from the hit
  94509. */
  94510. get hitDistance(): number;
  94511. /**
  94512. * Gets the hit normal/direction in the world
  94513. */
  94514. get hitNormalWorld(): Vector3;
  94515. /**
  94516. * Gets the hit point in the world
  94517. */
  94518. get hitPointWorld(): Vector3;
  94519. /**
  94520. * Gets the ray "start point" of the ray in the world
  94521. */
  94522. get rayFromWorld(): Vector3;
  94523. /**
  94524. * Gets the ray "end point" of the ray in the world
  94525. */
  94526. get rayToWorld(): Vector3;
  94527. /**
  94528. * Sets the hit data (normal & point in world space)
  94529. * @param hitNormalWorld defines the normal in world space
  94530. * @param hitPointWorld defines the point in world space
  94531. */
  94532. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  94533. /**
  94534. * Sets the distance from the start point to the hit point
  94535. * @param distance
  94536. */
  94537. setHitDistance(distance: number): void;
  94538. /**
  94539. * Calculates the distance manually
  94540. */
  94541. calculateHitDistance(): void;
  94542. /**
  94543. * Resets all the values to default
  94544. * @param from The from point on world space
  94545. * @param to The to point on world space
  94546. */
  94547. reset(from?: Vector3, to?: Vector3): void;
  94548. }
  94549. /**
  94550. * Interface for the size containing width and height
  94551. */
  94552. interface IXYZ {
  94553. /**
  94554. * X
  94555. */
  94556. x: number;
  94557. /**
  94558. * Y
  94559. */
  94560. y: number;
  94561. /**
  94562. * Z
  94563. */
  94564. z: number;
  94565. }
  94566. }
  94567. declare module BABYLON {
  94568. /**
  94569. * Interface used to describe a physics joint
  94570. */
  94571. export interface PhysicsImpostorJoint {
  94572. /** Defines the main impostor to which the joint is linked */
  94573. mainImpostor: PhysicsImpostor;
  94574. /** Defines the impostor that is connected to the main impostor using this joint */
  94575. connectedImpostor: PhysicsImpostor;
  94576. /** Defines the joint itself */
  94577. joint: PhysicsJoint;
  94578. }
  94579. /** @hidden */
  94580. export interface IPhysicsEnginePlugin {
  94581. world: any;
  94582. name: string;
  94583. setGravity(gravity: Vector3): void;
  94584. setTimeStep(timeStep: number): void;
  94585. getTimeStep(): number;
  94586. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  94587. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  94588. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  94589. generatePhysicsBody(impostor: PhysicsImpostor): void;
  94590. removePhysicsBody(impostor: PhysicsImpostor): void;
  94591. generateJoint(joint: PhysicsImpostorJoint): void;
  94592. removeJoint(joint: PhysicsImpostorJoint): void;
  94593. isSupported(): boolean;
  94594. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  94595. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  94596. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  94597. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  94598. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  94599. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  94600. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  94601. getBodyMass(impostor: PhysicsImpostor): number;
  94602. getBodyFriction(impostor: PhysicsImpostor): number;
  94603. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  94604. getBodyRestitution(impostor: PhysicsImpostor): number;
  94605. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  94606. getBodyPressure?(impostor: PhysicsImpostor): number;
  94607. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  94608. getBodyStiffness?(impostor: PhysicsImpostor): number;
  94609. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  94610. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  94611. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  94612. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  94613. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  94614. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  94615. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  94616. sleepBody(impostor: PhysicsImpostor): void;
  94617. wakeUpBody(impostor: PhysicsImpostor): void;
  94618. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  94619. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  94620. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  94621. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  94622. getRadius(impostor: PhysicsImpostor): number;
  94623. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  94624. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  94625. dispose(): void;
  94626. }
  94627. /**
  94628. * Interface used to define a physics engine
  94629. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  94630. */
  94631. export interface IPhysicsEngine {
  94632. /**
  94633. * Gets the gravity vector used by the simulation
  94634. */
  94635. gravity: Vector3;
  94636. /**
  94637. * Sets the gravity vector used by the simulation
  94638. * @param gravity defines the gravity vector to use
  94639. */
  94640. setGravity(gravity: Vector3): void;
  94641. /**
  94642. * Set the time step of the physics engine.
  94643. * Default is 1/60.
  94644. * To slow it down, enter 1/600 for example.
  94645. * To speed it up, 1/30
  94646. * @param newTimeStep the new timestep to apply to this world.
  94647. */
  94648. setTimeStep(newTimeStep: number): void;
  94649. /**
  94650. * Get the time step of the physics engine.
  94651. * @returns the current time step
  94652. */
  94653. getTimeStep(): number;
  94654. /**
  94655. * Set the sub time step of the physics engine.
  94656. * Default is 0 meaning there is no sub steps
  94657. * To increase physics resolution precision, set a small value (like 1 ms)
  94658. * @param subTimeStep defines the new sub timestep used for physics resolution.
  94659. */
  94660. setSubTimeStep(subTimeStep: number): void;
  94661. /**
  94662. * Get the sub time step of the physics engine.
  94663. * @returns the current sub time step
  94664. */
  94665. getSubTimeStep(): number;
  94666. /**
  94667. * Release all resources
  94668. */
  94669. dispose(): void;
  94670. /**
  94671. * Gets the name of the current physics plugin
  94672. * @returns the name of the plugin
  94673. */
  94674. getPhysicsPluginName(): string;
  94675. /**
  94676. * Adding a new impostor for the impostor tracking.
  94677. * This will be done by the impostor itself.
  94678. * @param impostor the impostor to add
  94679. */
  94680. addImpostor(impostor: PhysicsImpostor): void;
  94681. /**
  94682. * Remove an impostor from the engine.
  94683. * This impostor and its mesh will not longer be updated by the physics engine.
  94684. * @param impostor the impostor to remove
  94685. */
  94686. removeImpostor(impostor: PhysicsImpostor): void;
  94687. /**
  94688. * Add a joint to the physics engine
  94689. * @param mainImpostor defines the main impostor to which the joint is added.
  94690. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  94691. * @param joint defines the joint that will connect both impostors.
  94692. */
  94693. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  94694. /**
  94695. * Removes a joint from the simulation
  94696. * @param mainImpostor defines the impostor used with the joint
  94697. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  94698. * @param joint defines the joint to remove
  94699. */
  94700. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  94701. /**
  94702. * Gets the current plugin used to run the simulation
  94703. * @returns current plugin
  94704. */
  94705. getPhysicsPlugin(): IPhysicsEnginePlugin;
  94706. /**
  94707. * Gets the list of physic impostors
  94708. * @returns an array of PhysicsImpostor
  94709. */
  94710. getImpostors(): Array<PhysicsImpostor>;
  94711. /**
  94712. * Gets the impostor for a physics enabled object
  94713. * @param object defines the object impersonated by the impostor
  94714. * @returns the PhysicsImpostor or null if not found
  94715. */
  94716. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  94717. /**
  94718. * Gets the impostor for a physics body object
  94719. * @param body defines physics body used by the impostor
  94720. * @returns the PhysicsImpostor or null if not found
  94721. */
  94722. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  94723. /**
  94724. * Does a raycast in the physics world
  94725. * @param from when should the ray start?
  94726. * @param to when should the ray end?
  94727. * @returns PhysicsRaycastResult
  94728. */
  94729. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  94730. /**
  94731. * Called by the scene. No need to call it.
  94732. * @param delta defines the timespam between frames
  94733. */
  94734. _step(delta: number): void;
  94735. }
  94736. }
  94737. declare module BABYLON {
  94738. /**
  94739. * The interface for the physics imposter parameters
  94740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94741. */
  94742. export interface PhysicsImpostorParameters {
  94743. /**
  94744. * The mass of the physics imposter
  94745. */
  94746. mass: number;
  94747. /**
  94748. * The friction of the physics imposter
  94749. */
  94750. friction?: number;
  94751. /**
  94752. * The coefficient of restitution of the physics imposter
  94753. */
  94754. restitution?: number;
  94755. /**
  94756. * The native options of the physics imposter
  94757. */
  94758. nativeOptions?: any;
  94759. /**
  94760. * Specifies if the parent should be ignored
  94761. */
  94762. ignoreParent?: boolean;
  94763. /**
  94764. * Specifies if bi-directional transformations should be disabled
  94765. */
  94766. disableBidirectionalTransformation?: boolean;
  94767. /**
  94768. * The pressure inside the physics imposter, soft object only
  94769. */
  94770. pressure?: number;
  94771. /**
  94772. * The stiffness the physics imposter, soft object only
  94773. */
  94774. stiffness?: number;
  94775. /**
  94776. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  94777. */
  94778. velocityIterations?: number;
  94779. /**
  94780. * The number of iterations used in maintaining consistent vertex positions, soft object only
  94781. */
  94782. positionIterations?: number;
  94783. /**
  94784. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  94785. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  94786. * Add to fix multiple points
  94787. */
  94788. fixedPoints?: number;
  94789. /**
  94790. * The collision margin around a soft object
  94791. */
  94792. margin?: number;
  94793. /**
  94794. * The collision margin around a soft object
  94795. */
  94796. damping?: number;
  94797. /**
  94798. * The path for a rope based on an extrusion
  94799. */
  94800. path?: any;
  94801. /**
  94802. * The shape of an extrusion used for a rope based on an extrusion
  94803. */
  94804. shape?: any;
  94805. }
  94806. /**
  94807. * Interface for a physics-enabled object
  94808. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94809. */
  94810. export interface IPhysicsEnabledObject {
  94811. /**
  94812. * The position of the physics-enabled object
  94813. */
  94814. position: Vector3;
  94815. /**
  94816. * The rotation of the physics-enabled object
  94817. */
  94818. rotationQuaternion: Nullable<Quaternion>;
  94819. /**
  94820. * The scale of the physics-enabled object
  94821. */
  94822. scaling: Vector3;
  94823. /**
  94824. * The rotation of the physics-enabled object
  94825. */
  94826. rotation?: Vector3;
  94827. /**
  94828. * The parent of the physics-enabled object
  94829. */
  94830. parent?: any;
  94831. /**
  94832. * The bounding info of the physics-enabled object
  94833. * @returns The bounding info of the physics-enabled object
  94834. */
  94835. getBoundingInfo(): BoundingInfo;
  94836. /**
  94837. * Computes the world matrix
  94838. * @param force Specifies if the world matrix should be computed by force
  94839. * @returns A world matrix
  94840. */
  94841. computeWorldMatrix(force: boolean): Matrix;
  94842. /**
  94843. * Gets the world matrix
  94844. * @returns A world matrix
  94845. */
  94846. getWorldMatrix?(): Matrix;
  94847. /**
  94848. * Gets the child meshes
  94849. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  94850. * @returns An array of abstract meshes
  94851. */
  94852. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  94853. /**
  94854. * Gets the vertex data
  94855. * @param kind The type of vertex data
  94856. * @returns A nullable array of numbers, or a float32 array
  94857. */
  94858. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  94859. /**
  94860. * Gets the indices from the mesh
  94861. * @returns A nullable array of index arrays
  94862. */
  94863. getIndices?(): Nullable<IndicesArray>;
  94864. /**
  94865. * Gets the scene from the mesh
  94866. * @returns the indices array or null
  94867. */
  94868. getScene?(): Scene;
  94869. /**
  94870. * Gets the absolute position from the mesh
  94871. * @returns the absolute position
  94872. */
  94873. getAbsolutePosition(): Vector3;
  94874. /**
  94875. * Gets the absolute pivot point from the mesh
  94876. * @returns the absolute pivot point
  94877. */
  94878. getAbsolutePivotPoint(): Vector3;
  94879. /**
  94880. * Rotates the mesh
  94881. * @param axis The axis of rotation
  94882. * @param amount The amount of rotation
  94883. * @param space The space of the rotation
  94884. * @returns The rotation transform node
  94885. */
  94886. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  94887. /**
  94888. * Translates the mesh
  94889. * @param axis The axis of translation
  94890. * @param distance The distance of translation
  94891. * @param space The space of the translation
  94892. * @returns The transform node
  94893. */
  94894. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  94895. /**
  94896. * Sets the absolute position of the mesh
  94897. * @param absolutePosition The absolute position of the mesh
  94898. * @returns The transform node
  94899. */
  94900. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  94901. /**
  94902. * Gets the class name of the mesh
  94903. * @returns The class name
  94904. */
  94905. getClassName(): string;
  94906. }
  94907. /**
  94908. * Represents a physics imposter
  94909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  94910. */
  94911. export class PhysicsImpostor {
  94912. /**
  94913. * The physics-enabled object used as the physics imposter
  94914. */
  94915. object: IPhysicsEnabledObject;
  94916. /**
  94917. * The type of the physics imposter
  94918. */
  94919. type: number;
  94920. private _options;
  94921. private _scene?;
  94922. /**
  94923. * The default object size of the imposter
  94924. */
  94925. static DEFAULT_OBJECT_SIZE: Vector3;
  94926. /**
  94927. * The identity quaternion of the imposter
  94928. */
  94929. static IDENTITY_QUATERNION: Quaternion;
  94930. /** @hidden */
  94931. _pluginData: any;
  94932. private _physicsEngine;
  94933. private _physicsBody;
  94934. private _bodyUpdateRequired;
  94935. private _onBeforePhysicsStepCallbacks;
  94936. private _onAfterPhysicsStepCallbacks;
  94937. /** @hidden */
  94938. _onPhysicsCollideCallbacks: Array<{
  94939. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  94940. otherImpostors: Array<PhysicsImpostor>;
  94941. }>;
  94942. private _deltaPosition;
  94943. private _deltaRotation;
  94944. private _deltaRotationConjugated;
  94945. /** @hidden */
  94946. _isFromLine: boolean;
  94947. private _parent;
  94948. private _isDisposed;
  94949. private static _tmpVecs;
  94950. private static _tmpQuat;
  94951. /**
  94952. * Specifies if the physics imposter is disposed
  94953. */
  94954. get isDisposed(): boolean;
  94955. /**
  94956. * Gets the mass of the physics imposter
  94957. */
  94958. get mass(): number;
  94959. set mass(value: number);
  94960. /**
  94961. * Gets the coefficient of friction
  94962. */
  94963. get friction(): number;
  94964. /**
  94965. * Sets the coefficient of friction
  94966. */
  94967. set friction(value: number);
  94968. /**
  94969. * Gets the coefficient of restitution
  94970. */
  94971. get restitution(): number;
  94972. /**
  94973. * Sets the coefficient of restitution
  94974. */
  94975. set restitution(value: number);
  94976. /**
  94977. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  94978. */
  94979. get pressure(): number;
  94980. /**
  94981. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  94982. */
  94983. set pressure(value: number);
  94984. /**
  94985. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94986. */
  94987. get stiffness(): number;
  94988. /**
  94989. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  94990. */
  94991. set stiffness(value: number);
  94992. /**
  94993. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94994. */
  94995. get velocityIterations(): number;
  94996. /**
  94997. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  94998. */
  94999. set velocityIterations(value: number);
  95000. /**
  95001. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  95002. */
  95003. get positionIterations(): number;
  95004. /**
  95005. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  95006. */
  95007. set positionIterations(value: number);
  95008. /**
  95009. * The unique id of the physics imposter
  95010. * set by the physics engine when adding this impostor to the array
  95011. */
  95012. uniqueId: number;
  95013. /**
  95014. * @hidden
  95015. */
  95016. soft: boolean;
  95017. /**
  95018. * @hidden
  95019. */
  95020. segments: number;
  95021. private _joints;
  95022. /**
  95023. * Initializes the physics imposter
  95024. * @param object The physics-enabled object used as the physics imposter
  95025. * @param type The type of the physics imposter
  95026. * @param _options The options for the physics imposter
  95027. * @param _scene The Babylon scene
  95028. */
  95029. constructor(
  95030. /**
  95031. * The physics-enabled object used as the physics imposter
  95032. */
  95033. object: IPhysicsEnabledObject,
  95034. /**
  95035. * The type of the physics imposter
  95036. */
  95037. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  95038. /**
  95039. * This function will completly initialize this impostor.
  95040. * It will create a new body - but only if this mesh has no parent.
  95041. * If it has, this impostor will not be used other than to define the impostor
  95042. * of the child mesh.
  95043. * @hidden
  95044. */
  95045. _init(): void;
  95046. private _getPhysicsParent;
  95047. /**
  95048. * Should a new body be generated.
  95049. * @returns boolean specifying if body initialization is required
  95050. */
  95051. isBodyInitRequired(): boolean;
  95052. /**
  95053. * Sets the updated scaling
  95054. * @param updated Specifies if the scaling is updated
  95055. */
  95056. setScalingUpdated(): void;
  95057. /**
  95058. * Force a regeneration of this or the parent's impostor's body.
  95059. * Use under cautious - This will remove all joints already implemented.
  95060. */
  95061. forceUpdate(): void;
  95062. /**
  95063. * Gets the body that holds this impostor. Either its own, or its parent.
  95064. */
  95065. get physicsBody(): any;
  95066. /**
  95067. * Get the parent of the physics imposter
  95068. * @returns Physics imposter or null
  95069. */
  95070. get parent(): Nullable<PhysicsImpostor>;
  95071. /**
  95072. * Sets the parent of the physics imposter
  95073. */
  95074. set parent(value: Nullable<PhysicsImpostor>);
  95075. /**
  95076. * Set the physics body. Used mainly by the physics engine/plugin
  95077. */
  95078. set physicsBody(physicsBody: any);
  95079. /**
  95080. * Resets the update flags
  95081. */
  95082. resetUpdateFlags(): void;
  95083. /**
  95084. * Gets the object extend size
  95085. * @returns the object extend size
  95086. */
  95087. getObjectExtendSize(): Vector3;
  95088. /**
  95089. * Gets the object center
  95090. * @returns The object center
  95091. */
  95092. getObjectCenter(): Vector3;
  95093. /**
  95094. * Get a specific parametes from the options parameter
  95095. * @param paramName The object parameter name
  95096. * @returns The object parameter
  95097. */
  95098. getParam(paramName: string): any;
  95099. /**
  95100. * Sets a specific parameter in the options given to the physics plugin
  95101. * @param paramName The parameter name
  95102. * @param value The value of the parameter
  95103. */
  95104. setParam(paramName: string, value: number): void;
  95105. /**
  95106. * Specifically change the body's mass option. Won't recreate the physics body object
  95107. * @param mass The mass of the physics imposter
  95108. */
  95109. setMass(mass: number): void;
  95110. /**
  95111. * Gets the linear velocity
  95112. * @returns linear velocity or null
  95113. */
  95114. getLinearVelocity(): Nullable<Vector3>;
  95115. /**
  95116. * Sets the linear velocity
  95117. * @param velocity linear velocity or null
  95118. */
  95119. setLinearVelocity(velocity: Nullable<Vector3>): void;
  95120. /**
  95121. * Gets the angular velocity
  95122. * @returns angular velocity or null
  95123. */
  95124. getAngularVelocity(): Nullable<Vector3>;
  95125. /**
  95126. * Sets the angular velocity
  95127. * @param velocity The velocity or null
  95128. */
  95129. setAngularVelocity(velocity: Nullable<Vector3>): void;
  95130. /**
  95131. * Execute a function with the physics plugin native code
  95132. * Provide a function the will have two variables - the world object and the physics body object
  95133. * @param func The function to execute with the physics plugin native code
  95134. */
  95135. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  95136. /**
  95137. * Register a function that will be executed before the physics world is stepping forward
  95138. * @param func The function to execute before the physics world is stepped forward
  95139. */
  95140. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  95141. /**
  95142. * Unregister a function that will be executed before the physics world is stepping forward
  95143. * @param func The function to execute before the physics world is stepped forward
  95144. */
  95145. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  95146. /**
  95147. * Register a function that will be executed after the physics step
  95148. * @param func The function to execute after physics step
  95149. */
  95150. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  95151. /**
  95152. * Unregisters a function that will be executed after the physics step
  95153. * @param func The function to execute after physics step
  95154. */
  95155. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  95156. /**
  95157. * register a function that will be executed when this impostor collides against a different body
  95158. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  95159. * @param func Callback that is executed on collision
  95160. */
  95161. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  95162. /**
  95163. * Unregisters the physics imposter on contact
  95164. * @param collideAgainst The physics object to collide against
  95165. * @param func Callback to execute on collision
  95166. */
  95167. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  95168. private _tmpQuat;
  95169. private _tmpQuat2;
  95170. /**
  95171. * Get the parent rotation
  95172. * @returns The parent rotation
  95173. */
  95174. getParentsRotation(): Quaternion;
  95175. /**
  95176. * this function is executed by the physics engine.
  95177. */
  95178. beforeStep: () => void;
  95179. /**
  95180. * this function is executed by the physics engine
  95181. */
  95182. afterStep: () => void;
  95183. /**
  95184. * Legacy collision detection event support
  95185. */
  95186. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  95187. /**
  95188. * event and body object due to cannon's event-based architecture.
  95189. */
  95190. onCollide: (e: {
  95191. body: any;
  95192. }) => void;
  95193. /**
  95194. * Apply a force
  95195. * @param force The force to apply
  95196. * @param contactPoint The contact point for the force
  95197. * @returns The physics imposter
  95198. */
  95199. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  95200. /**
  95201. * Apply an impulse
  95202. * @param force The impulse force
  95203. * @param contactPoint The contact point for the impulse force
  95204. * @returns The physics imposter
  95205. */
  95206. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  95207. /**
  95208. * A help function to create a joint
  95209. * @param otherImpostor A physics imposter used to create a joint
  95210. * @param jointType The type of joint
  95211. * @param jointData The data for the joint
  95212. * @returns The physics imposter
  95213. */
  95214. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  95215. /**
  95216. * Add a joint to this impostor with a different impostor
  95217. * @param otherImpostor A physics imposter used to add a joint
  95218. * @param joint The joint to add
  95219. * @returns The physics imposter
  95220. */
  95221. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  95222. /**
  95223. * Add an anchor to a cloth impostor
  95224. * @param otherImpostor rigid impostor to anchor to
  95225. * @param width ratio across width from 0 to 1
  95226. * @param height ratio up height from 0 to 1
  95227. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  95228. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  95229. * @returns impostor the soft imposter
  95230. */
  95231. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  95232. /**
  95233. * Add a hook to a rope impostor
  95234. * @param otherImpostor rigid impostor to anchor to
  95235. * @param length ratio across rope from 0 to 1
  95236. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  95237. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  95238. * @returns impostor the rope imposter
  95239. */
  95240. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  95241. /**
  95242. * Will keep this body still, in a sleep mode.
  95243. * @returns the physics imposter
  95244. */
  95245. sleep(): PhysicsImpostor;
  95246. /**
  95247. * Wake the body up.
  95248. * @returns The physics imposter
  95249. */
  95250. wakeUp(): PhysicsImpostor;
  95251. /**
  95252. * Clones the physics imposter
  95253. * @param newObject The physics imposter clones to this physics-enabled object
  95254. * @returns A nullable physics imposter
  95255. */
  95256. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  95257. /**
  95258. * Disposes the physics imposter
  95259. */
  95260. dispose(): void;
  95261. /**
  95262. * Sets the delta position
  95263. * @param position The delta position amount
  95264. */
  95265. setDeltaPosition(position: Vector3): void;
  95266. /**
  95267. * Sets the delta rotation
  95268. * @param rotation The delta rotation amount
  95269. */
  95270. setDeltaRotation(rotation: Quaternion): void;
  95271. /**
  95272. * Gets the box size of the physics imposter and stores the result in the input parameter
  95273. * @param result Stores the box size
  95274. * @returns The physics imposter
  95275. */
  95276. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  95277. /**
  95278. * Gets the radius of the physics imposter
  95279. * @returns Radius of the physics imposter
  95280. */
  95281. getRadius(): number;
  95282. /**
  95283. * Sync a bone with this impostor
  95284. * @param bone The bone to sync to the impostor.
  95285. * @param boneMesh The mesh that the bone is influencing.
  95286. * @param jointPivot The pivot of the joint / bone in local space.
  95287. * @param distToJoint Optional distance from the impostor to the joint.
  95288. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  95289. */
  95290. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  95291. /**
  95292. * Sync impostor to a bone
  95293. * @param bone The bone that the impostor will be synced to.
  95294. * @param boneMesh The mesh that the bone is influencing.
  95295. * @param jointPivot The pivot of the joint / bone in local space.
  95296. * @param distToJoint Optional distance from the impostor to the joint.
  95297. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  95298. * @param boneAxis Optional vector3 axis the bone is aligned with
  95299. */
  95300. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  95301. /**
  95302. * No-Imposter type
  95303. */
  95304. static NoImpostor: number;
  95305. /**
  95306. * Sphere-Imposter type
  95307. */
  95308. static SphereImpostor: number;
  95309. /**
  95310. * Box-Imposter type
  95311. */
  95312. static BoxImpostor: number;
  95313. /**
  95314. * Plane-Imposter type
  95315. */
  95316. static PlaneImpostor: number;
  95317. /**
  95318. * Mesh-imposter type
  95319. */
  95320. static MeshImpostor: number;
  95321. /**
  95322. * Capsule-Impostor type (Ammo.js plugin only)
  95323. */
  95324. static CapsuleImpostor: number;
  95325. /**
  95326. * Cylinder-Imposter type
  95327. */
  95328. static CylinderImpostor: number;
  95329. /**
  95330. * Particle-Imposter type
  95331. */
  95332. static ParticleImpostor: number;
  95333. /**
  95334. * Heightmap-Imposter type
  95335. */
  95336. static HeightmapImpostor: number;
  95337. /**
  95338. * ConvexHull-Impostor type (Ammo.js plugin only)
  95339. */
  95340. static ConvexHullImpostor: number;
  95341. /**
  95342. * Custom-Imposter type (Ammo.js plugin only)
  95343. */
  95344. static CustomImpostor: number;
  95345. /**
  95346. * Rope-Imposter type
  95347. */
  95348. static RopeImpostor: number;
  95349. /**
  95350. * Cloth-Imposter type
  95351. */
  95352. static ClothImpostor: number;
  95353. /**
  95354. * Softbody-Imposter type
  95355. */
  95356. static SoftbodyImpostor: number;
  95357. }
  95358. }
  95359. declare module BABYLON {
  95360. /**
  95361. * @hidden
  95362. **/
  95363. export class _CreationDataStorage {
  95364. closePath?: boolean;
  95365. closeArray?: boolean;
  95366. idx: number[];
  95367. dashSize: number;
  95368. gapSize: number;
  95369. path3D: Path3D;
  95370. pathArray: Vector3[][];
  95371. arc: number;
  95372. radius: number;
  95373. cap: number;
  95374. tessellation: number;
  95375. }
  95376. /**
  95377. * @hidden
  95378. **/
  95379. class _InstanceDataStorage {
  95380. visibleInstances: any;
  95381. batchCache: _InstancesBatch;
  95382. instancesBufferSize: number;
  95383. instancesBuffer: Nullable<Buffer>;
  95384. instancesData: Float32Array;
  95385. overridenInstanceCount: number;
  95386. isFrozen: boolean;
  95387. previousBatch: Nullable<_InstancesBatch>;
  95388. hardwareInstancedRendering: boolean;
  95389. sideOrientation: number;
  95390. manualUpdate: boolean;
  95391. }
  95392. /**
  95393. * @hidden
  95394. **/
  95395. export class _InstancesBatch {
  95396. mustReturn: boolean;
  95397. visibleInstances: Nullable<InstancedMesh[]>[];
  95398. renderSelf: boolean[];
  95399. hardwareInstancedRendering: boolean[];
  95400. }
  95401. /**
  95402. * Class used to represent renderable models
  95403. */
  95404. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  95405. /**
  95406. * Mesh side orientation : usually the external or front surface
  95407. */
  95408. static readonly FRONTSIDE: number;
  95409. /**
  95410. * Mesh side orientation : usually the internal or back surface
  95411. */
  95412. static readonly BACKSIDE: number;
  95413. /**
  95414. * Mesh side orientation : both internal and external or front and back surfaces
  95415. */
  95416. static readonly DOUBLESIDE: number;
  95417. /**
  95418. * Mesh side orientation : by default, `FRONTSIDE`
  95419. */
  95420. static readonly DEFAULTSIDE: number;
  95421. /**
  95422. * Mesh cap setting : no cap
  95423. */
  95424. static readonly NO_CAP: number;
  95425. /**
  95426. * Mesh cap setting : one cap at the beginning of the mesh
  95427. */
  95428. static readonly CAP_START: number;
  95429. /**
  95430. * Mesh cap setting : one cap at the end of the mesh
  95431. */
  95432. static readonly CAP_END: number;
  95433. /**
  95434. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  95435. */
  95436. static readonly CAP_ALL: number;
  95437. /**
  95438. * Mesh pattern setting : no flip or rotate
  95439. */
  95440. static readonly NO_FLIP: number;
  95441. /**
  95442. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  95443. */
  95444. static readonly FLIP_TILE: number;
  95445. /**
  95446. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  95447. */
  95448. static readonly ROTATE_TILE: number;
  95449. /**
  95450. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  95451. */
  95452. static readonly FLIP_ROW: number;
  95453. /**
  95454. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  95455. */
  95456. static readonly ROTATE_ROW: number;
  95457. /**
  95458. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  95459. */
  95460. static readonly FLIP_N_ROTATE_TILE: number;
  95461. /**
  95462. * Mesh pattern setting : rotate pattern and rotate
  95463. */
  95464. static readonly FLIP_N_ROTATE_ROW: number;
  95465. /**
  95466. * Mesh tile positioning : part tiles same on left/right or top/bottom
  95467. */
  95468. static readonly CENTER: number;
  95469. /**
  95470. * Mesh tile positioning : part tiles on left
  95471. */
  95472. static readonly LEFT: number;
  95473. /**
  95474. * Mesh tile positioning : part tiles on right
  95475. */
  95476. static readonly RIGHT: number;
  95477. /**
  95478. * Mesh tile positioning : part tiles on top
  95479. */
  95480. static readonly TOP: number;
  95481. /**
  95482. * Mesh tile positioning : part tiles on bottom
  95483. */
  95484. static readonly BOTTOM: number;
  95485. /**
  95486. * Gets the default side orientation.
  95487. * @param orientation the orientation to value to attempt to get
  95488. * @returns the default orientation
  95489. * @hidden
  95490. */
  95491. static _GetDefaultSideOrientation(orientation?: number): number;
  95492. private _internalMeshDataInfo;
  95493. /**
  95494. * An event triggered before rendering the mesh
  95495. */
  95496. get onBeforeRenderObservable(): Observable<Mesh>;
  95497. /**
  95498. * An event triggered before binding the mesh
  95499. */
  95500. get onBeforeBindObservable(): Observable<Mesh>;
  95501. /**
  95502. * An event triggered after rendering the mesh
  95503. */
  95504. get onAfterRenderObservable(): Observable<Mesh>;
  95505. /**
  95506. * An event triggered before drawing the mesh
  95507. */
  95508. get onBeforeDrawObservable(): Observable<Mesh>;
  95509. private _onBeforeDrawObserver;
  95510. /**
  95511. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  95512. */
  95513. set onBeforeDraw(callback: () => void);
  95514. get hasInstances(): boolean;
  95515. /**
  95516. * Gets the delay loading state of the mesh (when delay loading is turned on)
  95517. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  95518. */
  95519. delayLoadState: number;
  95520. /**
  95521. * Gets the list of instances created from this mesh
  95522. * it is not supposed to be modified manually.
  95523. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  95524. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  95525. */
  95526. instances: InstancedMesh[];
  95527. /**
  95528. * Gets the file containing delay loading data for this mesh
  95529. */
  95530. delayLoadingFile: string;
  95531. /** @hidden */
  95532. _binaryInfo: any;
  95533. /**
  95534. * User defined function used to change how LOD level selection is done
  95535. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  95536. */
  95537. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  95538. /**
  95539. * Gets or sets the morph target manager
  95540. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95541. */
  95542. get morphTargetManager(): Nullable<MorphTargetManager>;
  95543. set morphTargetManager(value: Nullable<MorphTargetManager>);
  95544. /** @hidden */
  95545. _creationDataStorage: Nullable<_CreationDataStorage>;
  95546. /** @hidden */
  95547. _geometry: Nullable<Geometry>;
  95548. /** @hidden */
  95549. _delayInfo: Array<string>;
  95550. /** @hidden */
  95551. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  95552. /** @hidden */
  95553. _instanceDataStorage: _InstanceDataStorage;
  95554. private _effectiveMaterial;
  95555. /** @hidden */
  95556. _shouldGenerateFlatShading: boolean;
  95557. /** @hidden */
  95558. _originalBuilderSideOrientation: number;
  95559. /**
  95560. * Use this property to change the original side orientation defined at construction time
  95561. */
  95562. overrideMaterialSideOrientation: Nullable<number>;
  95563. /**
  95564. * Gets the source mesh (the one used to clone this one from)
  95565. */
  95566. get source(): Nullable<Mesh>;
  95567. /**
  95568. * Gets or sets a boolean indicating that this mesh does not use index buffer
  95569. */
  95570. get isUnIndexed(): boolean;
  95571. set isUnIndexed(value: boolean);
  95572. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  95573. get worldMatrixInstancedBuffer(): Float32Array;
  95574. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  95575. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  95576. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  95577. /**
  95578. * @constructor
  95579. * @param name The value used by scene.getMeshByName() to do a lookup.
  95580. * @param scene The scene to add this mesh to.
  95581. * @param parent The parent of this mesh, if it has one
  95582. * @param source An optional Mesh from which geometry is shared, cloned.
  95583. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  95584. * When false, achieved by calling a clone(), also passing False.
  95585. * This will make creation of children, recursive.
  95586. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  95587. */
  95588. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  95589. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95590. doNotInstantiate: boolean;
  95591. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95592. /**
  95593. * Gets the class name
  95594. * @returns the string "Mesh".
  95595. */
  95596. getClassName(): string;
  95597. /** @hidden */
  95598. get _isMesh(): boolean;
  95599. /**
  95600. * Returns a description of this mesh
  95601. * @param fullDetails define if full details about this mesh must be used
  95602. * @returns a descriptive string representing this mesh
  95603. */
  95604. toString(fullDetails?: boolean): string;
  95605. /** @hidden */
  95606. _unBindEffect(): void;
  95607. /**
  95608. * Gets a boolean indicating if this mesh has LOD
  95609. */
  95610. get hasLODLevels(): boolean;
  95611. /**
  95612. * Gets the list of MeshLODLevel associated with the current mesh
  95613. * @returns an array of MeshLODLevel
  95614. */
  95615. getLODLevels(): MeshLODLevel[];
  95616. private _sortLODLevels;
  95617. /**
  95618. * Add a mesh as LOD level triggered at the given distance.
  95619. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  95620. * @param distance The distance from the center of the object to show this level
  95621. * @param mesh The mesh to be added as LOD level (can be null)
  95622. * @return This mesh (for chaining)
  95623. */
  95624. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  95625. /**
  95626. * Returns the LOD level mesh at the passed distance or null if not found.
  95627. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  95628. * @param distance The distance from the center of the object to show this level
  95629. * @returns a Mesh or `null`
  95630. */
  95631. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  95632. /**
  95633. * Remove a mesh from the LOD array
  95634. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  95635. * @param mesh defines the mesh to be removed
  95636. * @return This mesh (for chaining)
  95637. */
  95638. removeLODLevel(mesh: Mesh): Mesh;
  95639. /**
  95640. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  95641. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  95642. * @param camera defines the camera to use to compute distance
  95643. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  95644. * @return This mesh (for chaining)
  95645. */
  95646. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  95647. /**
  95648. * Gets the mesh internal Geometry object
  95649. */
  95650. get geometry(): Nullable<Geometry>;
  95651. /**
  95652. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  95653. * @returns the total number of vertices
  95654. */
  95655. getTotalVertices(): number;
  95656. /**
  95657. * Returns the content of an associated vertex buffer
  95658. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  95659. * - VertexBuffer.PositionKind
  95660. * - VertexBuffer.UVKind
  95661. * - VertexBuffer.UV2Kind
  95662. * - VertexBuffer.UV3Kind
  95663. * - VertexBuffer.UV4Kind
  95664. * - VertexBuffer.UV5Kind
  95665. * - VertexBuffer.UV6Kind
  95666. * - VertexBuffer.ColorKind
  95667. * - VertexBuffer.MatricesIndicesKind
  95668. * - VertexBuffer.MatricesIndicesExtraKind
  95669. * - VertexBuffer.MatricesWeightsKind
  95670. * - VertexBuffer.MatricesWeightsExtraKind
  95671. * @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
  95672. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  95673. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  95674. */
  95675. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95676. /**
  95677. * Returns the mesh VertexBuffer object from the requested `kind`
  95678. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  95679. * - VertexBuffer.PositionKind
  95680. * - VertexBuffer.NormalKind
  95681. * - VertexBuffer.UVKind
  95682. * - VertexBuffer.UV2Kind
  95683. * - VertexBuffer.UV3Kind
  95684. * - VertexBuffer.UV4Kind
  95685. * - VertexBuffer.UV5Kind
  95686. * - VertexBuffer.UV6Kind
  95687. * - VertexBuffer.ColorKind
  95688. * - VertexBuffer.MatricesIndicesKind
  95689. * - VertexBuffer.MatricesIndicesExtraKind
  95690. * - VertexBuffer.MatricesWeightsKind
  95691. * - VertexBuffer.MatricesWeightsExtraKind
  95692. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  95693. */
  95694. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95695. /**
  95696. * Tests if a specific vertex buffer is associated with this mesh
  95697. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  95698. * - VertexBuffer.PositionKind
  95699. * - VertexBuffer.NormalKind
  95700. * - VertexBuffer.UVKind
  95701. * - VertexBuffer.UV2Kind
  95702. * - VertexBuffer.UV3Kind
  95703. * - VertexBuffer.UV4Kind
  95704. * - VertexBuffer.UV5Kind
  95705. * - VertexBuffer.UV6Kind
  95706. * - VertexBuffer.ColorKind
  95707. * - VertexBuffer.MatricesIndicesKind
  95708. * - VertexBuffer.MatricesIndicesExtraKind
  95709. * - VertexBuffer.MatricesWeightsKind
  95710. * - VertexBuffer.MatricesWeightsExtraKind
  95711. * @returns a boolean
  95712. */
  95713. isVerticesDataPresent(kind: string): boolean;
  95714. /**
  95715. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  95716. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  95717. * - VertexBuffer.PositionKind
  95718. * - VertexBuffer.UVKind
  95719. * - VertexBuffer.UV2Kind
  95720. * - VertexBuffer.UV3Kind
  95721. * - VertexBuffer.UV4Kind
  95722. * - VertexBuffer.UV5Kind
  95723. * - VertexBuffer.UV6Kind
  95724. * - VertexBuffer.ColorKind
  95725. * - VertexBuffer.MatricesIndicesKind
  95726. * - VertexBuffer.MatricesIndicesExtraKind
  95727. * - VertexBuffer.MatricesWeightsKind
  95728. * - VertexBuffer.MatricesWeightsExtraKind
  95729. * @returns a boolean
  95730. */
  95731. isVertexBufferUpdatable(kind: string): boolean;
  95732. /**
  95733. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  95734. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  95735. * - VertexBuffer.PositionKind
  95736. * - VertexBuffer.NormalKind
  95737. * - VertexBuffer.UVKind
  95738. * - VertexBuffer.UV2Kind
  95739. * - VertexBuffer.UV3Kind
  95740. * - VertexBuffer.UV4Kind
  95741. * - VertexBuffer.UV5Kind
  95742. * - VertexBuffer.UV6Kind
  95743. * - VertexBuffer.ColorKind
  95744. * - VertexBuffer.MatricesIndicesKind
  95745. * - VertexBuffer.MatricesIndicesExtraKind
  95746. * - VertexBuffer.MatricesWeightsKind
  95747. * - VertexBuffer.MatricesWeightsExtraKind
  95748. * @returns an array of strings
  95749. */
  95750. getVerticesDataKinds(): string[];
  95751. /**
  95752. * Returns a positive integer : the total number of indices in this mesh geometry.
  95753. * @returns the numner of indices or zero if the mesh has no geometry.
  95754. */
  95755. getTotalIndices(): number;
  95756. /**
  95757. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95758. * @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.
  95759. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95760. * @returns the indices array or an empty array if the mesh has no geometry
  95761. */
  95762. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95763. get isBlocked(): boolean;
  95764. /**
  95765. * Determine if the current mesh is ready to be rendered
  95766. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  95767. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  95768. * @returns true if all associated assets are ready (material, textures, shaders)
  95769. */
  95770. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  95771. /**
  95772. * 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.
  95773. */
  95774. get areNormalsFrozen(): boolean;
  95775. /**
  95776. * 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.
  95777. * @returns the current mesh
  95778. */
  95779. freezeNormals(): Mesh;
  95780. /**
  95781. * 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
  95782. * @returns the current mesh
  95783. */
  95784. unfreezeNormals(): Mesh;
  95785. /**
  95786. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  95787. */
  95788. set overridenInstanceCount(count: number);
  95789. /** @hidden */
  95790. _preActivate(): Mesh;
  95791. /** @hidden */
  95792. _preActivateForIntermediateRendering(renderId: number): Mesh;
  95793. /** @hidden */
  95794. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  95795. /**
  95796. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  95797. * This means the mesh underlying bounding box and sphere are recomputed.
  95798. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  95799. * @returns the current mesh
  95800. */
  95801. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  95802. /** @hidden */
  95803. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  95804. /**
  95805. * This function will subdivide the mesh into multiple submeshes
  95806. * @param count defines the expected number of submeshes
  95807. */
  95808. subdivide(count: number): void;
  95809. /**
  95810. * Copy a FloatArray into a specific associated vertex buffer
  95811. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95812. * - VertexBuffer.PositionKind
  95813. * - VertexBuffer.UVKind
  95814. * - VertexBuffer.UV2Kind
  95815. * - VertexBuffer.UV3Kind
  95816. * - VertexBuffer.UV4Kind
  95817. * - VertexBuffer.UV5Kind
  95818. * - VertexBuffer.UV6Kind
  95819. * - VertexBuffer.ColorKind
  95820. * - VertexBuffer.MatricesIndicesKind
  95821. * - VertexBuffer.MatricesIndicesExtraKind
  95822. * - VertexBuffer.MatricesWeightsKind
  95823. * - VertexBuffer.MatricesWeightsExtraKind
  95824. * @param data defines the data source
  95825. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95826. * @param stride defines the data stride size (can be null)
  95827. * @returns the current mesh
  95828. */
  95829. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  95830. /**
  95831. * Delete a vertex buffer associated with this mesh
  95832. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  95833. * - VertexBuffer.PositionKind
  95834. * - VertexBuffer.UVKind
  95835. * - VertexBuffer.UV2Kind
  95836. * - VertexBuffer.UV3Kind
  95837. * - VertexBuffer.UV4Kind
  95838. * - VertexBuffer.UV5Kind
  95839. * - VertexBuffer.UV6Kind
  95840. * - VertexBuffer.ColorKind
  95841. * - VertexBuffer.MatricesIndicesKind
  95842. * - VertexBuffer.MatricesIndicesExtraKind
  95843. * - VertexBuffer.MatricesWeightsKind
  95844. * - VertexBuffer.MatricesWeightsExtraKind
  95845. */
  95846. removeVerticesData(kind: string): void;
  95847. /**
  95848. * Flags an associated vertex buffer as updatable
  95849. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  95850. * - VertexBuffer.PositionKind
  95851. * - VertexBuffer.UVKind
  95852. * - VertexBuffer.UV2Kind
  95853. * - VertexBuffer.UV3Kind
  95854. * - VertexBuffer.UV4Kind
  95855. * - VertexBuffer.UV5Kind
  95856. * - VertexBuffer.UV6Kind
  95857. * - VertexBuffer.ColorKind
  95858. * - VertexBuffer.MatricesIndicesKind
  95859. * - VertexBuffer.MatricesIndicesExtraKind
  95860. * - VertexBuffer.MatricesWeightsKind
  95861. * - VertexBuffer.MatricesWeightsExtraKind
  95862. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  95863. */
  95864. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  95865. /**
  95866. * Sets the mesh global Vertex Buffer
  95867. * @param buffer defines the buffer to use
  95868. * @returns the current mesh
  95869. */
  95870. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  95871. /**
  95872. * Update a specific associated vertex buffer
  95873. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95874. * - VertexBuffer.PositionKind
  95875. * - VertexBuffer.UVKind
  95876. * - VertexBuffer.UV2Kind
  95877. * - VertexBuffer.UV3Kind
  95878. * - VertexBuffer.UV4Kind
  95879. * - VertexBuffer.UV5Kind
  95880. * - VertexBuffer.UV6Kind
  95881. * - VertexBuffer.ColorKind
  95882. * - VertexBuffer.MatricesIndicesKind
  95883. * - VertexBuffer.MatricesIndicesExtraKind
  95884. * - VertexBuffer.MatricesWeightsKind
  95885. * - VertexBuffer.MatricesWeightsExtraKind
  95886. * @param data defines the data source
  95887. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95888. * @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)
  95889. * @returns the current mesh
  95890. */
  95891. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  95892. /**
  95893. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  95894. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  95895. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  95896. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  95897. * @returns the current mesh
  95898. */
  95899. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  95900. /**
  95901. * Creates a un-shared specific occurence of the geometry for the mesh.
  95902. * @returns the current mesh
  95903. */
  95904. makeGeometryUnique(): Mesh;
  95905. /**
  95906. * Set the index buffer of this mesh
  95907. * @param indices defines the source data
  95908. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  95909. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  95910. * @returns the current mesh
  95911. */
  95912. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  95913. /**
  95914. * Update the current index buffer
  95915. * @param indices defines the source data
  95916. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  95917. * @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)
  95918. * @returns the current mesh
  95919. */
  95920. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  95921. /**
  95922. * Invert the geometry to move from a right handed system to a left handed one.
  95923. * @returns the current mesh
  95924. */
  95925. toLeftHanded(): Mesh;
  95926. /** @hidden */
  95927. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95928. /** @hidden */
  95929. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95930. /**
  95931. * Registers for this mesh a javascript function called just before the rendering process
  95932. * @param func defines the function to call before rendering this mesh
  95933. * @returns the current mesh
  95934. */
  95935. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95936. /**
  95937. * Disposes a previously registered javascript function called before the rendering
  95938. * @param func defines the function to remove
  95939. * @returns the current mesh
  95940. */
  95941. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  95942. /**
  95943. * Registers for this mesh a javascript function called just after the rendering is complete
  95944. * @param func defines the function to call after rendering this mesh
  95945. * @returns the current mesh
  95946. */
  95947. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95948. /**
  95949. * Disposes a previously registered javascript function called after the rendering.
  95950. * @param func defines the function to remove
  95951. * @returns the current mesh
  95952. */
  95953. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  95954. /** @hidden */
  95955. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  95956. /** @hidden */
  95957. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  95958. /** @hidden */
  95959. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  95960. /** @hidden */
  95961. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  95962. /** @hidden */
  95963. _rebuild(): void;
  95964. /** @hidden */
  95965. _freeze(): void;
  95966. /** @hidden */
  95967. _unFreeze(): void;
  95968. /**
  95969. * 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
  95970. * @param subMesh defines the subMesh to render
  95971. * @param enableAlphaMode defines if alpha mode can be changed
  95972. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  95973. * @returns the current mesh
  95974. */
  95975. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  95976. private _onBeforeDraw;
  95977. /**
  95978. * Renormalize the mesh and patch it up if there are no weights
  95979. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  95980. * However in the case of zero weights then we set just a single influence to 1.
  95981. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  95982. */
  95983. cleanMatrixWeights(): void;
  95984. private normalizeSkinFourWeights;
  95985. private normalizeSkinWeightsAndExtra;
  95986. /**
  95987. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  95988. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  95989. * the user know there was an issue with importing the mesh
  95990. * @returns a validation object with skinned, valid and report string
  95991. */
  95992. validateSkinning(): {
  95993. skinned: boolean;
  95994. valid: boolean;
  95995. report: string;
  95996. };
  95997. /** @hidden */
  95998. _checkDelayState(): Mesh;
  95999. private _queueLoad;
  96000. /**
  96001. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  96002. * A mesh is in the frustum if its bounding box intersects the frustum
  96003. * @param frustumPlanes defines the frustum to test
  96004. * @returns true if the mesh is in the frustum planes
  96005. */
  96006. isInFrustum(frustumPlanes: Plane[]): boolean;
  96007. /**
  96008. * Sets the mesh material by the material or multiMaterial `id` property
  96009. * @param id is a string identifying the material or the multiMaterial
  96010. * @returns the current mesh
  96011. */
  96012. setMaterialByID(id: string): Mesh;
  96013. /**
  96014. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  96015. * @returns an array of IAnimatable
  96016. */
  96017. getAnimatables(): IAnimatable[];
  96018. /**
  96019. * Modifies the mesh geometry according to the passed transformation matrix.
  96020. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  96021. * The mesh normals are modified using the same transformation.
  96022. * Note that, under the hood, this method sets a new VertexBuffer each call.
  96023. * @param transform defines the transform matrix to use
  96024. * @see http://doc.babylonjs.com/resources/baking_transformations
  96025. * @returns the current mesh
  96026. */
  96027. bakeTransformIntoVertices(transform: Matrix): Mesh;
  96028. /**
  96029. * Modifies the mesh geometry according to its own current World Matrix.
  96030. * The mesh World Matrix is then reset.
  96031. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  96032. * Note that, under the hood, this method sets a new VertexBuffer each call.
  96033. * @see http://doc.babylonjs.com/resources/baking_transformations
  96034. * @returns the current mesh
  96035. */
  96036. bakeCurrentTransformIntoVertices(): Mesh;
  96037. /** @hidden */
  96038. get _positions(): Nullable<Vector3[]>;
  96039. /** @hidden */
  96040. _resetPointsArrayCache(): Mesh;
  96041. /** @hidden */
  96042. _generatePointsArray(): boolean;
  96043. /**
  96044. * Returns a new Mesh object generated from the current mesh properties.
  96045. * This method must not get confused with createInstance()
  96046. * @param name is a string, the name given to the new mesh
  96047. * @param newParent can be any Node object (default `null`)
  96048. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  96049. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  96050. * @returns a new mesh
  96051. */
  96052. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  96053. /**
  96054. * Releases resources associated with this mesh.
  96055. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96056. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96057. */
  96058. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96059. /** @hidden */
  96060. _disposeInstanceSpecificData(): void;
  96061. /**
  96062. * Modifies the mesh geometry according to a displacement map.
  96063. * 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.
  96064. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  96065. * @param url is a string, the URL from the image file is to be downloaded.
  96066. * @param minHeight is the lower limit of the displacement.
  96067. * @param maxHeight is the upper limit of the displacement.
  96068. * @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.
  96069. * @param uvOffset is an optional vector2 used to offset UV.
  96070. * @param uvScale is an optional vector2 used to scale UV.
  96071. * @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.
  96072. * @returns the Mesh.
  96073. */
  96074. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  96075. /**
  96076. * Modifies the mesh geometry according to a displacementMap buffer.
  96077. * 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.
  96078. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  96079. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  96080. * @param heightMapWidth is the width of the buffer image.
  96081. * @param heightMapHeight is the height of the buffer image.
  96082. * @param minHeight is the lower limit of the displacement.
  96083. * @param maxHeight is the upper limit of the displacement.
  96084. * @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.
  96085. * @param uvOffset is an optional vector2 used to offset UV.
  96086. * @param uvScale is an optional vector2 used to scale UV.
  96087. * @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.
  96088. * @returns the Mesh.
  96089. */
  96090. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  96091. /**
  96092. * Modify the mesh to get a flat shading rendering.
  96093. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  96094. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  96095. * @returns current mesh
  96096. */
  96097. convertToFlatShadedMesh(): Mesh;
  96098. /**
  96099. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  96100. * In other words, more vertices, no more indices and a single bigger VBO.
  96101. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  96102. * @returns current mesh
  96103. */
  96104. convertToUnIndexedMesh(): Mesh;
  96105. /**
  96106. * Inverses facet orientations.
  96107. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  96108. * @param flipNormals will also inverts the normals
  96109. * @returns current mesh
  96110. */
  96111. flipFaces(flipNormals?: boolean): Mesh;
  96112. /**
  96113. * Increase the number of facets and hence vertices in a mesh
  96114. * Vertex normals are interpolated from existing vertex normals
  96115. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  96116. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  96117. */
  96118. increaseVertices(numberPerEdge: number): void;
  96119. /**
  96120. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  96121. * This will undo any application of covertToFlatShadedMesh
  96122. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  96123. */
  96124. forceSharedVertices(): void;
  96125. /** @hidden */
  96126. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  96127. /** @hidden */
  96128. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  96129. /**
  96130. * Creates a new InstancedMesh object from the mesh model.
  96131. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  96132. * @param name defines the name of the new instance
  96133. * @returns a new InstancedMesh
  96134. */
  96135. createInstance(name: string): InstancedMesh;
  96136. /**
  96137. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  96138. * After this call, all the mesh instances have the same submeshes than the current mesh.
  96139. * @returns the current mesh
  96140. */
  96141. synchronizeInstances(): Mesh;
  96142. /**
  96143. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  96144. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  96145. * This should be used together with the simplification to avoid disappearing triangles.
  96146. * @param successCallback an optional success callback to be called after the optimization finished.
  96147. * @returns the current mesh
  96148. */
  96149. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  96150. /**
  96151. * Serialize current mesh
  96152. * @param serializationObject defines the object which will receive the serialization data
  96153. */
  96154. serialize(serializationObject: any): void;
  96155. /** @hidden */
  96156. _syncGeometryWithMorphTargetManager(): void;
  96157. /** @hidden */
  96158. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  96159. /**
  96160. * Returns a new Mesh object parsed from the source provided.
  96161. * @param parsedMesh is the source
  96162. * @param scene defines the hosting scene
  96163. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  96164. * @returns a new Mesh
  96165. */
  96166. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  96167. /**
  96168. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  96169. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  96170. * @param name defines the name of the mesh to create
  96171. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  96172. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  96173. * @param closePath creates a seam between the first and the last points of each path of the path array
  96174. * @param offset is taken in account only if the `pathArray` is containing a single path
  96175. * @param scene defines the hosting scene
  96176. * @param updatable defines if the mesh must be flagged as updatable
  96177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96178. * @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)
  96179. * @returns a new Mesh
  96180. */
  96181. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  96182. /**
  96183. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  96184. * @param name defines the name of the mesh to create
  96185. * @param radius sets the radius size (float) of the polygon (default 0.5)
  96186. * @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
  96187. * @param scene defines the hosting scene
  96188. * @param updatable defines if the mesh must be flagged as updatable
  96189. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96190. * @returns a new Mesh
  96191. */
  96192. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  96193. /**
  96194. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  96195. * @param name defines the name of the mesh to create
  96196. * @param size sets the size (float) of each box side (default 1)
  96197. * @param scene defines the hosting scene
  96198. * @param updatable defines if the mesh must be flagged as updatable
  96199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96200. * @returns a new Mesh
  96201. */
  96202. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  96203. /**
  96204. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  96205. * @param name defines the name of the mesh to create
  96206. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  96207. * @param diameter sets the diameter size (float) of the sphere (default 1)
  96208. * @param scene defines the hosting scene
  96209. * @param updatable defines if the mesh must be flagged as updatable
  96210. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96211. * @returns a new Mesh
  96212. */
  96213. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96214. /**
  96215. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  96216. * @param name defines the name of the mesh to create
  96217. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  96218. * @param diameter sets the diameter size (float) of the sphere (default 1)
  96219. * @param scene defines the hosting scene
  96220. * @returns a new Mesh
  96221. */
  96222. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  96223. /**
  96224. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  96225. * @param name defines the name of the mesh to create
  96226. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  96227. * @param diameterTop set the top cap diameter (floats, default 1)
  96228. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  96229. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  96230. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  96231. * @param scene defines the hosting scene
  96232. * @param updatable defines if the mesh must be flagged as updatable
  96233. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96234. * @returns a new Mesh
  96235. */
  96236. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  96237. /**
  96238. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  96239. * @param name defines the name of the mesh to create
  96240. * @param diameter sets the diameter size (float) of the torus (default 1)
  96241. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  96242. * @param tessellation sets the number of torus sides (postive integer, default 16)
  96243. * @param scene defines the hosting scene
  96244. * @param updatable defines if the mesh must be flagged as updatable
  96245. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96246. * @returns a new Mesh
  96247. */
  96248. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96249. /**
  96250. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  96251. * @param name defines the name of the mesh to create
  96252. * @param radius sets the global radius size (float) of the torus knot (default 2)
  96253. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  96254. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  96255. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  96256. * @param p the number of windings on X axis (positive integers, default 2)
  96257. * @param q the number of windings on Y axis (positive integers, default 3)
  96258. * @param scene defines the hosting scene
  96259. * @param updatable defines if the mesh must be flagged as updatable
  96260. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96261. * @returns a new Mesh
  96262. */
  96263. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96264. /**
  96265. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  96266. * @param name defines the name of the mesh to create
  96267. * @param points is an array successive Vector3
  96268. * @param scene defines the hosting scene
  96269. * @param updatable defines if the mesh must be flagged as updatable
  96270. * @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).
  96271. * @returns a new Mesh
  96272. */
  96273. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  96274. /**
  96275. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  96276. * @param name defines the name of the mesh to create
  96277. * @param points is an array successive Vector3
  96278. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  96279. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  96280. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  96281. * @param scene defines the hosting scene
  96282. * @param updatable defines if the mesh must be flagged as updatable
  96283. * @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)
  96284. * @returns a new Mesh
  96285. */
  96286. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  96287. /**
  96288. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  96289. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  96290. * 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.
  96291. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96292. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  96293. * Remember you can only change the shape positions, not their number when updating a polygon.
  96294. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  96295. * @param name defines the name of the mesh to create
  96296. * @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
  96297. * @param scene defines the hosting scene
  96298. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  96299. * @param updatable defines if the mesh must be flagged as updatable
  96300. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96301. * @param earcutInjection can be used to inject your own earcut reference
  96302. * @returns a new Mesh
  96303. */
  96304. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  96305. /**
  96306. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  96307. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  96308. * @param name defines the name of the mesh to create
  96309. * @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
  96310. * @param depth defines the height of extrusion
  96311. * @param scene defines the hosting scene
  96312. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  96313. * @param updatable defines if the mesh must be flagged as updatable
  96314. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96315. * @param earcutInjection can be used to inject your own earcut reference
  96316. * @returns a new Mesh
  96317. */
  96318. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  96319. /**
  96320. * Creates an extruded shape mesh.
  96321. * 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
  96322. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  96323. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  96324. * @param name defines the name of the mesh to create
  96325. * @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
  96326. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  96327. * @param scale is the value to scale the shape
  96328. * @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
  96329. * @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
  96330. * @param scene defines the hosting scene
  96331. * @param updatable defines if the mesh must be flagged as updatable
  96332. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96333. * @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)
  96334. * @returns a new Mesh
  96335. */
  96336. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  96337. /**
  96338. * Creates an custom extruded shape mesh.
  96339. * The custom extrusion is a parametric shape.
  96340. * It has no predefined shape. Its final shape will depend on the input parameters.
  96341. * Please consider using the same method from the MeshBuilder class instead
  96342. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  96343. * @param name defines the name of the mesh to create
  96344. * @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
  96345. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  96346. * @param scaleFunction is a custom Javascript function called on each path point
  96347. * @param rotationFunction is a custom Javascript function called on each path point
  96348. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  96349. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  96350. * @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
  96351. * @param scene defines the hosting scene
  96352. * @param updatable defines if the mesh must be flagged as updatable
  96353. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96354. * @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)
  96355. * @returns a new Mesh
  96356. */
  96357. 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;
  96358. /**
  96359. * Creates lathe mesh.
  96360. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  96361. * Please consider using the same method from the MeshBuilder class instead
  96362. * @param name defines the name of the mesh to create
  96363. * @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
  96364. * @param radius is the radius value of the lathe
  96365. * @param tessellation is the side number of the lathe.
  96366. * @param scene defines the hosting scene
  96367. * @param updatable defines if the mesh must be flagged as updatable
  96368. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96369. * @returns a new Mesh
  96370. */
  96371. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96372. /**
  96373. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  96374. * @param name defines the name of the mesh to create
  96375. * @param size sets the size (float) of both sides of the plane at once (default 1)
  96376. * @param scene defines the hosting scene
  96377. * @param updatable defines if the mesh must be flagged as updatable
  96378. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96379. * @returns a new Mesh
  96380. */
  96381. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  96382. /**
  96383. * Creates a ground mesh.
  96384. * Please consider using the same method from the MeshBuilder class instead
  96385. * @param name defines the name of the mesh to create
  96386. * @param width set the width of the ground
  96387. * @param height set the height of the ground
  96388. * @param subdivisions sets the number of subdivisions per side
  96389. * @param scene defines the hosting scene
  96390. * @param updatable defines if the mesh must be flagged as updatable
  96391. * @returns a new Mesh
  96392. */
  96393. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  96394. /**
  96395. * Creates a tiled ground mesh.
  96396. * Please consider using the same method from the MeshBuilder class instead
  96397. * @param name defines the name of the mesh to create
  96398. * @param xmin set the ground minimum X coordinate
  96399. * @param zmin set the ground minimum Y coordinate
  96400. * @param xmax set the ground maximum X coordinate
  96401. * @param zmax set the ground maximum Z coordinate
  96402. * @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
  96403. * @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
  96404. * @param scene defines the hosting scene
  96405. * @param updatable defines if the mesh must be flagged as updatable
  96406. * @returns a new Mesh
  96407. */
  96408. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  96409. w: number;
  96410. h: number;
  96411. }, precision: {
  96412. w: number;
  96413. h: number;
  96414. }, scene: Scene, updatable?: boolean): Mesh;
  96415. /**
  96416. * Creates a ground mesh from a height map.
  96417. * Please consider using the same method from the MeshBuilder class instead
  96418. * @see http://doc.babylonjs.com/babylon101/height_map
  96419. * @param name defines the name of the mesh to create
  96420. * @param url sets the URL of the height map image resource
  96421. * @param width set the ground width size
  96422. * @param height set the ground height size
  96423. * @param subdivisions sets the number of subdivision per side
  96424. * @param minHeight is the minimum altitude on the ground
  96425. * @param maxHeight is the maximum altitude on the ground
  96426. * @param scene defines the hosting scene
  96427. * @param updatable defines if the mesh must be flagged as updatable
  96428. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  96429. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  96430. * @returns a new Mesh
  96431. */
  96432. 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;
  96433. /**
  96434. * Creates a tube mesh.
  96435. * The tube is a parametric shape.
  96436. * It has no predefined shape. Its final shape will depend on the input parameters.
  96437. * Please consider using the same method from the MeshBuilder class instead
  96438. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  96439. * @param name defines the name of the mesh to create
  96440. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  96441. * @param radius sets the tube radius size
  96442. * @param tessellation is the number of sides on the tubular surface
  96443. * @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
  96444. * @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
  96445. * @param scene defines the hosting scene
  96446. * @param updatable defines if the mesh must be flagged as updatable
  96447. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  96448. * @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)
  96449. * @returns a new Mesh
  96450. */
  96451. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  96452. (i: number, distance: number): number;
  96453. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  96454. /**
  96455. * Creates a polyhedron mesh.
  96456. * Please consider using the same method from the MeshBuilder class instead.
  96457. * * 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
  96458. * * The parameter `size` (positive float, default 1) sets the polygon size
  96459. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  96460. * * 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`
  96461. * * 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
  96462. * * 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)`)
  96463. * * 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
  96464. * * 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
  96465. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96466. * * If you create a double-sided mesh, you can choose what parts of 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
  96467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96468. * @param name defines the name of the mesh to create
  96469. * @param options defines the options used to create the mesh
  96470. * @param scene defines the hosting scene
  96471. * @returns a new Mesh
  96472. */
  96473. static CreatePolyhedron(name: string, options: {
  96474. type?: number;
  96475. size?: number;
  96476. sizeX?: number;
  96477. sizeY?: number;
  96478. sizeZ?: number;
  96479. custom?: any;
  96480. faceUV?: Vector4[];
  96481. faceColors?: Color4[];
  96482. updatable?: boolean;
  96483. sideOrientation?: number;
  96484. }, scene: Scene): Mesh;
  96485. /**
  96486. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  96487. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  96488. * * 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`)
  96489. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  96490. * * 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
  96491. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96492. * * If you create a double-sided mesh, you can choose what parts of 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
  96493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96494. * @param name defines the name of the mesh
  96495. * @param options defines the options used to create the mesh
  96496. * @param scene defines the hosting scene
  96497. * @returns a new Mesh
  96498. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  96499. */
  96500. static CreateIcoSphere(name: string, options: {
  96501. radius?: number;
  96502. flat?: boolean;
  96503. subdivisions?: number;
  96504. sideOrientation?: number;
  96505. updatable?: boolean;
  96506. }, scene: Scene): Mesh;
  96507. /**
  96508. * Creates a decal mesh.
  96509. * Please consider using the same method from the MeshBuilder class instead.
  96510. * A decal is a mesh usually applied as a model onto the surface of another mesh
  96511. * @param name defines the name of the mesh
  96512. * @param sourceMesh defines the mesh receiving the decal
  96513. * @param position sets the position of the decal in world coordinates
  96514. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  96515. * @param size sets the decal scaling
  96516. * @param angle sets the angle to rotate the decal
  96517. * @returns a new Mesh
  96518. */
  96519. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  96520. /**
  96521. * Prepare internal position array for software CPU skinning
  96522. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  96523. */
  96524. setPositionsForCPUSkinning(): Float32Array;
  96525. /**
  96526. * Prepare internal normal array for software CPU skinning
  96527. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  96528. */
  96529. setNormalsForCPUSkinning(): Float32Array;
  96530. /**
  96531. * Updates the vertex buffer by applying transformation from the bones
  96532. * @param skeleton defines the skeleton to apply to current mesh
  96533. * @returns the current mesh
  96534. */
  96535. applySkeleton(skeleton: Skeleton): Mesh;
  96536. /**
  96537. * 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
  96538. * @param meshes defines the list of meshes to scan
  96539. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  96540. */
  96541. static MinMax(meshes: AbstractMesh[]): {
  96542. min: Vector3;
  96543. max: Vector3;
  96544. };
  96545. /**
  96546. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  96547. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  96548. * @returns a vector3
  96549. */
  96550. static Center(meshesOrMinMaxVector: {
  96551. min: Vector3;
  96552. max: Vector3;
  96553. } | AbstractMesh[]): Vector3;
  96554. /**
  96555. * Merge the array of meshes into a single mesh for performance reasons.
  96556. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  96557. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  96558. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  96559. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  96560. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  96561. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  96562. * @returns a new mesh
  96563. */
  96564. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  96565. /** @hidden */
  96566. addInstance(instance: InstancedMesh): void;
  96567. /** @hidden */
  96568. removeInstance(instance: InstancedMesh): void;
  96569. }
  96570. }
  96571. declare module BABYLON {
  96572. /**
  96573. * This is the base class of all the camera used in the application.
  96574. * @see http://doc.babylonjs.com/features/cameras
  96575. */
  96576. export class Camera extends Node {
  96577. /** @hidden */
  96578. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  96579. /**
  96580. * This is the default projection mode used by the cameras.
  96581. * It helps recreating a feeling of perspective and better appreciate depth.
  96582. * This is the best way to simulate real life cameras.
  96583. */
  96584. static readonly PERSPECTIVE_CAMERA: number;
  96585. /**
  96586. * This helps creating camera with an orthographic mode.
  96587. * 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.
  96588. */
  96589. static readonly ORTHOGRAPHIC_CAMERA: number;
  96590. /**
  96591. * This is the default FOV mode for perspective cameras.
  96592. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  96593. */
  96594. static readonly FOVMODE_VERTICAL_FIXED: number;
  96595. /**
  96596. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  96597. */
  96598. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  96599. /**
  96600. * This specifies ther is no need for a camera rig.
  96601. * Basically only one eye is rendered corresponding to the camera.
  96602. */
  96603. static readonly RIG_MODE_NONE: number;
  96604. /**
  96605. * Simulates a camera Rig with one blue eye and one red eye.
  96606. * This can be use with 3d blue and red glasses.
  96607. */
  96608. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  96609. /**
  96610. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  96611. */
  96612. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  96613. /**
  96614. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  96615. */
  96616. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  96617. /**
  96618. * Defines that both eyes of the camera will be rendered over under each other.
  96619. */
  96620. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  96621. /**
  96622. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  96623. */
  96624. static readonly RIG_MODE_VR: number;
  96625. /**
  96626. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  96627. */
  96628. static readonly RIG_MODE_WEBVR: number;
  96629. /**
  96630. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  96631. */
  96632. static readonly RIG_MODE_CUSTOM: number;
  96633. /**
  96634. * Defines if by default attaching controls should prevent the default javascript event to continue.
  96635. */
  96636. static ForceAttachControlToAlwaysPreventDefault: boolean;
  96637. /**
  96638. * Define the input manager associated with the camera.
  96639. */
  96640. inputs: CameraInputsManager<Camera>;
  96641. /** @hidden */
  96642. _position: Vector3;
  96643. /**
  96644. * Define the current local position of the camera in the scene
  96645. */
  96646. get position(): Vector3;
  96647. set position(newPosition: Vector3);
  96648. /**
  96649. * The vector the camera should consider as up.
  96650. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  96651. */
  96652. upVector: Vector3;
  96653. /**
  96654. * Define the current limit on the left side for an orthographic camera
  96655. * In scene unit
  96656. */
  96657. orthoLeft: Nullable<number>;
  96658. /**
  96659. * Define the current limit on the right side for an orthographic camera
  96660. * In scene unit
  96661. */
  96662. orthoRight: Nullable<number>;
  96663. /**
  96664. * Define the current limit on the bottom side for an orthographic camera
  96665. * In scene unit
  96666. */
  96667. orthoBottom: Nullable<number>;
  96668. /**
  96669. * Define the current limit on the top side for an orthographic camera
  96670. * In scene unit
  96671. */
  96672. orthoTop: Nullable<number>;
  96673. /**
  96674. * Field Of View is set in Radians. (default is 0.8)
  96675. */
  96676. fov: number;
  96677. /**
  96678. * Define the minimum distance the camera can see from.
  96679. * This is important to note that the depth buffer are not infinite and the closer it starts
  96680. * the more your scene might encounter depth fighting issue.
  96681. */
  96682. minZ: number;
  96683. /**
  96684. * Define the maximum distance the camera can see to.
  96685. * This is important to note that the depth buffer are not infinite and the further it end
  96686. * the more your scene might encounter depth fighting issue.
  96687. */
  96688. maxZ: number;
  96689. /**
  96690. * Define the default inertia of the camera.
  96691. * This helps giving a smooth feeling to the camera movement.
  96692. */
  96693. inertia: number;
  96694. /**
  96695. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  96696. */
  96697. mode: number;
  96698. /**
  96699. * Define wether the camera is intermediate.
  96700. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  96701. */
  96702. isIntermediate: boolean;
  96703. /**
  96704. * Define the viewport of the camera.
  96705. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  96706. */
  96707. viewport: Viewport;
  96708. /**
  96709. * Restricts the camera to viewing objects with the same layerMask.
  96710. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  96711. */
  96712. layerMask: number;
  96713. /**
  96714. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  96715. */
  96716. fovMode: number;
  96717. /**
  96718. * Rig mode of the camera.
  96719. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  96720. * This is normally controlled byt the camera themselves as internal use.
  96721. */
  96722. cameraRigMode: number;
  96723. /**
  96724. * Defines the distance between both "eyes" in case of a RIG
  96725. */
  96726. interaxialDistance: number;
  96727. /**
  96728. * Defines if stereoscopic rendering is done side by side or over under.
  96729. */
  96730. isStereoscopicSideBySide: boolean;
  96731. /**
  96732. * 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
  96733. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  96734. * else in the scene. (Eg. security camera)
  96735. *
  96736. * 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)
  96737. */
  96738. customRenderTargets: RenderTargetTexture[];
  96739. /**
  96740. * When set, the camera will render to this render target instead of the default canvas
  96741. *
  96742. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  96743. */
  96744. outputRenderTarget: Nullable<RenderTargetTexture>;
  96745. /**
  96746. * Observable triggered when the camera view matrix has changed.
  96747. */
  96748. onViewMatrixChangedObservable: Observable<Camera>;
  96749. /**
  96750. * Observable triggered when the camera Projection matrix has changed.
  96751. */
  96752. onProjectionMatrixChangedObservable: Observable<Camera>;
  96753. /**
  96754. * Observable triggered when the inputs have been processed.
  96755. */
  96756. onAfterCheckInputsObservable: Observable<Camera>;
  96757. /**
  96758. * Observable triggered when reset has been called and applied to the camera.
  96759. */
  96760. onRestoreStateObservable: Observable<Camera>;
  96761. /** @hidden */
  96762. _cameraRigParams: any;
  96763. /** @hidden */
  96764. _rigCameras: Camera[];
  96765. /** @hidden */
  96766. _rigPostProcess: Nullable<PostProcess>;
  96767. protected _webvrViewMatrix: Matrix;
  96768. /** @hidden */
  96769. _skipRendering: boolean;
  96770. /** @hidden */
  96771. _projectionMatrix: Matrix;
  96772. /** @hidden */
  96773. _postProcesses: Nullable<PostProcess>[];
  96774. /** @hidden */
  96775. _activeMeshes: SmartArray<AbstractMesh>;
  96776. protected _globalPosition: Vector3;
  96777. /** @hidden */
  96778. _computedViewMatrix: Matrix;
  96779. private _doNotComputeProjectionMatrix;
  96780. private _transformMatrix;
  96781. private _frustumPlanes;
  96782. private _refreshFrustumPlanes;
  96783. private _storedFov;
  96784. private _stateStored;
  96785. /**
  96786. * Instantiates a new camera object.
  96787. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  96788. * @see http://doc.babylonjs.com/features/cameras
  96789. * @param name Defines the name of the camera in the scene
  96790. * @param position Defines the position of the camera
  96791. * @param scene Defines the scene the camera belongs too
  96792. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  96793. */
  96794. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96795. /**
  96796. * Store current camera state (fov, position, etc..)
  96797. * @returns the camera
  96798. */
  96799. storeState(): Camera;
  96800. /**
  96801. * Restores the camera state values if it has been stored. You must call storeState() first
  96802. */
  96803. protected _restoreStateValues(): boolean;
  96804. /**
  96805. * Restored camera state. You must call storeState() first.
  96806. * @returns true if restored and false otherwise
  96807. */
  96808. restoreState(): boolean;
  96809. /**
  96810. * Gets the class name of the camera.
  96811. * @returns the class name
  96812. */
  96813. getClassName(): string;
  96814. /** @hidden */
  96815. readonly _isCamera: boolean;
  96816. /**
  96817. * Gets a string representation of the camera useful for debug purpose.
  96818. * @param fullDetails Defines that a more verboe level of logging is required
  96819. * @returns the string representation
  96820. */
  96821. toString(fullDetails?: boolean): string;
  96822. /**
  96823. * Gets the current world space position of the camera.
  96824. */
  96825. get globalPosition(): Vector3;
  96826. /**
  96827. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  96828. * @returns the active meshe list
  96829. */
  96830. getActiveMeshes(): SmartArray<AbstractMesh>;
  96831. /**
  96832. * Check wether a mesh is part of the current active mesh list of the camera
  96833. * @param mesh Defines the mesh to check
  96834. * @returns true if active, false otherwise
  96835. */
  96836. isActiveMesh(mesh: Mesh): boolean;
  96837. /**
  96838. * Is this camera ready to be used/rendered
  96839. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  96840. * @return true if the camera is ready
  96841. */
  96842. isReady(completeCheck?: boolean): boolean;
  96843. /** @hidden */
  96844. _initCache(): void;
  96845. /** @hidden */
  96846. _updateCache(ignoreParentClass?: boolean): void;
  96847. /** @hidden */
  96848. _isSynchronized(): boolean;
  96849. /** @hidden */
  96850. _isSynchronizedViewMatrix(): boolean;
  96851. /** @hidden */
  96852. _isSynchronizedProjectionMatrix(): boolean;
  96853. /**
  96854. * Attach the input controls to a specific dom element to get the input from.
  96855. * @param element Defines the element the controls should be listened from
  96856. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96857. */
  96858. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96859. /**
  96860. * Detach the current controls from the specified dom element.
  96861. * @param element Defines the element to stop listening the inputs from
  96862. */
  96863. detachControl(element: HTMLElement): void;
  96864. /**
  96865. * Update the camera state according to the different inputs gathered during the frame.
  96866. */
  96867. update(): void;
  96868. /** @hidden */
  96869. _checkInputs(): void;
  96870. /** @hidden */
  96871. get rigCameras(): Camera[];
  96872. /**
  96873. * Gets the post process used by the rig cameras
  96874. */
  96875. get rigPostProcess(): Nullable<PostProcess>;
  96876. /**
  96877. * Internal, gets the first post proces.
  96878. * @returns the first post process to be run on this camera.
  96879. */
  96880. _getFirstPostProcess(): Nullable<PostProcess>;
  96881. private _cascadePostProcessesToRigCams;
  96882. /**
  96883. * Attach a post process to the camera.
  96884. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96885. * @param postProcess The post process to attach to the camera
  96886. * @param insertAt The position of the post process in case several of them are in use in the scene
  96887. * @returns the position the post process has been inserted at
  96888. */
  96889. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  96890. /**
  96891. * Detach a post process to the camera.
  96892. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  96893. * @param postProcess The post process to detach from the camera
  96894. */
  96895. detachPostProcess(postProcess: PostProcess): void;
  96896. /**
  96897. * Gets the current world matrix of the camera
  96898. */
  96899. getWorldMatrix(): Matrix;
  96900. /** @hidden */
  96901. _getViewMatrix(): Matrix;
  96902. /**
  96903. * Gets the current view matrix of the camera.
  96904. * @param force forces the camera to recompute the matrix without looking at the cached state
  96905. * @returns the view matrix
  96906. */
  96907. getViewMatrix(force?: boolean): Matrix;
  96908. /**
  96909. * Freeze the projection matrix.
  96910. * It will prevent the cache check of the camera projection compute and can speed up perf
  96911. * if no parameter of the camera are meant to change
  96912. * @param projection Defines manually a projection if necessary
  96913. */
  96914. freezeProjectionMatrix(projection?: Matrix): void;
  96915. /**
  96916. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  96917. */
  96918. unfreezeProjectionMatrix(): void;
  96919. /**
  96920. * Gets the current projection matrix of the camera.
  96921. * @param force forces the camera to recompute the matrix without looking at the cached state
  96922. * @returns the projection matrix
  96923. */
  96924. getProjectionMatrix(force?: boolean): Matrix;
  96925. /**
  96926. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  96927. * @returns a Matrix
  96928. */
  96929. getTransformationMatrix(): Matrix;
  96930. private _updateFrustumPlanes;
  96931. /**
  96932. * Checks if a cullable object (mesh...) is in the camera frustum
  96933. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  96934. * @param target The object to check
  96935. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  96936. * @returns true if the object is in frustum otherwise false
  96937. */
  96938. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  96939. /**
  96940. * Checks if a cullable object (mesh...) is in the camera frustum
  96941. * Unlike isInFrustum this cheks the full bounding box
  96942. * @param target The object to check
  96943. * @returns true if the object is in frustum otherwise false
  96944. */
  96945. isCompletelyInFrustum(target: ICullable): boolean;
  96946. /**
  96947. * Gets a ray in the forward direction from the camera.
  96948. * @param length Defines the length of the ray to create
  96949. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  96950. * @param origin Defines the start point of the ray which defaults to the camera position
  96951. * @returns the forward ray
  96952. */
  96953. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  96954. /**
  96955. * Releases resources associated with this node.
  96956. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96957. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96958. */
  96959. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96960. /** @hidden */
  96961. _isLeftCamera: boolean;
  96962. /**
  96963. * Gets the left camera of a rig setup in case of Rigged Camera
  96964. */
  96965. get isLeftCamera(): boolean;
  96966. /** @hidden */
  96967. _isRightCamera: boolean;
  96968. /**
  96969. * Gets the right camera of a rig setup in case of Rigged Camera
  96970. */
  96971. get isRightCamera(): boolean;
  96972. /**
  96973. * Gets the left camera of a rig setup in case of Rigged Camera
  96974. */
  96975. get leftCamera(): Nullable<FreeCamera>;
  96976. /**
  96977. * Gets the right camera of a rig setup in case of Rigged Camera
  96978. */
  96979. get rightCamera(): Nullable<FreeCamera>;
  96980. /**
  96981. * Gets the left camera target of a rig setup in case of Rigged Camera
  96982. * @returns the target position
  96983. */
  96984. getLeftTarget(): Nullable<Vector3>;
  96985. /**
  96986. * Gets the right camera target of a rig setup in case of Rigged Camera
  96987. * @returns the target position
  96988. */
  96989. getRightTarget(): Nullable<Vector3>;
  96990. /**
  96991. * @hidden
  96992. */
  96993. setCameraRigMode(mode: number, rigParams: any): void;
  96994. /** @hidden */
  96995. static _setStereoscopicRigMode(camera: Camera): void;
  96996. /** @hidden */
  96997. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  96998. /** @hidden */
  96999. static _setVRRigMode(camera: Camera, rigParams: any): void;
  97000. /** @hidden */
  97001. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  97002. /** @hidden */
  97003. _getVRProjectionMatrix(): Matrix;
  97004. protected _updateCameraRotationMatrix(): void;
  97005. protected _updateWebVRCameraRotationMatrix(): void;
  97006. /**
  97007. * This function MUST be overwritten by the different WebVR cameras available.
  97008. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  97009. * @hidden
  97010. */
  97011. _getWebVRProjectionMatrix(): Matrix;
  97012. /**
  97013. * This function MUST be overwritten by the different WebVR cameras available.
  97014. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  97015. * @hidden
  97016. */
  97017. _getWebVRViewMatrix(): Matrix;
  97018. /** @hidden */
  97019. setCameraRigParameter(name: string, value: any): void;
  97020. /**
  97021. * needs to be overridden by children so sub has required properties to be copied
  97022. * @hidden
  97023. */
  97024. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  97025. /**
  97026. * May need to be overridden by children
  97027. * @hidden
  97028. */
  97029. _updateRigCameras(): void;
  97030. /** @hidden */
  97031. _setupInputs(): void;
  97032. /**
  97033. * Serialiaze the camera setup to a json represention
  97034. * @returns the JSON representation
  97035. */
  97036. serialize(): any;
  97037. /**
  97038. * Clones the current camera.
  97039. * @param name The cloned camera name
  97040. * @returns the cloned camera
  97041. */
  97042. clone(name: string): Camera;
  97043. /**
  97044. * Gets the direction of the camera relative to a given local axis.
  97045. * @param localAxis Defines the reference axis to provide a relative direction.
  97046. * @return the direction
  97047. */
  97048. getDirection(localAxis: Vector3): Vector3;
  97049. /**
  97050. * Returns the current camera absolute rotation
  97051. */
  97052. get absoluteRotation(): Quaternion;
  97053. /**
  97054. * Gets the direction of the camera relative to a given local axis into a passed vector.
  97055. * @param localAxis Defines the reference axis to provide a relative direction.
  97056. * @param result Defines the vector to store the result in
  97057. */
  97058. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  97059. /**
  97060. * Gets a camera constructor for a given camera type
  97061. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  97062. * @param name The name of the camera the result will be able to instantiate
  97063. * @param scene The scene the result will construct the camera in
  97064. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  97065. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  97066. * @returns a factory method to construc the camera
  97067. */
  97068. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  97069. /**
  97070. * Compute the world matrix of the camera.
  97071. * @returns the camera world matrix
  97072. */
  97073. computeWorldMatrix(): Matrix;
  97074. /**
  97075. * Parse a JSON and creates the camera from the parsed information
  97076. * @param parsedCamera The JSON to parse
  97077. * @param scene The scene to instantiate the camera in
  97078. * @returns the newly constructed camera
  97079. */
  97080. static Parse(parsedCamera: any, scene: Scene): Camera;
  97081. }
  97082. }
  97083. declare module BABYLON {
  97084. /**
  97085. * Class containing static functions to help procedurally build meshes
  97086. */
  97087. export class DiscBuilder {
  97088. /**
  97089. * Creates a plane polygonal mesh. By default, this is a disc
  97090. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  97091. * * 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
  97092. * * 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
  97093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97096. * @param name defines the name of the mesh
  97097. * @param options defines the options used to create the mesh
  97098. * @param scene defines the hosting scene
  97099. * @returns the plane polygonal mesh
  97100. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  97101. */
  97102. static CreateDisc(name: string, options: {
  97103. radius?: number;
  97104. tessellation?: number;
  97105. arc?: number;
  97106. updatable?: boolean;
  97107. sideOrientation?: number;
  97108. frontUVs?: Vector4;
  97109. backUVs?: Vector4;
  97110. }, scene?: Nullable<Scene>): Mesh;
  97111. }
  97112. }
  97113. declare module BABYLON {
  97114. /**
  97115. * This represents all the required information to add a fresnel effect on a material:
  97116. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97117. */
  97118. export class FresnelParameters {
  97119. private _isEnabled;
  97120. /**
  97121. * Define if the fresnel effect is enable or not.
  97122. */
  97123. get isEnabled(): boolean;
  97124. set isEnabled(value: boolean);
  97125. /**
  97126. * Define the color used on edges (grazing angle)
  97127. */
  97128. leftColor: Color3;
  97129. /**
  97130. * Define the color used on center
  97131. */
  97132. rightColor: Color3;
  97133. /**
  97134. * Define bias applied to computed fresnel term
  97135. */
  97136. bias: number;
  97137. /**
  97138. * Defined the power exponent applied to fresnel term
  97139. */
  97140. power: number;
  97141. /**
  97142. * Clones the current fresnel and its valuues
  97143. * @returns a clone fresnel configuration
  97144. */
  97145. clone(): FresnelParameters;
  97146. /**
  97147. * Serializes the current fresnel parameters to a JSON representation.
  97148. * @return the JSON serialization
  97149. */
  97150. serialize(): any;
  97151. /**
  97152. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  97153. * @param parsedFresnelParameters Define the JSON representation
  97154. * @returns the parsed parameters
  97155. */
  97156. static Parse(parsedFresnelParameters: any): FresnelParameters;
  97157. }
  97158. }
  97159. declare module BABYLON {
  97160. /**
  97161. * Base class of materials working in push mode in babylon JS
  97162. * @hidden
  97163. */
  97164. export class PushMaterial extends Material {
  97165. protected _activeEffect: Effect;
  97166. protected _normalMatrix: Matrix;
  97167. /**
  97168. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97169. * This means that the material can keep using a previous shader while a new one is being compiled.
  97170. * This is mostly used when shader parallel compilation is supported (true by default)
  97171. */
  97172. allowShaderHotSwapping: boolean;
  97173. constructor(name: string, scene: Scene);
  97174. getEffect(): Effect;
  97175. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97176. /**
  97177. * Binds the given world matrix to the active effect
  97178. *
  97179. * @param world the matrix to bind
  97180. */
  97181. bindOnlyWorldMatrix(world: Matrix): void;
  97182. /**
  97183. * Binds the given normal matrix to the active effect
  97184. *
  97185. * @param normalMatrix the matrix to bind
  97186. */
  97187. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97188. bind(world: Matrix, mesh?: Mesh): void;
  97189. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97190. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97191. }
  97192. }
  97193. declare module BABYLON {
  97194. /**
  97195. * This groups all the flags used to control the materials channel.
  97196. */
  97197. export class MaterialFlags {
  97198. private static _DiffuseTextureEnabled;
  97199. /**
  97200. * Are diffuse textures enabled in the application.
  97201. */
  97202. static get DiffuseTextureEnabled(): boolean;
  97203. static set DiffuseTextureEnabled(value: boolean);
  97204. private static _AmbientTextureEnabled;
  97205. /**
  97206. * Are ambient textures enabled in the application.
  97207. */
  97208. static get AmbientTextureEnabled(): boolean;
  97209. static set AmbientTextureEnabled(value: boolean);
  97210. private static _OpacityTextureEnabled;
  97211. /**
  97212. * Are opacity textures enabled in the application.
  97213. */
  97214. static get OpacityTextureEnabled(): boolean;
  97215. static set OpacityTextureEnabled(value: boolean);
  97216. private static _ReflectionTextureEnabled;
  97217. /**
  97218. * Are reflection textures enabled in the application.
  97219. */
  97220. static get ReflectionTextureEnabled(): boolean;
  97221. static set ReflectionTextureEnabled(value: boolean);
  97222. private static _EmissiveTextureEnabled;
  97223. /**
  97224. * Are emissive textures enabled in the application.
  97225. */
  97226. static get EmissiveTextureEnabled(): boolean;
  97227. static set EmissiveTextureEnabled(value: boolean);
  97228. private static _SpecularTextureEnabled;
  97229. /**
  97230. * Are specular textures enabled in the application.
  97231. */
  97232. static get SpecularTextureEnabled(): boolean;
  97233. static set SpecularTextureEnabled(value: boolean);
  97234. private static _BumpTextureEnabled;
  97235. /**
  97236. * Are bump textures enabled in the application.
  97237. */
  97238. static get BumpTextureEnabled(): boolean;
  97239. static set BumpTextureEnabled(value: boolean);
  97240. private static _LightmapTextureEnabled;
  97241. /**
  97242. * Are lightmap textures enabled in the application.
  97243. */
  97244. static get LightmapTextureEnabled(): boolean;
  97245. static set LightmapTextureEnabled(value: boolean);
  97246. private static _RefractionTextureEnabled;
  97247. /**
  97248. * Are refraction textures enabled in the application.
  97249. */
  97250. static get RefractionTextureEnabled(): boolean;
  97251. static set RefractionTextureEnabled(value: boolean);
  97252. private static _ColorGradingTextureEnabled;
  97253. /**
  97254. * Are color grading textures enabled in the application.
  97255. */
  97256. static get ColorGradingTextureEnabled(): boolean;
  97257. static set ColorGradingTextureEnabled(value: boolean);
  97258. private static _FresnelEnabled;
  97259. /**
  97260. * Are fresnels enabled in the application.
  97261. */
  97262. static get FresnelEnabled(): boolean;
  97263. static set FresnelEnabled(value: boolean);
  97264. private static _ClearCoatTextureEnabled;
  97265. /**
  97266. * Are clear coat textures enabled in the application.
  97267. */
  97268. static get ClearCoatTextureEnabled(): boolean;
  97269. static set ClearCoatTextureEnabled(value: boolean);
  97270. private static _ClearCoatBumpTextureEnabled;
  97271. /**
  97272. * Are clear coat bump textures enabled in the application.
  97273. */
  97274. static get ClearCoatBumpTextureEnabled(): boolean;
  97275. static set ClearCoatBumpTextureEnabled(value: boolean);
  97276. private static _ClearCoatTintTextureEnabled;
  97277. /**
  97278. * Are clear coat tint textures enabled in the application.
  97279. */
  97280. static get ClearCoatTintTextureEnabled(): boolean;
  97281. static set ClearCoatTintTextureEnabled(value: boolean);
  97282. private static _SheenTextureEnabled;
  97283. /**
  97284. * Are sheen textures enabled in the application.
  97285. */
  97286. static get SheenTextureEnabled(): boolean;
  97287. static set SheenTextureEnabled(value: boolean);
  97288. private static _AnisotropicTextureEnabled;
  97289. /**
  97290. * Are anisotropic textures enabled in the application.
  97291. */
  97292. static get AnisotropicTextureEnabled(): boolean;
  97293. static set AnisotropicTextureEnabled(value: boolean);
  97294. private static _ThicknessTextureEnabled;
  97295. /**
  97296. * Are thickness textures enabled in the application.
  97297. */
  97298. static get ThicknessTextureEnabled(): boolean;
  97299. static set ThicknessTextureEnabled(value: boolean);
  97300. }
  97301. }
  97302. declare module BABYLON {
  97303. /** @hidden */
  97304. export var defaultFragmentDeclaration: {
  97305. name: string;
  97306. shader: string;
  97307. };
  97308. }
  97309. declare module BABYLON {
  97310. /** @hidden */
  97311. export var defaultUboDeclaration: {
  97312. name: string;
  97313. shader: string;
  97314. };
  97315. }
  97316. declare module BABYLON {
  97317. /** @hidden */
  97318. export var lightFragmentDeclaration: {
  97319. name: string;
  97320. shader: string;
  97321. };
  97322. }
  97323. declare module BABYLON {
  97324. /** @hidden */
  97325. export var lightUboDeclaration: {
  97326. name: string;
  97327. shader: string;
  97328. };
  97329. }
  97330. declare module BABYLON {
  97331. /** @hidden */
  97332. export var lightsFragmentFunctions: {
  97333. name: string;
  97334. shader: string;
  97335. };
  97336. }
  97337. declare module BABYLON {
  97338. /** @hidden */
  97339. export var shadowsFragmentFunctions: {
  97340. name: string;
  97341. shader: string;
  97342. };
  97343. }
  97344. declare module BABYLON {
  97345. /** @hidden */
  97346. export var fresnelFunction: {
  97347. name: string;
  97348. shader: string;
  97349. };
  97350. }
  97351. declare module BABYLON {
  97352. /** @hidden */
  97353. export var reflectionFunction: {
  97354. name: string;
  97355. shader: string;
  97356. };
  97357. }
  97358. declare module BABYLON {
  97359. /** @hidden */
  97360. export var bumpFragmentFunctions: {
  97361. name: string;
  97362. shader: string;
  97363. };
  97364. }
  97365. declare module BABYLON {
  97366. /** @hidden */
  97367. export var logDepthDeclaration: {
  97368. name: string;
  97369. shader: string;
  97370. };
  97371. }
  97372. declare module BABYLON {
  97373. /** @hidden */
  97374. export var bumpFragment: {
  97375. name: string;
  97376. shader: string;
  97377. };
  97378. }
  97379. declare module BABYLON {
  97380. /** @hidden */
  97381. export var depthPrePass: {
  97382. name: string;
  97383. shader: string;
  97384. };
  97385. }
  97386. declare module BABYLON {
  97387. /** @hidden */
  97388. export var lightFragment: {
  97389. name: string;
  97390. shader: string;
  97391. };
  97392. }
  97393. declare module BABYLON {
  97394. /** @hidden */
  97395. export var logDepthFragment: {
  97396. name: string;
  97397. shader: string;
  97398. };
  97399. }
  97400. declare module BABYLON {
  97401. /** @hidden */
  97402. export var defaultPixelShader: {
  97403. name: string;
  97404. shader: string;
  97405. };
  97406. }
  97407. declare module BABYLON {
  97408. /** @hidden */
  97409. export var defaultVertexDeclaration: {
  97410. name: string;
  97411. shader: string;
  97412. };
  97413. }
  97414. declare module BABYLON {
  97415. /** @hidden */
  97416. export var bumpVertexDeclaration: {
  97417. name: string;
  97418. shader: string;
  97419. };
  97420. }
  97421. declare module BABYLON {
  97422. /** @hidden */
  97423. export var bumpVertex: {
  97424. name: string;
  97425. shader: string;
  97426. };
  97427. }
  97428. declare module BABYLON {
  97429. /** @hidden */
  97430. export var fogVertex: {
  97431. name: string;
  97432. shader: string;
  97433. };
  97434. }
  97435. declare module BABYLON {
  97436. /** @hidden */
  97437. export var shadowsVertex: {
  97438. name: string;
  97439. shader: string;
  97440. };
  97441. }
  97442. declare module BABYLON {
  97443. /** @hidden */
  97444. export var pointCloudVertex: {
  97445. name: string;
  97446. shader: string;
  97447. };
  97448. }
  97449. declare module BABYLON {
  97450. /** @hidden */
  97451. export var logDepthVertex: {
  97452. name: string;
  97453. shader: string;
  97454. };
  97455. }
  97456. declare module BABYLON {
  97457. /** @hidden */
  97458. export var defaultVertexShader: {
  97459. name: string;
  97460. shader: string;
  97461. };
  97462. }
  97463. declare module BABYLON {
  97464. /** @hidden */
  97465. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97466. MAINUV1: boolean;
  97467. MAINUV2: boolean;
  97468. DIFFUSE: boolean;
  97469. DIFFUSEDIRECTUV: number;
  97470. AMBIENT: boolean;
  97471. AMBIENTDIRECTUV: number;
  97472. OPACITY: boolean;
  97473. OPACITYDIRECTUV: number;
  97474. OPACITYRGB: boolean;
  97475. REFLECTION: boolean;
  97476. EMISSIVE: boolean;
  97477. EMISSIVEDIRECTUV: number;
  97478. SPECULAR: boolean;
  97479. SPECULARDIRECTUV: number;
  97480. BUMP: boolean;
  97481. BUMPDIRECTUV: number;
  97482. PARALLAX: boolean;
  97483. PARALLAXOCCLUSION: boolean;
  97484. SPECULAROVERALPHA: boolean;
  97485. CLIPPLANE: boolean;
  97486. CLIPPLANE2: boolean;
  97487. CLIPPLANE3: boolean;
  97488. CLIPPLANE4: boolean;
  97489. CLIPPLANE5: boolean;
  97490. CLIPPLANE6: boolean;
  97491. ALPHATEST: boolean;
  97492. DEPTHPREPASS: boolean;
  97493. ALPHAFROMDIFFUSE: boolean;
  97494. POINTSIZE: boolean;
  97495. FOG: boolean;
  97496. SPECULARTERM: boolean;
  97497. DIFFUSEFRESNEL: boolean;
  97498. OPACITYFRESNEL: boolean;
  97499. REFLECTIONFRESNEL: boolean;
  97500. REFRACTIONFRESNEL: boolean;
  97501. EMISSIVEFRESNEL: boolean;
  97502. FRESNEL: boolean;
  97503. NORMAL: boolean;
  97504. UV1: boolean;
  97505. UV2: boolean;
  97506. VERTEXCOLOR: boolean;
  97507. VERTEXALPHA: boolean;
  97508. NUM_BONE_INFLUENCERS: number;
  97509. BonesPerMesh: number;
  97510. BONETEXTURE: boolean;
  97511. INSTANCES: boolean;
  97512. GLOSSINESS: boolean;
  97513. ROUGHNESS: boolean;
  97514. EMISSIVEASILLUMINATION: boolean;
  97515. LINKEMISSIVEWITHDIFFUSE: boolean;
  97516. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97517. LIGHTMAP: boolean;
  97518. LIGHTMAPDIRECTUV: number;
  97519. OBJECTSPACE_NORMALMAP: boolean;
  97520. USELIGHTMAPASSHADOWMAP: boolean;
  97521. REFLECTIONMAP_3D: boolean;
  97522. REFLECTIONMAP_SPHERICAL: boolean;
  97523. REFLECTIONMAP_PLANAR: boolean;
  97524. REFLECTIONMAP_CUBIC: boolean;
  97525. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  97526. REFLECTIONMAP_PROJECTION: boolean;
  97527. REFLECTIONMAP_SKYBOX: boolean;
  97528. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  97529. REFLECTIONMAP_EXPLICIT: boolean;
  97530. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  97531. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  97532. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  97533. INVERTCUBICMAP: boolean;
  97534. LOGARITHMICDEPTH: boolean;
  97535. REFRACTION: boolean;
  97536. REFRACTIONMAP_3D: boolean;
  97537. REFLECTIONOVERALPHA: boolean;
  97538. TWOSIDEDLIGHTING: boolean;
  97539. SHADOWFLOAT: boolean;
  97540. MORPHTARGETS: boolean;
  97541. MORPHTARGETS_NORMAL: boolean;
  97542. MORPHTARGETS_TANGENT: boolean;
  97543. MORPHTARGETS_UV: boolean;
  97544. NUM_MORPH_INFLUENCERS: number;
  97545. NONUNIFORMSCALING: boolean;
  97546. PREMULTIPLYALPHA: boolean;
  97547. IMAGEPROCESSING: boolean;
  97548. VIGNETTE: boolean;
  97549. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97550. VIGNETTEBLENDMODEOPAQUE: boolean;
  97551. TONEMAPPING: boolean;
  97552. TONEMAPPING_ACES: boolean;
  97553. CONTRAST: boolean;
  97554. COLORCURVES: boolean;
  97555. COLORGRADING: boolean;
  97556. COLORGRADING3D: boolean;
  97557. SAMPLER3DGREENDEPTH: boolean;
  97558. SAMPLER3DBGRMAP: boolean;
  97559. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97560. MULTIVIEW: boolean;
  97561. /**
  97562. * If the reflection texture on this material is in linear color space
  97563. * @hidden
  97564. */
  97565. IS_REFLECTION_LINEAR: boolean;
  97566. /**
  97567. * If the refraction texture on this material is in linear color space
  97568. * @hidden
  97569. */
  97570. IS_REFRACTION_LINEAR: boolean;
  97571. EXPOSURE: boolean;
  97572. constructor();
  97573. setReflectionMode(modeToEnable: string): void;
  97574. }
  97575. /**
  97576. * This is the default material used in Babylon. It is the best trade off between quality
  97577. * and performances.
  97578. * @see http://doc.babylonjs.com/babylon101/materials
  97579. */
  97580. export class StandardMaterial extends PushMaterial {
  97581. private _diffuseTexture;
  97582. /**
  97583. * The basic texture of the material as viewed under a light.
  97584. */
  97585. diffuseTexture: Nullable<BaseTexture>;
  97586. private _ambientTexture;
  97587. /**
  97588. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  97589. */
  97590. ambientTexture: Nullable<BaseTexture>;
  97591. private _opacityTexture;
  97592. /**
  97593. * Define the transparency of the material from a texture.
  97594. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  97595. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  97596. */
  97597. opacityTexture: Nullable<BaseTexture>;
  97598. private _reflectionTexture;
  97599. /**
  97600. * Define the texture used to display the reflection.
  97601. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97602. */
  97603. reflectionTexture: Nullable<BaseTexture>;
  97604. private _emissiveTexture;
  97605. /**
  97606. * Define texture of the material as if self lit.
  97607. * This will be mixed in the final result even in the absence of light.
  97608. */
  97609. emissiveTexture: Nullable<BaseTexture>;
  97610. private _specularTexture;
  97611. /**
  97612. * Define how the color and intensity of the highlight given by the light in the material.
  97613. */
  97614. specularTexture: Nullable<BaseTexture>;
  97615. private _bumpTexture;
  97616. /**
  97617. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  97618. * 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.
  97619. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  97620. */
  97621. bumpTexture: Nullable<BaseTexture>;
  97622. private _lightmapTexture;
  97623. /**
  97624. * Complex lighting can be computationally expensive to compute at runtime.
  97625. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  97626. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  97627. */
  97628. lightmapTexture: Nullable<BaseTexture>;
  97629. private _refractionTexture;
  97630. /**
  97631. * Define the texture used to display the refraction.
  97632. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97633. */
  97634. refractionTexture: Nullable<BaseTexture>;
  97635. /**
  97636. * The color of the material lit by the environmental background lighting.
  97637. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  97638. */
  97639. ambientColor: Color3;
  97640. /**
  97641. * The basic color of the material as viewed under a light.
  97642. */
  97643. diffuseColor: Color3;
  97644. /**
  97645. * Define how the color and intensity of the highlight given by the light in the material.
  97646. */
  97647. specularColor: Color3;
  97648. /**
  97649. * Define the color of the material as if self lit.
  97650. * This will be mixed in the final result even in the absence of light.
  97651. */
  97652. emissiveColor: Color3;
  97653. /**
  97654. * Defines how sharp are the highlights in the material.
  97655. * The bigger the value the sharper giving a more glossy feeling to the result.
  97656. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  97657. */
  97658. specularPower: number;
  97659. private _useAlphaFromDiffuseTexture;
  97660. /**
  97661. * Does the transparency come from the diffuse texture alpha channel.
  97662. */
  97663. useAlphaFromDiffuseTexture: boolean;
  97664. private _useEmissiveAsIllumination;
  97665. /**
  97666. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97667. */
  97668. useEmissiveAsIllumination: boolean;
  97669. private _linkEmissiveWithDiffuse;
  97670. /**
  97671. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97672. * the emissive level when the final color is close to one.
  97673. */
  97674. linkEmissiveWithDiffuse: boolean;
  97675. private _useSpecularOverAlpha;
  97676. /**
  97677. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97678. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97679. */
  97680. useSpecularOverAlpha: boolean;
  97681. private _useReflectionOverAlpha;
  97682. /**
  97683. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97684. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97685. */
  97686. useReflectionOverAlpha: boolean;
  97687. private _disableLighting;
  97688. /**
  97689. * Does lights from the scene impacts this material.
  97690. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97691. */
  97692. disableLighting: boolean;
  97693. private _useObjectSpaceNormalMap;
  97694. /**
  97695. * Allows using an object space normal map (instead of tangent space).
  97696. */
  97697. useObjectSpaceNormalMap: boolean;
  97698. private _useParallax;
  97699. /**
  97700. * Is parallax enabled or not.
  97701. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97702. */
  97703. useParallax: boolean;
  97704. private _useParallaxOcclusion;
  97705. /**
  97706. * Is parallax occlusion enabled or not.
  97707. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97708. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97709. */
  97710. useParallaxOcclusion: boolean;
  97711. /**
  97712. * 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.
  97713. */
  97714. parallaxScaleBias: number;
  97715. private _roughness;
  97716. /**
  97717. * Helps to define how blurry the reflections should appears in the material.
  97718. */
  97719. roughness: number;
  97720. /**
  97721. * In case of refraction, define the value of the index of refraction.
  97722. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97723. */
  97724. indexOfRefraction: number;
  97725. /**
  97726. * Invert the refraction texture alongside the y axis.
  97727. * It can be useful with procedural textures or probe for instance.
  97728. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97729. */
  97730. invertRefractionY: boolean;
  97731. /**
  97732. * Defines the alpha limits in alpha test mode.
  97733. */
  97734. alphaCutOff: number;
  97735. private _useLightmapAsShadowmap;
  97736. /**
  97737. * In case of light mapping, define whether the map contains light or shadow informations.
  97738. */
  97739. useLightmapAsShadowmap: boolean;
  97740. private _diffuseFresnelParameters;
  97741. /**
  97742. * Define the diffuse fresnel parameters of the material.
  97743. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97744. */
  97745. diffuseFresnelParameters: FresnelParameters;
  97746. private _opacityFresnelParameters;
  97747. /**
  97748. * Define the opacity fresnel parameters of the material.
  97749. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97750. */
  97751. opacityFresnelParameters: FresnelParameters;
  97752. private _reflectionFresnelParameters;
  97753. /**
  97754. * Define the reflection fresnel parameters of the material.
  97755. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97756. */
  97757. reflectionFresnelParameters: FresnelParameters;
  97758. private _refractionFresnelParameters;
  97759. /**
  97760. * Define the refraction fresnel parameters of the material.
  97761. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97762. */
  97763. refractionFresnelParameters: FresnelParameters;
  97764. private _emissiveFresnelParameters;
  97765. /**
  97766. * Define the emissive fresnel parameters of the material.
  97767. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97768. */
  97769. emissiveFresnelParameters: FresnelParameters;
  97770. private _useReflectionFresnelFromSpecular;
  97771. /**
  97772. * If true automatically deducts the fresnels values from the material specularity.
  97773. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  97774. */
  97775. useReflectionFresnelFromSpecular: boolean;
  97776. private _useGlossinessFromSpecularMapAlpha;
  97777. /**
  97778. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  97779. */
  97780. useGlossinessFromSpecularMapAlpha: boolean;
  97781. private _maxSimultaneousLights;
  97782. /**
  97783. * Defines the maximum number of lights that can be used in the material
  97784. */
  97785. maxSimultaneousLights: number;
  97786. private _invertNormalMapX;
  97787. /**
  97788. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  97789. */
  97790. invertNormalMapX: boolean;
  97791. private _invertNormalMapY;
  97792. /**
  97793. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  97794. */
  97795. invertNormalMapY: boolean;
  97796. private _twoSidedLighting;
  97797. /**
  97798. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  97799. */
  97800. twoSidedLighting: boolean;
  97801. /**
  97802. * Default configuration related to image processing available in the standard Material.
  97803. */
  97804. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  97805. /**
  97806. * Gets the image processing configuration used either in this material.
  97807. */
  97808. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  97809. /**
  97810. * Sets the Default image processing configuration used either in the this material.
  97811. *
  97812. * If sets to null, the scene one is in use.
  97813. */
  97814. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  97815. /**
  97816. * Keep track of the image processing observer to allow dispose and replace.
  97817. */
  97818. private _imageProcessingObserver;
  97819. /**
  97820. * Attaches a new image processing configuration to the Standard Material.
  97821. * @param configuration
  97822. */
  97823. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  97824. /**
  97825. * Gets wether the color curves effect is enabled.
  97826. */
  97827. get cameraColorCurvesEnabled(): boolean;
  97828. /**
  97829. * Sets wether the color curves effect is enabled.
  97830. */
  97831. set cameraColorCurvesEnabled(value: boolean);
  97832. /**
  97833. * Gets wether the color grading effect is enabled.
  97834. */
  97835. get cameraColorGradingEnabled(): boolean;
  97836. /**
  97837. * Gets wether the color grading effect is enabled.
  97838. */
  97839. set cameraColorGradingEnabled(value: boolean);
  97840. /**
  97841. * Gets wether tonemapping is enabled or not.
  97842. */
  97843. get cameraToneMappingEnabled(): boolean;
  97844. /**
  97845. * Sets wether tonemapping is enabled or not
  97846. */
  97847. set cameraToneMappingEnabled(value: boolean);
  97848. /**
  97849. * The camera exposure used on this material.
  97850. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97851. * This corresponds to a photographic exposure.
  97852. */
  97853. get cameraExposure(): number;
  97854. /**
  97855. * The camera exposure used on this material.
  97856. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  97857. * This corresponds to a photographic exposure.
  97858. */
  97859. set cameraExposure(value: number);
  97860. /**
  97861. * Gets The camera contrast used on this material.
  97862. */
  97863. get cameraContrast(): number;
  97864. /**
  97865. * Sets The camera contrast used on this material.
  97866. */
  97867. set cameraContrast(value: number);
  97868. /**
  97869. * Gets the Color Grading 2D Lookup Texture.
  97870. */
  97871. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  97872. /**
  97873. * Sets the Color Grading 2D Lookup Texture.
  97874. */
  97875. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  97876. /**
  97877. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97878. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97879. * 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;
  97880. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97881. */
  97882. get cameraColorCurves(): Nullable<ColorCurves>;
  97883. /**
  97884. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  97885. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  97886. * 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;
  97887. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  97888. */
  97889. set cameraColorCurves(value: Nullable<ColorCurves>);
  97890. /**
  97891. * Custom callback helping to override the default shader used in the material.
  97892. */
  97893. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  97894. protected _renderTargets: SmartArray<RenderTargetTexture>;
  97895. protected _worldViewProjectionMatrix: Matrix;
  97896. protected _globalAmbientColor: Color3;
  97897. protected _useLogarithmicDepth: boolean;
  97898. protected _rebuildInParallel: boolean;
  97899. /**
  97900. * Instantiates a new standard material.
  97901. * This is the default material used in Babylon. It is the best trade off between quality
  97902. * and performances.
  97903. * @see http://doc.babylonjs.com/babylon101/materials
  97904. * @param name Define the name of the material in the scene
  97905. * @param scene Define the scene the material belong to
  97906. */
  97907. constructor(name: string, scene: Scene);
  97908. /**
  97909. * Gets a boolean indicating that current material needs to register RTT
  97910. */
  97911. get hasRenderTargetTextures(): boolean;
  97912. /**
  97913. * Gets the current class name of the material e.g. "StandardMaterial"
  97914. * Mainly use in serialization.
  97915. * @returns the class name
  97916. */
  97917. getClassName(): string;
  97918. /**
  97919. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  97920. * You can try switching to logarithmic depth.
  97921. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  97922. */
  97923. get useLogarithmicDepth(): boolean;
  97924. set useLogarithmicDepth(value: boolean);
  97925. /**
  97926. * Specifies if the material will require alpha blending
  97927. * @returns a boolean specifying if alpha blending is needed
  97928. */
  97929. needAlphaBlending(): boolean;
  97930. /**
  97931. * Specifies if this material should be rendered in alpha test mode
  97932. * @returns a boolean specifying if an alpha test is needed.
  97933. */
  97934. needAlphaTesting(): boolean;
  97935. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  97936. /**
  97937. * Get the texture used for alpha test purpose.
  97938. * @returns the diffuse texture in case of the standard material.
  97939. */
  97940. getAlphaTestTexture(): Nullable<BaseTexture>;
  97941. /**
  97942. * Get if the submesh is ready to be used and all its information available.
  97943. * Child classes can use it to update shaders
  97944. * @param mesh defines the mesh to check
  97945. * @param subMesh defines which submesh to check
  97946. * @param useInstances specifies that instances should be used
  97947. * @returns a boolean indicating that the submesh is ready or not
  97948. */
  97949. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97950. /**
  97951. * Builds the material UBO layouts.
  97952. * Used internally during the effect preparation.
  97953. */
  97954. buildUniformLayout(): void;
  97955. /**
  97956. * Unbinds the material from the mesh
  97957. */
  97958. unbind(): void;
  97959. /**
  97960. * Binds the submesh to this material by preparing the effect and shader to draw
  97961. * @param world defines the world transformation matrix
  97962. * @param mesh defines the mesh containing the submesh
  97963. * @param subMesh defines the submesh to bind the material to
  97964. */
  97965. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97966. /**
  97967. * Get the list of animatables in the material.
  97968. * @returns the list of animatables object used in the material
  97969. */
  97970. getAnimatables(): IAnimatable[];
  97971. /**
  97972. * Gets the active textures from the material
  97973. * @returns an array of textures
  97974. */
  97975. getActiveTextures(): BaseTexture[];
  97976. /**
  97977. * Specifies if the material uses a texture
  97978. * @param texture defines the texture to check against the material
  97979. * @returns a boolean specifying if the material uses the texture
  97980. */
  97981. hasTexture(texture: BaseTexture): boolean;
  97982. /**
  97983. * Disposes the material
  97984. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97985. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97986. */
  97987. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  97988. /**
  97989. * Makes a duplicate of the material, and gives it a new name
  97990. * @param name defines the new name for the duplicated material
  97991. * @returns the cloned material
  97992. */
  97993. clone(name: string): StandardMaterial;
  97994. /**
  97995. * Serializes this material in a JSON representation
  97996. * @returns the serialized material object
  97997. */
  97998. serialize(): any;
  97999. /**
  98000. * Creates a standard material from parsed material data
  98001. * @param source defines the JSON representation of the material
  98002. * @param scene defines the hosting scene
  98003. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98004. * @returns a new standard material
  98005. */
  98006. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98007. /**
  98008. * Are diffuse textures enabled in the application.
  98009. */
  98010. static get DiffuseTextureEnabled(): boolean;
  98011. static set DiffuseTextureEnabled(value: boolean);
  98012. /**
  98013. * Are ambient textures enabled in the application.
  98014. */
  98015. static get AmbientTextureEnabled(): boolean;
  98016. static set AmbientTextureEnabled(value: boolean);
  98017. /**
  98018. * Are opacity textures enabled in the application.
  98019. */
  98020. static get OpacityTextureEnabled(): boolean;
  98021. static set OpacityTextureEnabled(value: boolean);
  98022. /**
  98023. * Are reflection textures enabled in the application.
  98024. */
  98025. static get ReflectionTextureEnabled(): boolean;
  98026. static set ReflectionTextureEnabled(value: boolean);
  98027. /**
  98028. * Are emissive textures enabled in the application.
  98029. */
  98030. static get EmissiveTextureEnabled(): boolean;
  98031. static set EmissiveTextureEnabled(value: boolean);
  98032. /**
  98033. * Are specular textures enabled in the application.
  98034. */
  98035. static get SpecularTextureEnabled(): boolean;
  98036. static set SpecularTextureEnabled(value: boolean);
  98037. /**
  98038. * Are bump textures enabled in the application.
  98039. */
  98040. static get BumpTextureEnabled(): boolean;
  98041. static set BumpTextureEnabled(value: boolean);
  98042. /**
  98043. * Are lightmap textures enabled in the application.
  98044. */
  98045. static get LightmapTextureEnabled(): boolean;
  98046. static set LightmapTextureEnabled(value: boolean);
  98047. /**
  98048. * Are refraction textures enabled in the application.
  98049. */
  98050. static get RefractionTextureEnabled(): boolean;
  98051. static set RefractionTextureEnabled(value: boolean);
  98052. /**
  98053. * Are color grading textures enabled in the application.
  98054. */
  98055. static get ColorGradingTextureEnabled(): boolean;
  98056. static set ColorGradingTextureEnabled(value: boolean);
  98057. /**
  98058. * Are fresnels enabled in the application.
  98059. */
  98060. static get FresnelEnabled(): boolean;
  98061. static set FresnelEnabled(value: boolean);
  98062. }
  98063. }
  98064. declare module BABYLON {
  98065. /**
  98066. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  98067. *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.
  98068. * The SPS is also a particle system. It provides some methods to manage the particles.
  98069. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  98070. *
  98071. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  98072. */
  98073. export class SolidParticleSystem implements IDisposable {
  98074. /**
  98075. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  98076. * Example : var p = SPS.particles[i];
  98077. */
  98078. particles: SolidParticle[];
  98079. /**
  98080. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  98081. */
  98082. nbParticles: number;
  98083. /**
  98084. * If the particles must ever face the camera (default false). Useful for planar particles.
  98085. */
  98086. billboard: boolean;
  98087. /**
  98088. * Recompute normals when adding a shape
  98089. */
  98090. recomputeNormals: boolean;
  98091. /**
  98092. * This a counter ofr your own usage. It's not set by any SPS functions.
  98093. */
  98094. counter: number;
  98095. /**
  98096. * The SPS name. This name is also given to the underlying mesh.
  98097. */
  98098. name: string;
  98099. /**
  98100. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  98101. */
  98102. mesh: Mesh;
  98103. /**
  98104. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  98105. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  98106. */
  98107. vars: any;
  98108. /**
  98109. * This array is populated when the SPS is set as 'pickable'.
  98110. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  98111. * Each element of this array is an object `{idx: int, faceId: int}`.
  98112. * `idx` is the picked particle index in the `SPS.particles` array
  98113. * `faceId` is the picked face index counted within this particle.
  98114. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  98115. */
  98116. pickedParticles: {
  98117. idx: number;
  98118. faceId: number;
  98119. }[];
  98120. /**
  98121. * This array is populated when `enableDepthSort` is set to true.
  98122. * Each element of this array is an instance of the class DepthSortedParticle.
  98123. */
  98124. depthSortedParticles: DepthSortedParticle[];
  98125. /**
  98126. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  98127. * @hidden
  98128. */
  98129. _bSphereOnly: boolean;
  98130. /**
  98131. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  98132. * @hidden
  98133. */
  98134. _bSphereRadiusFactor: number;
  98135. private _scene;
  98136. private _positions;
  98137. private _indices;
  98138. private _normals;
  98139. private _colors;
  98140. private _uvs;
  98141. private _indices32;
  98142. private _positions32;
  98143. private _normals32;
  98144. private _fixedNormal32;
  98145. private _colors32;
  98146. private _uvs32;
  98147. private _index;
  98148. private _updatable;
  98149. private _pickable;
  98150. private _isVisibilityBoxLocked;
  98151. private _alwaysVisible;
  98152. private _depthSort;
  98153. private _expandable;
  98154. private _shapeCounter;
  98155. private _copy;
  98156. private _color;
  98157. private _computeParticleColor;
  98158. private _computeParticleTexture;
  98159. private _computeParticleRotation;
  98160. private _computeParticleVertex;
  98161. private _computeBoundingBox;
  98162. private _depthSortParticles;
  98163. private _camera;
  98164. private _mustUnrotateFixedNormals;
  98165. private _particlesIntersect;
  98166. private _needs32Bits;
  98167. private _isNotBuilt;
  98168. private _lastParticleId;
  98169. private _idxOfId;
  98170. private _multimaterialEnabled;
  98171. private _useModelMaterial;
  98172. private _indicesByMaterial;
  98173. private _materialIndexes;
  98174. private _depthSortFunction;
  98175. private _materialSortFunction;
  98176. private _materials;
  98177. private _multimaterial;
  98178. private _materialIndexesById;
  98179. private _defaultMaterial;
  98180. private _autoUpdateSubMeshes;
  98181. /**
  98182. * Creates a SPS (Solid Particle System) object.
  98183. * @param name (String) is the SPS name, this will be the underlying mesh name.
  98184. * @param scene (Scene) is the scene in which the SPS is added.
  98185. * @param options defines the options of the sps e.g.
  98186. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  98187. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  98188. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  98189. * * 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.
  98190. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  98191. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  98192. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  98193. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  98194. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  98195. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  98196. */
  98197. constructor(name: string, scene: Scene, options?: {
  98198. updatable?: boolean;
  98199. isPickable?: boolean;
  98200. enableDepthSort?: boolean;
  98201. particleIntersection?: boolean;
  98202. boundingSphereOnly?: boolean;
  98203. bSphereRadiusFactor?: number;
  98204. expandable?: boolean;
  98205. useModelMaterial?: boolean;
  98206. enableMultiMaterial?: boolean;
  98207. });
  98208. /**
  98209. * Builds the SPS underlying mesh. Returns a standard Mesh.
  98210. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  98211. * @returns the created mesh
  98212. */
  98213. buildMesh(): Mesh;
  98214. /**
  98215. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  98216. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  98217. * Thus the particles generated from `digest()` have their property `position` set yet.
  98218. * @param mesh ( Mesh ) is the mesh to be digested
  98219. * @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
  98220. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  98221. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  98222. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  98223. * @returns the current SPS
  98224. */
  98225. digest(mesh: Mesh, options?: {
  98226. facetNb?: number;
  98227. number?: number;
  98228. delta?: number;
  98229. storage?: [];
  98230. }): SolidParticleSystem;
  98231. /**
  98232. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  98233. * @hidden
  98234. */
  98235. private _unrotateFixedNormals;
  98236. /**
  98237. * Resets the temporary working copy particle
  98238. * @hidden
  98239. */
  98240. private _resetCopy;
  98241. /**
  98242. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  98243. * @param p the current index in the positions array to be updated
  98244. * @param ind the current index in the indices array
  98245. * @param shape a Vector3 array, the shape geometry
  98246. * @param positions the positions array to be updated
  98247. * @param meshInd the shape indices array
  98248. * @param indices the indices array to be updated
  98249. * @param meshUV the shape uv array
  98250. * @param uvs the uv array to be updated
  98251. * @param meshCol the shape color array
  98252. * @param colors the color array to be updated
  98253. * @param meshNor the shape normals array
  98254. * @param normals the normals array to be updated
  98255. * @param idx the particle index
  98256. * @param idxInShape the particle index in its shape
  98257. * @param options the addShape() method passed options
  98258. * @model the particle model
  98259. * @hidden
  98260. */
  98261. private _meshBuilder;
  98262. /**
  98263. * Returns a shape Vector3 array from positions float array
  98264. * @param positions float array
  98265. * @returns a vector3 array
  98266. * @hidden
  98267. */
  98268. private _posToShape;
  98269. /**
  98270. * Returns a shapeUV array from a float uvs (array deep copy)
  98271. * @param uvs as a float array
  98272. * @returns a shapeUV array
  98273. * @hidden
  98274. */
  98275. private _uvsToShapeUV;
  98276. /**
  98277. * Adds a new particle object in the particles array
  98278. * @param idx particle index in particles array
  98279. * @param id particle id
  98280. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  98281. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  98282. * @param model particle ModelShape object
  98283. * @param shapeId model shape identifier
  98284. * @param idxInShape index of the particle in the current model
  98285. * @param bInfo model bounding info object
  98286. * @param storage target storage array, if any
  98287. * @hidden
  98288. */
  98289. private _addParticle;
  98290. /**
  98291. * Adds some particles to the SPS from the model shape. Returns the shape id.
  98292. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  98293. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  98294. * @param nb (positive integer) the number of particles to be created from this model
  98295. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  98296. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  98297. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  98298. * @returns the number of shapes in the system
  98299. */
  98300. addShape(mesh: Mesh, nb: number, options?: {
  98301. positionFunction?: any;
  98302. vertexFunction?: any;
  98303. storage?: [];
  98304. }): number;
  98305. /**
  98306. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  98307. * @hidden
  98308. */
  98309. private _rebuildParticle;
  98310. /**
  98311. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  98312. * @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.
  98313. * @returns the SPS.
  98314. */
  98315. rebuildMesh(reset?: boolean): SolidParticleSystem;
  98316. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  98317. * Returns an array with the removed particles.
  98318. * 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.
  98319. * The SPS can't be empty so at least one particle needs to remain in place.
  98320. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  98321. * @param start index of the first particle to remove
  98322. * @param end index of the last particle to remove (included)
  98323. * @returns an array populated with the removed particles
  98324. */
  98325. removeParticles(start: number, end: number): SolidParticle[];
  98326. /**
  98327. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  98328. * @param solidParticleArray an array populated with Solid Particles objects
  98329. * @returns the SPS
  98330. */
  98331. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  98332. /**
  98333. * Creates a new particle and modifies the SPS mesh geometry :
  98334. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  98335. * - calls _addParticle() to populate the particle array
  98336. * factorized code from addShape() and insertParticlesFromArray()
  98337. * @param idx particle index in the particles array
  98338. * @param i particle index in its shape
  98339. * @param modelShape particle ModelShape object
  98340. * @param shape shape vertex array
  98341. * @param meshInd shape indices array
  98342. * @param meshUV shape uv array
  98343. * @param meshCol shape color array
  98344. * @param meshNor shape normals array
  98345. * @param bbInfo shape bounding info
  98346. * @param storage target particle storage
  98347. * @options addShape() passed options
  98348. * @hidden
  98349. */
  98350. private _insertNewParticle;
  98351. /**
  98352. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  98353. * This method calls `updateParticle()` for each particle of the SPS.
  98354. * For an animated SPS, it is usually called within the render loop.
  98355. * 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.
  98356. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  98357. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  98358. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  98359. * @returns the SPS.
  98360. */
  98361. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  98362. /**
  98363. * Disposes the SPS.
  98364. */
  98365. dispose(): void;
  98366. /**
  98367. * Returns a SolidParticle object from its identifier : particle.id
  98368. * @param id (integer) the particle Id
  98369. * @returns the searched particle or null if not found in the SPS.
  98370. */
  98371. getParticleById(id: number): Nullable<SolidParticle>;
  98372. /**
  98373. * Returns a new array populated with the particles having the passed shapeId.
  98374. * @param shapeId (integer) the shape identifier
  98375. * @returns a new solid particle array
  98376. */
  98377. getParticlesByShapeId(shapeId: number): SolidParticle[];
  98378. /**
  98379. * Populates the passed array "ref" with the particles having the passed shapeId.
  98380. * @param shapeId the shape identifier
  98381. * @returns the SPS
  98382. * @param ref
  98383. */
  98384. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  98385. /**
  98386. * Computes the required SubMeshes according the materials assigned to the particles.
  98387. * @returns the solid particle system.
  98388. * Does nothing if called before the SPS mesh is built.
  98389. */
  98390. computeSubMeshes(): SolidParticleSystem;
  98391. /**
  98392. * Sorts the solid particles by material when MultiMaterial is enabled.
  98393. * Updates the indices32 array.
  98394. * Updates the indicesByMaterial array.
  98395. * Updates the mesh indices array.
  98396. * @returns the SPS
  98397. * @hidden
  98398. */
  98399. private _sortParticlesByMaterial;
  98400. /**
  98401. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  98402. * @hidden
  98403. */
  98404. private _setMaterialIndexesById;
  98405. /**
  98406. * Returns an array with unique values of Materials from the passed array
  98407. * @param array the material array to be checked and filtered
  98408. * @hidden
  98409. */
  98410. private _filterUniqueMaterialId;
  98411. /**
  98412. * Sets a new Standard Material as _defaultMaterial if not already set.
  98413. * @hidden
  98414. */
  98415. private _setDefaultMaterial;
  98416. /**
  98417. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  98418. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98419. * @returns the SPS.
  98420. */
  98421. refreshVisibleSize(): SolidParticleSystem;
  98422. /**
  98423. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  98424. * @param size the size (float) of the visibility box
  98425. * note : this doesn't lock the SPS mesh bounding box.
  98426. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98427. */
  98428. setVisibilityBox(size: number): void;
  98429. /**
  98430. * Gets whether the SPS as always visible or not
  98431. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98432. */
  98433. get isAlwaysVisible(): boolean;
  98434. /**
  98435. * Sets the SPS as always visible or not
  98436. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98437. */
  98438. set isAlwaysVisible(val: boolean);
  98439. /**
  98440. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  98441. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98442. */
  98443. set isVisibilityBoxLocked(val: boolean);
  98444. /**
  98445. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  98446. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  98447. */
  98448. get isVisibilityBoxLocked(): boolean;
  98449. /**
  98450. * Tells to `setParticles()` to compute the particle rotations or not.
  98451. * Default value : true. The SPS is faster when it's set to false.
  98452. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  98453. */
  98454. set computeParticleRotation(val: boolean);
  98455. /**
  98456. * Tells to `setParticles()` to compute the particle colors or not.
  98457. * Default value : true. The SPS is faster when it's set to false.
  98458. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  98459. */
  98460. set computeParticleColor(val: boolean);
  98461. set computeParticleTexture(val: boolean);
  98462. /**
  98463. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  98464. * Default value : false. The SPS is faster when it's set to false.
  98465. * Note : the particle custom vertex positions aren't stored values.
  98466. */
  98467. set computeParticleVertex(val: boolean);
  98468. /**
  98469. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  98470. */
  98471. set computeBoundingBox(val: boolean);
  98472. /**
  98473. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  98474. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  98475. * Default : `true`
  98476. */
  98477. set depthSortParticles(val: boolean);
  98478. /**
  98479. * Gets if `setParticles()` computes the particle rotations or not.
  98480. * Default value : true. The SPS is faster when it's set to false.
  98481. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  98482. */
  98483. get computeParticleRotation(): boolean;
  98484. /**
  98485. * Gets if `setParticles()` computes the particle colors or not.
  98486. * Default value : true. The SPS is faster when it's set to false.
  98487. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  98488. */
  98489. get computeParticleColor(): boolean;
  98490. /**
  98491. * Gets if `setParticles()` computes the particle textures or not.
  98492. * Default value : true. The SPS is faster when it's set to false.
  98493. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  98494. */
  98495. get computeParticleTexture(): boolean;
  98496. /**
  98497. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  98498. * Default value : false. The SPS is faster when it's set to false.
  98499. * Note : the particle custom vertex positions aren't stored values.
  98500. */
  98501. get computeParticleVertex(): boolean;
  98502. /**
  98503. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  98504. */
  98505. get computeBoundingBox(): boolean;
  98506. /**
  98507. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  98508. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  98509. * Default : `true`
  98510. */
  98511. get depthSortParticles(): boolean;
  98512. /**
  98513. * Gets if the SPS is created as expandable at construction time.
  98514. * Default : `false`
  98515. */
  98516. get expandable(): boolean;
  98517. /**
  98518. * Gets if the SPS supports the Multi Materials
  98519. */
  98520. get multimaterialEnabled(): boolean;
  98521. /**
  98522. * Gets if the SPS uses the model materials for its own multimaterial.
  98523. */
  98524. get useModelMaterial(): boolean;
  98525. /**
  98526. * The SPS used material array.
  98527. */
  98528. get materials(): Material[];
  98529. /**
  98530. * Sets the SPS MultiMaterial from the passed materials.
  98531. * Note : the passed array is internally copied and not used then by reference.
  98532. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  98533. */
  98534. setMultiMaterial(materials: Material[]): void;
  98535. /**
  98536. * The SPS computed multimaterial object
  98537. */
  98538. get multimaterial(): MultiMaterial;
  98539. set multimaterial(mm: MultiMaterial);
  98540. /**
  98541. * If the subMeshes must be updated on the next call to setParticles()
  98542. */
  98543. get autoUpdateSubMeshes(): boolean;
  98544. set autoUpdateSubMeshes(val: boolean);
  98545. /**
  98546. * This function does nothing. It may be overwritten to set all the particle first values.
  98547. * The SPS doesn't call this function, you may have to call it by your own.
  98548. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  98549. */
  98550. initParticles(): void;
  98551. /**
  98552. * This function does nothing. It may be overwritten to recycle a particle.
  98553. * The SPS doesn't call this function, you may have to call it by your own.
  98554. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  98555. * @param particle The particle to recycle
  98556. * @returns the recycled particle
  98557. */
  98558. recycleParticle(particle: SolidParticle): SolidParticle;
  98559. /**
  98560. * Updates a particle : this function should be overwritten by the user.
  98561. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  98562. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  98563. * @example : just set a particle position or velocity and recycle conditions
  98564. * @param particle The particle to update
  98565. * @returns the updated particle
  98566. */
  98567. updateParticle(particle: SolidParticle): SolidParticle;
  98568. /**
  98569. * Updates a vertex of a particle : it can be overwritten by the user.
  98570. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  98571. * @param particle the current particle
  98572. * @param vertex the current index of the current particle
  98573. * @param pt the index of the current vertex in the particle shape
  98574. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  98575. * @example : just set a vertex particle position
  98576. * @returns the updated vertex
  98577. */
  98578. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  98579. /**
  98580. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  98581. * This does nothing and may be overwritten by the user.
  98582. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  98583. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  98584. * @param update the boolean update value actually passed to setParticles()
  98585. */
  98586. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  98587. /**
  98588. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  98589. * This will be passed three parameters.
  98590. * This does nothing and may be overwritten by the user.
  98591. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  98592. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  98593. * @param update the boolean update value actually passed to setParticles()
  98594. */
  98595. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  98596. }
  98597. }
  98598. declare module BABYLON {
  98599. /**
  98600. * Represents one particle of a solid particle system.
  98601. */
  98602. export class SolidParticle {
  98603. /**
  98604. * particle global index
  98605. */
  98606. idx: number;
  98607. /**
  98608. * particle identifier
  98609. */
  98610. id: number;
  98611. /**
  98612. * The color of the particle
  98613. */
  98614. color: Nullable<Color4>;
  98615. /**
  98616. * The world space position of the particle.
  98617. */
  98618. position: Vector3;
  98619. /**
  98620. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  98621. */
  98622. rotation: Vector3;
  98623. /**
  98624. * The world space rotation quaternion of the particle.
  98625. */
  98626. rotationQuaternion: Nullable<Quaternion>;
  98627. /**
  98628. * The scaling of the particle.
  98629. */
  98630. scaling: Vector3;
  98631. /**
  98632. * The uvs of the particle.
  98633. */
  98634. uvs: Vector4;
  98635. /**
  98636. * The current speed of the particle.
  98637. */
  98638. velocity: Vector3;
  98639. /**
  98640. * The pivot point in the particle local space.
  98641. */
  98642. pivot: Vector3;
  98643. /**
  98644. * Must the particle be translated from its pivot point in its local space ?
  98645. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  98646. * Default : false
  98647. */
  98648. translateFromPivot: boolean;
  98649. /**
  98650. * Is the particle active or not ?
  98651. */
  98652. alive: boolean;
  98653. /**
  98654. * Is the particle visible or not ?
  98655. */
  98656. isVisible: boolean;
  98657. /**
  98658. * Index of this particle in the global "positions" array (Internal use)
  98659. * @hidden
  98660. */
  98661. _pos: number;
  98662. /**
  98663. * @hidden Index of this particle in the global "indices" array (Internal use)
  98664. */
  98665. _ind: number;
  98666. /**
  98667. * @hidden ModelShape of this particle (Internal use)
  98668. */
  98669. _model: ModelShape;
  98670. /**
  98671. * ModelShape id of this particle
  98672. */
  98673. shapeId: number;
  98674. /**
  98675. * Index of the particle in its shape id
  98676. */
  98677. idxInShape: number;
  98678. /**
  98679. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  98680. */
  98681. _modelBoundingInfo: BoundingInfo;
  98682. /**
  98683. * @hidden Particle BoundingInfo object (Internal use)
  98684. */
  98685. _boundingInfo: BoundingInfo;
  98686. /**
  98687. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  98688. */
  98689. _sps: SolidParticleSystem;
  98690. /**
  98691. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  98692. */
  98693. _stillInvisible: boolean;
  98694. /**
  98695. * @hidden Last computed particle rotation matrix
  98696. */
  98697. _rotationMatrix: number[];
  98698. /**
  98699. * Parent particle Id, if any.
  98700. * Default null.
  98701. */
  98702. parentId: Nullable<number>;
  98703. /**
  98704. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  98705. */
  98706. materialIndex: Nullable<number>;
  98707. /**
  98708. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  98709. * The possible values are :
  98710. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  98711. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98712. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  98713. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  98714. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  98715. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  98716. * */
  98717. cullingStrategy: number;
  98718. /**
  98719. * @hidden Internal global position in the SPS.
  98720. */
  98721. _globalPosition: Vector3;
  98722. /**
  98723. * Creates a Solid Particle object.
  98724. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  98725. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  98726. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  98727. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  98728. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  98729. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  98730. * @param shapeId (integer) is the model shape identifier in the SPS.
  98731. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  98732. * @param sps defines the sps it is associated to
  98733. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  98734. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  98735. */
  98736. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  98737. /**
  98738. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  98739. * @param target the particle target
  98740. * @returns the current particle
  98741. */
  98742. copyToRef(target: SolidParticle): SolidParticle;
  98743. /**
  98744. * Legacy support, changed scale to scaling
  98745. */
  98746. get scale(): Vector3;
  98747. /**
  98748. * Legacy support, changed scale to scaling
  98749. */
  98750. set scale(scale: Vector3);
  98751. /**
  98752. * Legacy support, changed quaternion to rotationQuaternion
  98753. */
  98754. get quaternion(): Nullable<Quaternion>;
  98755. /**
  98756. * Legacy support, changed quaternion to rotationQuaternion
  98757. */
  98758. set quaternion(q: Nullable<Quaternion>);
  98759. /**
  98760. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  98761. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  98762. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  98763. * @returns true if it intersects
  98764. */
  98765. intersectsMesh(target: Mesh | SolidParticle): boolean;
  98766. /**
  98767. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  98768. * A particle is in the frustum if its bounding box intersects the frustum
  98769. * @param frustumPlanes defines the frustum to test
  98770. * @returns true if the particle is in the frustum planes
  98771. */
  98772. isInFrustum(frustumPlanes: Plane[]): boolean;
  98773. /**
  98774. * get the rotation matrix of the particle
  98775. * @hidden
  98776. */
  98777. getRotationMatrix(m: Matrix): void;
  98778. }
  98779. /**
  98780. * Represents the shape of the model used by one particle of a solid particle system.
  98781. * SPS internal tool, don't use it manually.
  98782. */
  98783. export class ModelShape {
  98784. /**
  98785. * The shape id
  98786. * @hidden
  98787. */
  98788. shapeID: number;
  98789. /**
  98790. * flat array of model positions (internal use)
  98791. * @hidden
  98792. */
  98793. _shape: Vector3[];
  98794. /**
  98795. * flat array of model UVs (internal use)
  98796. * @hidden
  98797. */
  98798. _shapeUV: number[];
  98799. /**
  98800. * color array of the model
  98801. * @hidden
  98802. */
  98803. _shapeColors: number[];
  98804. /**
  98805. * indices array of the model
  98806. * @hidden
  98807. */
  98808. _indices: number[];
  98809. /**
  98810. * normals array of the model
  98811. * @hidden
  98812. */
  98813. _normals: number[];
  98814. /**
  98815. * length of the shape in the model indices array (internal use)
  98816. * @hidden
  98817. */
  98818. _indicesLength: number;
  98819. /**
  98820. * Custom position function (internal use)
  98821. * @hidden
  98822. */
  98823. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  98824. /**
  98825. * Custom vertex function (internal use)
  98826. * @hidden
  98827. */
  98828. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  98829. /**
  98830. * Model material (internal use)
  98831. * @hidden
  98832. */
  98833. _material: Nullable<Material>;
  98834. /**
  98835. * 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.
  98836. * SPS internal tool, don't use it manually.
  98837. * @hidden
  98838. */
  98839. 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>);
  98840. }
  98841. /**
  98842. * Represents a Depth Sorted Particle in the solid particle system.
  98843. * @hidden
  98844. */
  98845. export class DepthSortedParticle {
  98846. /**
  98847. * Index of the particle in the "indices" array
  98848. */
  98849. ind: number;
  98850. /**
  98851. * Length of the particle shape in the "indices" array
  98852. */
  98853. indicesLength: number;
  98854. /**
  98855. * Squared distance from the particle to the camera
  98856. */
  98857. sqDistance: number;
  98858. /**
  98859. * Material index when used with MultiMaterials
  98860. */
  98861. materialIndex: number;
  98862. /**
  98863. * Creates a new sorted particle
  98864. * @param materialIndex
  98865. */
  98866. constructor(ind: number, indLength: number, materialIndex: number);
  98867. }
  98868. }
  98869. declare module BABYLON {
  98870. /**
  98871. * @hidden
  98872. */
  98873. export class _MeshCollisionData {
  98874. _checkCollisions: boolean;
  98875. _collisionMask: number;
  98876. _collisionGroup: number;
  98877. _collider: Nullable<Collider>;
  98878. _oldPositionForCollisions: Vector3;
  98879. _diffPositionForCollisions: Vector3;
  98880. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  98881. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  98882. }
  98883. }
  98884. declare module BABYLON {
  98885. /** @hidden */
  98886. class _FacetDataStorage {
  98887. facetPositions: Vector3[];
  98888. facetNormals: Vector3[];
  98889. facetPartitioning: number[][];
  98890. facetNb: number;
  98891. partitioningSubdivisions: number;
  98892. partitioningBBoxRatio: number;
  98893. facetDataEnabled: boolean;
  98894. facetParameters: any;
  98895. bbSize: Vector3;
  98896. subDiv: {
  98897. max: number;
  98898. X: number;
  98899. Y: number;
  98900. Z: number;
  98901. };
  98902. facetDepthSort: boolean;
  98903. facetDepthSortEnabled: boolean;
  98904. depthSortedIndices: IndicesArray;
  98905. depthSortedFacets: {
  98906. ind: number;
  98907. sqDistance: number;
  98908. }[];
  98909. facetDepthSortFunction: (f1: {
  98910. ind: number;
  98911. sqDistance: number;
  98912. }, f2: {
  98913. ind: number;
  98914. sqDistance: number;
  98915. }) => number;
  98916. facetDepthSortFrom: Vector3;
  98917. facetDepthSortOrigin: Vector3;
  98918. invertedMatrix: Matrix;
  98919. }
  98920. /**
  98921. * @hidden
  98922. **/
  98923. class _InternalAbstractMeshDataInfo {
  98924. _hasVertexAlpha: boolean;
  98925. _useVertexColors: boolean;
  98926. _numBoneInfluencers: number;
  98927. _applyFog: boolean;
  98928. _receiveShadows: boolean;
  98929. _facetData: _FacetDataStorage;
  98930. _visibility: number;
  98931. _skeleton: Nullable<Skeleton>;
  98932. _layerMask: number;
  98933. _computeBonesUsingShaders: boolean;
  98934. _isActive: boolean;
  98935. _onlyForInstances: boolean;
  98936. _isActiveIntermediate: boolean;
  98937. _onlyForInstancesIntermediate: boolean;
  98938. _actAsRegularMesh: boolean;
  98939. }
  98940. /**
  98941. * Class used to store all common mesh properties
  98942. */
  98943. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  98944. /** No occlusion */
  98945. static OCCLUSION_TYPE_NONE: number;
  98946. /** Occlusion set to optimisitic */
  98947. static OCCLUSION_TYPE_OPTIMISTIC: number;
  98948. /** Occlusion set to strict */
  98949. static OCCLUSION_TYPE_STRICT: number;
  98950. /** Use an accurante occlusion algorithm */
  98951. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  98952. /** Use a conservative occlusion algorithm */
  98953. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  98954. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  98955. * Test order :
  98956. * Is the bounding sphere outside the frustum ?
  98957. * If not, are the bounding box vertices outside the frustum ?
  98958. * It not, then the cullable object is in the frustum.
  98959. */
  98960. static readonly CULLINGSTRATEGY_STANDARD: number;
  98961. /** Culling strategy : Bounding Sphere Only.
  98962. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  98963. * It's also less accurate than the standard because some not visible objects can still be selected.
  98964. * Test : is the bounding sphere outside the frustum ?
  98965. * If not, then the cullable object is in the frustum.
  98966. */
  98967. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  98968. /** Culling strategy : Optimistic Inclusion.
  98969. * This in an inclusion test first, then the standard exclusion test.
  98970. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  98971. * 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.
  98972. * Anyway, it's as accurate as the standard strategy.
  98973. * Test :
  98974. * Is the cullable object bounding sphere center in the frustum ?
  98975. * If not, apply the default culling strategy.
  98976. */
  98977. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  98978. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  98979. * This in an inclusion test first, then the bounding sphere only exclusion test.
  98980. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  98981. * 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.
  98982. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  98983. * Test :
  98984. * Is the cullable object bounding sphere center in the frustum ?
  98985. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  98986. */
  98987. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  98988. /**
  98989. * No billboard
  98990. */
  98991. static get BILLBOARDMODE_NONE(): number;
  98992. /** Billboard on X axis */
  98993. static get BILLBOARDMODE_X(): number;
  98994. /** Billboard on Y axis */
  98995. static get BILLBOARDMODE_Y(): number;
  98996. /** Billboard on Z axis */
  98997. static get BILLBOARDMODE_Z(): number;
  98998. /** Billboard on all axes */
  98999. static get BILLBOARDMODE_ALL(): number;
  99000. /** Billboard on using position instead of orientation */
  99001. static get BILLBOARDMODE_USE_POSITION(): number;
  99002. /** @hidden */
  99003. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  99004. /**
  99005. * The culling strategy to use to check whether the mesh must be rendered or not.
  99006. * This value can be changed at any time and will be used on the next render mesh selection.
  99007. * The possible values are :
  99008. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  99009. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  99010. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  99011. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  99012. * Please read each static variable documentation to get details about the culling process.
  99013. * */
  99014. cullingStrategy: number;
  99015. /**
  99016. * Gets the number of facets in the mesh
  99017. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  99018. */
  99019. get facetNb(): number;
  99020. /**
  99021. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  99022. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  99023. */
  99024. get partitioningSubdivisions(): number;
  99025. set partitioningSubdivisions(nb: number);
  99026. /**
  99027. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  99028. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  99029. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  99030. */
  99031. get partitioningBBoxRatio(): number;
  99032. set partitioningBBoxRatio(ratio: number);
  99033. /**
  99034. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  99035. * Works only for updatable meshes.
  99036. * Doesn't work with multi-materials
  99037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  99038. */
  99039. get mustDepthSortFacets(): boolean;
  99040. set mustDepthSortFacets(sort: boolean);
  99041. /**
  99042. * The location (Vector3) where the facet depth sort must be computed from.
  99043. * By default, the active camera position.
  99044. * Used only when facet depth sort is enabled
  99045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  99046. */
  99047. get facetDepthSortFrom(): Vector3;
  99048. set facetDepthSortFrom(location: Vector3);
  99049. /**
  99050. * gets a boolean indicating if facetData is enabled
  99051. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  99052. */
  99053. get isFacetDataEnabled(): boolean;
  99054. /** @hidden */
  99055. _updateNonUniformScalingState(value: boolean): boolean;
  99056. /**
  99057. * An event triggered when this mesh collides with another one
  99058. */
  99059. onCollideObservable: Observable<AbstractMesh>;
  99060. /** Set a function to call when this mesh collides with another one */
  99061. set onCollide(callback: () => void);
  99062. /**
  99063. * An event triggered when the collision's position changes
  99064. */
  99065. onCollisionPositionChangeObservable: Observable<Vector3>;
  99066. /** Set a function to call when the collision's position changes */
  99067. set onCollisionPositionChange(callback: () => void);
  99068. /**
  99069. * An event triggered when material is changed
  99070. */
  99071. onMaterialChangedObservable: Observable<AbstractMesh>;
  99072. /**
  99073. * Gets or sets the orientation for POV movement & rotation
  99074. */
  99075. definedFacingForward: boolean;
  99076. /** @hidden */
  99077. _occlusionQuery: Nullable<WebGLQuery>;
  99078. /** @hidden */
  99079. _renderingGroup: Nullable<RenderingGroup>;
  99080. /**
  99081. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  99082. */
  99083. get visibility(): number;
  99084. /**
  99085. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  99086. */
  99087. set visibility(value: number);
  99088. /** Gets or sets the alpha index used to sort transparent meshes
  99089. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  99090. */
  99091. alphaIndex: number;
  99092. /**
  99093. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  99094. */
  99095. isVisible: boolean;
  99096. /**
  99097. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  99098. */
  99099. isPickable: boolean;
  99100. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  99101. showSubMeshesBoundingBox: boolean;
  99102. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  99103. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  99104. */
  99105. isBlocker: boolean;
  99106. /**
  99107. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  99108. */
  99109. enablePointerMoveEvents: boolean;
  99110. /**
  99111. * Specifies the rendering group id for this mesh (0 by default)
  99112. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  99113. */
  99114. renderingGroupId: number;
  99115. private _material;
  99116. /** Gets or sets current material */
  99117. get material(): Nullable<Material>;
  99118. set material(value: Nullable<Material>);
  99119. /**
  99120. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  99121. * @see http://doc.babylonjs.com/babylon101/shadows
  99122. */
  99123. get receiveShadows(): boolean;
  99124. set receiveShadows(value: boolean);
  99125. /** Defines color to use when rendering outline */
  99126. outlineColor: Color3;
  99127. /** Define width to use when rendering outline */
  99128. outlineWidth: number;
  99129. /** Defines color to use when rendering overlay */
  99130. overlayColor: Color3;
  99131. /** Defines alpha to use when rendering overlay */
  99132. overlayAlpha: number;
  99133. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  99134. get hasVertexAlpha(): boolean;
  99135. set hasVertexAlpha(value: boolean);
  99136. /** 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) */
  99137. get useVertexColors(): boolean;
  99138. set useVertexColors(value: boolean);
  99139. /**
  99140. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  99141. */
  99142. get computeBonesUsingShaders(): boolean;
  99143. set computeBonesUsingShaders(value: boolean);
  99144. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  99145. get numBoneInfluencers(): number;
  99146. set numBoneInfluencers(value: number);
  99147. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  99148. get applyFog(): boolean;
  99149. set applyFog(value: boolean);
  99150. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  99151. useOctreeForRenderingSelection: boolean;
  99152. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  99153. useOctreeForPicking: boolean;
  99154. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  99155. useOctreeForCollisions: boolean;
  99156. /**
  99157. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  99158. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  99159. */
  99160. get layerMask(): number;
  99161. set layerMask(value: number);
  99162. /**
  99163. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  99164. */
  99165. alwaysSelectAsActiveMesh: boolean;
  99166. /**
  99167. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  99168. */
  99169. doNotSyncBoundingInfo: boolean;
  99170. /**
  99171. * Gets or sets the current action manager
  99172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99173. */
  99174. actionManager: Nullable<AbstractActionManager>;
  99175. private _meshCollisionData;
  99176. /**
  99177. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  99178. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99179. */
  99180. ellipsoid: Vector3;
  99181. /**
  99182. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  99183. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99184. */
  99185. ellipsoidOffset: Vector3;
  99186. /**
  99187. * Gets or sets a collision mask used to mask collisions (default is -1).
  99188. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  99189. */
  99190. get collisionMask(): number;
  99191. set collisionMask(mask: number);
  99192. /**
  99193. * Gets or sets the current collision group mask (-1 by default).
  99194. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  99195. */
  99196. get collisionGroup(): number;
  99197. set collisionGroup(mask: number);
  99198. /**
  99199. * Defines edge width used when edgesRenderer is enabled
  99200. * @see https://www.babylonjs-playground.com/#10OJSG#13
  99201. */
  99202. edgesWidth: number;
  99203. /**
  99204. * Defines edge color used when edgesRenderer is enabled
  99205. * @see https://www.babylonjs-playground.com/#10OJSG#13
  99206. */
  99207. edgesColor: Color4;
  99208. /** @hidden */
  99209. _edgesRenderer: Nullable<IEdgesRenderer>;
  99210. /** @hidden */
  99211. _masterMesh: Nullable<AbstractMesh>;
  99212. /** @hidden */
  99213. _boundingInfo: Nullable<BoundingInfo>;
  99214. /** @hidden */
  99215. _renderId: number;
  99216. /**
  99217. * Gets or sets the list of subMeshes
  99218. * @see http://doc.babylonjs.com/how_to/multi_materials
  99219. */
  99220. subMeshes: SubMesh[];
  99221. /** @hidden */
  99222. _intersectionsInProgress: AbstractMesh[];
  99223. /** @hidden */
  99224. _unIndexed: boolean;
  99225. /** @hidden */
  99226. _lightSources: Light[];
  99227. /** Gets the list of lights affecting that mesh */
  99228. get lightSources(): Light[];
  99229. /** @hidden */
  99230. get _positions(): Nullable<Vector3[]>;
  99231. /** @hidden */
  99232. _waitingData: {
  99233. lods: Nullable<any>;
  99234. actions: Nullable<any>;
  99235. freezeWorldMatrix: Nullable<boolean>;
  99236. };
  99237. /** @hidden */
  99238. _bonesTransformMatrices: Nullable<Float32Array>;
  99239. /** @hidden */
  99240. _transformMatrixTexture: Nullable<RawTexture>;
  99241. /**
  99242. * Gets or sets a skeleton to apply skining transformations
  99243. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  99244. */
  99245. set skeleton(value: Nullable<Skeleton>);
  99246. get skeleton(): Nullable<Skeleton>;
  99247. /**
  99248. * An event triggered when the mesh is rebuilt.
  99249. */
  99250. onRebuildObservable: Observable<AbstractMesh>;
  99251. /**
  99252. * Creates a new AbstractMesh
  99253. * @param name defines the name of the mesh
  99254. * @param scene defines the hosting scene
  99255. */
  99256. constructor(name: string, scene?: Nullable<Scene>);
  99257. /**
  99258. * Returns the string "AbstractMesh"
  99259. * @returns "AbstractMesh"
  99260. */
  99261. getClassName(): string;
  99262. /**
  99263. * Gets a string representation of the current mesh
  99264. * @param fullDetails defines a boolean indicating if full details must be included
  99265. * @returns a string representation of the current mesh
  99266. */
  99267. toString(fullDetails?: boolean): string;
  99268. /**
  99269. * @hidden
  99270. */
  99271. protected _getEffectiveParent(): Nullable<Node>;
  99272. /** @hidden */
  99273. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  99274. /** @hidden */
  99275. _rebuild(): void;
  99276. /** @hidden */
  99277. _resyncLightSources(): void;
  99278. /** @hidden */
  99279. _resyncLightSource(light: Light): void;
  99280. /** @hidden */
  99281. _unBindEffect(): void;
  99282. /** @hidden */
  99283. _removeLightSource(light: Light, dispose: boolean): void;
  99284. private _markSubMeshesAsDirty;
  99285. /** @hidden */
  99286. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  99287. /** @hidden */
  99288. _markSubMeshesAsAttributesDirty(): void;
  99289. /** @hidden */
  99290. _markSubMeshesAsMiscDirty(): void;
  99291. /**
  99292. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  99293. */
  99294. get scaling(): Vector3;
  99295. set scaling(newScaling: Vector3);
  99296. /**
  99297. * Returns true if the mesh is blocked. Implemented by child classes
  99298. */
  99299. get isBlocked(): boolean;
  99300. /**
  99301. * Returns the mesh itself by default. Implemented by child classes
  99302. * @param camera defines the camera to use to pick the right LOD level
  99303. * @returns the currentAbstractMesh
  99304. */
  99305. getLOD(camera: Camera): Nullable<AbstractMesh>;
  99306. /**
  99307. * Returns 0 by default. Implemented by child classes
  99308. * @returns an integer
  99309. */
  99310. getTotalVertices(): number;
  99311. /**
  99312. * Returns a positive integer : the total number of indices in this mesh geometry.
  99313. * @returns the numner of indices or zero if the mesh has no geometry.
  99314. */
  99315. getTotalIndices(): number;
  99316. /**
  99317. * Returns null by default. Implemented by child classes
  99318. * @returns null
  99319. */
  99320. getIndices(): Nullable<IndicesArray>;
  99321. /**
  99322. * Returns the array of the requested vertex data kind. Implemented by child classes
  99323. * @param kind defines the vertex data kind to use
  99324. * @returns null
  99325. */
  99326. getVerticesData(kind: string): Nullable<FloatArray>;
  99327. /**
  99328. * Sets the vertex data of the mesh geometry for the requested `kind`.
  99329. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  99330. * Note that a new underlying VertexBuffer object is created each call.
  99331. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  99332. * @param kind defines vertex data kind:
  99333. * * VertexBuffer.PositionKind
  99334. * * VertexBuffer.UVKind
  99335. * * VertexBuffer.UV2Kind
  99336. * * VertexBuffer.UV3Kind
  99337. * * VertexBuffer.UV4Kind
  99338. * * VertexBuffer.UV5Kind
  99339. * * VertexBuffer.UV6Kind
  99340. * * VertexBuffer.ColorKind
  99341. * * VertexBuffer.MatricesIndicesKind
  99342. * * VertexBuffer.MatricesIndicesExtraKind
  99343. * * VertexBuffer.MatricesWeightsKind
  99344. * * VertexBuffer.MatricesWeightsExtraKind
  99345. * @param data defines the data source
  99346. * @param updatable defines if the data must be flagged as updatable (or static)
  99347. * @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
  99348. * @returns the current mesh
  99349. */
  99350. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  99351. /**
  99352. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  99353. * If the mesh has no geometry, it is simply returned as it is.
  99354. * @param kind defines vertex data kind:
  99355. * * VertexBuffer.PositionKind
  99356. * * VertexBuffer.UVKind
  99357. * * VertexBuffer.UV2Kind
  99358. * * VertexBuffer.UV3Kind
  99359. * * VertexBuffer.UV4Kind
  99360. * * VertexBuffer.UV5Kind
  99361. * * VertexBuffer.UV6Kind
  99362. * * VertexBuffer.ColorKind
  99363. * * VertexBuffer.MatricesIndicesKind
  99364. * * VertexBuffer.MatricesIndicesExtraKind
  99365. * * VertexBuffer.MatricesWeightsKind
  99366. * * VertexBuffer.MatricesWeightsExtraKind
  99367. * @param data defines the data source
  99368. * @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
  99369. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  99370. * @returns the current mesh
  99371. */
  99372. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  99373. /**
  99374. * Sets the mesh indices,
  99375. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  99376. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  99377. * @param totalVertices Defines the total number of vertices
  99378. * @returns the current mesh
  99379. */
  99380. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  99381. /**
  99382. * Gets a boolean indicating if specific vertex data is present
  99383. * @param kind defines the vertex data kind to use
  99384. * @returns true is data kind is present
  99385. */
  99386. isVerticesDataPresent(kind: string): boolean;
  99387. /**
  99388. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  99389. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  99390. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  99391. * @returns a BoundingInfo
  99392. */
  99393. getBoundingInfo(): BoundingInfo;
  99394. /**
  99395. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  99396. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  99397. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  99398. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  99399. * @returns the current mesh
  99400. */
  99401. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  99402. /**
  99403. * Overwrite the current bounding info
  99404. * @param boundingInfo defines the new bounding info
  99405. * @returns the current mesh
  99406. */
  99407. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  99408. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  99409. get useBones(): boolean;
  99410. /** @hidden */
  99411. _preActivate(): void;
  99412. /** @hidden */
  99413. _preActivateForIntermediateRendering(renderId: number): void;
  99414. /** @hidden */
  99415. _activate(renderId: number, intermediateRendering: boolean): boolean;
  99416. /** @hidden */
  99417. _postActivate(): void;
  99418. /** @hidden */
  99419. _freeze(): void;
  99420. /** @hidden */
  99421. _unFreeze(): void;
  99422. /**
  99423. * Gets the current world matrix
  99424. * @returns a Matrix
  99425. */
  99426. getWorldMatrix(): Matrix;
  99427. /** @hidden */
  99428. _getWorldMatrixDeterminant(): number;
  99429. /**
  99430. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  99431. */
  99432. get isAnInstance(): boolean;
  99433. /**
  99434. * Gets a boolean indicating if this mesh has instances
  99435. */
  99436. get hasInstances(): boolean;
  99437. /**
  99438. * Perform relative position change from the point of view of behind the front of the mesh.
  99439. * This is performed taking into account the meshes current rotation, so you do not have to care.
  99440. * Supports definition of mesh facing forward or backward
  99441. * @param amountRight defines the distance on the right axis
  99442. * @param amountUp defines the distance on the up axis
  99443. * @param amountForward defines the distance on the forward axis
  99444. * @returns the current mesh
  99445. */
  99446. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  99447. /**
  99448. * Calculate relative position change from the point of view of behind the front of the mesh.
  99449. * This is performed taking into account the meshes current rotation, so you do not have to care.
  99450. * Supports definition of mesh facing forward or backward
  99451. * @param amountRight defines the distance on the right axis
  99452. * @param amountUp defines the distance on the up axis
  99453. * @param amountForward defines the distance on the forward axis
  99454. * @returns the new displacement vector
  99455. */
  99456. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  99457. /**
  99458. * Perform relative rotation change from the point of view of behind the front of the mesh.
  99459. * Supports definition of mesh facing forward or backward
  99460. * @param flipBack defines the flip
  99461. * @param twirlClockwise defines the twirl
  99462. * @param tiltRight defines the tilt
  99463. * @returns the current mesh
  99464. */
  99465. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  99466. /**
  99467. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  99468. * Supports definition of mesh facing forward or backward.
  99469. * @param flipBack defines the flip
  99470. * @param twirlClockwise defines the twirl
  99471. * @param tiltRight defines the tilt
  99472. * @returns the new rotation vector
  99473. */
  99474. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  99475. /**
  99476. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  99477. * This means the mesh underlying bounding box and sphere are recomputed.
  99478. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  99479. * @returns the current mesh
  99480. */
  99481. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  99482. /** @hidden */
  99483. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  99484. /** @hidden */
  99485. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  99486. /** @hidden */
  99487. _updateBoundingInfo(): AbstractMesh;
  99488. /** @hidden */
  99489. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  99490. /** @hidden */
  99491. protected _afterComputeWorldMatrix(): void;
  99492. /** @hidden */
  99493. get _effectiveMesh(): AbstractMesh;
  99494. /**
  99495. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  99496. * A mesh is in the frustum if its bounding box intersects the frustum
  99497. * @param frustumPlanes defines the frustum to test
  99498. * @returns true if the mesh is in the frustum planes
  99499. */
  99500. isInFrustum(frustumPlanes: Plane[]): boolean;
  99501. /**
  99502. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  99503. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  99504. * @param frustumPlanes defines the frustum to test
  99505. * @returns true if the mesh is completely in the frustum planes
  99506. */
  99507. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  99508. /**
  99509. * True if the mesh intersects another mesh or a SolidParticle object
  99510. * @param mesh defines a target mesh or SolidParticle to test
  99511. * @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)
  99512. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  99513. * @returns true if there is an intersection
  99514. */
  99515. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  99516. /**
  99517. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  99518. * @param point defines the point to test
  99519. * @returns true if there is an intersection
  99520. */
  99521. intersectsPoint(point: Vector3): boolean;
  99522. /**
  99523. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  99524. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99525. */
  99526. get checkCollisions(): boolean;
  99527. set checkCollisions(collisionEnabled: boolean);
  99528. /**
  99529. * Gets Collider object used to compute collisions (not physics)
  99530. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99531. */
  99532. get collider(): Nullable<Collider>;
  99533. /**
  99534. * Move the mesh using collision engine
  99535. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  99536. * @param displacement defines the requested displacement vector
  99537. * @returns the current mesh
  99538. */
  99539. moveWithCollisions(displacement: Vector3): AbstractMesh;
  99540. private _onCollisionPositionChange;
  99541. /** @hidden */
  99542. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  99543. /** @hidden */
  99544. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  99545. /** @hidden */
  99546. _checkCollision(collider: Collider): AbstractMesh;
  99547. /** @hidden */
  99548. _generatePointsArray(): boolean;
  99549. /**
  99550. * Checks if the passed Ray intersects with the mesh
  99551. * @param ray defines the ray to use
  99552. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  99553. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  99554. * @returns the picking info
  99555. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  99556. */
  99557. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  99558. /**
  99559. * Clones the current mesh
  99560. * @param name defines the mesh name
  99561. * @param newParent defines the new mesh parent
  99562. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  99563. * @returns the new mesh
  99564. */
  99565. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  99566. /**
  99567. * Disposes all the submeshes of the current meshnp
  99568. * @returns the current mesh
  99569. */
  99570. releaseSubMeshes(): AbstractMesh;
  99571. /**
  99572. * Releases resources associated with this abstract mesh.
  99573. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99574. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99575. */
  99576. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99577. /**
  99578. * Adds the passed mesh as a child to the current mesh
  99579. * @param mesh defines the child mesh
  99580. * @returns the current mesh
  99581. */
  99582. addChild(mesh: AbstractMesh): AbstractMesh;
  99583. /**
  99584. * Removes the passed mesh from the current mesh children list
  99585. * @param mesh defines the child mesh
  99586. * @returns the current mesh
  99587. */
  99588. removeChild(mesh: AbstractMesh): AbstractMesh;
  99589. /** @hidden */
  99590. private _initFacetData;
  99591. /**
  99592. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  99593. * This method can be called within the render loop.
  99594. * 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
  99595. * @returns the current mesh
  99596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99597. */
  99598. updateFacetData(): AbstractMesh;
  99599. /**
  99600. * Returns the facetLocalNormals array.
  99601. * The normals are expressed in the mesh local spac
  99602. * @returns an array of Vector3
  99603. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99604. */
  99605. getFacetLocalNormals(): Vector3[];
  99606. /**
  99607. * Returns the facetLocalPositions array.
  99608. * The facet positions are expressed in the mesh local space
  99609. * @returns an array of Vector3
  99610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99611. */
  99612. getFacetLocalPositions(): Vector3[];
  99613. /**
  99614. * Returns the facetLocalPartioning array
  99615. * @returns an array of array of numbers
  99616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99617. */
  99618. getFacetLocalPartitioning(): number[][];
  99619. /**
  99620. * Returns the i-th facet position in the world system.
  99621. * This method allocates a new Vector3 per call
  99622. * @param i defines the facet index
  99623. * @returns a new Vector3
  99624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99625. */
  99626. getFacetPosition(i: number): Vector3;
  99627. /**
  99628. * Sets the reference Vector3 with the i-th facet position in the world system
  99629. * @param i defines the facet index
  99630. * @param ref defines the target vector
  99631. * @returns the current mesh
  99632. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99633. */
  99634. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  99635. /**
  99636. * Returns the i-th facet normal in the world system.
  99637. * This method allocates a new Vector3 per call
  99638. * @param i defines the facet index
  99639. * @returns a new Vector3
  99640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99641. */
  99642. getFacetNormal(i: number): Vector3;
  99643. /**
  99644. * Sets the reference Vector3 with the i-th facet normal in the world system
  99645. * @param i defines the facet index
  99646. * @param ref defines the target vector
  99647. * @returns the current mesh
  99648. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99649. */
  99650. getFacetNormalToRef(i: number, ref: Vector3): this;
  99651. /**
  99652. * 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)
  99653. * @param x defines x coordinate
  99654. * @param y defines y coordinate
  99655. * @param z defines z coordinate
  99656. * @returns the array of facet indexes
  99657. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99658. */
  99659. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  99660. /**
  99661. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  99662. * @param projected sets as the (x,y,z) world projection on the facet
  99663. * @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
  99664. * @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
  99665. * @param x defines x coordinate
  99666. * @param y defines y coordinate
  99667. * @param z defines z coordinate
  99668. * @returns the face index if found (or null instead)
  99669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99670. */
  99671. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  99672. /**
  99673. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  99674. * @param projected sets as the (x,y,z) local projection on the facet
  99675. * @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
  99676. * @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
  99677. * @param x defines x coordinate
  99678. * @param y defines y coordinate
  99679. * @param z defines z coordinate
  99680. * @returns the face index if found (or null instead)
  99681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99682. */
  99683. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  99684. /**
  99685. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  99686. * @returns the parameters
  99687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99688. */
  99689. getFacetDataParameters(): any;
  99690. /**
  99691. * Disables the feature FacetData and frees the related memory
  99692. * @returns the current mesh
  99693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  99694. */
  99695. disableFacetData(): AbstractMesh;
  99696. /**
  99697. * Updates the AbstractMesh indices array
  99698. * @param indices defines the data source
  99699. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  99700. * @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)
  99701. * @returns the current mesh
  99702. */
  99703. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  99704. /**
  99705. * Creates new normals data for the mesh
  99706. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  99707. * @returns the current mesh
  99708. */
  99709. createNormals(updatable: boolean): AbstractMesh;
  99710. /**
  99711. * Align the mesh with a normal
  99712. * @param normal defines the normal to use
  99713. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  99714. * @returns the current mesh
  99715. */
  99716. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  99717. /** @hidden */
  99718. _checkOcclusionQuery(): boolean;
  99719. /**
  99720. * Disables the mesh edge rendering mode
  99721. * @returns the currentAbstractMesh
  99722. */
  99723. disableEdgesRendering(): AbstractMesh;
  99724. /**
  99725. * Enables the edge rendering mode on the mesh.
  99726. * This mode makes the mesh edges visible
  99727. * @param epsilon defines the maximal distance between two angles to detect a face
  99728. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  99729. * @returns the currentAbstractMesh
  99730. * @see https://www.babylonjs-playground.com/#19O9TU#0
  99731. */
  99732. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  99733. }
  99734. }
  99735. declare module BABYLON {
  99736. /**
  99737. * Interface used to define ActionEvent
  99738. */
  99739. export interface IActionEvent {
  99740. /** The mesh or sprite that triggered the action */
  99741. source: any;
  99742. /** The X mouse cursor position at the time of the event */
  99743. pointerX: number;
  99744. /** The Y mouse cursor position at the time of the event */
  99745. pointerY: number;
  99746. /** The mesh that is currently pointed at (can be null) */
  99747. meshUnderPointer: Nullable<AbstractMesh>;
  99748. /** the original (browser) event that triggered the ActionEvent */
  99749. sourceEvent?: any;
  99750. /** additional data for the event */
  99751. additionalData?: any;
  99752. }
  99753. /**
  99754. * ActionEvent is the event being sent when an action is triggered.
  99755. */
  99756. export class ActionEvent implements IActionEvent {
  99757. /** The mesh or sprite that triggered the action */
  99758. source: any;
  99759. /** The X mouse cursor position at the time of the event */
  99760. pointerX: number;
  99761. /** The Y mouse cursor position at the time of the event */
  99762. pointerY: number;
  99763. /** The mesh that is currently pointed at (can be null) */
  99764. meshUnderPointer: Nullable<AbstractMesh>;
  99765. /** the original (browser) event that triggered the ActionEvent */
  99766. sourceEvent?: any;
  99767. /** additional data for the event */
  99768. additionalData?: any;
  99769. /**
  99770. * Creates a new ActionEvent
  99771. * @param source The mesh or sprite that triggered the action
  99772. * @param pointerX The X mouse cursor position at the time of the event
  99773. * @param pointerY The Y mouse cursor position at the time of the event
  99774. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  99775. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  99776. * @param additionalData additional data for the event
  99777. */
  99778. constructor(
  99779. /** The mesh or sprite that triggered the action */
  99780. source: any,
  99781. /** The X mouse cursor position at the time of the event */
  99782. pointerX: number,
  99783. /** The Y mouse cursor position at the time of the event */
  99784. pointerY: number,
  99785. /** The mesh that is currently pointed at (can be null) */
  99786. meshUnderPointer: Nullable<AbstractMesh>,
  99787. /** the original (browser) event that triggered the ActionEvent */
  99788. sourceEvent?: any,
  99789. /** additional data for the event */
  99790. additionalData?: any);
  99791. /**
  99792. * Helper function to auto-create an ActionEvent from a source mesh.
  99793. * @param source The source mesh that triggered the event
  99794. * @param evt The original (browser) event
  99795. * @param additionalData additional data for the event
  99796. * @returns the new ActionEvent
  99797. */
  99798. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  99799. /**
  99800. * Helper function to auto-create an ActionEvent from a source sprite
  99801. * @param source The source sprite that triggered the event
  99802. * @param scene Scene associated with the sprite
  99803. * @param evt The original (browser) event
  99804. * @param additionalData additional data for the event
  99805. * @returns the new ActionEvent
  99806. */
  99807. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  99808. /**
  99809. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  99810. * @param scene the scene where the event occurred
  99811. * @param evt The original (browser) event
  99812. * @returns the new ActionEvent
  99813. */
  99814. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  99815. /**
  99816. * Helper function to auto-create an ActionEvent from a primitive
  99817. * @param prim defines the target primitive
  99818. * @param pointerPos defines the pointer position
  99819. * @param evt The original (browser) event
  99820. * @param additionalData additional data for the event
  99821. * @returns the new ActionEvent
  99822. */
  99823. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  99824. }
  99825. }
  99826. declare module BABYLON {
  99827. /**
  99828. * Abstract class used to decouple action Manager from scene and meshes.
  99829. * Do not instantiate.
  99830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  99831. */
  99832. export abstract class AbstractActionManager implements IDisposable {
  99833. /** Gets the list of active triggers */
  99834. static Triggers: {
  99835. [key: string]: number;
  99836. };
  99837. /** Gets the cursor to use when hovering items */
  99838. hoverCursor: string;
  99839. /** Gets the list of actions */
  99840. actions: IAction[];
  99841. /**
  99842. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  99843. */
  99844. isRecursive: boolean;
  99845. /**
  99846. * Releases all associated resources
  99847. */
  99848. abstract dispose(): void;
  99849. /**
  99850. * Does this action manager has pointer triggers
  99851. */
  99852. abstract get hasPointerTriggers(): boolean;
  99853. /**
  99854. * Does this action manager has pick triggers
  99855. */
  99856. abstract get hasPickTriggers(): boolean;
  99857. /**
  99858. * Process a specific trigger
  99859. * @param trigger defines the trigger to process
  99860. * @param evt defines the event details to be processed
  99861. */
  99862. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  99863. /**
  99864. * Does this action manager handles actions of any of the given triggers
  99865. * @param triggers defines the triggers to be tested
  99866. * @return a boolean indicating whether one (or more) of the triggers is handled
  99867. */
  99868. abstract hasSpecificTriggers(triggers: number[]): boolean;
  99869. /**
  99870. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  99871. * speed.
  99872. * @param triggerA defines the trigger to be tested
  99873. * @param triggerB defines the trigger to be tested
  99874. * @return a boolean indicating whether one (or more) of the triggers is handled
  99875. */
  99876. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  99877. /**
  99878. * Does this action manager handles actions of a given trigger
  99879. * @param trigger defines the trigger to be tested
  99880. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  99881. * @return whether the trigger is handled
  99882. */
  99883. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  99884. /**
  99885. * Serialize this manager to a JSON object
  99886. * @param name defines the property name to store this manager
  99887. * @returns a JSON representation of this manager
  99888. */
  99889. abstract serialize(name: string): any;
  99890. /**
  99891. * Registers an action to this action manager
  99892. * @param action defines the action to be registered
  99893. * @return the action amended (prepared) after registration
  99894. */
  99895. abstract registerAction(action: IAction): Nullable<IAction>;
  99896. /**
  99897. * Unregisters an action to this action manager
  99898. * @param action defines the action to be unregistered
  99899. * @return a boolean indicating whether the action has been unregistered
  99900. */
  99901. abstract unregisterAction(action: IAction): Boolean;
  99902. /**
  99903. * Does exist one action manager with at least one trigger
  99904. **/
  99905. static get HasTriggers(): boolean;
  99906. /**
  99907. * Does exist one action manager with at least one pick trigger
  99908. **/
  99909. static get HasPickTriggers(): boolean;
  99910. /**
  99911. * Does exist one action manager that handles actions of a given trigger
  99912. * @param trigger defines the trigger to be tested
  99913. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  99914. **/
  99915. static HasSpecificTrigger(trigger: number): boolean;
  99916. }
  99917. }
  99918. declare module BABYLON {
  99919. /**
  99920. * Defines how a node can be built from a string name.
  99921. */
  99922. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  99923. /**
  99924. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  99925. */
  99926. export class Node implements IBehaviorAware<Node> {
  99927. /** @hidden */
  99928. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  99929. private static _NodeConstructors;
  99930. /**
  99931. * Add a new node constructor
  99932. * @param type defines the type name of the node to construct
  99933. * @param constructorFunc defines the constructor function
  99934. */
  99935. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  99936. /**
  99937. * Returns a node constructor based on type name
  99938. * @param type defines the type name
  99939. * @param name defines the new node name
  99940. * @param scene defines the hosting scene
  99941. * @param options defines optional options to transmit to constructors
  99942. * @returns the new constructor or null
  99943. */
  99944. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  99945. /**
  99946. * Gets or sets the name of the node
  99947. */
  99948. name: string;
  99949. /**
  99950. * Gets or sets the id of the node
  99951. */
  99952. id: string;
  99953. /**
  99954. * Gets or sets the unique id of the node
  99955. */
  99956. uniqueId: number;
  99957. /**
  99958. * Gets or sets a string used to store user defined state for the node
  99959. */
  99960. state: string;
  99961. /**
  99962. * Gets or sets an object used to store user defined information for the node
  99963. */
  99964. metadata: any;
  99965. /**
  99966. * For internal use only. Please do not use.
  99967. */
  99968. reservedDataStore: any;
  99969. /**
  99970. * List of inspectable custom properties (used by the Inspector)
  99971. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  99972. */
  99973. inspectableCustomProperties: IInspectable[];
  99974. private _doNotSerialize;
  99975. /**
  99976. * Gets or sets a boolean used to define if the node must be serialized
  99977. */
  99978. get doNotSerialize(): boolean;
  99979. set doNotSerialize(value: boolean);
  99980. /** @hidden */
  99981. _isDisposed: boolean;
  99982. /**
  99983. * Gets a list of Animations associated with the node
  99984. */
  99985. animations: Animation[];
  99986. protected _ranges: {
  99987. [name: string]: Nullable<AnimationRange>;
  99988. };
  99989. /**
  99990. * Callback raised when the node is ready to be used
  99991. */
  99992. onReady: Nullable<(node: Node) => void>;
  99993. private _isEnabled;
  99994. private _isParentEnabled;
  99995. private _isReady;
  99996. /** @hidden */
  99997. _currentRenderId: number;
  99998. private _parentUpdateId;
  99999. /** @hidden */
  100000. _childUpdateId: number;
  100001. /** @hidden */
  100002. _waitingParentId: Nullable<string>;
  100003. /** @hidden */
  100004. _scene: Scene;
  100005. /** @hidden */
  100006. _cache: any;
  100007. private _parentNode;
  100008. private _children;
  100009. /** @hidden */
  100010. _worldMatrix: Matrix;
  100011. /** @hidden */
  100012. _worldMatrixDeterminant: number;
  100013. /** @hidden */
  100014. _worldMatrixDeterminantIsDirty: boolean;
  100015. /** @hidden */
  100016. private _sceneRootNodesIndex;
  100017. /**
  100018. * Gets a boolean indicating if the node has been disposed
  100019. * @returns true if the node was disposed
  100020. */
  100021. isDisposed(): boolean;
  100022. /**
  100023. * Gets or sets the parent of the node (without keeping the current position in the scene)
  100024. * @see https://doc.babylonjs.com/how_to/parenting
  100025. */
  100026. set parent(parent: Nullable<Node>);
  100027. get parent(): Nullable<Node>;
  100028. /** @hidden */
  100029. _addToSceneRootNodes(): void;
  100030. /** @hidden */
  100031. _removeFromSceneRootNodes(): void;
  100032. private _animationPropertiesOverride;
  100033. /**
  100034. * Gets or sets the animation properties override
  100035. */
  100036. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  100037. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  100038. /**
  100039. * Gets a string idenfifying the name of the class
  100040. * @returns "Node" string
  100041. */
  100042. getClassName(): string;
  100043. /** @hidden */
  100044. readonly _isNode: boolean;
  100045. /**
  100046. * An event triggered when the mesh is disposed
  100047. */
  100048. onDisposeObservable: Observable<Node>;
  100049. private _onDisposeObserver;
  100050. /**
  100051. * Sets a callback that will be raised when the node will be disposed
  100052. */
  100053. set onDispose(callback: () => void);
  100054. /**
  100055. * Creates a new Node
  100056. * @param name the name and id to be given to this node
  100057. * @param scene the scene this node will be added to
  100058. */
  100059. constructor(name: string, scene?: Nullable<Scene>);
  100060. /**
  100061. * Gets the scene of the node
  100062. * @returns a scene
  100063. */
  100064. getScene(): Scene;
  100065. /**
  100066. * Gets the engine of the node
  100067. * @returns a Engine
  100068. */
  100069. getEngine(): Engine;
  100070. private _behaviors;
  100071. /**
  100072. * Attach a behavior to the node
  100073. * @see http://doc.babylonjs.com/features/behaviour
  100074. * @param behavior defines the behavior to attach
  100075. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  100076. * @returns the current Node
  100077. */
  100078. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  100079. /**
  100080. * Remove an attached behavior
  100081. * @see http://doc.babylonjs.com/features/behaviour
  100082. * @param behavior defines the behavior to attach
  100083. * @returns the current Node
  100084. */
  100085. removeBehavior(behavior: Behavior<Node>): Node;
  100086. /**
  100087. * Gets the list of attached behaviors
  100088. * @see http://doc.babylonjs.com/features/behaviour
  100089. */
  100090. get behaviors(): Behavior<Node>[];
  100091. /**
  100092. * Gets an attached behavior by name
  100093. * @param name defines the name of the behavior to look for
  100094. * @see http://doc.babylonjs.com/features/behaviour
  100095. * @returns null if behavior was not found else the requested behavior
  100096. */
  100097. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  100098. /**
  100099. * Returns the latest update of the World matrix
  100100. * @returns a Matrix
  100101. */
  100102. getWorldMatrix(): Matrix;
  100103. /** @hidden */
  100104. _getWorldMatrixDeterminant(): number;
  100105. /**
  100106. * Returns directly the latest state of the mesh World matrix.
  100107. * A Matrix is returned.
  100108. */
  100109. get worldMatrixFromCache(): Matrix;
  100110. /** @hidden */
  100111. _initCache(): void;
  100112. /** @hidden */
  100113. updateCache(force?: boolean): void;
  100114. /** @hidden */
  100115. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  100116. /** @hidden */
  100117. _updateCache(ignoreParentClass?: boolean): void;
  100118. /** @hidden */
  100119. _isSynchronized(): boolean;
  100120. /** @hidden */
  100121. _markSyncedWithParent(): void;
  100122. /** @hidden */
  100123. isSynchronizedWithParent(): boolean;
  100124. /** @hidden */
  100125. isSynchronized(): boolean;
  100126. /**
  100127. * Is this node ready to be used/rendered
  100128. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  100129. * @return true if the node is ready
  100130. */
  100131. isReady(completeCheck?: boolean): boolean;
  100132. /**
  100133. * Is this node enabled?
  100134. * 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
  100135. * @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
  100136. * @return whether this node (and its parent) is enabled
  100137. */
  100138. isEnabled(checkAncestors?: boolean): boolean;
  100139. /** @hidden */
  100140. protected _syncParentEnabledState(): void;
  100141. /**
  100142. * Set the enabled state of this node
  100143. * @param value defines the new enabled state
  100144. */
  100145. setEnabled(value: boolean): void;
  100146. /**
  100147. * Is this node a descendant of the given node?
  100148. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  100149. * @param ancestor defines the parent node to inspect
  100150. * @returns a boolean indicating if this node is a descendant of the given node
  100151. */
  100152. isDescendantOf(ancestor: Node): boolean;
  100153. /** @hidden */
  100154. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  100155. /**
  100156. * Will return all nodes that have this node as ascendant
  100157. * @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
  100158. * @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
  100159. * @return all children nodes of all types
  100160. */
  100161. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  100162. /**
  100163. * Get all child-meshes of this node
  100164. * @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)
  100165. * @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
  100166. * @returns an array of AbstractMesh
  100167. */
  100168. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  100169. /**
  100170. * Get all direct children of this node
  100171. * @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
  100172. * @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)
  100173. * @returns an array of Node
  100174. */
  100175. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  100176. /** @hidden */
  100177. _setReady(state: boolean): void;
  100178. /**
  100179. * Get an animation by name
  100180. * @param name defines the name of the animation to look for
  100181. * @returns null if not found else the requested animation
  100182. */
  100183. getAnimationByName(name: string): Nullable<Animation>;
  100184. /**
  100185. * Creates an animation range for this node
  100186. * @param name defines the name of the range
  100187. * @param from defines the starting key
  100188. * @param to defines the end key
  100189. */
  100190. createAnimationRange(name: string, from: number, to: number): void;
  100191. /**
  100192. * Delete a specific animation range
  100193. * @param name defines the name of the range to delete
  100194. * @param deleteFrames defines if animation frames from the range must be deleted as well
  100195. */
  100196. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  100197. /**
  100198. * Get an animation range by name
  100199. * @param name defines the name of the animation range to look for
  100200. * @returns null if not found else the requested animation range
  100201. */
  100202. getAnimationRange(name: string): Nullable<AnimationRange>;
  100203. /**
  100204. * Gets the list of all animation ranges defined on this node
  100205. * @returns an array
  100206. */
  100207. getAnimationRanges(): Nullable<AnimationRange>[];
  100208. /**
  100209. * Will start the animation sequence
  100210. * @param name defines the range frames for animation sequence
  100211. * @param loop defines if the animation should loop (false by default)
  100212. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  100213. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  100214. * @returns the object created for this animation. If range does not exist, it will return null
  100215. */
  100216. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  100217. /**
  100218. * Serialize animation ranges into a JSON compatible object
  100219. * @returns serialization object
  100220. */
  100221. serializeAnimationRanges(): any;
  100222. /**
  100223. * Computes the world matrix of the node
  100224. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100225. * @returns the world matrix
  100226. */
  100227. computeWorldMatrix(force?: boolean): Matrix;
  100228. /**
  100229. * Releases resources associated with this node.
  100230. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100231. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100232. */
  100233. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100234. /**
  100235. * Parse animation range data from a serialization object and store them into a given node
  100236. * @param node defines where to store the animation ranges
  100237. * @param parsedNode defines the serialization object to read data from
  100238. * @param scene defines the hosting scene
  100239. */
  100240. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  100241. /**
  100242. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  100243. * @param includeDescendants Include bounding info from descendants as well (true by default)
  100244. * @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
  100245. * @returns the new bounding vectors
  100246. */
  100247. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  100248. min: Vector3;
  100249. max: Vector3;
  100250. };
  100251. }
  100252. }
  100253. declare module BABYLON {
  100254. /**
  100255. * @hidden
  100256. */
  100257. export class _IAnimationState {
  100258. key: number;
  100259. repeatCount: number;
  100260. workValue?: any;
  100261. loopMode?: number;
  100262. offsetValue?: any;
  100263. highLimitValue?: any;
  100264. }
  100265. /**
  100266. * Class used to store any kind of animation
  100267. */
  100268. export class Animation {
  100269. /**Name of the animation */
  100270. name: string;
  100271. /**Property to animate */
  100272. targetProperty: string;
  100273. /**The frames per second of the animation */
  100274. framePerSecond: number;
  100275. /**The data type of the animation */
  100276. dataType: number;
  100277. /**The loop mode of the animation */
  100278. loopMode?: number | undefined;
  100279. /**Specifies if blending should be enabled */
  100280. enableBlending?: boolean | undefined;
  100281. /**
  100282. * Use matrix interpolation instead of using direct key value when animating matrices
  100283. */
  100284. static AllowMatricesInterpolation: boolean;
  100285. /**
  100286. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  100287. */
  100288. static AllowMatrixDecomposeForInterpolation: boolean;
  100289. /**
  100290. * Stores the key frames of the animation
  100291. */
  100292. private _keys;
  100293. /**
  100294. * Stores the easing function of the animation
  100295. */
  100296. private _easingFunction;
  100297. /**
  100298. * @hidden Internal use only
  100299. */
  100300. _runtimeAnimations: RuntimeAnimation[];
  100301. /**
  100302. * The set of event that will be linked to this animation
  100303. */
  100304. private _events;
  100305. /**
  100306. * Stores an array of target property paths
  100307. */
  100308. targetPropertyPath: string[];
  100309. /**
  100310. * Stores the blending speed of the animation
  100311. */
  100312. blendingSpeed: number;
  100313. /**
  100314. * Stores the animation ranges for the animation
  100315. */
  100316. private _ranges;
  100317. /**
  100318. * @hidden Internal use
  100319. */
  100320. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  100321. /**
  100322. * Sets up an animation
  100323. * @param property The property to animate
  100324. * @param animationType The animation type to apply
  100325. * @param framePerSecond The frames per second of the animation
  100326. * @param easingFunction The easing function used in the animation
  100327. * @returns The created animation
  100328. */
  100329. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  100330. /**
  100331. * Create and start an animation on a node
  100332. * @param name defines the name of the global animation that will be run on all nodes
  100333. * @param node defines the root node where the animation will take place
  100334. * @param targetProperty defines property to animate
  100335. * @param framePerSecond defines the number of frame per second yo use
  100336. * @param totalFrame defines the number of frames in total
  100337. * @param from defines the initial value
  100338. * @param to defines the final value
  100339. * @param loopMode defines which loop mode you want to use (off by default)
  100340. * @param easingFunction defines the easing function to use (linear by default)
  100341. * @param onAnimationEnd defines the callback to call when animation end
  100342. * @returns the animatable created for this animation
  100343. */
  100344. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  100345. /**
  100346. * Create and start an animation on a node and its descendants
  100347. * @param name defines the name of the global animation that will be run on all nodes
  100348. * @param node defines the root node where the animation will take place
  100349. * @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
  100350. * @param targetProperty defines property to animate
  100351. * @param framePerSecond defines the number of frame per second to use
  100352. * @param totalFrame defines the number of frames in total
  100353. * @param from defines the initial value
  100354. * @param to defines the final value
  100355. * @param loopMode defines which loop mode you want to use (off by default)
  100356. * @param easingFunction defines the easing function to use (linear by default)
  100357. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  100358. * @returns the list of animatables created for all nodes
  100359. * @example https://www.babylonjs-playground.com/#MH0VLI
  100360. */
  100361. 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[]>;
  100362. /**
  100363. * Creates a new animation, merges it with the existing animations and starts it
  100364. * @param name Name of the animation
  100365. * @param node Node which contains the scene that begins the animations
  100366. * @param targetProperty Specifies which property to animate
  100367. * @param framePerSecond The frames per second of the animation
  100368. * @param totalFrame The total number of frames
  100369. * @param from The frame at the beginning of the animation
  100370. * @param to The frame at the end of the animation
  100371. * @param loopMode Specifies the loop mode of the animation
  100372. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  100373. * @param onAnimationEnd Callback to run once the animation is complete
  100374. * @returns Nullable animation
  100375. */
  100376. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  100377. /**
  100378. * Transition property of an host to the target Value
  100379. * @param property The property to transition
  100380. * @param targetValue The target Value of the property
  100381. * @param host The object where the property to animate belongs
  100382. * @param scene Scene used to run the animation
  100383. * @param frameRate Framerate (in frame/s) to use
  100384. * @param transition The transition type we want to use
  100385. * @param duration The duration of the animation, in milliseconds
  100386. * @param onAnimationEnd Callback trigger at the end of the animation
  100387. * @returns Nullable animation
  100388. */
  100389. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  100390. /**
  100391. * Return the array of runtime animations currently using this animation
  100392. */
  100393. get runtimeAnimations(): RuntimeAnimation[];
  100394. /**
  100395. * Specifies if any of the runtime animations are currently running
  100396. */
  100397. get hasRunningRuntimeAnimations(): boolean;
  100398. /**
  100399. * Initializes the animation
  100400. * @param name Name of the animation
  100401. * @param targetProperty Property to animate
  100402. * @param framePerSecond The frames per second of the animation
  100403. * @param dataType The data type of the animation
  100404. * @param loopMode The loop mode of the animation
  100405. * @param enableBlending Specifies if blending should be enabled
  100406. */
  100407. constructor(
  100408. /**Name of the animation */
  100409. name: string,
  100410. /**Property to animate */
  100411. targetProperty: string,
  100412. /**The frames per second of the animation */
  100413. framePerSecond: number,
  100414. /**The data type of the animation */
  100415. dataType: number,
  100416. /**The loop mode of the animation */
  100417. loopMode?: number | undefined,
  100418. /**Specifies if blending should be enabled */
  100419. enableBlending?: boolean | undefined);
  100420. /**
  100421. * Converts the animation to a string
  100422. * @param fullDetails support for multiple levels of logging within scene loading
  100423. * @returns String form of the animation
  100424. */
  100425. toString(fullDetails?: boolean): string;
  100426. /**
  100427. * Add an event to this animation
  100428. * @param event Event to add
  100429. */
  100430. addEvent(event: AnimationEvent): void;
  100431. /**
  100432. * Remove all events found at the given frame
  100433. * @param frame The frame to remove events from
  100434. */
  100435. removeEvents(frame: number): void;
  100436. /**
  100437. * Retrieves all the events from the animation
  100438. * @returns Events from the animation
  100439. */
  100440. getEvents(): AnimationEvent[];
  100441. /**
  100442. * Creates an animation range
  100443. * @param name Name of the animation range
  100444. * @param from Starting frame of the animation range
  100445. * @param to Ending frame of the animation
  100446. */
  100447. createRange(name: string, from: number, to: number): void;
  100448. /**
  100449. * Deletes an animation range by name
  100450. * @param name Name of the animation range to delete
  100451. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  100452. */
  100453. deleteRange(name: string, deleteFrames?: boolean): void;
  100454. /**
  100455. * Gets the animation range by name, or null if not defined
  100456. * @param name Name of the animation range
  100457. * @returns Nullable animation range
  100458. */
  100459. getRange(name: string): Nullable<AnimationRange>;
  100460. /**
  100461. * Gets the key frames from the animation
  100462. * @returns The key frames of the animation
  100463. */
  100464. getKeys(): Array<IAnimationKey>;
  100465. /**
  100466. * Gets the highest frame rate of the animation
  100467. * @returns Highest frame rate of the animation
  100468. */
  100469. getHighestFrame(): number;
  100470. /**
  100471. * Gets the easing function of the animation
  100472. * @returns Easing function of the animation
  100473. */
  100474. getEasingFunction(): IEasingFunction;
  100475. /**
  100476. * Sets the easing function of the animation
  100477. * @param easingFunction A custom mathematical formula for animation
  100478. */
  100479. setEasingFunction(easingFunction: EasingFunction): void;
  100480. /**
  100481. * Interpolates a scalar linearly
  100482. * @param startValue Start value of the animation curve
  100483. * @param endValue End value of the animation curve
  100484. * @param gradient Scalar amount to interpolate
  100485. * @returns Interpolated scalar value
  100486. */
  100487. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  100488. /**
  100489. * Interpolates a scalar cubically
  100490. * @param startValue Start value of the animation curve
  100491. * @param outTangent End tangent of the animation
  100492. * @param endValue End value of the animation curve
  100493. * @param inTangent Start tangent of the animation curve
  100494. * @param gradient Scalar amount to interpolate
  100495. * @returns Interpolated scalar value
  100496. */
  100497. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  100498. /**
  100499. * Interpolates a quaternion using a spherical linear interpolation
  100500. * @param startValue Start value of the animation curve
  100501. * @param endValue End value of the animation curve
  100502. * @param gradient Scalar amount to interpolate
  100503. * @returns Interpolated quaternion value
  100504. */
  100505. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  100506. /**
  100507. * Interpolates a quaternion cubically
  100508. * @param startValue Start value of the animation curve
  100509. * @param outTangent End tangent of the animation curve
  100510. * @param endValue End value of the animation curve
  100511. * @param inTangent Start tangent of the animation curve
  100512. * @param gradient Scalar amount to interpolate
  100513. * @returns Interpolated quaternion value
  100514. */
  100515. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  100516. /**
  100517. * Interpolates a Vector3 linearl
  100518. * @param startValue Start value of the animation curve
  100519. * @param endValue End value of the animation curve
  100520. * @param gradient Scalar amount to interpolate
  100521. * @returns Interpolated scalar value
  100522. */
  100523. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  100524. /**
  100525. * Interpolates a Vector3 cubically
  100526. * @param startValue Start value of the animation curve
  100527. * @param outTangent End tangent of the animation
  100528. * @param endValue End value of the animation curve
  100529. * @param inTangent Start tangent of the animation curve
  100530. * @param gradient Scalar amount to interpolate
  100531. * @returns InterpolatedVector3 value
  100532. */
  100533. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  100534. /**
  100535. * Interpolates a Vector2 linearly
  100536. * @param startValue Start value of the animation curve
  100537. * @param endValue End value of the animation curve
  100538. * @param gradient Scalar amount to interpolate
  100539. * @returns Interpolated Vector2 value
  100540. */
  100541. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  100542. /**
  100543. * Interpolates a Vector2 cubically
  100544. * @param startValue Start value of the animation curve
  100545. * @param outTangent End tangent of the animation
  100546. * @param endValue End value of the animation curve
  100547. * @param inTangent Start tangent of the animation curve
  100548. * @param gradient Scalar amount to interpolate
  100549. * @returns Interpolated Vector2 value
  100550. */
  100551. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  100552. /**
  100553. * Interpolates a size linearly
  100554. * @param startValue Start value of the animation curve
  100555. * @param endValue End value of the animation curve
  100556. * @param gradient Scalar amount to interpolate
  100557. * @returns Interpolated Size value
  100558. */
  100559. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  100560. /**
  100561. * Interpolates a Color3 linearly
  100562. * @param startValue Start value of the animation curve
  100563. * @param endValue End value of the animation curve
  100564. * @param gradient Scalar amount to interpolate
  100565. * @returns Interpolated Color3 value
  100566. */
  100567. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  100568. /**
  100569. * Interpolates a Color4 linearly
  100570. * @param startValue Start value of the animation curve
  100571. * @param endValue End value of the animation curve
  100572. * @param gradient Scalar amount to interpolate
  100573. * @returns Interpolated Color3 value
  100574. */
  100575. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  100576. /**
  100577. * @hidden Internal use only
  100578. */
  100579. _getKeyValue(value: any): any;
  100580. /**
  100581. * @hidden Internal use only
  100582. */
  100583. _interpolate(currentFrame: number, state: _IAnimationState): any;
  100584. /**
  100585. * Defines the function to use to interpolate matrices
  100586. * @param startValue defines the start matrix
  100587. * @param endValue defines the end matrix
  100588. * @param gradient defines the gradient between both matrices
  100589. * @param result defines an optional target matrix where to store the interpolation
  100590. * @returns the interpolated matrix
  100591. */
  100592. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  100593. /**
  100594. * Makes a copy of the animation
  100595. * @returns Cloned animation
  100596. */
  100597. clone(): Animation;
  100598. /**
  100599. * Sets the key frames of the animation
  100600. * @param values The animation key frames to set
  100601. */
  100602. setKeys(values: Array<IAnimationKey>): void;
  100603. /**
  100604. * Serializes the animation to an object
  100605. * @returns Serialized object
  100606. */
  100607. serialize(): any;
  100608. /**
  100609. * Float animation type
  100610. */
  100611. static readonly ANIMATIONTYPE_FLOAT: number;
  100612. /**
  100613. * Vector3 animation type
  100614. */
  100615. static readonly ANIMATIONTYPE_VECTOR3: number;
  100616. /**
  100617. * Quaternion animation type
  100618. */
  100619. static readonly ANIMATIONTYPE_QUATERNION: number;
  100620. /**
  100621. * Matrix animation type
  100622. */
  100623. static readonly ANIMATIONTYPE_MATRIX: number;
  100624. /**
  100625. * Color3 animation type
  100626. */
  100627. static readonly ANIMATIONTYPE_COLOR3: number;
  100628. /**
  100629. * Color3 animation type
  100630. */
  100631. static readonly ANIMATIONTYPE_COLOR4: number;
  100632. /**
  100633. * Vector2 animation type
  100634. */
  100635. static readonly ANIMATIONTYPE_VECTOR2: number;
  100636. /**
  100637. * Size animation type
  100638. */
  100639. static readonly ANIMATIONTYPE_SIZE: number;
  100640. /**
  100641. * Relative Loop Mode
  100642. */
  100643. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  100644. /**
  100645. * Cycle Loop Mode
  100646. */
  100647. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  100648. /**
  100649. * Constant Loop Mode
  100650. */
  100651. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  100652. /** @hidden */
  100653. static _UniversalLerp(left: any, right: any, amount: number): any;
  100654. /**
  100655. * Parses an animation object and creates an animation
  100656. * @param parsedAnimation Parsed animation object
  100657. * @returns Animation object
  100658. */
  100659. static Parse(parsedAnimation: any): Animation;
  100660. /**
  100661. * Appends the serialized animations from the source animations
  100662. * @param source Source containing the animations
  100663. * @param destination Target to store the animations
  100664. */
  100665. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  100666. }
  100667. }
  100668. declare module BABYLON {
  100669. /**
  100670. * Interface containing an array of animations
  100671. */
  100672. export interface IAnimatable {
  100673. /**
  100674. * Array of animations
  100675. */
  100676. animations: Nullable<Array<Animation>>;
  100677. }
  100678. }
  100679. declare module BABYLON {
  100680. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  100681. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100682. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100683. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100684. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100685. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100686. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100687. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100688. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100689. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100690. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100691. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100692. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100693. /**
  100694. * Decorator used to define property that can be serialized as reference to a camera
  100695. * @param sourceName defines the name of the property to decorate
  100696. */
  100697. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  100698. /**
  100699. * Class used to help serialization objects
  100700. */
  100701. export class SerializationHelper {
  100702. /** @hidden */
  100703. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  100704. /** @hidden */
  100705. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  100706. /** @hidden */
  100707. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  100708. /** @hidden */
  100709. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  100710. /**
  100711. * Appends the serialized animations from the source animations
  100712. * @param source Source containing the animations
  100713. * @param destination Target to store the animations
  100714. */
  100715. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  100716. /**
  100717. * Static function used to serialized a specific entity
  100718. * @param entity defines the entity to serialize
  100719. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  100720. * @returns a JSON compatible object representing the serialization of the entity
  100721. */
  100722. static Serialize<T>(entity: T, serializationObject?: any): any;
  100723. /**
  100724. * Creates a new entity from a serialization data object
  100725. * @param creationFunction defines a function used to instanciated the new entity
  100726. * @param source defines the source serialization data
  100727. * @param scene defines the hosting scene
  100728. * @param rootUrl defines the root url for resources
  100729. * @returns a new entity
  100730. */
  100731. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  100732. /**
  100733. * Clones an object
  100734. * @param creationFunction defines the function used to instanciate the new object
  100735. * @param source defines the source object
  100736. * @returns the cloned object
  100737. */
  100738. static Clone<T>(creationFunction: () => T, source: T): T;
  100739. /**
  100740. * Instanciates a new object based on a source one (some data will be shared between both object)
  100741. * @param creationFunction defines the function used to instanciate the new object
  100742. * @param source defines the source object
  100743. * @returns the new object
  100744. */
  100745. static Instanciate<T>(creationFunction: () => T, source: T): T;
  100746. }
  100747. }
  100748. declare module BABYLON {
  100749. /**
  100750. * Class used to manipulate GUIDs
  100751. */
  100752. export class GUID {
  100753. /**
  100754. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100755. * Be aware Math.random() could cause collisions, but:
  100756. * "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"
  100757. * @returns a pseudo random id
  100758. */
  100759. static RandomId(): string;
  100760. }
  100761. }
  100762. declare module BABYLON {
  100763. /**
  100764. * Base class of all the textures in babylon.
  100765. * It groups all the common properties the materials, post process, lights... might need
  100766. * in order to make a correct use of the texture.
  100767. */
  100768. export class BaseTexture implements IAnimatable {
  100769. /**
  100770. * Default anisotropic filtering level for the application.
  100771. * It is set to 4 as a good tradeoff between perf and quality.
  100772. */
  100773. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  100774. /**
  100775. * Gets or sets the unique id of the texture
  100776. */
  100777. uniqueId: number;
  100778. /**
  100779. * Define the name of the texture.
  100780. */
  100781. name: string;
  100782. /**
  100783. * Gets or sets an object used to store user defined information.
  100784. */
  100785. metadata: any;
  100786. /**
  100787. * For internal use only. Please do not use.
  100788. */
  100789. reservedDataStore: any;
  100790. private _hasAlpha;
  100791. /**
  100792. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  100793. */
  100794. set hasAlpha(value: boolean);
  100795. get hasAlpha(): boolean;
  100796. /**
  100797. * Defines if the alpha value should be determined via the rgb values.
  100798. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  100799. */
  100800. getAlphaFromRGB: boolean;
  100801. /**
  100802. * Intensity or strength of the texture.
  100803. * It is commonly used by materials to fine tune the intensity of the texture
  100804. */
  100805. level: number;
  100806. /**
  100807. * Define the UV chanel to use starting from 0 and defaulting to 0.
  100808. * This is part of the texture as textures usually maps to one uv set.
  100809. */
  100810. coordinatesIndex: number;
  100811. private _coordinatesMode;
  100812. /**
  100813. * How a texture is mapped.
  100814. *
  100815. * | Value | Type | Description |
  100816. * | ----- | ----------------------------------- | ----------- |
  100817. * | 0 | EXPLICIT_MODE | |
  100818. * | 1 | SPHERICAL_MODE | |
  100819. * | 2 | PLANAR_MODE | |
  100820. * | 3 | CUBIC_MODE | |
  100821. * | 4 | PROJECTION_MODE | |
  100822. * | 5 | SKYBOX_MODE | |
  100823. * | 6 | INVCUBIC_MODE | |
  100824. * | 7 | EQUIRECTANGULAR_MODE | |
  100825. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  100826. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  100827. */
  100828. set coordinatesMode(value: number);
  100829. get coordinatesMode(): number;
  100830. /**
  100831. * | Value | Type | Description |
  100832. * | ----- | ------------------ | ----------- |
  100833. * | 0 | CLAMP_ADDRESSMODE | |
  100834. * | 1 | WRAP_ADDRESSMODE | |
  100835. * | 2 | MIRROR_ADDRESSMODE | |
  100836. */
  100837. wrapU: number;
  100838. /**
  100839. * | Value | Type | Description |
  100840. * | ----- | ------------------ | ----------- |
  100841. * | 0 | CLAMP_ADDRESSMODE | |
  100842. * | 1 | WRAP_ADDRESSMODE | |
  100843. * | 2 | MIRROR_ADDRESSMODE | |
  100844. */
  100845. wrapV: number;
  100846. /**
  100847. * | Value | Type | Description |
  100848. * | ----- | ------------------ | ----------- |
  100849. * | 0 | CLAMP_ADDRESSMODE | |
  100850. * | 1 | WRAP_ADDRESSMODE | |
  100851. * | 2 | MIRROR_ADDRESSMODE | |
  100852. */
  100853. wrapR: number;
  100854. /**
  100855. * With compliant hardware and browser (supporting anisotropic filtering)
  100856. * this defines the level of anisotropic filtering in the texture.
  100857. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  100858. */
  100859. anisotropicFilteringLevel: number;
  100860. /**
  100861. * Define if the texture is a cube texture or if false a 2d texture.
  100862. */
  100863. get isCube(): boolean;
  100864. set isCube(value: boolean);
  100865. /**
  100866. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  100867. */
  100868. get is3D(): boolean;
  100869. set is3D(value: boolean);
  100870. /**
  100871. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  100872. */
  100873. get is2DArray(): boolean;
  100874. set is2DArray(value: boolean);
  100875. /**
  100876. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  100877. * HDR texture are usually stored in linear space.
  100878. * This only impacts the PBR and Background materials
  100879. */
  100880. gammaSpace: boolean;
  100881. /**
  100882. * Gets or sets whether or not the texture contains RGBD data.
  100883. */
  100884. get isRGBD(): boolean;
  100885. set isRGBD(value: boolean);
  100886. /**
  100887. * Is Z inverted in the texture (useful in a cube texture).
  100888. */
  100889. invertZ: boolean;
  100890. /**
  100891. * Are mip maps generated for this texture or not.
  100892. */
  100893. get noMipmap(): boolean;
  100894. /**
  100895. * @hidden
  100896. */
  100897. lodLevelInAlpha: boolean;
  100898. /**
  100899. * With prefiltered texture, defined the offset used during the prefiltering steps.
  100900. */
  100901. get lodGenerationOffset(): number;
  100902. set lodGenerationOffset(value: number);
  100903. /**
  100904. * With prefiltered texture, defined the scale used during the prefiltering steps.
  100905. */
  100906. get lodGenerationScale(): number;
  100907. set lodGenerationScale(value: number);
  100908. /**
  100909. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  100910. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  100911. * average roughness values.
  100912. */
  100913. get linearSpecularLOD(): boolean;
  100914. set linearSpecularLOD(value: boolean);
  100915. /**
  100916. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  100917. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  100918. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  100919. */
  100920. get irradianceTexture(): Nullable<BaseTexture>;
  100921. set irradianceTexture(value: Nullable<BaseTexture>);
  100922. /**
  100923. * Define if the texture is a render target.
  100924. */
  100925. isRenderTarget: boolean;
  100926. /**
  100927. * Define the unique id of the texture in the scene.
  100928. */
  100929. get uid(): string;
  100930. /**
  100931. * Return a string representation of the texture.
  100932. * @returns the texture as a string
  100933. */
  100934. toString(): string;
  100935. /**
  100936. * Get the class name of the texture.
  100937. * @returns "BaseTexture"
  100938. */
  100939. getClassName(): string;
  100940. /**
  100941. * Define the list of animation attached to the texture.
  100942. */
  100943. animations: Animation[];
  100944. /**
  100945. * An event triggered when the texture is disposed.
  100946. */
  100947. onDisposeObservable: Observable<BaseTexture>;
  100948. private _onDisposeObserver;
  100949. /**
  100950. * Callback triggered when the texture has been disposed.
  100951. * Kept for back compatibility, you can use the onDisposeObservable instead.
  100952. */
  100953. set onDispose(callback: () => void);
  100954. /**
  100955. * Define the current state of the loading sequence when in delayed load mode.
  100956. */
  100957. delayLoadState: number;
  100958. private _scene;
  100959. /** @hidden */
  100960. _texture: Nullable<InternalTexture>;
  100961. private _uid;
  100962. /**
  100963. * Define if the texture is preventinga material to render or not.
  100964. * If not and the texture is not ready, the engine will use a default black texture instead.
  100965. */
  100966. get isBlocking(): boolean;
  100967. /**
  100968. * Instantiates a new BaseTexture.
  100969. * Base class of all the textures in babylon.
  100970. * It groups all the common properties the materials, post process, lights... might need
  100971. * in order to make a correct use of the texture.
  100972. * @param scene Define the scene the texture blongs to
  100973. */
  100974. constructor(scene: Nullable<Scene>);
  100975. /**
  100976. * Get the scene the texture belongs to.
  100977. * @returns the scene or null if undefined
  100978. */
  100979. getScene(): Nullable<Scene>;
  100980. /**
  100981. * Get the texture transform matrix used to offset tile the texture for istance.
  100982. * @returns the transformation matrix
  100983. */
  100984. getTextureMatrix(): Matrix;
  100985. /**
  100986. * Get the texture reflection matrix used to rotate/transform the reflection.
  100987. * @returns the reflection matrix
  100988. */
  100989. getReflectionTextureMatrix(): Matrix;
  100990. /**
  100991. * Get the underlying lower level texture from Babylon.
  100992. * @returns the insternal texture
  100993. */
  100994. getInternalTexture(): Nullable<InternalTexture>;
  100995. /**
  100996. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  100997. * @returns true if ready or not blocking
  100998. */
  100999. isReadyOrNotBlocking(): boolean;
  101000. /**
  101001. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  101002. * @returns true if fully ready
  101003. */
  101004. isReady(): boolean;
  101005. private _cachedSize;
  101006. /**
  101007. * Get the size of the texture.
  101008. * @returns the texture size.
  101009. */
  101010. getSize(): ISize;
  101011. /**
  101012. * Get the base size of the texture.
  101013. * It can be different from the size if the texture has been resized for POT for instance
  101014. * @returns the base size
  101015. */
  101016. getBaseSize(): ISize;
  101017. /**
  101018. * Update the sampling mode of the texture.
  101019. * Default is Trilinear mode.
  101020. *
  101021. * | Value | Type | Description |
  101022. * | ----- | ------------------ | ----------- |
  101023. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  101024. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  101025. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  101026. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  101027. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  101028. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  101029. * | 7 | NEAREST_LINEAR | |
  101030. * | 8 | NEAREST_NEAREST | |
  101031. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  101032. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  101033. * | 11 | LINEAR_LINEAR | |
  101034. * | 12 | LINEAR_NEAREST | |
  101035. *
  101036. * > _mag_: magnification filter (close to the viewer)
  101037. * > _min_: minification filter (far from the viewer)
  101038. * > _mip_: filter used between mip map levels
  101039. *@param samplingMode Define the new sampling mode of the texture
  101040. */
  101041. updateSamplingMode(samplingMode: number): void;
  101042. /**
  101043. * Scales the texture if is `canRescale()`
  101044. * @param ratio the resize factor we want to use to rescale
  101045. */
  101046. scale(ratio: number): void;
  101047. /**
  101048. * Get if the texture can rescale.
  101049. */
  101050. get canRescale(): boolean;
  101051. /** @hidden */
  101052. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  101053. /** @hidden */
  101054. _rebuild(): void;
  101055. /**
  101056. * Triggers the load sequence in delayed load mode.
  101057. */
  101058. delayLoad(): void;
  101059. /**
  101060. * Clones the texture.
  101061. * @returns the cloned texture
  101062. */
  101063. clone(): Nullable<BaseTexture>;
  101064. /**
  101065. * Get the texture underlying type (INT, FLOAT...)
  101066. */
  101067. get textureType(): number;
  101068. /**
  101069. * Get the texture underlying format (RGB, RGBA...)
  101070. */
  101071. get textureFormat(): number;
  101072. /**
  101073. * Indicates that textures need to be re-calculated for all materials
  101074. */
  101075. protected _markAllSubMeshesAsTexturesDirty(): void;
  101076. /**
  101077. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  101078. * This will returns an RGBA array buffer containing either in values (0-255) or
  101079. * float values (0-1) depending of the underlying buffer type.
  101080. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  101081. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  101082. * @param buffer defines a user defined buffer to fill with data (can be null)
  101083. * @returns The Array buffer containing the pixels data.
  101084. */
  101085. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  101086. /**
  101087. * Release and destroy the underlying lower level texture aka internalTexture.
  101088. */
  101089. releaseInternalTexture(): void;
  101090. /** @hidden */
  101091. get _lodTextureHigh(): Nullable<BaseTexture>;
  101092. /** @hidden */
  101093. get _lodTextureMid(): Nullable<BaseTexture>;
  101094. /** @hidden */
  101095. get _lodTextureLow(): Nullable<BaseTexture>;
  101096. /**
  101097. * Dispose the texture and release its associated resources.
  101098. */
  101099. dispose(): void;
  101100. /**
  101101. * Serialize the texture into a JSON representation that can be parsed later on.
  101102. * @returns the JSON representation of the texture
  101103. */
  101104. serialize(): any;
  101105. /**
  101106. * Helper function to be called back once a list of texture contains only ready textures.
  101107. * @param textures Define the list of textures to wait for
  101108. * @param callback Define the callback triggered once the entire list will be ready
  101109. */
  101110. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  101111. }
  101112. }
  101113. declare module BABYLON {
  101114. /**
  101115. * Options to be used when creating an effect.
  101116. */
  101117. export interface IEffectCreationOptions {
  101118. /**
  101119. * Atrributes that will be used in the shader.
  101120. */
  101121. attributes: string[];
  101122. /**
  101123. * Uniform varible names that will be set in the shader.
  101124. */
  101125. uniformsNames: string[];
  101126. /**
  101127. * Uniform buffer variable names that will be set in the shader.
  101128. */
  101129. uniformBuffersNames: string[];
  101130. /**
  101131. * Sampler texture variable names that will be set in the shader.
  101132. */
  101133. samplers: string[];
  101134. /**
  101135. * Define statements that will be set in the shader.
  101136. */
  101137. defines: any;
  101138. /**
  101139. * Possible fallbacks for this effect to improve performance when needed.
  101140. */
  101141. fallbacks: Nullable<IEffectFallbacks>;
  101142. /**
  101143. * Callback that will be called when the shader is compiled.
  101144. */
  101145. onCompiled: Nullable<(effect: Effect) => void>;
  101146. /**
  101147. * Callback that will be called if an error occurs during shader compilation.
  101148. */
  101149. onError: Nullable<(effect: Effect, errors: string) => void>;
  101150. /**
  101151. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  101152. */
  101153. indexParameters?: any;
  101154. /**
  101155. * Max number of lights that can be used in the shader.
  101156. */
  101157. maxSimultaneousLights?: number;
  101158. /**
  101159. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  101160. */
  101161. transformFeedbackVaryings?: Nullable<string[]>;
  101162. }
  101163. /**
  101164. * Effect containing vertex and fragment shader that can be executed on an object.
  101165. */
  101166. export class Effect implements IDisposable {
  101167. /**
  101168. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  101169. */
  101170. static ShadersRepository: string;
  101171. /**
  101172. * Name of the effect.
  101173. */
  101174. name: any;
  101175. /**
  101176. * String container all the define statements that should be set on the shader.
  101177. */
  101178. defines: string;
  101179. /**
  101180. * Callback that will be called when the shader is compiled.
  101181. */
  101182. onCompiled: Nullable<(effect: Effect) => void>;
  101183. /**
  101184. * Callback that will be called if an error occurs during shader compilation.
  101185. */
  101186. onError: Nullable<(effect: Effect, errors: string) => void>;
  101187. /**
  101188. * Callback that will be called when effect is bound.
  101189. */
  101190. onBind: Nullable<(effect: Effect) => void>;
  101191. /**
  101192. * Unique ID of the effect.
  101193. */
  101194. uniqueId: number;
  101195. /**
  101196. * Observable that will be called when the shader is compiled.
  101197. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  101198. */
  101199. onCompileObservable: Observable<Effect>;
  101200. /**
  101201. * Observable that will be called if an error occurs during shader compilation.
  101202. */
  101203. onErrorObservable: Observable<Effect>;
  101204. /** @hidden */
  101205. _onBindObservable: Nullable<Observable<Effect>>;
  101206. /**
  101207. * @hidden
  101208. * Specifies if the effect was previously ready
  101209. */
  101210. _wasPreviouslyReady: boolean;
  101211. /**
  101212. * Observable that will be called when effect is bound.
  101213. */
  101214. get onBindObservable(): Observable<Effect>;
  101215. /** @hidden */
  101216. _bonesComputationForcedToCPU: boolean;
  101217. private static _uniqueIdSeed;
  101218. private _engine;
  101219. private _uniformBuffersNames;
  101220. private _uniformsNames;
  101221. private _samplerList;
  101222. private _samplers;
  101223. private _isReady;
  101224. private _compilationError;
  101225. private _allFallbacksProcessed;
  101226. private _attributesNames;
  101227. private _attributes;
  101228. private _attributeLocationByName;
  101229. private _uniforms;
  101230. /**
  101231. * Key for the effect.
  101232. * @hidden
  101233. */
  101234. _key: string;
  101235. private _indexParameters;
  101236. private _fallbacks;
  101237. private _vertexSourceCode;
  101238. private _fragmentSourceCode;
  101239. private _vertexSourceCodeOverride;
  101240. private _fragmentSourceCodeOverride;
  101241. private _transformFeedbackVaryings;
  101242. /**
  101243. * Compiled shader to webGL program.
  101244. * @hidden
  101245. */
  101246. _pipelineContext: Nullable<IPipelineContext>;
  101247. private _valueCache;
  101248. private static _baseCache;
  101249. /**
  101250. * Instantiates an effect.
  101251. * An effect can be used to create/manage/execute vertex and fragment shaders.
  101252. * @param baseName Name of the effect.
  101253. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  101254. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  101255. * @param samplers List of sampler variables that will be passed to the shader.
  101256. * @param engine Engine to be used to render the effect
  101257. * @param defines Define statements to be added to the shader.
  101258. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  101259. * @param onCompiled Callback that will be called when the shader is compiled.
  101260. * @param onError Callback that will be called if an error occurs during shader compilation.
  101261. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  101262. */
  101263. 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);
  101264. private _useFinalCode;
  101265. /**
  101266. * Unique key for this effect
  101267. */
  101268. get key(): string;
  101269. /**
  101270. * If the effect has been compiled and prepared.
  101271. * @returns if the effect is compiled and prepared.
  101272. */
  101273. isReady(): boolean;
  101274. private _isReadyInternal;
  101275. /**
  101276. * The engine the effect was initialized with.
  101277. * @returns the engine.
  101278. */
  101279. getEngine(): Engine;
  101280. /**
  101281. * The pipeline context for this effect
  101282. * @returns the associated pipeline context
  101283. */
  101284. getPipelineContext(): Nullable<IPipelineContext>;
  101285. /**
  101286. * The set of names of attribute variables for the shader.
  101287. * @returns An array of attribute names.
  101288. */
  101289. getAttributesNames(): string[];
  101290. /**
  101291. * Returns the attribute at the given index.
  101292. * @param index The index of the attribute.
  101293. * @returns The location of the attribute.
  101294. */
  101295. getAttributeLocation(index: number): number;
  101296. /**
  101297. * Returns the attribute based on the name of the variable.
  101298. * @param name of the attribute to look up.
  101299. * @returns the attribute location.
  101300. */
  101301. getAttributeLocationByName(name: string): number;
  101302. /**
  101303. * The number of attributes.
  101304. * @returns the numnber of attributes.
  101305. */
  101306. getAttributesCount(): number;
  101307. /**
  101308. * Gets the index of a uniform variable.
  101309. * @param uniformName of the uniform to look up.
  101310. * @returns the index.
  101311. */
  101312. getUniformIndex(uniformName: string): number;
  101313. /**
  101314. * Returns the attribute based on the name of the variable.
  101315. * @param uniformName of the uniform to look up.
  101316. * @returns the location of the uniform.
  101317. */
  101318. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  101319. /**
  101320. * Returns an array of sampler variable names
  101321. * @returns The array of sampler variable neames.
  101322. */
  101323. getSamplers(): string[];
  101324. /**
  101325. * The error from the last compilation.
  101326. * @returns the error string.
  101327. */
  101328. getCompilationError(): string;
  101329. /**
  101330. * Gets a boolean indicating that all fallbacks were used during compilation
  101331. * @returns true if all fallbacks were used
  101332. */
  101333. allFallbacksProcessed(): boolean;
  101334. /**
  101335. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  101336. * @param func The callback to be used.
  101337. */
  101338. executeWhenCompiled(func: (effect: Effect) => void): void;
  101339. private _checkIsReady;
  101340. private _loadShader;
  101341. /**
  101342. * Recompiles the webGL program
  101343. * @param vertexSourceCode The source code for the vertex shader.
  101344. * @param fragmentSourceCode The source code for the fragment shader.
  101345. * @param onCompiled Callback called when completed.
  101346. * @param onError Callback called on error.
  101347. * @hidden
  101348. */
  101349. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  101350. /**
  101351. * Prepares the effect
  101352. * @hidden
  101353. */
  101354. _prepareEffect(): void;
  101355. private _processCompilationErrors;
  101356. /**
  101357. * Checks if the effect is supported. (Must be called after compilation)
  101358. */
  101359. get isSupported(): boolean;
  101360. /**
  101361. * Binds a texture to the engine to be used as output of the shader.
  101362. * @param channel Name of the output variable.
  101363. * @param texture Texture to bind.
  101364. * @hidden
  101365. */
  101366. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  101367. /**
  101368. * Sets a texture on the engine to be used in the shader.
  101369. * @param channel Name of the sampler variable.
  101370. * @param texture Texture to set.
  101371. */
  101372. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  101373. /**
  101374. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  101375. * @param channel Name of the sampler variable.
  101376. * @param texture Texture to set.
  101377. */
  101378. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  101379. /**
  101380. * Sets an array of textures on the engine to be used in the shader.
  101381. * @param channel Name of the variable.
  101382. * @param textures Textures to set.
  101383. */
  101384. setTextureArray(channel: string, textures: BaseTexture[]): void;
  101385. /**
  101386. * 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)
  101387. * @param channel Name of the sampler variable.
  101388. * @param postProcess Post process to get the input texture from.
  101389. */
  101390. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  101391. /**
  101392. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  101393. * 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)
  101394. * @param channel Name of the sampler variable.
  101395. * @param postProcess Post process to get the output texture from.
  101396. */
  101397. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  101398. /** @hidden */
  101399. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  101400. /** @hidden */
  101401. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  101402. /** @hidden */
  101403. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  101404. /** @hidden */
  101405. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  101406. /**
  101407. * Binds a buffer to a uniform.
  101408. * @param buffer Buffer to bind.
  101409. * @param name Name of the uniform variable to bind to.
  101410. */
  101411. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  101412. /**
  101413. * Binds block to a uniform.
  101414. * @param blockName Name of the block to bind.
  101415. * @param index Index to bind.
  101416. */
  101417. bindUniformBlock(blockName: string, index: number): void;
  101418. /**
  101419. * Sets an interger value on a uniform variable.
  101420. * @param uniformName Name of the variable.
  101421. * @param value Value to be set.
  101422. * @returns this effect.
  101423. */
  101424. setInt(uniformName: string, value: number): Effect;
  101425. /**
  101426. * Sets an int array on a uniform variable.
  101427. * @param uniformName Name of the variable.
  101428. * @param array array to be set.
  101429. * @returns this effect.
  101430. */
  101431. setIntArray(uniformName: string, array: Int32Array): Effect;
  101432. /**
  101433. * 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)
  101434. * @param uniformName Name of the variable.
  101435. * @param array array to be set.
  101436. * @returns this effect.
  101437. */
  101438. setIntArray2(uniformName: string, array: Int32Array): Effect;
  101439. /**
  101440. * 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)
  101441. * @param uniformName Name of the variable.
  101442. * @param array array to be set.
  101443. * @returns this effect.
  101444. */
  101445. setIntArray3(uniformName: string, array: Int32Array): Effect;
  101446. /**
  101447. * 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)
  101448. * @param uniformName Name of the variable.
  101449. * @param array array to be set.
  101450. * @returns this effect.
  101451. */
  101452. setIntArray4(uniformName: string, array: Int32Array): Effect;
  101453. /**
  101454. * Sets an float array on a uniform variable.
  101455. * @param uniformName Name of the variable.
  101456. * @param array array to be set.
  101457. * @returns this effect.
  101458. */
  101459. setFloatArray(uniformName: string, array: Float32Array): Effect;
  101460. /**
  101461. * 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)
  101462. * @param uniformName Name of the variable.
  101463. * @param array array to be set.
  101464. * @returns this effect.
  101465. */
  101466. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  101467. /**
  101468. * 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)
  101469. * @param uniformName Name of the variable.
  101470. * @param array array to be set.
  101471. * @returns this effect.
  101472. */
  101473. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  101474. /**
  101475. * 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)
  101476. * @param uniformName Name of the variable.
  101477. * @param array array to be set.
  101478. * @returns this effect.
  101479. */
  101480. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  101481. /**
  101482. * Sets an array on a uniform variable.
  101483. * @param uniformName Name of the variable.
  101484. * @param array array to be set.
  101485. * @returns this effect.
  101486. */
  101487. setArray(uniformName: string, array: number[]): Effect;
  101488. /**
  101489. * 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)
  101490. * @param uniformName Name of the variable.
  101491. * @param array array to be set.
  101492. * @returns this effect.
  101493. */
  101494. setArray2(uniformName: string, array: number[]): Effect;
  101495. /**
  101496. * 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)
  101497. * @param uniformName Name of the variable.
  101498. * @param array array to be set.
  101499. * @returns this effect.
  101500. */
  101501. setArray3(uniformName: string, array: number[]): Effect;
  101502. /**
  101503. * 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)
  101504. * @param uniformName Name of the variable.
  101505. * @param array array to be set.
  101506. * @returns this effect.
  101507. */
  101508. setArray4(uniformName: string, array: number[]): Effect;
  101509. /**
  101510. * Sets matrices on a uniform variable.
  101511. * @param uniformName Name of the variable.
  101512. * @param matrices matrices to be set.
  101513. * @returns this effect.
  101514. */
  101515. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  101516. /**
  101517. * Sets matrix on a uniform variable.
  101518. * @param uniformName Name of the variable.
  101519. * @param matrix matrix to be set.
  101520. * @returns this effect.
  101521. */
  101522. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  101523. /**
  101524. * 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)
  101525. * @param uniformName Name of the variable.
  101526. * @param matrix matrix to be set.
  101527. * @returns this effect.
  101528. */
  101529. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  101530. /**
  101531. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  101532. * @param uniformName Name of the variable.
  101533. * @param matrix matrix to be set.
  101534. * @returns this effect.
  101535. */
  101536. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  101537. /**
  101538. * Sets a float on a uniform variable.
  101539. * @param uniformName Name of the variable.
  101540. * @param value value to be set.
  101541. * @returns this effect.
  101542. */
  101543. setFloat(uniformName: string, value: number): Effect;
  101544. /**
  101545. * Sets a boolean on a uniform variable.
  101546. * @param uniformName Name of the variable.
  101547. * @param bool value to be set.
  101548. * @returns this effect.
  101549. */
  101550. setBool(uniformName: string, bool: boolean): Effect;
  101551. /**
  101552. * Sets a Vector2 on a uniform variable.
  101553. * @param uniformName Name of the variable.
  101554. * @param vector2 vector2 to be set.
  101555. * @returns this effect.
  101556. */
  101557. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  101558. /**
  101559. * Sets a float2 on a uniform variable.
  101560. * @param uniformName Name of the variable.
  101561. * @param x First float in float2.
  101562. * @param y Second float in float2.
  101563. * @returns this effect.
  101564. */
  101565. setFloat2(uniformName: string, x: number, y: number): Effect;
  101566. /**
  101567. * Sets a Vector3 on a uniform variable.
  101568. * @param uniformName Name of the variable.
  101569. * @param vector3 Value to be set.
  101570. * @returns this effect.
  101571. */
  101572. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  101573. /**
  101574. * Sets a float3 on a uniform variable.
  101575. * @param uniformName Name of the variable.
  101576. * @param x First float in float3.
  101577. * @param y Second float in float3.
  101578. * @param z Third float in float3.
  101579. * @returns this effect.
  101580. */
  101581. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  101582. /**
  101583. * Sets a Vector4 on a uniform variable.
  101584. * @param uniformName Name of the variable.
  101585. * @param vector4 Value to be set.
  101586. * @returns this effect.
  101587. */
  101588. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  101589. /**
  101590. * Sets a float4 on a uniform variable.
  101591. * @param uniformName Name of the variable.
  101592. * @param x First float in float4.
  101593. * @param y Second float in float4.
  101594. * @param z Third float in float4.
  101595. * @param w Fourth float in float4.
  101596. * @returns this effect.
  101597. */
  101598. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  101599. /**
  101600. * Sets a Color3 on a uniform variable.
  101601. * @param uniformName Name of the variable.
  101602. * @param color3 Value to be set.
  101603. * @returns this effect.
  101604. */
  101605. setColor3(uniformName: string, color3: IColor3Like): Effect;
  101606. /**
  101607. * Sets a Color4 on a uniform variable.
  101608. * @param uniformName Name of the variable.
  101609. * @param color3 Value to be set.
  101610. * @param alpha Alpha value to be set.
  101611. * @returns this effect.
  101612. */
  101613. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  101614. /**
  101615. * Sets a Color4 on a uniform variable
  101616. * @param uniformName defines the name of the variable
  101617. * @param color4 defines the value to be set
  101618. * @returns this effect.
  101619. */
  101620. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  101621. /** Release all associated resources */
  101622. dispose(): void;
  101623. /**
  101624. * This function will add a new shader to the shader store
  101625. * @param name the name of the shader
  101626. * @param pixelShader optional pixel shader content
  101627. * @param vertexShader optional vertex shader content
  101628. */
  101629. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  101630. /**
  101631. * Store of each shader (The can be looked up using effect.key)
  101632. */
  101633. static ShadersStore: {
  101634. [key: string]: string;
  101635. };
  101636. /**
  101637. * Store of each included file for a shader (The can be looked up using effect.key)
  101638. */
  101639. static IncludesShadersStore: {
  101640. [key: string]: string;
  101641. };
  101642. /**
  101643. * Resets the cache of effects.
  101644. */
  101645. static ResetCache(): void;
  101646. }
  101647. }
  101648. declare module BABYLON {
  101649. /**
  101650. * Interface used to describe the capabilities of the engine relatively to the current browser
  101651. */
  101652. export interface EngineCapabilities {
  101653. /** Maximum textures units per fragment shader */
  101654. maxTexturesImageUnits: number;
  101655. /** Maximum texture units per vertex shader */
  101656. maxVertexTextureImageUnits: number;
  101657. /** Maximum textures units in the entire pipeline */
  101658. maxCombinedTexturesImageUnits: number;
  101659. /** Maximum texture size */
  101660. maxTextureSize: number;
  101661. /** Maximum texture samples */
  101662. maxSamples?: number;
  101663. /** Maximum cube texture size */
  101664. maxCubemapTextureSize: number;
  101665. /** Maximum render texture size */
  101666. maxRenderTextureSize: number;
  101667. /** Maximum number of vertex attributes */
  101668. maxVertexAttribs: number;
  101669. /** Maximum number of varyings */
  101670. maxVaryingVectors: number;
  101671. /** Maximum number of uniforms per vertex shader */
  101672. maxVertexUniformVectors: number;
  101673. /** Maximum number of uniforms per fragment shader */
  101674. maxFragmentUniformVectors: number;
  101675. /** Defines if standard derivates (dx/dy) are supported */
  101676. standardDerivatives: boolean;
  101677. /** Defines if s3tc texture compression is supported */
  101678. s3tc?: WEBGL_compressed_texture_s3tc;
  101679. /** Defines if pvrtc texture compression is supported */
  101680. pvrtc: any;
  101681. /** Defines if etc1 texture compression is supported */
  101682. etc1: any;
  101683. /** Defines if etc2 texture compression is supported */
  101684. etc2: any;
  101685. /** Defines if astc texture compression is supported */
  101686. astc: any;
  101687. /** Defines if float textures are supported */
  101688. textureFloat: boolean;
  101689. /** Defines if vertex array objects are supported */
  101690. vertexArrayObject: boolean;
  101691. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  101692. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  101693. /** Gets the maximum level of anisotropy supported */
  101694. maxAnisotropy: number;
  101695. /** Defines if instancing is supported */
  101696. instancedArrays: boolean;
  101697. /** Defines if 32 bits indices are supported */
  101698. uintIndices: boolean;
  101699. /** Defines if high precision shaders are supported */
  101700. highPrecisionShaderSupported: boolean;
  101701. /** Defines if depth reading in the fragment shader is supported */
  101702. fragmentDepthSupported: boolean;
  101703. /** Defines if float texture linear filtering is supported*/
  101704. textureFloatLinearFiltering: boolean;
  101705. /** Defines if rendering to float textures is supported */
  101706. textureFloatRender: boolean;
  101707. /** Defines if half float textures are supported*/
  101708. textureHalfFloat: boolean;
  101709. /** Defines if half float texture linear filtering is supported*/
  101710. textureHalfFloatLinearFiltering: boolean;
  101711. /** Defines if rendering to half float textures is supported */
  101712. textureHalfFloatRender: boolean;
  101713. /** Defines if textureLOD shader command is supported */
  101714. textureLOD: boolean;
  101715. /** Defines if draw buffers extension is supported */
  101716. drawBuffersExtension: boolean;
  101717. /** Defines if depth textures are supported */
  101718. depthTextureExtension: boolean;
  101719. /** Defines if float color buffer are supported */
  101720. colorBufferFloat: boolean;
  101721. /** Gets disjoint timer query extension (null if not supported) */
  101722. timerQuery?: EXT_disjoint_timer_query;
  101723. /** Defines if timestamp can be used with timer query */
  101724. canUseTimestampForTimerQuery: boolean;
  101725. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  101726. multiview?: any;
  101727. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  101728. oculusMultiview?: any;
  101729. /** Function used to let the system compiles shaders in background */
  101730. parallelShaderCompile?: {
  101731. COMPLETION_STATUS_KHR: number;
  101732. };
  101733. /** Max number of texture samples for MSAA */
  101734. maxMSAASamples: number;
  101735. /** Defines if the blend min max extension is supported */
  101736. blendMinMax: boolean;
  101737. }
  101738. }
  101739. declare module BABYLON {
  101740. /**
  101741. * @hidden
  101742. **/
  101743. export class DepthCullingState {
  101744. private _isDepthTestDirty;
  101745. private _isDepthMaskDirty;
  101746. private _isDepthFuncDirty;
  101747. private _isCullFaceDirty;
  101748. private _isCullDirty;
  101749. private _isZOffsetDirty;
  101750. private _isFrontFaceDirty;
  101751. private _depthTest;
  101752. private _depthMask;
  101753. private _depthFunc;
  101754. private _cull;
  101755. private _cullFace;
  101756. private _zOffset;
  101757. private _frontFace;
  101758. /**
  101759. * Initializes the state.
  101760. */
  101761. constructor();
  101762. get isDirty(): boolean;
  101763. get zOffset(): number;
  101764. set zOffset(value: number);
  101765. get cullFace(): Nullable<number>;
  101766. set cullFace(value: Nullable<number>);
  101767. get cull(): Nullable<boolean>;
  101768. set cull(value: Nullable<boolean>);
  101769. get depthFunc(): Nullable<number>;
  101770. set depthFunc(value: Nullable<number>);
  101771. get depthMask(): boolean;
  101772. set depthMask(value: boolean);
  101773. get depthTest(): boolean;
  101774. set depthTest(value: boolean);
  101775. get frontFace(): Nullable<number>;
  101776. set frontFace(value: Nullable<number>);
  101777. reset(): void;
  101778. apply(gl: WebGLRenderingContext): void;
  101779. }
  101780. }
  101781. declare module BABYLON {
  101782. /**
  101783. * @hidden
  101784. **/
  101785. export class StencilState {
  101786. /** 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 */
  101787. static readonly ALWAYS: number;
  101788. /** Passed to stencilOperation to specify that stencil value must be kept */
  101789. static readonly KEEP: number;
  101790. /** Passed to stencilOperation to specify that stencil value must be replaced */
  101791. static readonly REPLACE: number;
  101792. private _isStencilTestDirty;
  101793. private _isStencilMaskDirty;
  101794. private _isStencilFuncDirty;
  101795. private _isStencilOpDirty;
  101796. private _stencilTest;
  101797. private _stencilMask;
  101798. private _stencilFunc;
  101799. private _stencilFuncRef;
  101800. private _stencilFuncMask;
  101801. private _stencilOpStencilFail;
  101802. private _stencilOpDepthFail;
  101803. private _stencilOpStencilDepthPass;
  101804. get isDirty(): boolean;
  101805. get stencilFunc(): number;
  101806. set stencilFunc(value: number);
  101807. get stencilFuncRef(): number;
  101808. set stencilFuncRef(value: number);
  101809. get stencilFuncMask(): number;
  101810. set stencilFuncMask(value: number);
  101811. get stencilOpStencilFail(): number;
  101812. set stencilOpStencilFail(value: number);
  101813. get stencilOpDepthFail(): number;
  101814. set stencilOpDepthFail(value: number);
  101815. get stencilOpStencilDepthPass(): number;
  101816. set stencilOpStencilDepthPass(value: number);
  101817. get stencilMask(): number;
  101818. set stencilMask(value: number);
  101819. get stencilTest(): boolean;
  101820. set stencilTest(value: boolean);
  101821. constructor();
  101822. reset(): void;
  101823. apply(gl: WebGLRenderingContext): void;
  101824. }
  101825. }
  101826. declare module BABYLON {
  101827. /**
  101828. * @hidden
  101829. **/
  101830. export class AlphaState {
  101831. private _isAlphaBlendDirty;
  101832. private _isBlendFunctionParametersDirty;
  101833. private _isBlendEquationParametersDirty;
  101834. private _isBlendConstantsDirty;
  101835. private _alphaBlend;
  101836. private _blendFunctionParameters;
  101837. private _blendEquationParameters;
  101838. private _blendConstants;
  101839. /**
  101840. * Initializes the state.
  101841. */
  101842. constructor();
  101843. get isDirty(): boolean;
  101844. get alphaBlend(): boolean;
  101845. set alphaBlend(value: boolean);
  101846. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  101847. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  101848. setAlphaEquationParameters(rgb: number, alpha: number): void;
  101849. reset(): void;
  101850. apply(gl: WebGLRenderingContext): void;
  101851. }
  101852. }
  101853. declare module BABYLON {
  101854. /** @hidden */
  101855. export class WebGL2ShaderProcessor implements IShaderProcessor {
  101856. attributeProcessor(attribute: string): string;
  101857. varyingProcessor(varying: string, isFragment: boolean): string;
  101858. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  101859. }
  101860. }
  101861. declare module BABYLON {
  101862. /**
  101863. * Interface for attribute information associated with buffer instanciation
  101864. */
  101865. export interface InstancingAttributeInfo {
  101866. /**
  101867. * Name of the GLSL attribute
  101868. * if attribute index is not specified, this is used to retrieve the index from the effect
  101869. */
  101870. attributeName: string;
  101871. /**
  101872. * Index/offset of the attribute in the vertex shader
  101873. * if not specified, this will be computes from the name.
  101874. */
  101875. index?: number;
  101876. /**
  101877. * size of the attribute, 1, 2, 3 or 4
  101878. */
  101879. attributeSize: number;
  101880. /**
  101881. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  101882. */
  101883. offset: number;
  101884. /**
  101885. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  101886. * default to 1
  101887. */
  101888. divisor?: number;
  101889. /**
  101890. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  101891. * default is FLOAT
  101892. */
  101893. attributeType?: number;
  101894. /**
  101895. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  101896. */
  101897. normalized?: boolean;
  101898. }
  101899. }
  101900. declare module BABYLON {
  101901. interface ThinEngine {
  101902. /**
  101903. * Update a video texture
  101904. * @param texture defines the texture to update
  101905. * @param video defines the video element to use
  101906. * @param invertY defines if data must be stored with Y axis inverted
  101907. */
  101908. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  101909. }
  101910. }
  101911. declare module BABYLON {
  101912. /**
  101913. * Settings for finer control over video usage
  101914. */
  101915. export interface VideoTextureSettings {
  101916. /**
  101917. * Applies `autoplay` to video, if specified
  101918. */
  101919. autoPlay?: boolean;
  101920. /**
  101921. * Applies `loop` to video, if specified
  101922. */
  101923. loop?: boolean;
  101924. /**
  101925. * Automatically updates internal texture from video at every frame in the render loop
  101926. */
  101927. autoUpdateTexture: boolean;
  101928. /**
  101929. * Image src displayed during the video loading or until the user interacts with the video.
  101930. */
  101931. poster?: string;
  101932. }
  101933. /**
  101934. * If you want to display a video in your scene, this is the special texture for that.
  101935. * This special texture works similar to other textures, with the exception of a few parameters.
  101936. * @see https://doc.babylonjs.com/how_to/video_texture
  101937. */
  101938. export class VideoTexture extends Texture {
  101939. /**
  101940. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  101941. */
  101942. readonly autoUpdateTexture: boolean;
  101943. /**
  101944. * The video instance used by the texture internally
  101945. */
  101946. readonly video: HTMLVideoElement;
  101947. private _onUserActionRequestedObservable;
  101948. /**
  101949. * Event triggerd when a dom action is required by the user to play the video.
  101950. * This happens due to recent changes in browser policies preventing video to auto start.
  101951. */
  101952. get onUserActionRequestedObservable(): Observable<Texture>;
  101953. private _generateMipMaps;
  101954. private _engine;
  101955. private _stillImageCaptured;
  101956. private _displayingPosterTexture;
  101957. private _settings;
  101958. private _createInternalTextureOnEvent;
  101959. private _frameId;
  101960. private _currentSrc;
  101961. /**
  101962. * Creates a video texture.
  101963. * If you want to display a video in your scene, this is the special texture for that.
  101964. * This special texture works similar to other textures, with the exception of a few parameters.
  101965. * @see https://doc.babylonjs.com/how_to/video_texture
  101966. * @param name optional name, will detect from video source, if not defined
  101967. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  101968. * @param scene is obviously the current scene.
  101969. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  101970. * @param invertY is false by default but can be used to invert video on Y axis
  101971. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  101972. * @param settings allows finer control over video usage
  101973. */
  101974. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  101975. private _getName;
  101976. private _getVideo;
  101977. private _createInternalTexture;
  101978. private reset;
  101979. /**
  101980. * @hidden Internal method to initiate `update`.
  101981. */
  101982. _rebuild(): void;
  101983. /**
  101984. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  101985. */
  101986. update(): void;
  101987. /**
  101988. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  101989. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  101990. */
  101991. updateTexture(isVisible: boolean): void;
  101992. protected _updateInternalTexture: () => void;
  101993. /**
  101994. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  101995. * @param url New url.
  101996. */
  101997. updateURL(url: string): void;
  101998. /**
  101999. * Clones the texture.
  102000. * @returns the cloned texture
  102001. */
  102002. clone(): VideoTexture;
  102003. /**
  102004. * Dispose the texture and release its associated resources.
  102005. */
  102006. dispose(): void;
  102007. /**
  102008. * Creates a video texture straight from a stream.
  102009. * @param scene Define the scene the texture should be created in
  102010. * @param stream Define the stream the texture should be created from
  102011. * @returns The created video texture as a promise
  102012. */
  102013. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  102014. /**
  102015. * Creates a video texture straight from your WebCam video feed.
  102016. * @param scene Define the scene the texture should be created in
  102017. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  102018. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  102019. * @returns The created video texture as a promise
  102020. */
  102021. static CreateFromWebCamAsync(scene: Scene, constraints: {
  102022. minWidth: number;
  102023. maxWidth: number;
  102024. minHeight: number;
  102025. maxHeight: number;
  102026. deviceId: string;
  102027. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  102028. /**
  102029. * Creates a video texture straight from your WebCam video feed.
  102030. * @param scene Define the scene the texture should be created in
  102031. * @param onReady Define a callback to triggered once the texture will be ready
  102032. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  102033. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  102034. */
  102035. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  102036. minWidth: number;
  102037. maxWidth: number;
  102038. minHeight: number;
  102039. maxHeight: number;
  102040. deviceId: string;
  102041. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  102042. }
  102043. }
  102044. declare module BABYLON {
  102045. /**
  102046. * Defines the interface used by objects working like Scene
  102047. * @hidden
  102048. */
  102049. interface ISceneLike {
  102050. _addPendingData(data: any): void;
  102051. _removePendingData(data: any): void;
  102052. offlineProvider: IOfflineProvider;
  102053. }
  102054. /** Interface defining initialization parameters for Engine class */
  102055. export interface EngineOptions extends WebGLContextAttributes {
  102056. /**
  102057. * Defines if the engine should no exceed a specified device ratio
  102058. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  102059. */
  102060. limitDeviceRatio?: number;
  102061. /**
  102062. * Defines if webvr should be enabled automatically
  102063. * @see http://doc.babylonjs.com/how_to/webvr_camera
  102064. */
  102065. autoEnableWebVR?: boolean;
  102066. /**
  102067. * Defines if webgl2 should be turned off even if supported
  102068. * @see http://doc.babylonjs.com/features/webgl2
  102069. */
  102070. disableWebGL2Support?: boolean;
  102071. /**
  102072. * Defines if webaudio should be initialized as well
  102073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102074. */
  102075. audioEngine?: boolean;
  102076. /**
  102077. * Defines if animations should run using a deterministic lock step
  102078. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  102079. */
  102080. deterministicLockstep?: boolean;
  102081. /** Defines the maximum steps to use with deterministic lock step mode */
  102082. lockstepMaxSteps?: number;
  102083. /** Defines the seconds between each deterministic lock step */
  102084. timeStep?: number;
  102085. /**
  102086. * Defines that engine should ignore context lost events
  102087. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  102088. */
  102089. doNotHandleContextLost?: boolean;
  102090. /**
  102091. * Defines that engine should ignore modifying touch action attribute and style
  102092. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  102093. */
  102094. doNotHandleTouchAction?: boolean;
  102095. /**
  102096. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  102097. */
  102098. useHighPrecisionFloats?: boolean;
  102099. }
  102100. /**
  102101. * The base engine class (root of all engines)
  102102. */
  102103. export class ThinEngine {
  102104. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  102105. static ExceptionList: ({
  102106. key: string;
  102107. capture: string;
  102108. captureConstraint: number;
  102109. targets: string[];
  102110. } | {
  102111. key: string;
  102112. capture: null;
  102113. captureConstraint: null;
  102114. targets: string[];
  102115. })[];
  102116. /** @hidden */
  102117. static _TextureLoaders: IInternalTextureLoader[];
  102118. /**
  102119. * Returns the current npm package of the sdk
  102120. */
  102121. static get NpmPackage(): string;
  102122. /**
  102123. * Returns the current version of the framework
  102124. */
  102125. static get Version(): string;
  102126. /**
  102127. * Returns a string describing the current engine
  102128. */
  102129. get description(): string;
  102130. /**
  102131. * Gets or sets the epsilon value used by collision engine
  102132. */
  102133. static CollisionsEpsilon: number;
  102134. /**
  102135. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  102136. */
  102137. static get ShadersRepository(): string;
  102138. static set ShadersRepository(value: string);
  102139. /**
  102140. * Gets or sets the textures that the engine should not attempt to load as compressed
  102141. */
  102142. protected _excludedCompressedTextures: string[];
  102143. /**
  102144. * Filters the compressed texture formats to only include
  102145. * files that are not included in the skippable list
  102146. *
  102147. * @param url the current extension
  102148. * @param textureFormatInUse the current compressed texture format
  102149. * @returns "format" string
  102150. */
  102151. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  102152. /** @hidden */
  102153. _shaderProcessor: IShaderProcessor;
  102154. /**
  102155. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  102156. */
  102157. forcePOTTextures: boolean;
  102158. /**
  102159. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  102160. */
  102161. isFullscreen: boolean;
  102162. /**
  102163. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  102164. */
  102165. cullBackFaces: boolean;
  102166. /**
  102167. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  102168. */
  102169. renderEvenInBackground: boolean;
  102170. /**
  102171. * Gets or sets a boolean indicating that cache can be kept between frames
  102172. */
  102173. preventCacheWipeBetweenFrames: boolean;
  102174. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  102175. validateShaderPrograms: boolean;
  102176. /**
  102177. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  102178. * This can provide greater z depth for distant objects.
  102179. */
  102180. useReverseDepthBuffer: boolean;
  102181. /**
  102182. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  102183. */
  102184. disableUniformBuffers: boolean;
  102185. /** @hidden */
  102186. _uniformBuffers: UniformBuffer[];
  102187. /**
  102188. * Gets a boolean indicating that the engine supports uniform buffers
  102189. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  102190. */
  102191. get supportsUniformBuffers(): boolean;
  102192. /** @hidden */
  102193. _gl: WebGLRenderingContext;
  102194. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  102195. protected _windowIsBackground: boolean;
  102196. protected _webGLVersion: number;
  102197. protected _creationOptions: EngineOptions;
  102198. protected _highPrecisionShadersAllowed: boolean;
  102199. /** @hidden */
  102200. get _shouldUseHighPrecisionShader(): boolean;
  102201. /**
  102202. * Gets a boolean indicating that only power of 2 textures are supported
  102203. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  102204. */
  102205. get needPOTTextures(): boolean;
  102206. /** @hidden */
  102207. _badOS: boolean;
  102208. /** @hidden */
  102209. _badDesktopOS: boolean;
  102210. private _hardwareScalingLevel;
  102211. /** @hidden */
  102212. _caps: EngineCapabilities;
  102213. private _isStencilEnable;
  102214. private _glVersion;
  102215. private _glRenderer;
  102216. private _glVendor;
  102217. /** @hidden */
  102218. _videoTextureSupported: boolean;
  102219. protected _renderingQueueLaunched: boolean;
  102220. protected _activeRenderLoops: (() => void)[];
  102221. /**
  102222. * Observable signaled when a context lost event is raised
  102223. */
  102224. onContextLostObservable: Observable<ThinEngine>;
  102225. /**
  102226. * Observable signaled when a context restored event is raised
  102227. */
  102228. onContextRestoredObservable: Observable<ThinEngine>;
  102229. private _onContextLost;
  102230. private _onContextRestored;
  102231. protected _contextWasLost: boolean;
  102232. /** @hidden */
  102233. _doNotHandleContextLost: boolean;
  102234. /**
  102235. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  102236. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  102237. */
  102238. get doNotHandleContextLost(): boolean;
  102239. set doNotHandleContextLost(value: boolean);
  102240. /**
  102241. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  102242. */
  102243. disableVertexArrayObjects: boolean;
  102244. /** @hidden */
  102245. protected _colorWrite: boolean;
  102246. /** @hidden */
  102247. protected _colorWriteChanged: boolean;
  102248. /** @hidden */
  102249. protected _depthCullingState: DepthCullingState;
  102250. /** @hidden */
  102251. protected _stencilState: StencilState;
  102252. /** @hidden */
  102253. _alphaState: AlphaState;
  102254. /** @hidden */
  102255. _alphaMode: number;
  102256. /** @hidden */
  102257. _alphaEquation: number;
  102258. /** @hidden */
  102259. _internalTexturesCache: InternalTexture[];
  102260. /** @hidden */
  102261. protected _activeChannel: number;
  102262. private _currentTextureChannel;
  102263. /** @hidden */
  102264. protected _boundTexturesCache: {
  102265. [key: string]: Nullable<InternalTexture>;
  102266. };
  102267. /** @hidden */
  102268. protected _currentEffect: Nullable<Effect>;
  102269. /** @hidden */
  102270. protected _currentProgram: Nullable<WebGLProgram>;
  102271. private _compiledEffects;
  102272. private _vertexAttribArraysEnabled;
  102273. /** @hidden */
  102274. protected _cachedViewport: Nullable<IViewportLike>;
  102275. private _cachedVertexArrayObject;
  102276. /** @hidden */
  102277. protected _cachedVertexBuffers: any;
  102278. /** @hidden */
  102279. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  102280. /** @hidden */
  102281. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  102282. /** @hidden */
  102283. _currentRenderTarget: Nullable<InternalTexture>;
  102284. private _uintIndicesCurrentlySet;
  102285. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  102286. /** @hidden */
  102287. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  102288. private _currentBufferPointers;
  102289. private _currentInstanceLocations;
  102290. private _currentInstanceBuffers;
  102291. private _textureUnits;
  102292. /** @hidden */
  102293. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  102294. /** @hidden */
  102295. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  102296. /** @hidden */
  102297. _boundRenderFunction: any;
  102298. private _vaoRecordInProgress;
  102299. private _mustWipeVertexAttributes;
  102300. private _emptyTexture;
  102301. private _emptyCubeTexture;
  102302. private _emptyTexture3D;
  102303. private _emptyTexture2DArray;
  102304. /** @hidden */
  102305. _frameHandler: number;
  102306. private _nextFreeTextureSlots;
  102307. private _maxSimultaneousTextures;
  102308. private _activeRequests;
  102309. protected _texturesSupported: string[];
  102310. /** @hidden */
  102311. _textureFormatInUse: Nullable<string>;
  102312. protected get _supportsHardwareTextureRescaling(): boolean;
  102313. /**
  102314. * Gets the list of texture formats supported
  102315. */
  102316. get texturesSupported(): Array<string>;
  102317. /**
  102318. * Gets the list of texture formats in use
  102319. */
  102320. get textureFormatInUse(): Nullable<string>;
  102321. /**
  102322. * Gets the current viewport
  102323. */
  102324. get currentViewport(): Nullable<IViewportLike>;
  102325. /**
  102326. * Gets the default empty texture
  102327. */
  102328. get emptyTexture(): InternalTexture;
  102329. /**
  102330. * Gets the default empty 3D texture
  102331. */
  102332. get emptyTexture3D(): InternalTexture;
  102333. /**
  102334. * Gets the default empty 2D array texture
  102335. */
  102336. get emptyTexture2DArray(): InternalTexture;
  102337. /**
  102338. * Gets the default empty cube texture
  102339. */
  102340. get emptyCubeTexture(): InternalTexture;
  102341. /**
  102342. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  102343. */
  102344. readonly premultipliedAlpha: boolean;
  102345. /**
  102346. * Observable event triggered before each texture is initialized
  102347. */
  102348. onBeforeTextureInitObservable: Observable<Texture>;
  102349. /**
  102350. * Creates a new engine
  102351. * @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
  102352. * @param antialias defines enable antialiasing (default: false)
  102353. * @param options defines further options to be sent to the getContext() function
  102354. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  102355. */
  102356. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  102357. private _rebuildInternalTextures;
  102358. private _rebuildEffects;
  102359. /**
  102360. * Gets a boolean indicating if all created effects are ready
  102361. * @returns true if all effects are ready
  102362. */
  102363. areAllEffectsReady(): boolean;
  102364. protected _rebuildBuffers(): void;
  102365. private _initGLContext;
  102366. /**
  102367. * Gets version of the current webGL context
  102368. */
  102369. get webGLVersion(): number;
  102370. /**
  102371. * Gets a string idenfifying the name of the class
  102372. * @returns "Engine" string
  102373. */
  102374. getClassName(): string;
  102375. /**
  102376. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  102377. */
  102378. get isStencilEnable(): boolean;
  102379. /** @hidden */
  102380. _prepareWorkingCanvas(): void;
  102381. /**
  102382. * Reset the texture cache to empty state
  102383. */
  102384. resetTextureCache(): void;
  102385. /**
  102386. * Gets an object containing information about the current webGL context
  102387. * @returns an object containing the vender, the renderer and the version of the current webGL context
  102388. */
  102389. getGlInfo(): {
  102390. vendor: string;
  102391. renderer: string;
  102392. version: string;
  102393. };
  102394. /**
  102395. * Defines the hardware scaling level.
  102396. * By default the hardware scaling level is computed from the window device ratio.
  102397. * 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.
  102398. * @param level defines the level to use
  102399. */
  102400. setHardwareScalingLevel(level: number): void;
  102401. /**
  102402. * Gets the current hardware scaling level.
  102403. * By default the hardware scaling level is computed from the window device ratio.
  102404. * 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.
  102405. * @returns a number indicating the current hardware scaling level
  102406. */
  102407. getHardwareScalingLevel(): number;
  102408. /**
  102409. * Gets the list of loaded textures
  102410. * @returns an array containing all loaded textures
  102411. */
  102412. getLoadedTexturesCache(): InternalTexture[];
  102413. /**
  102414. * Gets the object containing all engine capabilities
  102415. * @returns the EngineCapabilities object
  102416. */
  102417. getCaps(): EngineCapabilities;
  102418. /**
  102419. * stop executing a render loop function and remove it from the execution array
  102420. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  102421. */
  102422. stopRenderLoop(renderFunction?: () => void): void;
  102423. /** @hidden */
  102424. _renderLoop(): void;
  102425. /**
  102426. * Gets the HTML canvas attached with the current webGL context
  102427. * @returns a HTML canvas
  102428. */
  102429. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  102430. /**
  102431. * Gets host window
  102432. * @returns the host window object
  102433. */
  102434. getHostWindow(): Nullable<Window>;
  102435. /**
  102436. * Gets the current render width
  102437. * @param useScreen defines if screen size must be used (or the current render target if any)
  102438. * @returns a number defining the current render width
  102439. */
  102440. getRenderWidth(useScreen?: boolean): number;
  102441. /**
  102442. * Gets the current render height
  102443. * @param useScreen defines if screen size must be used (or the current render target if any)
  102444. * @returns a number defining the current render height
  102445. */
  102446. getRenderHeight(useScreen?: boolean): number;
  102447. /**
  102448. * Can be used to override the current requestAnimationFrame requester.
  102449. * @hidden
  102450. */
  102451. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  102452. /**
  102453. * Register and execute a render loop. The engine can have more than one render function
  102454. * @param renderFunction defines the function to continuously execute
  102455. */
  102456. runRenderLoop(renderFunction: () => void): void;
  102457. /**
  102458. * Clear the current render buffer or the current render target (if any is set up)
  102459. * @param color defines the color to use
  102460. * @param backBuffer defines if the back buffer must be cleared
  102461. * @param depth defines if the depth buffer must be cleared
  102462. * @param stencil defines if the stencil buffer must be cleared
  102463. */
  102464. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  102465. private _viewportCached;
  102466. /** @hidden */
  102467. _viewport(x: number, y: number, width: number, height: number): void;
  102468. /**
  102469. * Set the WebGL's viewport
  102470. * @param viewport defines the viewport element to be used
  102471. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  102472. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  102473. */
  102474. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  102475. /**
  102476. * Begin a new frame
  102477. */
  102478. beginFrame(): void;
  102479. /**
  102480. * Enf the current frame
  102481. */
  102482. endFrame(): void;
  102483. /**
  102484. * Resize the view according to the canvas' size
  102485. */
  102486. resize(): void;
  102487. /**
  102488. * Force a specific size of the canvas
  102489. * @param width defines the new canvas' width
  102490. * @param height defines the new canvas' height
  102491. */
  102492. setSize(width: number, height: number): void;
  102493. /**
  102494. * Binds the frame buffer to the specified texture.
  102495. * @param texture The texture to render to or null for the default canvas
  102496. * @param faceIndex The face of the texture to render to in case of cube texture
  102497. * @param requiredWidth The width of the target to render to
  102498. * @param requiredHeight The height of the target to render to
  102499. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  102500. * @param depthStencilTexture The depth stencil texture to use to render
  102501. * @param lodLevel defines le lod level to bind to the frame buffer
  102502. */
  102503. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  102504. /** @hidden */
  102505. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  102506. /**
  102507. * Unbind the current render target texture from the webGL context
  102508. * @param texture defines the render target texture to unbind
  102509. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  102510. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  102511. */
  102512. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  102513. /**
  102514. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  102515. */
  102516. flushFramebuffer(): void;
  102517. /**
  102518. * Unbind the current render target and bind the default framebuffer
  102519. */
  102520. restoreDefaultFramebuffer(): void;
  102521. /** @hidden */
  102522. protected _resetVertexBufferBinding(): void;
  102523. /**
  102524. * Creates a vertex buffer
  102525. * @param data the data for the vertex buffer
  102526. * @returns the new WebGL static buffer
  102527. */
  102528. createVertexBuffer(data: DataArray): DataBuffer;
  102529. private _createVertexBuffer;
  102530. /**
  102531. * Creates a dynamic vertex buffer
  102532. * @param data the data for the dynamic vertex buffer
  102533. * @returns the new WebGL dynamic buffer
  102534. */
  102535. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  102536. protected _resetIndexBufferBinding(): void;
  102537. /**
  102538. * Creates a new index buffer
  102539. * @param indices defines the content of the index buffer
  102540. * @param updatable defines if the index buffer must be updatable
  102541. * @returns a new webGL buffer
  102542. */
  102543. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  102544. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  102545. /**
  102546. * Bind a webGL buffer to the webGL context
  102547. * @param buffer defines the buffer to bind
  102548. */
  102549. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  102550. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  102551. private bindBuffer;
  102552. /**
  102553. * update the bound buffer with the given data
  102554. * @param data defines the data to update
  102555. */
  102556. updateArrayBuffer(data: Float32Array): void;
  102557. private _vertexAttribPointer;
  102558. private _bindIndexBufferWithCache;
  102559. private _bindVertexBuffersAttributes;
  102560. /**
  102561. * Records a vertex array object
  102562. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  102563. * @param vertexBuffers defines the list of vertex buffers to store
  102564. * @param indexBuffer defines the index buffer to store
  102565. * @param effect defines the effect to store
  102566. * @returns the new vertex array object
  102567. */
  102568. recordVertexArrayObject(vertexBuffers: {
  102569. [key: string]: VertexBuffer;
  102570. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  102571. /**
  102572. * Bind a specific vertex array object
  102573. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  102574. * @param vertexArrayObject defines the vertex array object to bind
  102575. * @param indexBuffer defines the index buffer to bind
  102576. */
  102577. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  102578. /**
  102579. * Bind webGl buffers directly to the webGL context
  102580. * @param vertexBuffer defines the vertex buffer to bind
  102581. * @param indexBuffer defines the index buffer to bind
  102582. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  102583. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  102584. * @param effect defines the effect associated with the vertex buffer
  102585. */
  102586. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  102587. private _unbindVertexArrayObject;
  102588. /**
  102589. * Bind a list of vertex buffers to the webGL context
  102590. * @param vertexBuffers defines the list of vertex buffers to bind
  102591. * @param indexBuffer defines the index buffer to bind
  102592. * @param effect defines the effect associated with the vertex buffers
  102593. */
  102594. bindBuffers(vertexBuffers: {
  102595. [key: string]: Nullable<VertexBuffer>;
  102596. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  102597. /**
  102598. * Unbind all instance attributes
  102599. */
  102600. unbindInstanceAttributes(): void;
  102601. /**
  102602. * Release and free the memory of a vertex array object
  102603. * @param vao defines the vertex array object to delete
  102604. */
  102605. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  102606. /** @hidden */
  102607. _releaseBuffer(buffer: DataBuffer): boolean;
  102608. protected _deleteBuffer(buffer: DataBuffer): void;
  102609. /**
  102610. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  102611. * @param instancesBuffer defines the webGL buffer to update and bind
  102612. * @param data defines the data to store in the buffer
  102613. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  102614. */
  102615. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  102616. /**
  102617. * Bind the content of a webGL buffer used with instanciation
  102618. * @param instancesBuffer defines the webGL buffer to bind
  102619. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  102620. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  102621. */
  102622. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  102623. /**
  102624. * Disable the instance attribute corresponding to the name in parameter
  102625. * @param name defines the name of the attribute to disable
  102626. */
  102627. disableInstanceAttributeByName(name: string): void;
  102628. /**
  102629. * Disable the instance attribute corresponding to the location in parameter
  102630. * @param attributeLocation defines the attribute location of the attribute to disable
  102631. */
  102632. disableInstanceAttribute(attributeLocation: number): void;
  102633. /**
  102634. * Disable the attribute corresponding to the location in parameter
  102635. * @param attributeLocation defines the attribute location of the attribute to disable
  102636. */
  102637. disableAttributeByIndex(attributeLocation: number): void;
  102638. /**
  102639. * Send a draw order
  102640. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  102641. * @param indexStart defines the starting index
  102642. * @param indexCount defines the number of index to draw
  102643. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102644. */
  102645. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  102646. /**
  102647. * Draw a list of points
  102648. * @param verticesStart defines the index of first vertex to draw
  102649. * @param verticesCount defines the count of vertices to draw
  102650. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102651. */
  102652. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  102653. /**
  102654. * Draw a list of unindexed primitives
  102655. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  102656. * @param verticesStart defines the index of first vertex to draw
  102657. * @param verticesCount defines the count of vertices to draw
  102658. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102659. */
  102660. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  102661. /**
  102662. * Draw a list of indexed primitives
  102663. * @param fillMode defines the primitive to use
  102664. * @param indexStart defines the starting index
  102665. * @param indexCount defines the number of index to draw
  102666. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102667. */
  102668. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  102669. /**
  102670. * Draw a list of unindexed primitives
  102671. * @param fillMode defines the primitive to use
  102672. * @param verticesStart defines the index of first vertex to draw
  102673. * @param verticesCount defines the count of vertices to draw
  102674. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  102675. */
  102676. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  102677. private _drawMode;
  102678. /** @hidden */
  102679. protected _reportDrawCall(): void;
  102680. /** @hidden */
  102681. _releaseEffect(effect: Effect): void;
  102682. /** @hidden */
  102683. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  102684. /**
  102685. * Create a new effect (used to store vertex/fragment shaders)
  102686. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  102687. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  102688. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  102689. * @param samplers defines an array of string used to represent textures
  102690. * @param defines defines the string containing the defines to use to compile the shaders
  102691. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  102692. * @param onCompiled defines a function to call when the effect creation is successful
  102693. * @param onError defines a function to call when the effect creation has failed
  102694. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  102695. * @returns the new Effect
  102696. */
  102697. 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;
  102698. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  102699. private _compileShader;
  102700. private _compileRawShader;
  102701. /**
  102702. * Directly creates a webGL program
  102703. * @param pipelineContext defines the pipeline context to attach to
  102704. * @param vertexCode defines the vertex shader code to use
  102705. * @param fragmentCode defines the fragment shader code to use
  102706. * @param context defines the webGL context to use (if not set, the current one will be used)
  102707. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  102708. * @returns the new webGL program
  102709. */
  102710. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102711. /**
  102712. * Creates a webGL program
  102713. * @param pipelineContext defines the pipeline context to attach to
  102714. * @param vertexCode defines the vertex shader code to use
  102715. * @param fragmentCode defines the fragment shader code to use
  102716. * @param defines defines the string containing the defines to use to compile the shaders
  102717. * @param context defines the webGL context to use (if not set, the current one will be used)
  102718. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  102719. * @returns the new webGL program
  102720. */
  102721. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102722. /**
  102723. * Creates a new pipeline context
  102724. * @returns the new pipeline
  102725. */
  102726. createPipelineContext(): IPipelineContext;
  102727. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  102728. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  102729. /** @hidden */
  102730. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  102731. /** @hidden */
  102732. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  102733. /** @hidden */
  102734. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  102735. /**
  102736. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  102737. * @param pipelineContext defines the pipeline context to use
  102738. * @param uniformsNames defines the list of uniform names
  102739. * @returns an array of webGL uniform locations
  102740. */
  102741. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  102742. /**
  102743. * Gets the lsit of active attributes for a given webGL program
  102744. * @param pipelineContext defines the pipeline context to use
  102745. * @param attributesNames defines the list of attribute names to get
  102746. * @returns an array of indices indicating the offset of each attribute
  102747. */
  102748. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  102749. /**
  102750. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  102751. * @param effect defines the effect to activate
  102752. */
  102753. enableEffect(effect: Nullable<Effect>): void;
  102754. /**
  102755. * Set the value of an uniform to a number (int)
  102756. * @param uniform defines the webGL uniform location where to store the value
  102757. * @param value defines the int number to store
  102758. */
  102759. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102760. /**
  102761. * Set the value of an uniform to an array of int32
  102762. * @param uniform defines the webGL uniform location where to store the value
  102763. * @param array defines the array of int32 to store
  102764. */
  102765. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102766. /**
  102767. * Set the value of an uniform to an array of int32 (stored as vec2)
  102768. * @param uniform defines the webGL uniform location where to store the value
  102769. * @param array defines the array of int32 to store
  102770. */
  102771. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102772. /**
  102773. * Set the value of an uniform to an array of int32 (stored as vec3)
  102774. * @param uniform defines the webGL uniform location where to store the value
  102775. * @param array defines the array of int32 to store
  102776. */
  102777. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102778. /**
  102779. * Set the value of an uniform to an array of int32 (stored as vec4)
  102780. * @param uniform defines the webGL uniform location where to store the value
  102781. * @param array defines the array of int32 to store
  102782. */
  102783. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  102784. /**
  102785. * Set the value of an uniform to an array of number
  102786. * @param uniform defines the webGL uniform location where to store the value
  102787. * @param array defines the array of number to store
  102788. */
  102789. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102790. /**
  102791. * Set the value of an uniform to an array of number (stored as vec2)
  102792. * @param uniform defines the webGL uniform location where to store the value
  102793. * @param array defines the array of number to store
  102794. */
  102795. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102796. /**
  102797. * Set the value of an uniform to an array of number (stored as vec3)
  102798. * @param uniform defines the webGL uniform location where to store the value
  102799. * @param array defines the array of number to store
  102800. */
  102801. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102802. /**
  102803. * Set the value of an uniform to an array of number (stored as vec4)
  102804. * @param uniform defines the webGL uniform location where to store the value
  102805. * @param array defines the array of number to store
  102806. */
  102807. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  102808. /**
  102809. * Set the value of an uniform to an array of float32 (stored as matrices)
  102810. * @param uniform defines the webGL uniform location where to store the value
  102811. * @param matrices defines the array of float32 to store
  102812. */
  102813. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  102814. /**
  102815. * Set the value of an uniform to a matrix (3x3)
  102816. * @param uniform defines the webGL uniform location where to store the value
  102817. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  102818. */
  102819. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102820. /**
  102821. * Set the value of an uniform to a matrix (2x2)
  102822. * @param uniform defines the webGL uniform location where to store the value
  102823. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  102824. */
  102825. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  102826. /**
  102827. * Set the value of an uniform to a number (float)
  102828. * @param uniform defines the webGL uniform location where to store the value
  102829. * @param value defines the float number to store
  102830. */
  102831. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  102832. /**
  102833. * Set the value of an uniform to a vec2
  102834. * @param uniform defines the webGL uniform location where to store the value
  102835. * @param x defines the 1st component of the value
  102836. * @param y defines the 2nd component of the value
  102837. */
  102838. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  102839. /**
  102840. * Set the value of an uniform to a vec3
  102841. * @param uniform defines the webGL uniform location where to store the value
  102842. * @param x defines the 1st component of the value
  102843. * @param y defines the 2nd component of the value
  102844. * @param z defines the 3rd component of the value
  102845. */
  102846. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  102847. /**
  102848. * Set the value of an uniform to a vec4
  102849. * @param uniform defines the webGL uniform location where to store the value
  102850. * @param x defines the 1st component of the value
  102851. * @param y defines the 2nd component of the value
  102852. * @param z defines the 3rd component of the value
  102853. * @param w defines the 4th component of the value
  102854. */
  102855. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  102856. /**
  102857. * Apply all cached states (depth, culling, stencil and alpha)
  102858. */
  102859. applyStates(): void;
  102860. /**
  102861. * Enable or disable color writing
  102862. * @param enable defines the state to set
  102863. */
  102864. setColorWrite(enable: boolean): void;
  102865. /**
  102866. * Gets a boolean indicating if color writing is enabled
  102867. * @returns the current color writing state
  102868. */
  102869. getColorWrite(): boolean;
  102870. /**
  102871. * Gets the depth culling state manager
  102872. */
  102873. get depthCullingState(): DepthCullingState;
  102874. /**
  102875. * Gets the alpha state manager
  102876. */
  102877. get alphaState(): AlphaState;
  102878. /**
  102879. * Gets the stencil state manager
  102880. */
  102881. get stencilState(): StencilState;
  102882. /**
  102883. * Clears the list of texture accessible through engine.
  102884. * This can help preventing texture load conflict due to name collision.
  102885. */
  102886. clearInternalTexturesCache(): void;
  102887. /**
  102888. * Force the entire cache to be cleared
  102889. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  102890. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  102891. */
  102892. wipeCaches(bruteForce?: boolean): void;
  102893. /** @hidden */
  102894. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  102895. min: number;
  102896. mag: number;
  102897. };
  102898. /** @hidden */
  102899. _createTexture(): WebGLTexture;
  102900. /**
  102901. * Usually called from Texture.ts.
  102902. * Passed information to create a WebGLTexture
  102903. * @param urlArg defines a value which contains one of the following:
  102904. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  102905. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  102906. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  102907. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  102908. * @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)
  102909. * @param scene needed for loading to the correct scene
  102910. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  102911. * @param onLoad optional callback to be called upon successful completion
  102912. * @param onError optional callback to be called upon failure
  102913. * @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
  102914. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  102915. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  102916. * @param forcedExtension defines the extension to use to pick the right loader
  102917. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  102918. * @param mimeType defines an optional mime type
  102919. * @returns a InternalTexture for assignment back into BABYLON.Texture
  102920. */
  102921. 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>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  102922. /**
  102923. * Loads an image as an HTMLImageElement.
  102924. * @param input url string, ArrayBuffer, or Blob to load
  102925. * @param onLoad callback called when the image successfully loads
  102926. * @param onError callback called when the image fails to load
  102927. * @param offlineProvider offline provider for caching
  102928. * @param mimeType optional mime type
  102929. * @returns the HTMLImageElement of the loaded image
  102930. * @hidden
  102931. */
  102932. 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>;
  102933. /**
  102934. * @hidden
  102935. */
  102936. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  102937. /**
  102938. * Creates a raw texture
  102939. * @param data defines the data to store in the texture
  102940. * @param width defines the width of the texture
  102941. * @param height defines the height of the texture
  102942. * @param format defines the format of the data
  102943. * @param generateMipMaps defines if the engine should generate the mip levels
  102944. * @param invertY defines if data must be stored with Y axis inverted
  102945. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  102946. * @param compression defines the compression used (null by default)
  102947. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102948. * @returns the raw texture inside an InternalTexture
  102949. */
  102950. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  102951. /**
  102952. * Creates a new raw cube texture
  102953. * @param data defines the array of data to use to create each face
  102954. * @param size defines the size of the textures
  102955. * @param format defines the format of the data
  102956. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102957. * @param generateMipMaps defines if the engine should generate the mip levels
  102958. * @param invertY defines if data must be stored with Y axis inverted
  102959. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102960. * @param compression defines the compression used (null by default)
  102961. * @returns the cube texture as an InternalTexture
  102962. */
  102963. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  102964. /**
  102965. * Creates a new raw 3D texture
  102966. * @param data defines the data used to create the texture
  102967. * @param width defines the width of the texture
  102968. * @param height defines the height of the texture
  102969. * @param depth defines the depth of the texture
  102970. * @param format defines the format of the texture
  102971. * @param generateMipMaps defines if the engine must generate mip levels
  102972. * @param invertY defines if data must be stored with Y axis inverted
  102973. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102974. * @param compression defines the compressed used (can be null)
  102975. * @param textureType defines the compressed used (can be null)
  102976. * @returns a new raw 3D texture (stored in an InternalTexture)
  102977. */
  102978. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102979. /**
  102980. * Creates a new raw 2D array texture
  102981. * @param data defines the data used to create the texture
  102982. * @param width defines the width of the texture
  102983. * @param height defines the height of the texture
  102984. * @param depth defines the number of layers of the texture
  102985. * @param format defines the format of the texture
  102986. * @param generateMipMaps defines if the engine must generate mip levels
  102987. * @param invertY defines if data must be stored with Y axis inverted
  102988. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102989. * @param compression defines the compressed used (can be null)
  102990. * @param textureType defines the compressed used (can be null)
  102991. * @returns a new raw 2D array texture (stored in an InternalTexture)
  102992. */
  102993. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  102994. private _unpackFlipYCached;
  102995. /**
  102996. * In case you are sharing the context with other applications, it might
  102997. * be interested to not cache the unpack flip y state to ensure a consistent
  102998. * value would be set.
  102999. */
  103000. enableUnpackFlipYCached: boolean;
  103001. /** @hidden */
  103002. _unpackFlipY(value: boolean): void;
  103003. /** @hidden */
  103004. _getUnpackAlignement(): number;
  103005. private _getTextureTarget;
  103006. /**
  103007. * Update the sampling mode of a given texture
  103008. * @param samplingMode defines the required sampling mode
  103009. * @param texture defines the texture to update
  103010. * @param generateMipMaps defines whether to generate mipmaps for the texture
  103011. */
  103012. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  103013. /**
  103014. * Update the sampling mode of a given texture
  103015. * @param texture defines the texture to update
  103016. * @param wrapU defines the texture wrap mode of the u coordinates
  103017. * @param wrapV defines the texture wrap mode of the v coordinates
  103018. * @param wrapR defines the texture wrap mode of the r coordinates
  103019. */
  103020. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  103021. /** @hidden */
  103022. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  103023. width: number;
  103024. height: number;
  103025. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  103026. /** @hidden */
  103027. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  103028. /** @hidden */
  103029. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  103030. /** @hidden */
  103031. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  103032. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  103033. private _prepareWebGLTexture;
  103034. /** @hidden */
  103035. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  103036. private _getDepthStencilBuffer;
  103037. /** @hidden */
  103038. _releaseFramebufferObjects(texture: InternalTexture): void;
  103039. /** @hidden */
  103040. _releaseTexture(texture: InternalTexture): void;
  103041. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  103042. protected _setProgram(program: WebGLProgram): void;
  103043. protected _boundUniforms: {
  103044. [key: number]: WebGLUniformLocation;
  103045. };
  103046. /**
  103047. * Binds an effect to the webGL context
  103048. * @param effect defines the effect to bind
  103049. */
  103050. bindSamplers(effect: Effect): void;
  103051. private _activateCurrentTexture;
  103052. /** @hidden */
  103053. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  103054. /** @hidden */
  103055. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  103056. /**
  103057. * Unbind all textures from the webGL context
  103058. */
  103059. unbindAllTextures(): void;
  103060. /**
  103061. * Sets a texture to the according uniform.
  103062. * @param channel The texture channel
  103063. * @param uniform The uniform to set
  103064. * @param texture The texture to apply
  103065. */
  103066. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  103067. private _bindSamplerUniformToChannel;
  103068. private _getTextureWrapMode;
  103069. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  103070. /**
  103071. * Sets an array of texture to the webGL context
  103072. * @param channel defines the channel where the texture array must be set
  103073. * @param uniform defines the associated uniform location
  103074. * @param textures defines the array of textures to bind
  103075. */
  103076. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  103077. /** @hidden */
  103078. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  103079. private _setTextureParameterFloat;
  103080. private _setTextureParameterInteger;
  103081. /**
  103082. * Unbind all vertex attributes from the webGL context
  103083. */
  103084. unbindAllAttributes(): void;
  103085. /**
  103086. * 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
  103087. */
  103088. releaseEffects(): void;
  103089. /**
  103090. * Dispose and release all associated resources
  103091. */
  103092. dispose(): void;
  103093. /**
  103094. * Attach a new callback raised when context lost event is fired
  103095. * @param callback defines the callback to call
  103096. */
  103097. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  103098. /**
  103099. * Attach a new callback raised when context restored event is fired
  103100. * @param callback defines the callback to call
  103101. */
  103102. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  103103. /**
  103104. * Get the current error code of the webGL context
  103105. * @returns the error code
  103106. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  103107. */
  103108. getError(): number;
  103109. private _canRenderToFloatFramebuffer;
  103110. private _canRenderToHalfFloatFramebuffer;
  103111. private _canRenderToFramebuffer;
  103112. /** @hidden */
  103113. _getWebGLTextureType(type: number): number;
  103114. /** @hidden */
  103115. _getInternalFormat(format: number): number;
  103116. /** @hidden */
  103117. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  103118. /** @hidden */
  103119. _getRGBAMultiSampleBufferFormat(type: number): number;
  103120. /** @hidden */
  103121. _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;
  103122. /**
  103123. * Loads a file from a url
  103124. * @param url url to load
  103125. * @param onSuccess callback called when the file successfully loads
  103126. * @param onProgress callback called while file is loading (if the server supports this mode)
  103127. * @param offlineProvider defines the offline provider for caching
  103128. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  103129. * @param onError callback called when the file fails to load
  103130. * @returns a file request object
  103131. * @hidden
  103132. */
  103133. 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;
  103134. /**
  103135. * Reads pixels from the current frame buffer. Please note that this function can be slow
  103136. * @param x defines the x coordinate of the rectangle where pixels must be read
  103137. * @param y defines the y coordinate of the rectangle where pixels must be read
  103138. * @param width defines the width of the rectangle where pixels must be read
  103139. * @param height defines the height of the rectangle where pixels must be read
  103140. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  103141. * @returns a Uint8Array containing RGBA colors
  103142. */
  103143. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  103144. private static _isSupported;
  103145. /**
  103146. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  103147. * @returns true if the engine can be created
  103148. * @ignorenaming
  103149. */
  103150. static isSupported(): boolean;
  103151. /**
  103152. * Find the next highest power of two.
  103153. * @param x Number to start search from.
  103154. * @return Next highest power of two.
  103155. */
  103156. static CeilingPOT(x: number): number;
  103157. /**
  103158. * Find the next lowest power of two.
  103159. * @param x Number to start search from.
  103160. * @return Next lowest power of two.
  103161. */
  103162. static FloorPOT(x: number): number;
  103163. /**
  103164. * Find the nearest power of two.
  103165. * @param x Number to start search from.
  103166. * @return Next nearest power of two.
  103167. */
  103168. static NearestPOT(x: number): number;
  103169. /**
  103170. * Get the closest exponent of two
  103171. * @param value defines the value to approximate
  103172. * @param max defines the maximum value to return
  103173. * @param mode defines how to define the closest value
  103174. * @returns closest exponent of two of the given value
  103175. */
  103176. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  103177. /**
  103178. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  103179. * @param func - the function to be called
  103180. * @param requester - the object that will request the next frame. Falls back to window.
  103181. * @returns frame number
  103182. */
  103183. static QueueNewFrame(func: () => void, requester?: any): number;
  103184. /**
  103185. * Gets host document
  103186. * @returns the host document object
  103187. */
  103188. getHostDocument(): Nullable<Document>;
  103189. }
  103190. }
  103191. declare module BABYLON {
  103192. /**
  103193. * Class representing spherical harmonics coefficients to the 3rd degree
  103194. */
  103195. export class SphericalHarmonics {
  103196. /**
  103197. * Defines whether or not the harmonics have been prescaled for rendering.
  103198. */
  103199. preScaled: boolean;
  103200. /**
  103201. * The l0,0 coefficients of the spherical harmonics
  103202. */
  103203. l00: Vector3;
  103204. /**
  103205. * The l1,-1 coefficients of the spherical harmonics
  103206. */
  103207. l1_1: Vector3;
  103208. /**
  103209. * The l1,0 coefficients of the spherical harmonics
  103210. */
  103211. l10: Vector3;
  103212. /**
  103213. * The l1,1 coefficients of the spherical harmonics
  103214. */
  103215. l11: Vector3;
  103216. /**
  103217. * The l2,-2 coefficients of the spherical harmonics
  103218. */
  103219. l2_2: Vector3;
  103220. /**
  103221. * The l2,-1 coefficients of the spherical harmonics
  103222. */
  103223. l2_1: Vector3;
  103224. /**
  103225. * The l2,0 coefficients of the spherical harmonics
  103226. */
  103227. l20: Vector3;
  103228. /**
  103229. * The l2,1 coefficients of the spherical harmonics
  103230. */
  103231. l21: Vector3;
  103232. /**
  103233. * The l2,2 coefficients of the spherical harmonics
  103234. */
  103235. l22: Vector3;
  103236. /**
  103237. * Adds a light to the spherical harmonics
  103238. * @param direction the direction of the light
  103239. * @param color the color of the light
  103240. * @param deltaSolidAngle the delta solid angle of the light
  103241. */
  103242. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  103243. /**
  103244. * Scales the spherical harmonics by the given amount
  103245. * @param scale the amount to scale
  103246. */
  103247. scaleInPlace(scale: number): void;
  103248. /**
  103249. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  103250. *
  103251. * ```
  103252. * E_lm = A_l * L_lm
  103253. * ```
  103254. *
  103255. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  103256. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  103257. * the scaling factors are given in equation 9.
  103258. */
  103259. convertIncidentRadianceToIrradiance(): void;
  103260. /**
  103261. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  103262. *
  103263. * ```
  103264. * L = (1/pi) * E * rho
  103265. * ```
  103266. *
  103267. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  103268. */
  103269. convertIrradianceToLambertianRadiance(): void;
  103270. /**
  103271. * Integrates the reconstruction coefficients directly in to the SH preventing further
  103272. * required operations at run time.
  103273. *
  103274. * This is simply done by scaling back the SH with Ylm constants parameter.
  103275. * The trigonometric part being applied by the shader at run time.
  103276. */
  103277. preScaleForRendering(): void;
  103278. /**
  103279. * Constructs a spherical harmonics from an array.
  103280. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  103281. * @returns the spherical harmonics
  103282. */
  103283. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  103284. /**
  103285. * Gets the spherical harmonics from polynomial
  103286. * @param polynomial the spherical polynomial
  103287. * @returns the spherical harmonics
  103288. */
  103289. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  103290. }
  103291. /**
  103292. * Class representing spherical polynomial coefficients to the 3rd degree
  103293. */
  103294. export class SphericalPolynomial {
  103295. private _harmonics;
  103296. /**
  103297. * The spherical harmonics used to create the polynomials.
  103298. */
  103299. get preScaledHarmonics(): SphericalHarmonics;
  103300. /**
  103301. * The x coefficients of the spherical polynomial
  103302. */
  103303. x: Vector3;
  103304. /**
  103305. * The y coefficients of the spherical polynomial
  103306. */
  103307. y: Vector3;
  103308. /**
  103309. * The z coefficients of the spherical polynomial
  103310. */
  103311. z: Vector3;
  103312. /**
  103313. * The xx coefficients of the spherical polynomial
  103314. */
  103315. xx: Vector3;
  103316. /**
  103317. * The yy coefficients of the spherical polynomial
  103318. */
  103319. yy: Vector3;
  103320. /**
  103321. * The zz coefficients of the spherical polynomial
  103322. */
  103323. zz: Vector3;
  103324. /**
  103325. * The xy coefficients of the spherical polynomial
  103326. */
  103327. xy: Vector3;
  103328. /**
  103329. * The yz coefficients of the spherical polynomial
  103330. */
  103331. yz: Vector3;
  103332. /**
  103333. * The zx coefficients of the spherical polynomial
  103334. */
  103335. zx: Vector3;
  103336. /**
  103337. * Adds an ambient color to the spherical polynomial
  103338. * @param color the color to add
  103339. */
  103340. addAmbient(color: Color3): void;
  103341. /**
  103342. * Scales the spherical polynomial by the given amount
  103343. * @param scale the amount to scale
  103344. */
  103345. scaleInPlace(scale: number): void;
  103346. /**
  103347. * Gets the spherical polynomial from harmonics
  103348. * @param harmonics the spherical harmonics
  103349. * @returns the spherical polynomial
  103350. */
  103351. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  103352. /**
  103353. * Constructs a spherical polynomial from an array.
  103354. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  103355. * @returns the spherical polynomial
  103356. */
  103357. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  103358. }
  103359. }
  103360. declare module BABYLON {
  103361. /**
  103362. * Defines the source of the internal texture
  103363. */
  103364. export enum InternalTextureSource {
  103365. /**
  103366. * The source of the texture data is unknown
  103367. */
  103368. Unknown = 0,
  103369. /**
  103370. * Texture data comes from an URL
  103371. */
  103372. Url = 1,
  103373. /**
  103374. * Texture data is only used for temporary storage
  103375. */
  103376. Temp = 2,
  103377. /**
  103378. * Texture data comes from raw data (ArrayBuffer)
  103379. */
  103380. Raw = 3,
  103381. /**
  103382. * Texture content is dynamic (video or dynamic texture)
  103383. */
  103384. Dynamic = 4,
  103385. /**
  103386. * Texture content is generated by rendering to it
  103387. */
  103388. RenderTarget = 5,
  103389. /**
  103390. * Texture content is part of a multi render target process
  103391. */
  103392. MultiRenderTarget = 6,
  103393. /**
  103394. * Texture data comes from a cube data file
  103395. */
  103396. Cube = 7,
  103397. /**
  103398. * Texture data comes from a raw cube data
  103399. */
  103400. CubeRaw = 8,
  103401. /**
  103402. * Texture data come from a prefiltered cube data file
  103403. */
  103404. CubePrefiltered = 9,
  103405. /**
  103406. * Texture content is raw 3D data
  103407. */
  103408. Raw3D = 10,
  103409. /**
  103410. * Texture content is raw 2D array data
  103411. */
  103412. Raw2DArray = 11,
  103413. /**
  103414. * Texture content is a depth texture
  103415. */
  103416. Depth = 12,
  103417. /**
  103418. * Texture data comes from a raw cube data encoded with RGBD
  103419. */
  103420. CubeRawRGBD = 13
  103421. }
  103422. /**
  103423. * Class used to store data associated with WebGL texture data for the engine
  103424. * This class should not be used directly
  103425. */
  103426. export class InternalTexture {
  103427. /** @hidden */
  103428. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  103429. /**
  103430. * Defines if the texture is ready
  103431. */
  103432. isReady: boolean;
  103433. /**
  103434. * Defines if the texture is a cube texture
  103435. */
  103436. isCube: boolean;
  103437. /**
  103438. * Defines if the texture contains 3D data
  103439. */
  103440. is3D: boolean;
  103441. /**
  103442. * Defines if the texture contains 2D array data
  103443. */
  103444. is2DArray: boolean;
  103445. /**
  103446. * Defines if the texture contains multiview data
  103447. */
  103448. isMultiview: boolean;
  103449. /**
  103450. * Gets the URL used to load this texture
  103451. */
  103452. url: string;
  103453. /**
  103454. * Gets the sampling mode of the texture
  103455. */
  103456. samplingMode: number;
  103457. /**
  103458. * Gets a boolean indicating if the texture needs mipmaps generation
  103459. */
  103460. generateMipMaps: boolean;
  103461. /**
  103462. * Gets the number of samples used by the texture (WebGL2+ only)
  103463. */
  103464. samples: number;
  103465. /**
  103466. * Gets the type of the texture (int, float...)
  103467. */
  103468. type: number;
  103469. /**
  103470. * Gets the format of the texture (RGB, RGBA...)
  103471. */
  103472. format: number;
  103473. /**
  103474. * Observable called when the texture is loaded
  103475. */
  103476. onLoadedObservable: Observable<InternalTexture>;
  103477. /**
  103478. * Gets the width of the texture
  103479. */
  103480. width: number;
  103481. /**
  103482. * Gets the height of the texture
  103483. */
  103484. height: number;
  103485. /**
  103486. * Gets the depth of the texture
  103487. */
  103488. depth: number;
  103489. /**
  103490. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  103491. */
  103492. baseWidth: number;
  103493. /**
  103494. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  103495. */
  103496. baseHeight: number;
  103497. /**
  103498. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  103499. */
  103500. baseDepth: number;
  103501. /**
  103502. * Gets a boolean indicating if the texture is inverted on Y axis
  103503. */
  103504. invertY: boolean;
  103505. /** @hidden */
  103506. _invertVScale: boolean;
  103507. /** @hidden */
  103508. _associatedChannel: number;
  103509. /** @hidden */
  103510. _source: InternalTextureSource;
  103511. /** @hidden */
  103512. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103513. /** @hidden */
  103514. _bufferView: Nullable<ArrayBufferView>;
  103515. /** @hidden */
  103516. _bufferViewArray: Nullable<ArrayBufferView[]>;
  103517. /** @hidden */
  103518. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  103519. /** @hidden */
  103520. _size: number;
  103521. /** @hidden */
  103522. _extension: string;
  103523. /** @hidden */
  103524. _files: Nullable<string[]>;
  103525. /** @hidden */
  103526. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  103527. /** @hidden */
  103528. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  103529. /** @hidden */
  103530. _framebuffer: Nullable<WebGLFramebuffer>;
  103531. /** @hidden */
  103532. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  103533. /** @hidden */
  103534. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  103535. /** @hidden */
  103536. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  103537. /** @hidden */
  103538. _attachments: Nullable<number[]>;
  103539. /** @hidden */
  103540. _cachedCoordinatesMode: Nullable<number>;
  103541. /** @hidden */
  103542. _cachedWrapU: Nullable<number>;
  103543. /** @hidden */
  103544. _cachedWrapV: Nullable<number>;
  103545. /** @hidden */
  103546. _cachedWrapR: Nullable<number>;
  103547. /** @hidden */
  103548. _cachedAnisotropicFilteringLevel: Nullable<number>;
  103549. /** @hidden */
  103550. _isDisabled: boolean;
  103551. /** @hidden */
  103552. _compression: Nullable<string>;
  103553. /** @hidden */
  103554. _generateStencilBuffer: boolean;
  103555. /** @hidden */
  103556. _generateDepthBuffer: boolean;
  103557. /** @hidden */
  103558. _comparisonFunction: number;
  103559. /** @hidden */
  103560. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  103561. /** @hidden */
  103562. _lodGenerationScale: number;
  103563. /** @hidden */
  103564. _lodGenerationOffset: number;
  103565. /** @hidden */
  103566. _colorTextureArray: Nullable<WebGLTexture>;
  103567. /** @hidden */
  103568. _depthStencilTextureArray: Nullable<WebGLTexture>;
  103569. /** @hidden */
  103570. _lodTextureHigh: Nullable<BaseTexture>;
  103571. /** @hidden */
  103572. _lodTextureMid: Nullable<BaseTexture>;
  103573. /** @hidden */
  103574. _lodTextureLow: Nullable<BaseTexture>;
  103575. /** @hidden */
  103576. _isRGBD: boolean;
  103577. /** @hidden */
  103578. _linearSpecularLOD: boolean;
  103579. /** @hidden */
  103580. _irradianceTexture: Nullable<BaseTexture>;
  103581. /** @hidden */
  103582. _webGLTexture: Nullable<WebGLTexture>;
  103583. /** @hidden */
  103584. _references: number;
  103585. private _engine;
  103586. /**
  103587. * Gets the Engine the texture belongs to.
  103588. * @returns The babylon engine
  103589. */
  103590. getEngine(): ThinEngine;
  103591. /**
  103592. * Gets the data source type of the texture
  103593. */
  103594. get source(): InternalTextureSource;
  103595. /**
  103596. * Creates a new InternalTexture
  103597. * @param engine defines the engine to use
  103598. * @param source defines the type of data that will be used
  103599. * @param delayAllocation if the texture allocation should be delayed (default: false)
  103600. */
  103601. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  103602. /**
  103603. * Increments the number of references (ie. the number of Texture that point to it)
  103604. */
  103605. incrementReferences(): void;
  103606. /**
  103607. * Change the size of the texture (not the size of the content)
  103608. * @param width defines the new width
  103609. * @param height defines the new height
  103610. * @param depth defines the new depth (1 by default)
  103611. */
  103612. updateSize(width: int, height: int, depth?: int): void;
  103613. /** @hidden */
  103614. _rebuild(): void;
  103615. /** @hidden */
  103616. _swapAndDie(target: InternalTexture): void;
  103617. /**
  103618. * Dispose the current allocated resources
  103619. */
  103620. dispose(): void;
  103621. }
  103622. }
  103623. declare module BABYLON {
  103624. /**
  103625. * Class used to work with sound analyzer using fast fourier transform (FFT)
  103626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103627. */
  103628. export class Analyser {
  103629. /**
  103630. * Gets or sets the smoothing
  103631. * @ignorenaming
  103632. */
  103633. SMOOTHING: number;
  103634. /**
  103635. * Gets or sets the FFT table size
  103636. * @ignorenaming
  103637. */
  103638. FFT_SIZE: number;
  103639. /**
  103640. * Gets or sets the bar graph amplitude
  103641. * @ignorenaming
  103642. */
  103643. BARGRAPHAMPLITUDE: number;
  103644. /**
  103645. * Gets or sets the position of the debug canvas
  103646. * @ignorenaming
  103647. */
  103648. DEBUGCANVASPOS: {
  103649. x: number;
  103650. y: number;
  103651. };
  103652. /**
  103653. * Gets or sets the debug canvas size
  103654. * @ignorenaming
  103655. */
  103656. DEBUGCANVASSIZE: {
  103657. width: number;
  103658. height: number;
  103659. };
  103660. private _byteFreqs;
  103661. private _byteTime;
  103662. private _floatFreqs;
  103663. private _webAudioAnalyser;
  103664. private _debugCanvas;
  103665. private _debugCanvasContext;
  103666. private _scene;
  103667. private _registerFunc;
  103668. private _audioEngine;
  103669. /**
  103670. * Creates a new analyser
  103671. * @param scene defines hosting scene
  103672. */
  103673. constructor(scene: Scene);
  103674. /**
  103675. * Get the number of data values you will have to play with for the visualization
  103676. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  103677. * @returns a number
  103678. */
  103679. getFrequencyBinCount(): number;
  103680. /**
  103681. * Gets the current frequency data as a byte array
  103682. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  103683. * @returns a Uint8Array
  103684. */
  103685. getByteFrequencyData(): Uint8Array;
  103686. /**
  103687. * Gets the current waveform as a byte array
  103688. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  103689. * @returns a Uint8Array
  103690. */
  103691. getByteTimeDomainData(): Uint8Array;
  103692. /**
  103693. * Gets the current frequency data as a float array
  103694. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  103695. * @returns a Float32Array
  103696. */
  103697. getFloatFrequencyData(): Float32Array;
  103698. /**
  103699. * Renders the debug canvas
  103700. */
  103701. drawDebugCanvas(): void;
  103702. /**
  103703. * Stops rendering the debug canvas and removes it
  103704. */
  103705. stopDebugCanvas(): void;
  103706. /**
  103707. * Connects two audio nodes
  103708. * @param inputAudioNode defines first node to connect
  103709. * @param outputAudioNode defines second node to connect
  103710. */
  103711. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  103712. /**
  103713. * Releases all associated resources
  103714. */
  103715. dispose(): void;
  103716. }
  103717. }
  103718. declare module BABYLON {
  103719. /**
  103720. * This represents an audio engine and it is responsible
  103721. * to play, synchronize and analyse sounds throughout the application.
  103722. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103723. */
  103724. export interface IAudioEngine extends IDisposable {
  103725. /**
  103726. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  103727. */
  103728. readonly canUseWebAudio: boolean;
  103729. /**
  103730. * Gets the current AudioContext if available.
  103731. */
  103732. readonly audioContext: Nullable<AudioContext>;
  103733. /**
  103734. * The master gain node defines the global audio volume of your audio engine.
  103735. */
  103736. readonly masterGain: GainNode;
  103737. /**
  103738. * Gets whether or not mp3 are supported by your browser.
  103739. */
  103740. readonly isMP3supported: boolean;
  103741. /**
  103742. * Gets whether or not ogg are supported by your browser.
  103743. */
  103744. readonly isOGGsupported: boolean;
  103745. /**
  103746. * Defines if Babylon should emit a warning if WebAudio is not supported.
  103747. * @ignoreNaming
  103748. */
  103749. WarnedWebAudioUnsupported: boolean;
  103750. /**
  103751. * Defines if the audio engine relies on a custom unlocked button.
  103752. * In this case, the embedded button will not be displayed.
  103753. */
  103754. useCustomUnlockedButton: boolean;
  103755. /**
  103756. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  103757. */
  103758. readonly unlocked: boolean;
  103759. /**
  103760. * Event raised when audio has been unlocked on the browser.
  103761. */
  103762. onAudioUnlockedObservable: Observable<AudioEngine>;
  103763. /**
  103764. * Event raised when audio has been locked on the browser.
  103765. */
  103766. onAudioLockedObservable: Observable<AudioEngine>;
  103767. /**
  103768. * Flags the audio engine in Locked state.
  103769. * This happens due to new browser policies preventing audio to autoplay.
  103770. */
  103771. lock(): void;
  103772. /**
  103773. * Unlocks the audio engine once a user action has been done on the dom.
  103774. * This is helpful to resume play once browser policies have been satisfied.
  103775. */
  103776. unlock(): void;
  103777. }
  103778. /**
  103779. * This represents the default audio engine used in babylon.
  103780. * It is responsible to play, synchronize and analyse sounds throughout the application.
  103781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  103782. */
  103783. export class AudioEngine implements IAudioEngine {
  103784. private _audioContext;
  103785. private _audioContextInitialized;
  103786. private _muteButton;
  103787. private _hostElement;
  103788. /**
  103789. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  103790. */
  103791. canUseWebAudio: boolean;
  103792. /**
  103793. * The master gain node defines the global audio volume of your audio engine.
  103794. */
  103795. masterGain: GainNode;
  103796. /**
  103797. * Defines if Babylon should emit a warning if WebAudio is not supported.
  103798. * @ignoreNaming
  103799. */
  103800. WarnedWebAudioUnsupported: boolean;
  103801. /**
  103802. * Gets whether or not mp3 are supported by your browser.
  103803. */
  103804. isMP3supported: boolean;
  103805. /**
  103806. * Gets whether or not ogg are supported by your browser.
  103807. */
  103808. isOGGsupported: boolean;
  103809. /**
  103810. * Gets whether audio has been unlocked on the device.
  103811. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  103812. * a user interaction has happened.
  103813. */
  103814. unlocked: boolean;
  103815. /**
  103816. * Defines if the audio engine relies on a custom unlocked button.
  103817. * In this case, the embedded button will not be displayed.
  103818. */
  103819. useCustomUnlockedButton: boolean;
  103820. /**
  103821. * Event raised when audio has been unlocked on the browser.
  103822. */
  103823. onAudioUnlockedObservable: Observable<AudioEngine>;
  103824. /**
  103825. * Event raised when audio has been locked on the browser.
  103826. */
  103827. onAudioLockedObservable: Observable<AudioEngine>;
  103828. /**
  103829. * Gets the current AudioContext if available.
  103830. */
  103831. get audioContext(): Nullable<AudioContext>;
  103832. private _connectedAnalyser;
  103833. /**
  103834. * Instantiates a new audio engine.
  103835. *
  103836. * There should be only one per page as some browsers restrict the number
  103837. * of audio contexts you can create.
  103838. * @param hostElement defines the host element where to display the mute icon if necessary
  103839. */
  103840. constructor(hostElement?: Nullable<HTMLElement>);
  103841. /**
  103842. * Flags the audio engine in Locked state.
  103843. * This happens due to new browser policies preventing audio to autoplay.
  103844. */
  103845. lock(): void;
  103846. /**
  103847. * Unlocks the audio engine once a user action has been done on the dom.
  103848. * This is helpful to resume play once browser policies have been satisfied.
  103849. */
  103850. unlock(): void;
  103851. private _resumeAudioContext;
  103852. private _initializeAudioContext;
  103853. private _tryToRun;
  103854. private _triggerRunningState;
  103855. private _triggerSuspendedState;
  103856. private _displayMuteButton;
  103857. private _moveButtonToTopLeft;
  103858. private _onResize;
  103859. private _hideMuteButton;
  103860. /**
  103861. * Destroy and release the resources associated with the audio ccontext.
  103862. */
  103863. dispose(): void;
  103864. /**
  103865. * Gets the global volume sets on the master gain.
  103866. * @returns the global volume if set or -1 otherwise
  103867. */
  103868. getGlobalVolume(): number;
  103869. /**
  103870. * Sets the global volume of your experience (sets on the master gain).
  103871. * @param newVolume Defines the new global volume of the application
  103872. */
  103873. setGlobalVolume(newVolume: number): void;
  103874. /**
  103875. * Connect the audio engine to an audio analyser allowing some amazing
  103876. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  103877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  103878. * @param analyser The analyser to connect to the engine
  103879. */
  103880. connectToAnalyser(analyser: Analyser): void;
  103881. }
  103882. }
  103883. declare module BABYLON {
  103884. /**
  103885. * Interface used to present a loading screen while loading a scene
  103886. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103887. */
  103888. export interface ILoadingScreen {
  103889. /**
  103890. * Function called to display the loading screen
  103891. */
  103892. displayLoadingUI: () => void;
  103893. /**
  103894. * Function called to hide the loading screen
  103895. */
  103896. hideLoadingUI: () => void;
  103897. /**
  103898. * Gets or sets the color to use for the background
  103899. */
  103900. loadingUIBackgroundColor: string;
  103901. /**
  103902. * Gets or sets the text to display while loading
  103903. */
  103904. loadingUIText: string;
  103905. }
  103906. /**
  103907. * Class used for the default loading screen
  103908. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  103909. */
  103910. export class DefaultLoadingScreen implements ILoadingScreen {
  103911. private _renderingCanvas;
  103912. private _loadingText;
  103913. private _loadingDivBackgroundColor;
  103914. private _loadingDiv;
  103915. private _loadingTextDiv;
  103916. /** Gets or sets the logo url to use for the default loading screen */
  103917. static DefaultLogoUrl: string;
  103918. /** Gets or sets the spinner url to use for the default loading screen */
  103919. static DefaultSpinnerUrl: string;
  103920. /**
  103921. * Creates a new default loading screen
  103922. * @param _renderingCanvas defines the canvas used to render the scene
  103923. * @param _loadingText defines the default text to display
  103924. * @param _loadingDivBackgroundColor defines the default background color
  103925. */
  103926. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  103927. /**
  103928. * Function called to display the loading screen
  103929. */
  103930. displayLoadingUI(): void;
  103931. /**
  103932. * Function called to hide the loading screen
  103933. */
  103934. hideLoadingUI(): void;
  103935. /**
  103936. * Gets or sets the text to display while loading
  103937. */
  103938. set loadingUIText(text: string);
  103939. get loadingUIText(): string;
  103940. /**
  103941. * Gets or sets the color to use for the background
  103942. */
  103943. get loadingUIBackgroundColor(): string;
  103944. set loadingUIBackgroundColor(color: string);
  103945. private _resizeLoadingUI;
  103946. }
  103947. }
  103948. declare module BABYLON {
  103949. /**
  103950. * Interface for any object that can request an animation frame
  103951. */
  103952. export interface ICustomAnimationFrameRequester {
  103953. /**
  103954. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  103955. */
  103956. renderFunction?: Function;
  103957. /**
  103958. * Called to request the next frame to render to
  103959. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  103960. */
  103961. requestAnimationFrame: Function;
  103962. /**
  103963. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  103964. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  103965. */
  103966. requestID?: number;
  103967. }
  103968. }
  103969. declare module BABYLON {
  103970. /**
  103971. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  103972. */
  103973. export class PerformanceMonitor {
  103974. private _enabled;
  103975. private _rollingFrameTime;
  103976. private _lastFrameTimeMs;
  103977. /**
  103978. * constructor
  103979. * @param frameSampleSize The number of samples required to saturate the sliding window
  103980. */
  103981. constructor(frameSampleSize?: number);
  103982. /**
  103983. * Samples current frame
  103984. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  103985. */
  103986. sampleFrame(timeMs?: number): void;
  103987. /**
  103988. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103989. */
  103990. get averageFrameTime(): number;
  103991. /**
  103992. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  103993. */
  103994. get averageFrameTimeVariance(): number;
  103995. /**
  103996. * Returns the frame time of the most recent frame
  103997. */
  103998. get instantaneousFrameTime(): number;
  103999. /**
  104000. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  104001. */
  104002. get averageFPS(): number;
  104003. /**
  104004. * Returns the average framerate in frames per second using the most recent frame time
  104005. */
  104006. get instantaneousFPS(): number;
  104007. /**
  104008. * Returns true if enough samples have been taken to completely fill the sliding window
  104009. */
  104010. get isSaturated(): boolean;
  104011. /**
  104012. * Enables contributions to the sliding window sample set
  104013. */
  104014. enable(): void;
  104015. /**
  104016. * Disables contributions to the sliding window sample set
  104017. * Samples will not be interpolated over the disabled period
  104018. */
  104019. disable(): void;
  104020. /**
  104021. * Returns true if sampling is enabled
  104022. */
  104023. get isEnabled(): boolean;
  104024. /**
  104025. * Resets performance monitor
  104026. */
  104027. reset(): void;
  104028. }
  104029. /**
  104030. * RollingAverage
  104031. *
  104032. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  104033. */
  104034. export class RollingAverage {
  104035. /**
  104036. * Current average
  104037. */
  104038. average: number;
  104039. /**
  104040. * Current variance
  104041. */
  104042. variance: number;
  104043. protected _samples: Array<number>;
  104044. protected _sampleCount: number;
  104045. protected _pos: number;
  104046. protected _m2: number;
  104047. /**
  104048. * constructor
  104049. * @param length The number of samples required to saturate the sliding window
  104050. */
  104051. constructor(length: number);
  104052. /**
  104053. * Adds a sample to the sample set
  104054. * @param v The sample value
  104055. */
  104056. add(v: number): void;
  104057. /**
  104058. * Returns previously added values or null if outside of history or outside the sliding window domain
  104059. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  104060. * @return Value previously recorded with add() or null if outside of range
  104061. */
  104062. history(i: number): number;
  104063. /**
  104064. * Returns true if enough samples have been taken to completely fill the sliding window
  104065. * @return true if sample-set saturated
  104066. */
  104067. isSaturated(): boolean;
  104068. /**
  104069. * Resets the rolling average (equivalent to 0 samples taken so far)
  104070. */
  104071. reset(): void;
  104072. /**
  104073. * Wraps a value around the sample range boundaries
  104074. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  104075. * @return Wrapped position in sample range
  104076. */
  104077. protected _wrapPosition(i: number): number;
  104078. }
  104079. }
  104080. declare module BABYLON {
  104081. /**
  104082. * This class is used to track a performance counter which is number based.
  104083. * The user has access to many properties which give statistics of different nature.
  104084. *
  104085. * The implementer can track two kinds of Performance Counter: time and count.
  104086. * 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.
  104087. * 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.
  104088. */
  104089. export class PerfCounter {
  104090. /**
  104091. * Gets or sets a global boolean to turn on and off all the counters
  104092. */
  104093. static Enabled: boolean;
  104094. /**
  104095. * Returns the smallest value ever
  104096. */
  104097. get min(): number;
  104098. /**
  104099. * Returns the biggest value ever
  104100. */
  104101. get max(): number;
  104102. /**
  104103. * Returns the average value since the performance counter is running
  104104. */
  104105. get average(): number;
  104106. /**
  104107. * Returns the average value of the last second the counter was monitored
  104108. */
  104109. get lastSecAverage(): number;
  104110. /**
  104111. * Returns the current value
  104112. */
  104113. get current(): number;
  104114. /**
  104115. * Gets the accumulated total
  104116. */
  104117. get total(): number;
  104118. /**
  104119. * Gets the total value count
  104120. */
  104121. get count(): number;
  104122. /**
  104123. * Creates a new counter
  104124. */
  104125. constructor();
  104126. /**
  104127. * Call this method to start monitoring a new frame.
  104128. * 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.
  104129. */
  104130. fetchNewFrame(): void;
  104131. /**
  104132. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  104133. * @param newCount the count value to add to the monitored count
  104134. * @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.
  104135. */
  104136. addCount(newCount: number, fetchResult: boolean): void;
  104137. /**
  104138. * Start monitoring this performance counter
  104139. */
  104140. beginMonitoring(): void;
  104141. /**
  104142. * Compute the time lapsed since the previous beginMonitoring() call.
  104143. * @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
  104144. */
  104145. endMonitoring(newFrame?: boolean): void;
  104146. private _fetchResult;
  104147. private _startMonitoringTime;
  104148. private _min;
  104149. private _max;
  104150. private _average;
  104151. private _current;
  104152. private _totalValueCount;
  104153. private _totalAccumulated;
  104154. private _lastSecAverage;
  104155. private _lastSecAccumulated;
  104156. private _lastSecTime;
  104157. private _lastSecValueCount;
  104158. }
  104159. }
  104160. declare module BABYLON {
  104161. interface ThinEngine {
  104162. /**
  104163. * Sets alpha constants used by some alpha blending modes
  104164. * @param r defines the red component
  104165. * @param g defines the green component
  104166. * @param b defines the blue component
  104167. * @param a defines the alpha component
  104168. */
  104169. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  104170. /**
  104171. * Sets the current alpha mode
  104172. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  104173. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  104174. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  104175. */
  104176. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104177. /**
  104178. * Gets the current alpha mode
  104179. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  104180. * @returns the current alpha mode
  104181. */
  104182. getAlphaMode(): number;
  104183. /**
  104184. * Sets the current alpha equation
  104185. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  104186. */
  104187. setAlphaEquation(equation: number): void;
  104188. /**
  104189. * Gets the current alpha equation.
  104190. * @returns the current alpha equation
  104191. */
  104192. getAlphaEquation(): number;
  104193. }
  104194. }
  104195. declare module BABYLON {
  104196. /**
  104197. * Defines the interface used by display changed events
  104198. */
  104199. export interface IDisplayChangedEventArgs {
  104200. /** Gets the vrDisplay object (if any) */
  104201. vrDisplay: Nullable<any>;
  104202. /** Gets a boolean indicating if webVR is supported */
  104203. vrSupported: boolean;
  104204. }
  104205. /**
  104206. * Defines the interface used by objects containing a viewport (like a camera)
  104207. */
  104208. interface IViewportOwnerLike {
  104209. /**
  104210. * Gets or sets the viewport
  104211. */
  104212. viewport: IViewportLike;
  104213. }
  104214. /**
  104215. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  104216. */
  104217. export class Engine extends ThinEngine {
  104218. /** Defines that alpha blending is disabled */
  104219. static readonly ALPHA_DISABLE: number;
  104220. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  104221. static readonly ALPHA_ADD: number;
  104222. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  104223. static readonly ALPHA_COMBINE: number;
  104224. /** Defines that alpha blending to DEST - SRC * DEST */
  104225. static readonly ALPHA_SUBTRACT: number;
  104226. /** Defines that alpha blending to SRC * DEST */
  104227. static readonly ALPHA_MULTIPLY: number;
  104228. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  104229. static readonly ALPHA_MAXIMIZED: number;
  104230. /** Defines that alpha blending to SRC + DEST */
  104231. static readonly ALPHA_ONEONE: number;
  104232. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  104233. static readonly ALPHA_PREMULTIPLIED: number;
  104234. /**
  104235. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  104236. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  104237. */
  104238. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  104239. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  104240. static readonly ALPHA_INTERPOLATE: number;
  104241. /**
  104242. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  104243. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  104244. */
  104245. static readonly ALPHA_SCREENMODE: number;
  104246. /** Defines that the ressource is not delayed*/
  104247. static readonly DELAYLOADSTATE_NONE: number;
  104248. /** Defines that the ressource was successfully delay loaded */
  104249. static readonly DELAYLOADSTATE_LOADED: number;
  104250. /** Defines that the ressource is currently delay loading */
  104251. static readonly DELAYLOADSTATE_LOADING: number;
  104252. /** Defines that the ressource is delayed and has not started loading */
  104253. static readonly DELAYLOADSTATE_NOTLOADED: number;
  104254. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  104255. static readonly NEVER: number;
  104256. /** 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 */
  104257. static readonly ALWAYS: number;
  104258. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  104259. static readonly LESS: number;
  104260. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  104261. static readonly EQUAL: number;
  104262. /** 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 */
  104263. static readonly LEQUAL: number;
  104264. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  104265. static readonly GREATER: number;
  104266. /** 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 */
  104267. static readonly GEQUAL: number;
  104268. /** 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 */
  104269. static readonly NOTEQUAL: number;
  104270. /** Passed to stencilOperation to specify that stencil value must be kept */
  104271. static readonly KEEP: number;
  104272. /** Passed to stencilOperation to specify that stencil value must be replaced */
  104273. static readonly REPLACE: number;
  104274. /** Passed to stencilOperation to specify that stencil value must be incremented */
  104275. static readonly INCR: number;
  104276. /** Passed to stencilOperation to specify that stencil value must be decremented */
  104277. static readonly DECR: number;
  104278. /** Passed to stencilOperation to specify that stencil value must be inverted */
  104279. static readonly INVERT: number;
  104280. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  104281. static readonly INCR_WRAP: number;
  104282. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  104283. static readonly DECR_WRAP: number;
  104284. /** Texture is not repeating outside of 0..1 UVs */
  104285. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  104286. /** Texture is repeating outside of 0..1 UVs */
  104287. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  104288. /** Texture is repeating and mirrored */
  104289. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  104290. /** ALPHA */
  104291. static readonly TEXTUREFORMAT_ALPHA: number;
  104292. /** LUMINANCE */
  104293. static readonly TEXTUREFORMAT_LUMINANCE: number;
  104294. /** LUMINANCE_ALPHA */
  104295. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  104296. /** RGB */
  104297. static readonly TEXTUREFORMAT_RGB: number;
  104298. /** RGBA */
  104299. static readonly TEXTUREFORMAT_RGBA: number;
  104300. /** RED */
  104301. static readonly TEXTUREFORMAT_RED: number;
  104302. /** RED (2nd reference) */
  104303. static readonly TEXTUREFORMAT_R: number;
  104304. /** RG */
  104305. static readonly TEXTUREFORMAT_RG: number;
  104306. /** RED_INTEGER */
  104307. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  104308. /** RED_INTEGER (2nd reference) */
  104309. static readonly TEXTUREFORMAT_R_INTEGER: number;
  104310. /** RG_INTEGER */
  104311. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  104312. /** RGB_INTEGER */
  104313. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  104314. /** RGBA_INTEGER */
  104315. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  104316. /** UNSIGNED_BYTE */
  104317. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  104318. /** UNSIGNED_BYTE (2nd reference) */
  104319. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  104320. /** FLOAT */
  104321. static readonly TEXTURETYPE_FLOAT: number;
  104322. /** HALF_FLOAT */
  104323. static readonly TEXTURETYPE_HALF_FLOAT: number;
  104324. /** BYTE */
  104325. static readonly TEXTURETYPE_BYTE: number;
  104326. /** SHORT */
  104327. static readonly TEXTURETYPE_SHORT: number;
  104328. /** UNSIGNED_SHORT */
  104329. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  104330. /** INT */
  104331. static readonly TEXTURETYPE_INT: number;
  104332. /** UNSIGNED_INT */
  104333. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  104334. /** UNSIGNED_SHORT_4_4_4_4 */
  104335. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  104336. /** UNSIGNED_SHORT_5_5_5_1 */
  104337. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  104338. /** UNSIGNED_SHORT_5_6_5 */
  104339. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  104340. /** UNSIGNED_INT_2_10_10_10_REV */
  104341. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  104342. /** UNSIGNED_INT_24_8 */
  104343. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  104344. /** UNSIGNED_INT_10F_11F_11F_REV */
  104345. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  104346. /** UNSIGNED_INT_5_9_9_9_REV */
  104347. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  104348. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  104349. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  104350. /** nearest is mag = nearest and min = nearest and mip = linear */
  104351. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  104352. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104353. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  104354. /** Trilinear is mag = linear and min = linear and mip = linear */
  104355. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  104356. /** nearest is mag = nearest and min = nearest and mip = linear */
  104357. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  104358. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104359. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  104360. /** Trilinear is mag = linear and min = linear and mip = linear */
  104361. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  104362. /** mag = nearest and min = nearest and mip = nearest */
  104363. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  104364. /** mag = nearest and min = linear and mip = nearest */
  104365. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  104366. /** mag = nearest and min = linear and mip = linear */
  104367. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  104368. /** mag = nearest and min = linear and mip = none */
  104369. static readonly TEXTURE_NEAREST_LINEAR: number;
  104370. /** mag = nearest and min = nearest and mip = none */
  104371. static readonly TEXTURE_NEAREST_NEAREST: number;
  104372. /** mag = linear and min = nearest and mip = nearest */
  104373. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  104374. /** mag = linear and min = nearest and mip = linear */
  104375. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  104376. /** mag = linear and min = linear and mip = none */
  104377. static readonly TEXTURE_LINEAR_LINEAR: number;
  104378. /** mag = linear and min = nearest and mip = none */
  104379. static readonly TEXTURE_LINEAR_NEAREST: number;
  104380. /** Explicit coordinates mode */
  104381. static readonly TEXTURE_EXPLICIT_MODE: number;
  104382. /** Spherical coordinates mode */
  104383. static readonly TEXTURE_SPHERICAL_MODE: number;
  104384. /** Planar coordinates mode */
  104385. static readonly TEXTURE_PLANAR_MODE: number;
  104386. /** Cubic coordinates mode */
  104387. static readonly TEXTURE_CUBIC_MODE: number;
  104388. /** Projection coordinates mode */
  104389. static readonly TEXTURE_PROJECTION_MODE: number;
  104390. /** Skybox coordinates mode */
  104391. static readonly TEXTURE_SKYBOX_MODE: number;
  104392. /** Inverse Cubic coordinates mode */
  104393. static readonly TEXTURE_INVCUBIC_MODE: number;
  104394. /** Equirectangular coordinates mode */
  104395. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  104396. /** Equirectangular Fixed coordinates mode */
  104397. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  104398. /** Equirectangular Fixed Mirrored coordinates mode */
  104399. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  104400. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  104401. static readonly SCALEMODE_FLOOR: number;
  104402. /** Defines that texture rescaling will look for the nearest power of 2 size */
  104403. static readonly SCALEMODE_NEAREST: number;
  104404. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  104405. static readonly SCALEMODE_CEILING: number;
  104406. /**
  104407. * Returns the current npm package of the sdk
  104408. */
  104409. static get NpmPackage(): string;
  104410. /**
  104411. * Returns the current version of the framework
  104412. */
  104413. static get Version(): string;
  104414. /** Gets the list of created engines */
  104415. static get Instances(): Engine[];
  104416. /**
  104417. * Gets the latest created engine
  104418. */
  104419. static get LastCreatedEngine(): Nullable<Engine>;
  104420. /**
  104421. * Gets the latest created scene
  104422. */
  104423. static get LastCreatedScene(): Nullable<Scene>;
  104424. /**
  104425. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  104426. * @param flag defines which part of the materials must be marked as dirty
  104427. * @param predicate defines a predicate used to filter which materials should be affected
  104428. */
  104429. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  104430. /**
  104431. * Method called to create the default loading screen.
  104432. * This can be overriden in your own app.
  104433. * @param canvas The rendering canvas element
  104434. * @returns The loading screen
  104435. */
  104436. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  104437. /**
  104438. * Method called to create the default rescale post process on each engine.
  104439. */
  104440. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  104441. /**
  104442. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  104443. **/
  104444. enableOfflineSupport: boolean;
  104445. /**
  104446. * 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)
  104447. **/
  104448. disableManifestCheck: boolean;
  104449. /**
  104450. * Gets the list of created scenes
  104451. */
  104452. scenes: Scene[];
  104453. /**
  104454. * Event raised when a new scene is created
  104455. */
  104456. onNewSceneAddedObservable: Observable<Scene>;
  104457. /**
  104458. * Gets the list of created postprocesses
  104459. */
  104460. postProcesses: PostProcess[];
  104461. /**
  104462. * Gets a boolean indicating if the pointer is currently locked
  104463. */
  104464. isPointerLock: boolean;
  104465. /**
  104466. * Observable event triggered each time the rendering canvas is resized
  104467. */
  104468. onResizeObservable: Observable<Engine>;
  104469. /**
  104470. * Observable event triggered each time the canvas loses focus
  104471. */
  104472. onCanvasBlurObservable: Observable<Engine>;
  104473. /**
  104474. * Observable event triggered each time the canvas gains focus
  104475. */
  104476. onCanvasFocusObservable: Observable<Engine>;
  104477. /**
  104478. * Observable event triggered each time the canvas receives pointerout event
  104479. */
  104480. onCanvasPointerOutObservable: Observable<PointerEvent>;
  104481. /**
  104482. * Observable raised when the engine begins a new frame
  104483. */
  104484. onBeginFrameObservable: Observable<Engine>;
  104485. /**
  104486. * If set, will be used to request the next animation frame for the render loop
  104487. */
  104488. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  104489. /**
  104490. * Observable raised when the engine ends the current frame
  104491. */
  104492. onEndFrameObservable: Observable<Engine>;
  104493. /**
  104494. * Observable raised when the engine is about to compile a shader
  104495. */
  104496. onBeforeShaderCompilationObservable: Observable<Engine>;
  104497. /**
  104498. * Observable raised when the engine has jsut compiled a shader
  104499. */
  104500. onAfterShaderCompilationObservable: Observable<Engine>;
  104501. /**
  104502. * Gets the audio engine
  104503. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104504. * @ignorenaming
  104505. */
  104506. static audioEngine: IAudioEngine;
  104507. /**
  104508. * Default AudioEngine factory responsible of creating the Audio Engine.
  104509. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  104510. */
  104511. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  104512. /**
  104513. * Default offline support factory responsible of creating a tool used to store data locally.
  104514. * By default, this will create a Database object if the workload has been embedded.
  104515. */
  104516. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  104517. private _loadingScreen;
  104518. private _pointerLockRequested;
  104519. private _dummyFramebuffer;
  104520. private _rescalePostProcess;
  104521. private _deterministicLockstep;
  104522. private _lockstepMaxSteps;
  104523. private _timeStep;
  104524. protected get _supportsHardwareTextureRescaling(): boolean;
  104525. private _fps;
  104526. private _deltaTime;
  104527. /** @hidden */
  104528. _drawCalls: PerfCounter;
  104529. /**
  104530. * Turn this value on if you want to pause FPS computation when in background
  104531. */
  104532. disablePerformanceMonitorInBackground: boolean;
  104533. private _performanceMonitor;
  104534. /**
  104535. * Gets the performance monitor attached to this engine
  104536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  104537. */
  104538. get performanceMonitor(): PerformanceMonitor;
  104539. private _onFocus;
  104540. private _onBlur;
  104541. private _onCanvasPointerOut;
  104542. private _onCanvasBlur;
  104543. private _onCanvasFocus;
  104544. private _onFullscreenChange;
  104545. private _onPointerLockChange;
  104546. /**
  104547. * Gets the HTML element used to attach event listeners
  104548. * @returns a HTML element
  104549. */
  104550. getInputElement(): Nullable<HTMLElement>;
  104551. /**
  104552. * Creates a new engine
  104553. * @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
  104554. * @param antialias defines enable antialiasing (default: false)
  104555. * @param options defines further options to be sent to the getContext() function
  104556. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104557. */
  104558. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104559. /**
  104560. * Gets current aspect ratio
  104561. * @param viewportOwner defines the camera to use to get the aspect ratio
  104562. * @param useScreen defines if screen size must be used (or the current render target if any)
  104563. * @returns a number defining the aspect ratio
  104564. */
  104565. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  104566. /**
  104567. * Gets current screen aspect ratio
  104568. * @returns a number defining the aspect ratio
  104569. */
  104570. getScreenAspectRatio(): number;
  104571. /**
  104572. * Gets the client rect of the HTML canvas attached with the current webGL context
  104573. * @returns a client rectanglee
  104574. */
  104575. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  104576. /**
  104577. * Gets the client rect of the HTML element used for events
  104578. * @returns a client rectanglee
  104579. */
  104580. getInputElementClientRect(): Nullable<ClientRect>;
  104581. /**
  104582. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  104583. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104584. * @returns true if engine is in deterministic lock step mode
  104585. */
  104586. isDeterministicLockStep(): boolean;
  104587. /**
  104588. * Gets the max steps when engine is running in deterministic lock step
  104589. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104590. * @returns the max steps
  104591. */
  104592. getLockstepMaxSteps(): number;
  104593. /**
  104594. * Returns the time in ms between steps when using deterministic lock step.
  104595. * @returns time step in (ms)
  104596. */
  104597. getTimeStep(): number;
  104598. /**
  104599. * Force the mipmap generation for the given render target texture
  104600. * @param texture defines the render target texture to use
  104601. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  104602. */
  104603. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  104604. /** States */
  104605. /**
  104606. * Set various states to the webGL context
  104607. * @param culling defines backface culling state
  104608. * @param zOffset defines the value to apply to zOffset (0 by default)
  104609. * @param force defines if states must be applied even if cache is up to date
  104610. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  104611. */
  104612. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104613. /**
  104614. * Set the z offset to apply to current rendering
  104615. * @param value defines the offset to apply
  104616. */
  104617. setZOffset(value: number): void;
  104618. /**
  104619. * Gets the current value of the zOffset
  104620. * @returns the current zOffset state
  104621. */
  104622. getZOffset(): number;
  104623. /**
  104624. * Enable or disable depth buffering
  104625. * @param enable defines the state to set
  104626. */
  104627. setDepthBuffer(enable: boolean): void;
  104628. /**
  104629. * Gets a boolean indicating if depth writing is enabled
  104630. * @returns the current depth writing state
  104631. */
  104632. getDepthWrite(): boolean;
  104633. /**
  104634. * Enable or disable depth writing
  104635. * @param enable defines the state to set
  104636. */
  104637. setDepthWrite(enable: boolean): void;
  104638. /**
  104639. * Gets a boolean indicating if stencil buffer is enabled
  104640. * @returns the current stencil buffer state
  104641. */
  104642. getStencilBuffer(): boolean;
  104643. /**
  104644. * Enable or disable the stencil buffer
  104645. * @param enable defines if the stencil buffer must be enabled or disabled
  104646. */
  104647. setStencilBuffer(enable: boolean): void;
  104648. /**
  104649. * Gets the current stencil mask
  104650. * @returns a number defining the new stencil mask to use
  104651. */
  104652. getStencilMask(): number;
  104653. /**
  104654. * Sets the current stencil mask
  104655. * @param mask defines the new stencil mask to use
  104656. */
  104657. setStencilMask(mask: number): void;
  104658. /**
  104659. * Gets the current stencil function
  104660. * @returns a number defining the stencil function to use
  104661. */
  104662. getStencilFunction(): number;
  104663. /**
  104664. * Gets the current stencil reference value
  104665. * @returns a number defining the stencil reference value to use
  104666. */
  104667. getStencilFunctionReference(): number;
  104668. /**
  104669. * Gets the current stencil mask
  104670. * @returns a number defining the stencil mask to use
  104671. */
  104672. getStencilFunctionMask(): number;
  104673. /**
  104674. * Sets the current stencil function
  104675. * @param stencilFunc defines the new stencil function to use
  104676. */
  104677. setStencilFunction(stencilFunc: number): void;
  104678. /**
  104679. * Sets the current stencil reference
  104680. * @param reference defines the new stencil reference to use
  104681. */
  104682. setStencilFunctionReference(reference: number): void;
  104683. /**
  104684. * Sets the current stencil mask
  104685. * @param mask defines the new stencil mask to use
  104686. */
  104687. setStencilFunctionMask(mask: number): void;
  104688. /**
  104689. * Gets the current stencil operation when stencil fails
  104690. * @returns a number defining stencil operation to use when stencil fails
  104691. */
  104692. getStencilOperationFail(): number;
  104693. /**
  104694. * Gets the current stencil operation when depth fails
  104695. * @returns a number defining stencil operation to use when depth fails
  104696. */
  104697. getStencilOperationDepthFail(): number;
  104698. /**
  104699. * Gets the current stencil operation when stencil passes
  104700. * @returns a number defining stencil operation to use when stencil passes
  104701. */
  104702. getStencilOperationPass(): number;
  104703. /**
  104704. * Sets the stencil operation to use when stencil fails
  104705. * @param operation defines the stencil operation to use when stencil fails
  104706. */
  104707. setStencilOperationFail(operation: number): void;
  104708. /**
  104709. * Sets the stencil operation to use when depth fails
  104710. * @param operation defines the stencil operation to use when depth fails
  104711. */
  104712. setStencilOperationDepthFail(operation: number): void;
  104713. /**
  104714. * Sets the stencil operation to use when stencil passes
  104715. * @param operation defines the stencil operation to use when stencil passes
  104716. */
  104717. setStencilOperationPass(operation: number): void;
  104718. /**
  104719. * Sets a boolean indicating if the dithering state is enabled or disabled
  104720. * @param value defines the dithering state
  104721. */
  104722. setDitheringState(value: boolean): void;
  104723. /**
  104724. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  104725. * @param value defines the rasterizer state
  104726. */
  104727. setRasterizerState(value: boolean): void;
  104728. /**
  104729. * Gets the current depth function
  104730. * @returns a number defining the depth function
  104731. */
  104732. getDepthFunction(): Nullable<number>;
  104733. /**
  104734. * Sets the current depth function
  104735. * @param depthFunc defines the function to use
  104736. */
  104737. setDepthFunction(depthFunc: number): void;
  104738. /**
  104739. * Sets the current depth function to GREATER
  104740. */
  104741. setDepthFunctionToGreater(): void;
  104742. /**
  104743. * Sets the current depth function to GEQUAL
  104744. */
  104745. setDepthFunctionToGreaterOrEqual(): void;
  104746. /**
  104747. * Sets the current depth function to LESS
  104748. */
  104749. setDepthFunctionToLess(): void;
  104750. /**
  104751. * Sets the current depth function to LEQUAL
  104752. */
  104753. setDepthFunctionToLessOrEqual(): void;
  104754. private _cachedStencilBuffer;
  104755. private _cachedStencilFunction;
  104756. private _cachedStencilMask;
  104757. private _cachedStencilOperationPass;
  104758. private _cachedStencilOperationFail;
  104759. private _cachedStencilOperationDepthFail;
  104760. private _cachedStencilReference;
  104761. /**
  104762. * Caches the the state of the stencil buffer
  104763. */
  104764. cacheStencilState(): void;
  104765. /**
  104766. * Restores the state of the stencil buffer
  104767. */
  104768. restoreStencilState(): void;
  104769. /**
  104770. * Directly set the WebGL Viewport
  104771. * @param x defines the x coordinate of the viewport (in screen space)
  104772. * @param y defines the y coordinate of the viewport (in screen space)
  104773. * @param width defines the width of the viewport (in screen space)
  104774. * @param height defines the height of the viewport (in screen space)
  104775. * @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
  104776. */
  104777. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  104778. /**
  104779. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  104780. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104781. * @param y defines the y-coordinate of the corner of the clear rectangle
  104782. * @param width defines the width of the clear rectangle
  104783. * @param height defines the height of the clear rectangle
  104784. * @param clearColor defines the clear color
  104785. */
  104786. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  104787. /**
  104788. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  104789. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  104790. * @param y defines the y-coordinate of the corner of the clear rectangle
  104791. * @param width defines the width of the clear rectangle
  104792. * @param height defines the height of the clear rectangle
  104793. */
  104794. enableScissor(x: number, y: number, width: number, height: number): void;
  104795. /**
  104796. * Disable previously set scissor test rectangle
  104797. */
  104798. disableScissor(): void;
  104799. protected _reportDrawCall(): void;
  104800. /**
  104801. * Initializes a webVR display and starts listening to display change events
  104802. * The onVRDisplayChangedObservable will be notified upon these changes
  104803. * @returns The onVRDisplayChangedObservable
  104804. */
  104805. initWebVR(): Observable<IDisplayChangedEventArgs>;
  104806. /** @hidden */
  104807. _prepareVRComponent(): void;
  104808. /** @hidden */
  104809. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  104810. /** @hidden */
  104811. _submitVRFrame(): void;
  104812. /**
  104813. * Call this function to leave webVR mode
  104814. * Will do nothing if webVR is not supported or if there is no webVR device
  104815. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104816. */
  104817. disableVR(): void;
  104818. /**
  104819. * Gets a boolean indicating that the system is in VR mode and is presenting
  104820. * @returns true if VR mode is engaged
  104821. */
  104822. isVRPresenting(): boolean;
  104823. /** @hidden */
  104824. _requestVRFrame(): void;
  104825. /** @hidden */
  104826. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  104827. /**
  104828. * Gets the source code of the vertex shader associated with a specific webGL program
  104829. * @param program defines the program to use
  104830. * @returns a string containing the source code of the vertex shader associated with the program
  104831. */
  104832. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  104833. /**
  104834. * Gets the source code of the fragment shader associated with a specific webGL program
  104835. * @param program defines the program to use
  104836. * @returns a string containing the source code of the fragment shader associated with the program
  104837. */
  104838. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  104839. /**
  104840. * Sets a depth stencil texture from a render target to the according uniform.
  104841. * @param channel The texture channel
  104842. * @param uniform The uniform to set
  104843. * @param texture The render target texture containing the depth stencil texture to apply
  104844. */
  104845. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  104846. /**
  104847. * Sets a texture to the webGL context from a postprocess
  104848. * @param channel defines the channel to use
  104849. * @param postProcess defines the source postprocess
  104850. */
  104851. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  104852. /**
  104853. * Binds the output of the passed in post process to the texture channel specified
  104854. * @param channel The channel the texture should be bound to
  104855. * @param postProcess The post process which's output should be bound
  104856. */
  104857. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  104858. /** @hidden */
  104859. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  104860. protected _rebuildBuffers(): void;
  104861. /** @hidden */
  104862. _renderFrame(): void;
  104863. _renderLoop(): void;
  104864. /** @hidden */
  104865. _renderViews(): boolean;
  104866. /**
  104867. * Toggle full screen mode
  104868. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104869. */
  104870. switchFullscreen(requestPointerLock: boolean): void;
  104871. /**
  104872. * Enters full screen mode
  104873. * @param requestPointerLock defines if a pointer lock should be requested from the user
  104874. */
  104875. enterFullscreen(requestPointerLock: boolean): void;
  104876. /**
  104877. * Exits full screen mode
  104878. */
  104879. exitFullscreen(): void;
  104880. /**
  104881. * Enters Pointerlock mode
  104882. */
  104883. enterPointerlock(): void;
  104884. /**
  104885. * Exits Pointerlock mode
  104886. */
  104887. exitPointerlock(): void;
  104888. /**
  104889. * Begin a new frame
  104890. */
  104891. beginFrame(): void;
  104892. /**
  104893. * Enf the current frame
  104894. */
  104895. endFrame(): void;
  104896. resize(): void;
  104897. /**
  104898. * Set the compressed texture format to use, based on the formats you have, and the formats
  104899. * supported by the hardware / browser.
  104900. *
  104901. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  104902. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  104903. * to API arguments needed to compressed textures. This puts the burden on the container
  104904. * generator to house the arcane code for determining these for current & future formats.
  104905. *
  104906. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  104907. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  104908. *
  104909. * Note: The result of this call is not taken into account when a texture is base64.
  104910. *
  104911. * @param formatsAvailable defines the list of those format families you have created
  104912. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  104913. *
  104914. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  104915. * @returns The extension selected.
  104916. */
  104917. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  104918. /**
  104919. * Set the compressed texture extensions or file names to skip.
  104920. *
  104921. * @param skippedFiles defines the list of those texture files you want to skip
  104922. * Example: [".dds", ".env", "myfile.png"]
  104923. */
  104924. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  104925. /**
  104926. * Force a specific size of the canvas
  104927. * @param width defines the new canvas' width
  104928. * @param height defines the new canvas' height
  104929. */
  104930. setSize(width: number, height: number): void;
  104931. /**
  104932. * Updates a dynamic vertex buffer.
  104933. * @param vertexBuffer the vertex buffer to update
  104934. * @param data the data used to update the vertex buffer
  104935. * @param byteOffset the byte offset of the data
  104936. * @param byteLength the byte length of the data
  104937. */
  104938. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  104939. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104940. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104941. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104942. _releaseTexture(texture: InternalTexture): void;
  104943. /**
  104944. * @hidden
  104945. * Rescales a texture
  104946. * @param source input texutre
  104947. * @param destination destination texture
  104948. * @param scene scene to use to render the resize
  104949. * @param internalFormat format to use when resizing
  104950. * @param onComplete callback to be called when resize has completed
  104951. */
  104952. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104953. /**
  104954. * Gets the current framerate
  104955. * @returns a number representing the framerate
  104956. */
  104957. getFps(): number;
  104958. /**
  104959. * Gets the time spent between current and previous frame
  104960. * @returns a number representing the delta time in ms
  104961. */
  104962. getDeltaTime(): number;
  104963. private _measureFps;
  104964. /** @hidden */
  104965. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  104966. /**
  104967. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  104968. * @param renderTarget The render target to set the frame buffer for
  104969. */
  104970. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  104971. /**
  104972. * Update a dynamic index buffer
  104973. * @param indexBuffer defines the target index buffer
  104974. * @param indices defines the data to update
  104975. * @param offset defines the offset in the target index buffer where update should start
  104976. */
  104977. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  104978. /**
  104979. * Updates the sample count of a render target texture
  104980. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104981. * @param texture defines the texture to update
  104982. * @param samples defines the sample count to set
  104983. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104984. */
  104985. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  104986. /**
  104987. * Updates a depth texture Comparison Mode and Function.
  104988. * If the comparison Function is equal to 0, the mode will be set to none.
  104989. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  104990. * @param texture The texture to set the comparison function for
  104991. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  104992. */
  104993. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  104994. /**
  104995. * Creates a webGL buffer to use with instanciation
  104996. * @param capacity defines the size of the buffer
  104997. * @returns the webGL buffer
  104998. */
  104999. createInstancesBuffer(capacity: number): DataBuffer;
  105000. /**
  105001. * Delete a webGL buffer used with instanciation
  105002. * @param buffer defines the webGL buffer to delete
  105003. */
  105004. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  105005. /** @hidden */
  105006. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  105007. dispose(): void;
  105008. private _disableTouchAction;
  105009. /**
  105010. * Display the loading screen
  105011. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105012. */
  105013. displayLoadingUI(): void;
  105014. /**
  105015. * Hide the loading screen
  105016. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105017. */
  105018. hideLoadingUI(): void;
  105019. /**
  105020. * Gets the current loading screen object
  105021. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105022. */
  105023. get loadingScreen(): ILoadingScreen;
  105024. /**
  105025. * Sets the current loading screen object
  105026. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105027. */
  105028. set loadingScreen(loadingScreen: ILoadingScreen);
  105029. /**
  105030. * Sets the current loading screen text
  105031. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105032. */
  105033. set loadingUIText(text: string);
  105034. /**
  105035. * Sets the current loading screen background color
  105036. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105037. */
  105038. set loadingUIBackgroundColor(color: string);
  105039. /** Pointerlock and fullscreen */
  105040. /**
  105041. * Ask the browser to promote the current element to pointerlock mode
  105042. * @param element defines the DOM element to promote
  105043. */
  105044. static _RequestPointerlock(element: HTMLElement): void;
  105045. /**
  105046. * Asks the browser to exit pointerlock mode
  105047. */
  105048. static _ExitPointerlock(): void;
  105049. /**
  105050. * Ask the browser to promote the current element to fullscreen rendering mode
  105051. * @param element defines the DOM element to promote
  105052. */
  105053. static _RequestFullscreen(element: HTMLElement): void;
  105054. /**
  105055. * Asks the browser to exit fullscreen mode
  105056. */
  105057. static _ExitFullscreen(): void;
  105058. }
  105059. }
  105060. declare module BABYLON {
  105061. /**
  105062. * The engine store class is responsible to hold all the instances of Engine and Scene created
  105063. * during the life time of the application.
  105064. */
  105065. export class EngineStore {
  105066. /** Gets the list of created engines */
  105067. static Instances: Engine[];
  105068. /** @hidden */
  105069. static _LastCreatedScene: Nullable<Scene>;
  105070. /**
  105071. * Gets the latest created engine
  105072. */
  105073. static get LastCreatedEngine(): Nullable<Engine>;
  105074. /**
  105075. * Gets the latest created scene
  105076. */
  105077. static get LastCreatedScene(): Nullable<Scene>;
  105078. /**
  105079. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  105080. * @ignorenaming
  105081. */
  105082. static UseFallbackTexture: boolean;
  105083. /**
  105084. * Texture content used if a texture cannot loaded
  105085. * @ignorenaming
  105086. */
  105087. static FallbackTexture: string;
  105088. }
  105089. }
  105090. declare module BABYLON {
  105091. /**
  105092. * Helper class that provides a small promise polyfill
  105093. */
  105094. export class PromisePolyfill {
  105095. /**
  105096. * Static function used to check if the polyfill is required
  105097. * If this is the case then the function will inject the polyfill to window.Promise
  105098. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  105099. */
  105100. static Apply(force?: boolean): void;
  105101. }
  105102. }
  105103. declare module BABYLON {
  105104. /**
  105105. * Interface for screenshot methods with describe argument called `size` as object with options
  105106. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  105107. */
  105108. export interface IScreenshotSize {
  105109. /**
  105110. * number in pixels for canvas height
  105111. */
  105112. height?: number;
  105113. /**
  105114. * multiplier allowing render at a higher or lower resolution
  105115. * If value is defined then height and width will be ignored and taken from camera
  105116. */
  105117. precision?: number;
  105118. /**
  105119. * number in pixels for canvas width
  105120. */
  105121. width?: number;
  105122. }
  105123. }
  105124. declare module BABYLON {
  105125. interface IColor4Like {
  105126. r: float;
  105127. g: float;
  105128. b: float;
  105129. a: float;
  105130. }
  105131. /**
  105132. * Class containing a set of static utilities functions
  105133. */
  105134. export class Tools {
  105135. /**
  105136. * Gets or sets the base URL to use to load assets
  105137. */
  105138. static get BaseUrl(): string;
  105139. static set BaseUrl(value: string);
  105140. /**
  105141. * Enable/Disable Custom HTTP Request Headers globally.
  105142. * default = false
  105143. * @see CustomRequestHeaders
  105144. */
  105145. static UseCustomRequestHeaders: boolean;
  105146. /**
  105147. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  105148. * i.e. when loading files, where the server/service expects an Authorization header
  105149. */
  105150. static CustomRequestHeaders: {
  105151. [key: string]: string;
  105152. };
  105153. /**
  105154. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  105155. */
  105156. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  105157. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  105158. /**
  105159. * Default behaviour for cors in the application.
  105160. * It can be a string if the expected behavior is identical in the entire app.
  105161. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  105162. */
  105163. static CorsBehavior: string | ((url: string | string[]) => string);
  105164. /**
  105165. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  105166. * @ignorenaming
  105167. */
  105168. static get UseFallbackTexture(): boolean;
  105169. static set UseFallbackTexture(value: boolean);
  105170. /**
  105171. * Use this object to register external classes like custom textures or material
  105172. * to allow the laoders to instantiate them
  105173. */
  105174. static get RegisteredExternalClasses(): {
  105175. [key: string]: Object;
  105176. };
  105177. static set RegisteredExternalClasses(classes: {
  105178. [key: string]: Object;
  105179. });
  105180. /**
  105181. * Texture content used if a texture cannot loaded
  105182. * @ignorenaming
  105183. */
  105184. static get fallbackTexture(): string;
  105185. static set fallbackTexture(value: string);
  105186. /**
  105187. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  105188. * @param u defines the coordinate on X axis
  105189. * @param v defines the coordinate on Y axis
  105190. * @param width defines the width of the source data
  105191. * @param height defines the height of the source data
  105192. * @param pixels defines the source byte array
  105193. * @param color defines the output color
  105194. */
  105195. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  105196. /**
  105197. * Interpolates between a and b via alpha
  105198. * @param a The lower value (returned when alpha = 0)
  105199. * @param b The upper value (returned when alpha = 1)
  105200. * @param alpha The interpolation-factor
  105201. * @return The mixed value
  105202. */
  105203. static Mix(a: number, b: number, alpha: number): number;
  105204. /**
  105205. * Tries to instantiate a new object from a given class name
  105206. * @param className defines the class name to instantiate
  105207. * @returns the new object or null if the system was not able to do the instantiation
  105208. */
  105209. static Instantiate(className: string): any;
  105210. /**
  105211. * Provides a slice function that will work even on IE
  105212. * @param data defines the array to slice
  105213. * @param start defines the start of the data (optional)
  105214. * @param end defines the end of the data (optional)
  105215. * @returns the new sliced array
  105216. */
  105217. static Slice<T>(data: T, start?: number, end?: number): T;
  105218. /**
  105219. * Polyfill for setImmediate
  105220. * @param action defines the action to execute after the current execution block
  105221. */
  105222. static SetImmediate(action: () => void): void;
  105223. /**
  105224. * Function indicating if a number is an exponent of 2
  105225. * @param value defines the value to test
  105226. * @returns true if the value is an exponent of 2
  105227. */
  105228. static IsExponentOfTwo(value: number): boolean;
  105229. private static _tmpFloatArray;
  105230. /**
  105231. * Returns the nearest 32-bit single precision float representation of a Number
  105232. * @param value A Number. If the parameter is of a different type, it will get converted
  105233. * to a number or to NaN if it cannot be converted
  105234. * @returns number
  105235. */
  105236. static FloatRound(value: number): number;
  105237. /**
  105238. * Extracts the filename from a path
  105239. * @param path defines the path to use
  105240. * @returns the filename
  105241. */
  105242. static GetFilename(path: string): string;
  105243. /**
  105244. * Extracts the "folder" part of a path (everything before the filename).
  105245. * @param uri The URI to extract the info from
  105246. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  105247. * @returns The "folder" part of the path
  105248. */
  105249. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  105250. /**
  105251. * Extracts text content from a DOM element hierarchy
  105252. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  105253. */
  105254. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  105255. /**
  105256. * Convert an angle in radians to degrees
  105257. * @param angle defines the angle to convert
  105258. * @returns the angle in degrees
  105259. */
  105260. static ToDegrees(angle: number): number;
  105261. /**
  105262. * Convert an angle in degrees to radians
  105263. * @param angle defines the angle to convert
  105264. * @returns the angle in radians
  105265. */
  105266. static ToRadians(angle: number): number;
  105267. /**
  105268. * Returns an array if obj is not an array
  105269. * @param obj defines the object to evaluate as an array
  105270. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  105271. * @returns either obj directly if obj is an array or a new array containing obj
  105272. */
  105273. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  105274. /**
  105275. * Gets the pointer prefix to use
  105276. * @returns "pointer" if touch is enabled. Else returns "mouse"
  105277. */
  105278. static GetPointerPrefix(): string;
  105279. /**
  105280. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  105281. * @param url define the url we are trying
  105282. * @param element define the dom element where to configure the cors policy
  105283. */
  105284. static SetCorsBehavior(url: string | string[], element: {
  105285. crossOrigin: string | null;
  105286. }): void;
  105287. /**
  105288. * Removes unwanted characters from an url
  105289. * @param url defines the url to clean
  105290. * @returns the cleaned url
  105291. */
  105292. static CleanUrl(url: string): string;
  105293. /**
  105294. * Gets or sets a function used to pre-process url before using them to load assets
  105295. */
  105296. static get PreprocessUrl(): (url: string) => string;
  105297. static set PreprocessUrl(processor: (url: string) => string);
  105298. /**
  105299. * Loads an image as an HTMLImageElement.
  105300. * @param input url string, ArrayBuffer, or Blob to load
  105301. * @param onLoad callback called when the image successfully loads
  105302. * @param onError callback called when the image fails to load
  105303. * @param offlineProvider offline provider for caching
  105304. * @param mimeType optional mime type
  105305. * @returns the HTMLImageElement of the loaded image
  105306. */
  105307. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  105308. /**
  105309. * Loads a file from a url
  105310. * @param url url string, ArrayBuffer, or Blob to load
  105311. * @param onSuccess callback called when the file successfully loads
  105312. * @param onProgress callback called while file is loading (if the server supports this mode)
  105313. * @param offlineProvider defines the offline provider for caching
  105314. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105315. * @param onError callback called when the file fails to load
  105316. * @returns a file request object
  105317. */
  105318. 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;
  105319. /**
  105320. * Loads a file from a url
  105321. * @param url the file url to load
  105322. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  105323. */
  105324. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  105325. /**
  105326. * Load a script (identified by an url). When the url returns, the
  105327. * content of this file is added into a new script element, attached to the DOM (body element)
  105328. * @param scriptUrl defines the url of the script to laod
  105329. * @param onSuccess defines the callback called when the script is loaded
  105330. * @param onError defines the callback to call if an error occurs
  105331. * @param scriptId defines the id of the script element
  105332. */
  105333. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  105334. /**
  105335. * Load an asynchronous script (identified by an url). When the url returns, the
  105336. * content of this file is added into a new script element, attached to the DOM (body element)
  105337. * @param scriptUrl defines the url of the script to laod
  105338. * @param scriptId defines the id of the script element
  105339. * @returns a promise request object
  105340. */
  105341. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  105342. /**
  105343. * Loads a file from a blob
  105344. * @param fileToLoad defines the blob to use
  105345. * @param callback defines the callback to call when data is loaded
  105346. * @param progressCallback defines the callback to call during loading process
  105347. * @returns a file request object
  105348. */
  105349. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  105350. /**
  105351. * Reads a file from a File object
  105352. * @param file defines the file to load
  105353. * @param onSuccess defines the callback to call when data is loaded
  105354. * @param onProgress defines the callback to call during loading process
  105355. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  105356. * @param onError defines the callback to call when an error occurs
  105357. * @returns a file request object
  105358. */
  105359. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  105360. /**
  105361. * Creates a data url from a given string content
  105362. * @param content defines the content to convert
  105363. * @returns the new data url link
  105364. */
  105365. static FileAsURL(content: string): string;
  105366. /**
  105367. * Format the given number to a specific decimal format
  105368. * @param value defines the number to format
  105369. * @param decimals defines the number of decimals to use
  105370. * @returns the formatted string
  105371. */
  105372. static Format(value: number, decimals?: number): string;
  105373. /**
  105374. * Tries to copy an object by duplicating every property
  105375. * @param source defines the source object
  105376. * @param destination defines the target object
  105377. * @param doNotCopyList defines a list of properties to avoid
  105378. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  105379. */
  105380. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  105381. /**
  105382. * Gets a boolean indicating if the given object has no own property
  105383. * @param obj defines the object to test
  105384. * @returns true if object has no own property
  105385. */
  105386. static IsEmpty(obj: any): boolean;
  105387. /**
  105388. * Function used to register events at window level
  105389. * @param windowElement defines the Window object to use
  105390. * @param events defines the events to register
  105391. */
  105392. static RegisterTopRootEvents(windowElement: Window, events: {
  105393. name: string;
  105394. handler: Nullable<(e: FocusEvent) => any>;
  105395. }[]): void;
  105396. /**
  105397. * Function used to unregister events from window level
  105398. * @param windowElement defines the Window object to use
  105399. * @param events defines the events to unregister
  105400. */
  105401. static UnregisterTopRootEvents(windowElement: Window, events: {
  105402. name: string;
  105403. handler: Nullable<(e: FocusEvent) => any>;
  105404. }[]): void;
  105405. /**
  105406. * @ignore
  105407. */
  105408. static _ScreenshotCanvas: HTMLCanvasElement;
  105409. /**
  105410. * Dumps the current bound framebuffer
  105411. * @param width defines the rendering width
  105412. * @param height defines the rendering height
  105413. * @param engine defines the hosting engine
  105414. * @param successCallback defines the callback triggered once the data are available
  105415. * @param mimeType defines the mime type of the result
  105416. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  105417. */
  105418. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  105419. /**
  105420. * Converts the canvas data to blob.
  105421. * This acts as a polyfill for browsers not supporting the to blob function.
  105422. * @param canvas Defines the canvas to extract the data from
  105423. * @param successCallback Defines the callback triggered once the data are available
  105424. * @param mimeType Defines the mime type of the result
  105425. */
  105426. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  105427. /**
  105428. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  105429. * @param successCallback defines the callback triggered once the data are available
  105430. * @param mimeType defines the mime type of the result
  105431. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  105432. */
  105433. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  105434. /**
  105435. * Downloads a blob in the browser
  105436. * @param blob defines the blob to download
  105437. * @param fileName defines the name of the downloaded file
  105438. */
  105439. static Download(blob: Blob, fileName: string): void;
  105440. /**
  105441. * Captures a screenshot of the current rendering
  105442. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  105443. * @param engine defines the rendering engine
  105444. * @param camera defines the source camera
  105445. * @param size This parameter can be set to a single number or to an object with the
  105446. * following (optional) properties: precision, width, height. If a single number is passed,
  105447. * it will be used for both width and height. If an object is passed, the screenshot size
  105448. * will be derived from the parameters. The precision property is a multiplier allowing
  105449. * rendering at a higher or lower resolution
  105450. * @param successCallback defines the callback receives a single parameter which contains the
  105451. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  105452. * src parameter of an <img> to display it
  105453. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  105454. * Check your browser for supported MIME types
  105455. */
  105456. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  105457. /**
  105458. * Captures a screenshot of the current rendering
  105459. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  105460. * @param engine defines the rendering engine
  105461. * @param camera defines the source camera
  105462. * @param size This parameter can be set to a single number or to an object with the
  105463. * following (optional) properties: precision, width, height. If a single number is passed,
  105464. * it will be used for both width and height. If an object is passed, the screenshot size
  105465. * will be derived from the parameters. The precision property is a multiplier allowing
  105466. * rendering at a higher or lower resolution
  105467. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  105468. * Check your browser for supported MIME types
  105469. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  105470. * to the src parameter of an <img> to display it
  105471. */
  105472. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  105473. /**
  105474. * Generates an image screenshot from the specified camera.
  105475. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  105476. * @param engine The engine to use for rendering
  105477. * @param camera The camera to use for rendering
  105478. * @param size This parameter can be set to a single number or to an object with the
  105479. * following (optional) properties: precision, width, height. If a single number is passed,
  105480. * it will be used for both width and height. If an object is passed, the screenshot size
  105481. * will be derived from the parameters. The precision property is a multiplier allowing
  105482. * rendering at a higher or lower resolution
  105483. * @param successCallback The callback receives a single parameter which contains the
  105484. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  105485. * src parameter of an <img> to display it
  105486. * @param mimeType The MIME type of the screenshot image (default: image/png).
  105487. * Check your browser for supported MIME types
  105488. * @param samples Texture samples (default: 1)
  105489. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  105490. * @param fileName A name for for the downloaded file.
  105491. */
  105492. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  105493. /**
  105494. * Generates an image screenshot from the specified camera.
  105495. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  105496. * @param engine The engine to use for rendering
  105497. * @param camera The camera to use for rendering
  105498. * @param size This parameter can be set to a single number or to an object with the
  105499. * following (optional) properties: precision, width, height. If a single number is passed,
  105500. * it will be used for both width and height. If an object is passed, the screenshot size
  105501. * will be derived from the parameters. The precision property is a multiplier allowing
  105502. * rendering at a higher or lower resolution
  105503. * @param mimeType The MIME type of the screenshot image (default: image/png).
  105504. * Check your browser for supported MIME types
  105505. * @param samples Texture samples (default: 1)
  105506. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  105507. * @param fileName A name for for the downloaded file.
  105508. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  105509. * to the src parameter of an <img> to display it
  105510. */
  105511. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  105512. /**
  105513. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105514. * Be aware Math.random() could cause collisions, but:
  105515. * "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"
  105516. * @returns a pseudo random id
  105517. */
  105518. static RandomId(): string;
  105519. /**
  105520. * Test if the given uri is a base64 string
  105521. * @param uri The uri to test
  105522. * @return True if the uri is a base64 string or false otherwise
  105523. */
  105524. static IsBase64(uri: string): boolean;
  105525. /**
  105526. * Decode the given base64 uri.
  105527. * @param uri The uri to decode
  105528. * @return The decoded base64 data.
  105529. */
  105530. static DecodeBase64(uri: string): ArrayBuffer;
  105531. /**
  105532. * Gets the absolute url.
  105533. * @param url the input url
  105534. * @return the absolute url
  105535. */
  105536. static GetAbsoluteUrl(url: string): string;
  105537. /**
  105538. * No log
  105539. */
  105540. static readonly NoneLogLevel: number;
  105541. /**
  105542. * Only message logs
  105543. */
  105544. static readonly MessageLogLevel: number;
  105545. /**
  105546. * Only warning logs
  105547. */
  105548. static readonly WarningLogLevel: number;
  105549. /**
  105550. * Only error logs
  105551. */
  105552. static readonly ErrorLogLevel: number;
  105553. /**
  105554. * All logs
  105555. */
  105556. static readonly AllLogLevel: number;
  105557. /**
  105558. * Gets a value indicating the number of loading errors
  105559. * @ignorenaming
  105560. */
  105561. static get errorsCount(): number;
  105562. /**
  105563. * Callback called when a new log is added
  105564. */
  105565. static OnNewCacheEntry: (entry: string) => void;
  105566. /**
  105567. * Log a message to the console
  105568. * @param message defines the message to log
  105569. */
  105570. static Log(message: string): void;
  105571. /**
  105572. * Write a warning message to the console
  105573. * @param message defines the message to log
  105574. */
  105575. static Warn(message: string): void;
  105576. /**
  105577. * Write an error message to the console
  105578. * @param message defines the message to log
  105579. */
  105580. static Error(message: string): void;
  105581. /**
  105582. * Gets current log cache (list of logs)
  105583. */
  105584. static get LogCache(): string;
  105585. /**
  105586. * Clears the log cache
  105587. */
  105588. static ClearLogCache(): void;
  105589. /**
  105590. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  105591. */
  105592. static set LogLevels(level: number);
  105593. /**
  105594. * Checks if the window object exists
  105595. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  105596. */
  105597. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  105598. /**
  105599. * No performance log
  105600. */
  105601. static readonly PerformanceNoneLogLevel: number;
  105602. /**
  105603. * Use user marks to log performance
  105604. */
  105605. static readonly PerformanceUserMarkLogLevel: number;
  105606. /**
  105607. * Log performance to the console
  105608. */
  105609. static readonly PerformanceConsoleLogLevel: number;
  105610. private static _performance;
  105611. /**
  105612. * Sets the current performance log level
  105613. */
  105614. static set PerformanceLogLevel(level: number);
  105615. private static _StartPerformanceCounterDisabled;
  105616. private static _EndPerformanceCounterDisabled;
  105617. private static _StartUserMark;
  105618. private static _EndUserMark;
  105619. private static _StartPerformanceConsole;
  105620. private static _EndPerformanceConsole;
  105621. /**
  105622. * Starts a performance counter
  105623. */
  105624. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  105625. /**
  105626. * Ends a specific performance coutner
  105627. */
  105628. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  105629. /**
  105630. * Gets either window.performance.now() if supported or Date.now() else
  105631. */
  105632. static get Now(): number;
  105633. /**
  105634. * This method will return the name of the class used to create the instance of the given object.
  105635. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  105636. * @param object the object to get the class name from
  105637. * @param isType defines if the object is actually a type
  105638. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  105639. */
  105640. static GetClassName(object: any, isType?: boolean): string;
  105641. /**
  105642. * Gets the first element of an array satisfying a given predicate
  105643. * @param array defines the array to browse
  105644. * @param predicate defines the predicate to use
  105645. * @returns null if not found or the element
  105646. */
  105647. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  105648. /**
  105649. * This method will return the name of the full name of the class, including its owning module (if any).
  105650. * 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).
  105651. * @param object the object to get the class name from
  105652. * @param isType defines if the object is actually a type
  105653. * @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.
  105654. * @ignorenaming
  105655. */
  105656. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  105657. /**
  105658. * Returns a promise that resolves after the given amount of time.
  105659. * @param delay Number of milliseconds to delay
  105660. * @returns Promise that resolves after the given amount of time
  105661. */
  105662. static DelayAsync(delay: number): Promise<void>;
  105663. /**
  105664. * Utility function to detect if the current user agent is Safari
  105665. * @returns whether or not the current user agent is safari
  105666. */
  105667. static IsSafari(): boolean;
  105668. }
  105669. /**
  105670. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  105671. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  105672. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  105673. * @param name The name of the class, case should be preserved
  105674. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  105675. */
  105676. export function className(name: string, module?: string): (target: Object) => void;
  105677. /**
  105678. * An implementation of a loop for asynchronous functions.
  105679. */
  105680. export class AsyncLoop {
  105681. /**
  105682. * Defines the number of iterations for the loop
  105683. */
  105684. iterations: number;
  105685. /**
  105686. * Defines the current index of the loop.
  105687. */
  105688. index: number;
  105689. private _done;
  105690. private _fn;
  105691. private _successCallback;
  105692. /**
  105693. * Constructor.
  105694. * @param iterations the number of iterations.
  105695. * @param func the function to run each iteration
  105696. * @param successCallback the callback that will be called upon succesful execution
  105697. * @param offset starting offset.
  105698. */
  105699. constructor(
  105700. /**
  105701. * Defines the number of iterations for the loop
  105702. */
  105703. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  105704. /**
  105705. * Execute the next iteration. Must be called after the last iteration was finished.
  105706. */
  105707. executeNext(): void;
  105708. /**
  105709. * Break the loop and run the success callback.
  105710. */
  105711. breakLoop(): void;
  105712. /**
  105713. * Create and run an async loop.
  105714. * @param iterations the number of iterations.
  105715. * @param fn the function to run each iteration
  105716. * @param successCallback the callback that will be called upon succesful execution
  105717. * @param offset starting offset.
  105718. * @returns the created async loop object
  105719. */
  105720. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  105721. /**
  105722. * A for-loop that will run a given number of iterations synchronous and the rest async.
  105723. * @param iterations total number of iterations
  105724. * @param syncedIterations number of synchronous iterations in each async iteration.
  105725. * @param fn the function to call each iteration.
  105726. * @param callback a success call back that will be called when iterating stops.
  105727. * @param breakFunction a break condition (optional)
  105728. * @param timeout timeout settings for the setTimeout function. default - 0.
  105729. * @returns the created async loop object
  105730. */
  105731. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  105732. }
  105733. }
  105734. declare module BABYLON {
  105735. /**
  105736. * This class implement a typical dictionary using a string as key and the generic type T as value.
  105737. * The underlying implementation relies on an associative array to ensure the best performances.
  105738. * The value can be anything including 'null' but except 'undefined'
  105739. */
  105740. export class StringDictionary<T> {
  105741. /**
  105742. * This will clear this dictionary and copy the content from the 'source' one.
  105743. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  105744. * @param source the dictionary to take the content from and copy to this dictionary
  105745. */
  105746. copyFrom(source: StringDictionary<T>): void;
  105747. /**
  105748. * Get a value based from its key
  105749. * @param key the given key to get the matching value from
  105750. * @return the value if found, otherwise undefined is returned
  105751. */
  105752. get(key: string): T | undefined;
  105753. /**
  105754. * Get a value from its key or add it if it doesn't exist.
  105755. * This method will ensure you that a given key/data will be present in the dictionary.
  105756. * @param key the given key to get the matching value from
  105757. * @param factory the factory that will create the value if the key is not present in the dictionary.
  105758. * The factory will only be invoked if there's no data for the given key.
  105759. * @return the value corresponding to the key.
  105760. */
  105761. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  105762. /**
  105763. * Get a value from its key if present in the dictionary otherwise add it
  105764. * @param key the key to get the value from
  105765. * @param val if there's no such key/value pair in the dictionary add it with this value
  105766. * @return the value corresponding to the key
  105767. */
  105768. getOrAdd(key: string, val: T): T;
  105769. /**
  105770. * Check if there's a given key in the dictionary
  105771. * @param key the key to check for
  105772. * @return true if the key is present, false otherwise
  105773. */
  105774. contains(key: string): boolean;
  105775. /**
  105776. * Add a new key and its corresponding value
  105777. * @param key the key to add
  105778. * @param value the value corresponding to the key
  105779. * @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
  105780. */
  105781. add(key: string, value: T): boolean;
  105782. /**
  105783. * Update a specific value associated to a key
  105784. * @param key defines the key to use
  105785. * @param value defines the value to store
  105786. * @returns true if the value was updated (or false if the key was not found)
  105787. */
  105788. set(key: string, value: T): boolean;
  105789. /**
  105790. * Get the element of the given key and remove it from the dictionary
  105791. * @param key defines the key to search
  105792. * @returns the value associated with the key or null if not found
  105793. */
  105794. getAndRemove(key: string): Nullable<T>;
  105795. /**
  105796. * Remove a key/value from the dictionary.
  105797. * @param key the key to remove
  105798. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  105799. */
  105800. remove(key: string): boolean;
  105801. /**
  105802. * Clear the whole content of the dictionary
  105803. */
  105804. clear(): void;
  105805. /**
  105806. * Gets the current count
  105807. */
  105808. get count(): number;
  105809. /**
  105810. * Execute a callback on each key/val of the dictionary.
  105811. * Note that you can remove any element in this dictionary in the callback implementation
  105812. * @param callback the callback to execute on a given key/value pair
  105813. */
  105814. forEach(callback: (key: string, val: T) => void): void;
  105815. /**
  105816. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  105817. * If the callback returns null or undefined the method will iterate to the next key/value pair
  105818. * Note that you can remove any element in this dictionary in the callback implementation
  105819. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  105820. * @returns the first item
  105821. */
  105822. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  105823. private _count;
  105824. private _data;
  105825. }
  105826. }
  105827. declare module BABYLON {
  105828. /** @hidden */
  105829. export interface ICollisionCoordinator {
  105830. createCollider(): Collider;
  105831. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105832. init(scene: Scene): void;
  105833. }
  105834. /** @hidden */
  105835. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  105836. private _scene;
  105837. private _scaledPosition;
  105838. private _scaledVelocity;
  105839. private _finalPosition;
  105840. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  105841. createCollider(): Collider;
  105842. init(scene: Scene): void;
  105843. private _collideWithWorld;
  105844. }
  105845. }
  105846. declare module BABYLON {
  105847. /**
  105848. * Class used to manage all inputs for the scene.
  105849. */
  105850. export class InputManager {
  105851. /** The distance in pixel that you have to move to prevent some events */
  105852. static DragMovementThreshold: number;
  105853. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  105854. static LongPressDelay: number;
  105855. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  105856. static DoubleClickDelay: number;
  105857. /** If you need to check double click without raising a single click at first click, enable this flag */
  105858. static ExclusiveDoubleClickMode: boolean;
  105859. private _wheelEventName;
  105860. private _onPointerMove;
  105861. private _onPointerDown;
  105862. private _onPointerUp;
  105863. private _initClickEvent;
  105864. private _initActionManager;
  105865. private _delayedSimpleClick;
  105866. private _delayedSimpleClickTimeout;
  105867. private _previousDelayedSimpleClickTimeout;
  105868. private _meshPickProceed;
  105869. private _previousButtonPressed;
  105870. private _currentPickResult;
  105871. private _previousPickResult;
  105872. private _totalPointersPressed;
  105873. private _doubleClickOccured;
  105874. private _pointerOverMesh;
  105875. private _pickedDownMesh;
  105876. private _pickedUpMesh;
  105877. private _pointerX;
  105878. private _pointerY;
  105879. private _unTranslatedPointerX;
  105880. private _unTranslatedPointerY;
  105881. private _startingPointerPosition;
  105882. private _previousStartingPointerPosition;
  105883. private _startingPointerTime;
  105884. private _previousStartingPointerTime;
  105885. private _pointerCaptures;
  105886. private _onKeyDown;
  105887. private _onKeyUp;
  105888. private _onCanvasFocusObserver;
  105889. private _onCanvasBlurObserver;
  105890. private _scene;
  105891. /**
  105892. * Creates a new InputManager
  105893. * @param scene defines the hosting scene
  105894. */
  105895. constructor(scene: Scene);
  105896. /**
  105897. * Gets the mesh that is currently under the pointer
  105898. */
  105899. get meshUnderPointer(): Nullable<AbstractMesh>;
  105900. /**
  105901. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  105902. */
  105903. get unTranslatedPointer(): Vector2;
  105904. /**
  105905. * Gets or sets the current on-screen X position of the pointer
  105906. */
  105907. get pointerX(): number;
  105908. set pointerX(value: number);
  105909. /**
  105910. * Gets or sets the current on-screen Y position of the pointer
  105911. */
  105912. get pointerY(): number;
  105913. set pointerY(value: number);
  105914. private _updatePointerPosition;
  105915. private _processPointerMove;
  105916. private _setRayOnPointerInfo;
  105917. private _checkPrePointerObservable;
  105918. /**
  105919. * Use this method to simulate a pointer move on a mesh
  105920. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105921. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105922. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105923. */
  105924. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105925. /**
  105926. * Use this method to simulate a pointer down on a mesh
  105927. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105928. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105929. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105930. */
  105931. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  105932. private _processPointerDown;
  105933. /** @hidden */
  105934. _isPointerSwiping(): boolean;
  105935. /**
  105936. * Use this method to simulate a pointer up on a mesh
  105937. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  105938. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  105939. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  105940. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  105941. */
  105942. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  105943. private _processPointerUp;
  105944. /**
  105945. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  105946. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  105947. * @returns true if the pointer was captured
  105948. */
  105949. isPointerCaptured(pointerId?: number): boolean;
  105950. /**
  105951. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  105952. * @param attachUp defines if you want to attach events to pointerup
  105953. * @param attachDown defines if you want to attach events to pointerdown
  105954. * @param attachMove defines if you want to attach events to pointermove
  105955. */
  105956. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  105957. /**
  105958. * Detaches all event handlers
  105959. */
  105960. detachControl(): void;
  105961. /**
  105962. * Force the value of meshUnderPointer
  105963. * @param mesh defines the mesh to use
  105964. */
  105965. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  105966. /**
  105967. * Gets the mesh under the pointer
  105968. * @returns a Mesh or null if no mesh is under the pointer
  105969. */
  105970. getPointerOverMesh(): Nullable<AbstractMesh>;
  105971. }
  105972. }
  105973. declare module BABYLON {
  105974. /**
  105975. * Helper class used to generate session unique ID
  105976. */
  105977. export class UniqueIdGenerator {
  105978. private static _UniqueIdCounter;
  105979. /**
  105980. * Gets an unique (relatively to the current scene) Id
  105981. */
  105982. static get UniqueId(): number;
  105983. }
  105984. }
  105985. declare module BABYLON {
  105986. /**
  105987. * This class defines the direct association between an animation and a target
  105988. */
  105989. export class TargetedAnimation {
  105990. /**
  105991. * Animation to perform
  105992. */
  105993. animation: Animation;
  105994. /**
  105995. * Target to animate
  105996. */
  105997. target: any;
  105998. /**
  105999. * Serialize the object
  106000. * @returns the JSON object representing the current entity
  106001. */
  106002. serialize(): any;
  106003. }
  106004. /**
  106005. * Use this class to create coordinated animations on multiple targets
  106006. */
  106007. export class AnimationGroup implements IDisposable {
  106008. /** The name of the animation group */
  106009. name: string;
  106010. private _scene;
  106011. private _targetedAnimations;
  106012. private _animatables;
  106013. private _from;
  106014. private _to;
  106015. private _isStarted;
  106016. private _isPaused;
  106017. private _speedRatio;
  106018. private _loopAnimation;
  106019. /**
  106020. * Gets or sets the unique id of the node
  106021. */
  106022. uniqueId: number;
  106023. /**
  106024. * This observable will notify when one animation have ended
  106025. */
  106026. onAnimationEndObservable: Observable<TargetedAnimation>;
  106027. /**
  106028. * Observer raised when one animation loops
  106029. */
  106030. onAnimationLoopObservable: Observable<TargetedAnimation>;
  106031. /**
  106032. * Observer raised when all animations have looped
  106033. */
  106034. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  106035. /**
  106036. * This observable will notify when all animations have ended.
  106037. */
  106038. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  106039. /**
  106040. * This observable will notify when all animations have paused.
  106041. */
  106042. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  106043. /**
  106044. * This observable will notify when all animations are playing.
  106045. */
  106046. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  106047. /**
  106048. * Gets the first frame
  106049. */
  106050. get from(): number;
  106051. /**
  106052. * Gets the last frame
  106053. */
  106054. get to(): number;
  106055. /**
  106056. * Define if the animations are started
  106057. */
  106058. get isStarted(): boolean;
  106059. /**
  106060. * Gets a value indicating that the current group is playing
  106061. */
  106062. get isPlaying(): boolean;
  106063. /**
  106064. * Gets or sets the speed ratio to use for all animations
  106065. */
  106066. get speedRatio(): number;
  106067. /**
  106068. * Gets or sets the speed ratio to use for all animations
  106069. */
  106070. set speedRatio(value: number);
  106071. /**
  106072. * Gets or sets if all animations should loop or not
  106073. */
  106074. get loopAnimation(): boolean;
  106075. set loopAnimation(value: boolean);
  106076. /**
  106077. * Gets the targeted animations for this animation group
  106078. */
  106079. get targetedAnimations(): Array<TargetedAnimation>;
  106080. /**
  106081. * returning the list of animatables controlled by this animation group.
  106082. */
  106083. get animatables(): Array<Animatable>;
  106084. /**
  106085. * Instantiates a new Animation Group.
  106086. * This helps managing several animations at once.
  106087. * @see http://doc.babylonjs.com/how_to/group
  106088. * @param name Defines the name of the group
  106089. * @param scene Defines the scene the group belongs to
  106090. */
  106091. constructor(
  106092. /** The name of the animation group */
  106093. name: string, scene?: Nullable<Scene>);
  106094. /**
  106095. * Add an animation (with its target) in the group
  106096. * @param animation defines the animation we want to add
  106097. * @param target defines the target of the animation
  106098. * @returns the TargetedAnimation object
  106099. */
  106100. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  106101. /**
  106102. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  106103. * It can add constant keys at begin or end
  106104. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  106105. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  106106. * @returns the animation group
  106107. */
  106108. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  106109. private _animationLoopCount;
  106110. private _animationLoopFlags;
  106111. private _processLoop;
  106112. /**
  106113. * Start all animations on given targets
  106114. * @param loop defines if animations must loop
  106115. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  106116. * @param from defines the from key (optional)
  106117. * @param to defines the to key (optional)
  106118. * @returns the current animation group
  106119. */
  106120. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  106121. /**
  106122. * Pause all animations
  106123. * @returns the animation group
  106124. */
  106125. pause(): AnimationGroup;
  106126. /**
  106127. * Play all animations to initial state
  106128. * This function will start() the animations if they were not started or will restart() them if they were paused
  106129. * @param loop defines if animations must loop
  106130. * @returns the animation group
  106131. */
  106132. play(loop?: boolean): AnimationGroup;
  106133. /**
  106134. * Reset all animations to initial state
  106135. * @returns the animation group
  106136. */
  106137. reset(): AnimationGroup;
  106138. /**
  106139. * Restart animations from key 0
  106140. * @returns the animation group
  106141. */
  106142. restart(): AnimationGroup;
  106143. /**
  106144. * Stop all animations
  106145. * @returns the animation group
  106146. */
  106147. stop(): AnimationGroup;
  106148. /**
  106149. * Set animation weight for all animatables
  106150. * @param weight defines the weight to use
  106151. * @return the animationGroup
  106152. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  106153. */
  106154. setWeightForAllAnimatables(weight: number): AnimationGroup;
  106155. /**
  106156. * Synchronize and normalize all animatables with a source animatable
  106157. * @param root defines the root animatable to synchronize with
  106158. * @return the animationGroup
  106159. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  106160. */
  106161. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  106162. /**
  106163. * Goes to a specific frame in this animation group
  106164. * @param frame the frame number to go to
  106165. * @return the animationGroup
  106166. */
  106167. goToFrame(frame: number): AnimationGroup;
  106168. /**
  106169. * Dispose all associated resources
  106170. */
  106171. dispose(): void;
  106172. private _checkAnimationGroupEnded;
  106173. /**
  106174. * Clone the current animation group and returns a copy
  106175. * @param newName defines the name of the new group
  106176. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  106177. * @returns the new aniamtion group
  106178. */
  106179. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  106180. /**
  106181. * Serializes the animationGroup to an object
  106182. * @returns Serialized object
  106183. */
  106184. serialize(): any;
  106185. /**
  106186. * Returns a new AnimationGroup object parsed from the source provided.
  106187. * @param parsedAnimationGroup defines the source
  106188. * @param scene defines the scene that will receive the animationGroup
  106189. * @returns a new AnimationGroup
  106190. */
  106191. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  106192. /**
  106193. * Returns the string "AnimationGroup"
  106194. * @returns "AnimationGroup"
  106195. */
  106196. getClassName(): string;
  106197. /**
  106198. * Creates a detailled string about the object
  106199. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  106200. * @returns a string representing the object
  106201. */
  106202. toString(fullDetails?: boolean): string;
  106203. }
  106204. }
  106205. declare module BABYLON {
  106206. /**
  106207. * Define an interface for all classes that will hold resources
  106208. */
  106209. export interface IDisposable {
  106210. /**
  106211. * Releases all held resources
  106212. */
  106213. dispose(): void;
  106214. }
  106215. /** Interface defining initialization parameters for Scene class */
  106216. export interface SceneOptions {
  106217. /**
  106218. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  106219. * It will improve performance when the number of geometries becomes important.
  106220. */
  106221. useGeometryUniqueIdsMap?: boolean;
  106222. /**
  106223. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  106224. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  106225. */
  106226. useMaterialMeshMap?: boolean;
  106227. /**
  106228. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  106229. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  106230. */
  106231. useClonedMeshMap?: boolean;
  106232. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  106233. virtual?: boolean;
  106234. }
  106235. /**
  106236. * Represents a scene to be rendered by the engine.
  106237. * @see http://doc.babylonjs.com/features/scene
  106238. */
  106239. export class Scene extends AbstractScene implements IAnimatable {
  106240. /** The fog is deactivated */
  106241. static readonly FOGMODE_NONE: number;
  106242. /** The fog density is following an exponential function */
  106243. static readonly FOGMODE_EXP: number;
  106244. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  106245. static readonly FOGMODE_EXP2: number;
  106246. /** The fog density is following a linear function. */
  106247. static readonly FOGMODE_LINEAR: number;
  106248. /**
  106249. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  106250. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106251. */
  106252. static MinDeltaTime: number;
  106253. /**
  106254. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  106255. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106256. */
  106257. static MaxDeltaTime: number;
  106258. /**
  106259. * Factory used to create the default material.
  106260. * @param name The name of the material to create
  106261. * @param scene The scene to create the material for
  106262. * @returns The default material
  106263. */
  106264. static DefaultMaterialFactory(scene: Scene): Material;
  106265. /**
  106266. * Factory used to create the a collision coordinator.
  106267. * @returns The collision coordinator
  106268. */
  106269. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  106270. /** @hidden */
  106271. _inputManager: InputManager;
  106272. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  106273. cameraToUseForPointers: Nullable<Camera>;
  106274. /** @hidden */
  106275. readonly _isScene: boolean;
  106276. /**
  106277. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  106278. */
  106279. autoClear: boolean;
  106280. /**
  106281. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  106282. */
  106283. autoClearDepthAndStencil: boolean;
  106284. /**
  106285. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  106286. */
  106287. clearColor: Color4;
  106288. /**
  106289. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  106290. */
  106291. ambientColor: Color3;
  106292. /**
  106293. * This is use to store the default BRDF lookup for PBR materials in your scene.
  106294. * It should only be one of the following (if not the default embedded one):
  106295. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  106296. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  106297. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  106298. * The material properties need to be setup according to the type of texture in use.
  106299. */
  106300. environmentBRDFTexture: BaseTexture;
  106301. /** @hidden */
  106302. protected _environmentTexture: Nullable<BaseTexture>;
  106303. /**
  106304. * Texture used in all pbr material as the reflection texture.
  106305. * As in the majority of the scene they are the same (exception for multi room and so on),
  106306. * this is easier to reference from here than from all the materials.
  106307. */
  106308. get environmentTexture(): Nullable<BaseTexture>;
  106309. /**
  106310. * Texture used in all pbr material as the reflection texture.
  106311. * As in the majority of the scene they are the same (exception for multi room and so on),
  106312. * this is easier to set here than in all the materials.
  106313. */
  106314. set environmentTexture(value: Nullable<BaseTexture>);
  106315. /** @hidden */
  106316. protected _environmentIntensity: number;
  106317. /**
  106318. * Intensity of the environment in all pbr material.
  106319. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  106320. * As in the majority of the scene they are the same (exception for multi room and so on),
  106321. * this is easier to reference from here than from all the materials.
  106322. */
  106323. get environmentIntensity(): number;
  106324. /**
  106325. * Intensity of the environment in all pbr material.
  106326. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  106327. * As in the majority of the scene they are the same (exception for multi room and so on),
  106328. * this is easier to set here than in all the materials.
  106329. */
  106330. set environmentIntensity(value: number);
  106331. /** @hidden */
  106332. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106333. /**
  106334. * Default image processing configuration used either in the rendering
  106335. * Forward main pass or through the imageProcessingPostProcess if present.
  106336. * As in the majority of the scene they are the same (exception for multi camera),
  106337. * this is easier to reference from here than from all the materials and post process.
  106338. *
  106339. * No setter as we it is a shared configuration, you can set the values instead.
  106340. */
  106341. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  106342. private _forceWireframe;
  106343. /**
  106344. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  106345. */
  106346. set forceWireframe(value: boolean);
  106347. get forceWireframe(): boolean;
  106348. private _skipFrustumClipping;
  106349. /**
  106350. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  106351. */
  106352. set skipFrustumClipping(value: boolean);
  106353. get skipFrustumClipping(): boolean;
  106354. private _forcePointsCloud;
  106355. /**
  106356. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  106357. */
  106358. set forcePointsCloud(value: boolean);
  106359. get forcePointsCloud(): boolean;
  106360. /**
  106361. * Gets or sets the active clipplane 1
  106362. */
  106363. clipPlane: Nullable<Plane>;
  106364. /**
  106365. * Gets or sets the active clipplane 2
  106366. */
  106367. clipPlane2: Nullable<Plane>;
  106368. /**
  106369. * Gets or sets the active clipplane 3
  106370. */
  106371. clipPlane3: Nullable<Plane>;
  106372. /**
  106373. * Gets or sets the active clipplane 4
  106374. */
  106375. clipPlane4: Nullable<Plane>;
  106376. /**
  106377. * Gets or sets the active clipplane 5
  106378. */
  106379. clipPlane5: Nullable<Plane>;
  106380. /**
  106381. * Gets or sets the active clipplane 6
  106382. */
  106383. clipPlane6: Nullable<Plane>;
  106384. /**
  106385. * Gets or sets a boolean indicating if animations are enabled
  106386. */
  106387. animationsEnabled: boolean;
  106388. private _animationPropertiesOverride;
  106389. /**
  106390. * Gets or sets the animation properties override
  106391. */
  106392. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106393. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106394. /**
  106395. * Gets or sets a boolean indicating if a constant deltatime has to be used
  106396. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  106397. */
  106398. useConstantAnimationDeltaTime: boolean;
  106399. /**
  106400. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  106401. * Please note that it requires to run a ray cast through the scene on every frame
  106402. */
  106403. constantlyUpdateMeshUnderPointer: boolean;
  106404. /**
  106405. * Defines the HTML cursor to use when hovering over interactive elements
  106406. */
  106407. hoverCursor: string;
  106408. /**
  106409. * Defines the HTML default cursor to use (empty by default)
  106410. */
  106411. defaultCursor: string;
  106412. /**
  106413. * Defines wether cursors are handled by the scene.
  106414. */
  106415. doNotHandleCursors: boolean;
  106416. /**
  106417. * This is used to call preventDefault() on pointer down
  106418. * in order to block unwanted artifacts like system double clicks
  106419. */
  106420. preventDefaultOnPointerDown: boolean;
  106421. /**
  106422. * This is used to call preventDefault() on pointer up
  106423. * in order to block unwanted artifacts like system double clicks
  106424. */
  106425. preventDefaultOnPointerUp: boolean;
  106426. /**
  106427. * Gets or sets user defined metadata
  106428. */
  106429. metadata: any;
  106430. /**
  106431. * For internal use only. Please do not use.
  106432. */
  106433. reservedDataStore: any;
  106434. /**
  106435. * Gets the name of the plugin used to load this scene (null by default)
  106436. */
  106437. loadingPluginName: string;
  106438. /**
  106439. * Use this array to add regular expressions used to disable offline support for specific urls
  106440. */
  106441. disableOfflineSupportExceptionRules: RegExp[];
  106442. /**
  106443. * An event triggered when the scene is disposed.
  106444. */
  106445. onDisposeObservable: Observable<Scene>;
  106446. private _onDisposeObserver;
  106447. /** Sets a function to be executed when this scene is disposed. */
  106448. set onDispose(callback: () => void);
  106449. /**
  106450. * An event triggered before rendering the scene (right after animations and physics)
  106451. */
  106452. onBeforeRenderObservable: Observable<Scene>;
  106453. private _onBeforeRenderObserver;
  106454. /** Sets a function to be executed before rendering this scene */
  106455. set beforeRender(callback: Nullable<() => void>);
  106456. /**
  106457. * An event triggered after rendering the scene
  106458. */
  106459. onAfterRenderObservable: Observable<Scene>;
  106460. /**
  106461. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  106462. */
  106463. onAfterRenderCameraObservable: Observable<Camera>;
  106464. private _onAfterRenderObserver;
  106465. /** Sets a function to be executed after rendering this scene */
  106466. set afterRender(callback: Nullable<() => void>);
  106467. /**
  106468. * An event triggered before animating the scene
  106469. */
  106470. onBeforeAnimationsObservable: Observable<Scene>;
  106471. /**
  106472. * An event triggered after animations processing
  106473. */
  106474. onAfterAnimationsObservable: Observable<Scene>;
  106475. /**
  106476. * An event triggered before draw calls are ready to be sent
  106477. */
  106478. onBeforeDrawPhaseObservable: Observable<Scene>;
  106479. /**
  106480. * An event triggered after draw calls have been sent
  106481. */
  106482. onAfterDrawPhaseObservable: Observable<Scene>;
  106483. /**
  106484. * An event triggered when the scene is ready
  106485. */
  106486. onReadyObservable: Observable<Scene>;
  106487. /**
  106488. * An event triggered before rendering a camera
  106489. */
  106490. onBeforeCameraRenderObservable: Observable<Camera>;
  106491. private _onBeforeCameraRenderObserver;
  106492. /** Sets a function to be executed before rendering a camera*/
  106493. set beforeCameraRender(callback: () => void);
  106494. /**
  106495. * An event triggered after rendering a camera
  106496. */
  106497. onAfterCameraRenderObservable: Observable<Camera>;
  106498. private _onAfterCameraRenderObserver;
  106499. /** Sets a function to be executed after rendering a camera*/
  106500. set afterCameraRender(callback: () => void);
  106501. /**
  106502. * An event triggered when active meshes evaluation is about to start
  106503. */
  106504. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  106505. /**
  106506. * An event triggered when active meshes evaluation is done
  106507. */
  106508. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  106509. /**
  106510. * An event triggered when particles rendering is about to start
  106511. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  106512. */
  106513. onBeforeParticlesRenderingObservable: Observable<Scene>;
  106514. /**
  106515. * An event triggered when particles rendering is done
  106516. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  106517. */
  106518. onAfterParticlesRenderingObservable: Observable<Scene>;
  106519. /**
  106520. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  106521. */
  106522. onDataLoadedObservable: Observable<Scene>;
  106523. /**
  106524. * An event triggered when a camera is created
  106525. */
  106526. onNewCameraAddedObservable: Observable<Camera>;
  106527. /**
  106528. * An event triggered when a camera is removed
  106529. */
  106530. onCameraRemovedObservable: Observable<Camera>;
  106531. /**
  106532. * An event triggered when a light is created
  106533. */
  106534. onNewLightAddedObservable: Observable<Light>;
  106535. /**
  106536. * An event triggered when a light is removed
  106537. */
  106538. onLightRemovedObservable: Observable<Light>;
  106539. /**
  106540. * An event triggered when a geometry is created
  106541. */
  106542. onNewGeometryAddedObservable: Observable<Geometry>;
  106543. /**
  106544. * An event triggered when a geometry is removed
  106545. */
  106546. onGeometryRemovedObservable: Observable<Geometry>;
  106547. /**
  106548. * An event triggered when a transform node is created
  106549. */
  106550. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  106551. /**
  106552. * An event triggered when a transform node is removed
  106553. */
  106554. onTransformNodeRemovedObservable: Observable<TransformNode>;
  106555. /**
  106556. * An event triggered when a mesh is created
  106557. */
  106558. onNewMeshAddedObservable: Observable<AbstractMesh>;
  106559. /**
  106560. * An event triggered when a mesh is removed
  106561. */
  106562. onMeshRemovedObservable: Observable<AbstractMesh>;
  106563. /**
  106564. * An event triggered when a skeleton is created
  106565. */
  106566. onNewSkeletonAddedObservable: Observable<Skeleton>;
  106567. /**
  106568. * An event triggered when a skeleton is removed
  106569. */
  106570. onSkeletonRemovedObservable: Observable<Skeleton>;
  106571. /**
  106572. * An event triggered when a material is created
  106573. */
  106574. onNewMaterialAddedObservable: Observable<Material>;
  106575. /**
  106576. * An event triggered when a material is removed
  106577. */
  106578. onMaterialRemovedObservable: Observable<Material>;
  106579. /**
  106580. * An event triggered when a texture is created
  106581. */
  106582. onNewTextureAddedObservable: Observable<BaseTexture>;
  106583. /**
  106584. * An event triggered when a texture is removed
  106585. */
  106586. onTextureRemovedObservable: Observable<BaseTexture>;
  106587. /**
  106588. * An event triggered when render targets are about to be rendered
  106589. * Can happen multiple times per frame.
  106590. */
  106591. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  106592. /**
  106593. * An event triggered when render targets were rendered.
  106594. * Can happen multiple times per frame.
  106595. */
  106596. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  106597. /**
  106598. * An event triggered before calculating deterministic simulation step
  106599. */
  106600. onBeforeStepObservable: Observable<Scene>;
  106601. /**
  106602. * An event triggered after calculating deterministic simulation step
  106603. */
  106604. onAfterStepObservable: Observable<Scene>;
  106605. /**
  106606. * An event triggered when the activeCamera property is updated
  106607. */
  106608. onActiveCameraChanged: Observable<Scene>;
  106609. /**
  106610. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  106611. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  106612. * 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)
  106613. */
  106614. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  106615. /**
  106616. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  106617. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  106618. * 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)
  106619. */
  106620. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  106621. /**
  106622. * This Observable will when a mesh has been imported into the scene.
  106623. */
  106624. onMeshImportedObservable: Observable<AbstractMesh>;
  106625. /**
  106626. * This Observable will when an animation file has been imported into the scene.
  106627. */
  106628. onAnimationFileImportedObservable: Observable<Scene>;
  106629. /**
  106630. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  106631. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  106632. */
  106633. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  106634. /** @hidden */
  106635. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  106636. /**
  106637. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  106638. */
  106639. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  106640. /**
  106641. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  106642. */
  106643. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  106644. /**
  106645. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  106646. */
  106647. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  106648. /** Callback called when a pointer move is detected */
  106649. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  106650. /** Callback called when a pointer down is detected */
  106651. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  106652. /** Callback called when a pointer up is detected */
  106653. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  106654. /** Callback called when a pointer pick is detected */
  106655. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  106656. /**
  106657. * 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).
  106658. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  106659. */
  106660. onPrePointerObservable: Observable<PointerInfoPre>;
  106661. /**
  106662. * Observable event triggered each time an input event is received from the rendering canvas
  106663. */
  106664. onPointerObservable: Observable<PointerInfo>;
  106665. /**
  106666. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  106667. */
  106668. get unTranslatedPointer(): Vector2;
  106669. /**
  106670. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  106671. */
  106672. static get DragMovementThreshold(): number;
  106673. static set DragMovementThreshold(value: number);
  106674. /**
  106675. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  106676. */
  106677. static get LongPressDelay(): number;
  106678. static set LongPressDelay(value: number);
  106679. /**
  106680. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  106681. */
  106682. static get DoubleClickDelay(): number;
  106683. static set DoubleClickDelay(value: number);
  106684. /** If you need to check double click without raising a single click at first click, enable this flag */
  106685. static get ExclusiveDoubleClickMode(): boolean;
  106686. static set ExclusiveDoubleClickMode(value: boolean);
  106687. /** @hidden */
  106688. _mirroredCameraPosition: Nullable<Vector3>;
  106689. /**
  106690. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  106691. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  106692. */
  106693. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  106694. /**
  106695. * Observable event triggered each time an keyboard event is received from the hosting window
  106696. */
  106697. onKeyboardObservable: Observable<KeyboardInfo>;
  106698. private _useRightHandedSystem;
  106699. /**
  106700. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  106701. */
  106702. set useRightHandedSystem(value: boolean);
  106703. get useRightHandedSystem(): boolean;
  106704. private _timeAccumulator;
  106705. private _currentStepId;
  106706. private _currentInternalStep;
  106707. /**
  106708. * Sets the step Id used by deterministic lock step
  106709. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106710. * @param newStepId defines the step Id
  106711. */
  106712. setStepId(newStepId: number): void;
  106713. /**
  106714. * Gets the step Id used by deterministic lock step
  106715. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106716. * @returns the step Id
  106717. */
  106718. getStepId(): number;
  106719. /**
  106720. * Gets the internal step used by deterministic lock step
  106721. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106722. * @returns the internal step
  106723. */
  106724. getInternalStep(): number;
  106725. private _fogEnabled;
  106726. /**
  106727. * Gets or sets a boolean indicating if fog is enabled on this scene
  106728. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106729. * (Default is true)
  106730. */
  106731. set fogEnabled(value: boolean);
  106732. get fogEnabled(): boolean;
  106733. private _fogMode;
  106734. /**
  106735. * Gets or sets the fog mode to use
  106736. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106737. * | mode | value |
  106738. * | --- | --- |
  106739. * | FOGMODE_NONE | 0 |
  106740. * | FOGMODE_EXP | 1 |
  106741. * | FOGMODE_EXP2 | 2 |
  106742. * | FOGMODE_LINEAR | 3 |
  106743. */
  106744. set fogMode(value: number);
  106745. get fogMode(): number;
  106746. /**
  106747. * Gets or sets the fog color to use
  106748. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106749. * (Default is Color3(0.2, 0.2, 0.3))
  106750. */
  106751. fogColor: Color3;
  106752. /**
  106753. * Gets or sets the fog density to use
  106754. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106755. * (Default is 0.1)
  106756. */
  106757. fogDensity: number;
  106758. /**
  106759. * Gets or sets the fog start distance to use
  106760. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106761. * (Default is 0)
  106762. */
  106763. fogStart: number;
  106764. /**
  106765. * Gets or sets the fog end distance to use
  106766. * @see http://doc.babylonjs.com/babylon101/environment#fog
  106767. * (Default is 1000)
  106768. */
  106769. fogEnd: number;
  106770. private _shadowsEnabled;
  106771. /**
  106772. * Gets or sets a boolean indicating if shadows are enabled on this scene
  106773. */
  106774. set shadowsEnabled(value: boolean);
  106775. get shadowsEnabled(): boolean;
  106776. private _lightsEnabled;
  106777. /**
  106778. * Gets or sets a boolean indicating if lights are enabled on this scene
  106779. */
  106780. set lightsEnabled(value: boolean);
  106781. get lightsEnabled(): boolean;
  106782. /** All of the active cameras added to this scene. */
  106783. activeCameras: Camera[];
  106784. /** @hidden */
  106785. _activeCamera: Nullable<Camera>;
  106786. /** Gets or sets the current active camera */
  106787. get activeCamera(): Nullable<Camera>;
  106788. set activeCamera(value: Nullable<Camera>);
  106789. private _defaultMaterial;
  106790. /** The default material used on meshes when no material is affected */
  106791. get defaultMaterial(): Material;
  106792. /** The default material used on meshes when no material is affected */
  106793. set defaultMaterial(value: Material);
  106794. private _texturesEnabled;
  106795. /**
  106796. * Gets or sets a boolean indicating if textures are enabled on this scene
  106797. */
  106798. set texturesEnabled(value: boolean);
  106799. get texturesEnabled(): boolean;
  106800. /**
  106801. * Gets or sets a boolean indicating if particles are enabled on this scene
  106802. */
  106803. particlesEnabled: boolean;
  106804. /**
  106805. * Gets or sets a boolean indicating if sprites are enabled on this scene
  106806. */
  106807. spritesEnabled: boolean;
  106808. private _skeletonsEnabled;
  106809. /**
  106810. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  106811. */
  106812. set skeletonsEnabled(value: boolean);
  106813. get skeletonsEnabled(): boolean;
  106814. /**
  106815. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  106816. */
  106817. lensFlaresEnabled: boolean;
  106818. /**
  106819. * Gets or sets a boolean indicating if collisions are enabled on this scene
  106820. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106821. */
  106822. collisionsEnabled: boolean;
  106823. private _collisionCoordinator;
  106824. /** @hidden */
  106825. get collisionCoordinator(): ICollisionCoordinator;
  106826. /**
  106827. * Defines the gravity applied to this scene (used only for collisions)
  106828. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  106829. */
  106830. gravity: Vector3;
  106831. /**
  106832. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  106833. */
  106834. postProcessesEnabled: boolean;
  106835. /**
  106836. * The list of postprocesses added to the scene
  106837. */
  106838. postProcesses: PostProcess[];
  106839. /**
  106840. * Gets the current postprocess manager
  106841. */
  106842. postProcessManager: PostProcessManager;
  106843. /**
  106844. * Gets or sets a boolean indicating if render targets are enabled on this scene
  106845. */
  106846. renderTargetsEnabled: boolean;
  106847. /**
  106848. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  106849. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  106850. */
  106851. dumpNextRenderTargets: boolean;
  106852. /**
  106853. * The list of user defined render targets added to the scene
  106854. */
  106855. customRenderTargets: RenderTargetTexture[];
  106856. /**
  106857. * Defines if texture loading must be delayed
  106858. * If true, textures will only be loaded when they need to be rendered
  106859. */
  106860. useDelayedTextureLoading: boolean;
  106861. /**
  106862. * Gets the list of meshes imported to the scene through SceneLoader
  106863. */
  106864. importedMeshesFiles: String[];
  106865. /**
  106866. * Gets or sets a boolean indicating if probes are enabled on this scene
  106867. */
  106868. probesEnabled: boolean;
  106869. /**
  106870. * Gets or sets the current offline provider to use to store scene data
  106871. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  106872. */
  106873. offlineProvider: IOfflineProvider;
  106874. /**
  106875. * Gets or sets the action manager associated with the scene
  106876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  106877. */
  106878. actionManager: AbstractActionManager;
  106879. private _meshesForIntersections;
  106880. /**
  106881. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  106882. */
  106883. proceduralTexturesEnabled: boolean;
  106884. private _engine;
  106885. private _totalVertices;
  106886. /** @hidden */
  106887. _activeIndices: PerfCounter;
  106888. /** @hidden */
  106889. _activeParticles: PerfCounter;
  106890. /** @hidden */
  106891. _activeBones: PerfCounter;
  106892. private _animationRatio;
  106893. /** @hidden */
  106894. _animationTimeLast: number;
  106895. /** @hidden */
  106896. _animationTime: number;
  106897. /**
  106898. * Gets or sets a general scale for animation speed
  106899. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  106900. */
  106901. animationTimeScale: number;
  106902. /** @hidden */
  106903. _cachedMaterial: Nullable<Material>;
  106904. /** @hidden */
  106905. _cachedEffect: Nullable<Effect>;
  106906. /** @hidden */
  106907. _cachedVisibility: Nullable<number>;
  106908. private _renderId;
  106909. private _frameId;
  106910. private _executeWhenReadyTimeoutId;
  106911. private _intermediateRendering;
  106912. private _viewUpdateFlag;
  106913. private _projectionUpdateFlag;
  106914. /** @hidden */
  106915. _toBeDisposed: Nullable<IDisposable>[];
  106916. private _activeRequests;
  106917. /** @hidden */
  106918. _pendingData: any[];
  106919. private _isDisposed;
  106920. /**
  106921. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  106922. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  106923. */
  106924. dispatchAllSubMeshesOfActiveMeshes: boolean;
  106925. private _activeMeshes;
  106926. private _processedMaterials;
  106927. private _renderTargets;
  106928. /** @hidden */
  106929. _activeParticleSystems: SmartArray<IParticleSystem>;
  106930. private _activeSkeletons;
  106931. private _softwareSkinnedMeshes;
  106932. private _renderingManager;
  106933. /** @hidden */
  106934. _activeAnimatables: Animatable[];
  106935. private _transformMatrix;
  106936. private _sceneUbo;
  106937. /** @hidden */
  106938. _viewMatrix: Matrix;
  106939. private _projectionMatrix;
  106940. /** @hidden */
  106941. _forcedViewPosition: Nullable<Vector3>;
  106942. /** @hidden */
  106943. _frustumPlanes: Plane[];
  106944. /**
  106945. * Gets the list of frustum planes (built from the active camera)
  106946. */
  106947. get frustumPlanes(): Plane[];
  106948. /**
  106949. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  106950. * This is useful if there are more lights that the maximum simulteanous authorized
  106951. */
  106952. requireLightSorting: boolean;
  106953. /** @hidden */
  106954. readonly useMaterialMeshMap: boolean;
  106955. /** @hidden */
  106956. readonly useClonedMeshMap: boolean;
  106957. private _externalData;
  106958. private _uid;
  106959. /**
  106960. * @hidden
  106961. * Backing store of defined scene components.
  106962. */
  106963. _components: ISceneComponent[];
  106964. /**
  106965. * @hidden
  106966. * Backing store of defined scene components.
  106967. */
  106968. _serializableComponents: ISceneSerializableComponent[];
  106969. /**
  106970. * List of components to register on the next registration step.
  106971. */
  106972. private _transientComponents;
  106973. /**
  106974. * Registers the transient components if needed.
  106975. */
  106976. private _registerTransientComponents;
  106977. /**
  106978. * @hidden
  106979. * Add a component to the scene.
  106980. * Note that the ccomponent could be registered on th next frame if this is called after
  106981. * the register component stage.
  106982. * @param component Defines the component to add to the scene
  106983. */
  106984. _addComponent(component: ISceneComponent): void;
  106985. /**
  106986. * @hidden
  106987. * Gets a component from the scene.
  106988. * @param name defines the name of the component to retrieve
  106989. * @returns the component or null if not present
  106990. */
  106991. _getComponent(name: string): Nullable<ISceneComponent>;
  106992. /**
  106993. * @hidden
  106994. * Defines the actions happening before camera updates.
  106995. */
  106996. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  106997. /**
  106998. * @hidden
  106999. * Defines the actions happening before clear the canvas.
  107000. */
  107001. _beforeClearStage: Stage<SimpleStageAction>;
  107002. /**
  107003. * @hidden
  107004. * Defines the actions when collecting render targets for the frame.
  107005. */
  107006. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  107007. /**
  107008. * @hidden
  107009. * Defines the actions happening for one camera in the frame.
  107010. */
  107011. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  107012. /**
  107013. * @hidden
  107014. * Defines the actions happening during the per mesh ready checks.
  107015. */
  107016. _isReadyForMeshStage: Stage<MeshStageAction>;
  107017. /**
  107018. * @hidden
  107019. * Defines the actions happening before evaluate active mesh checks.
  107020. */
  107021. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  107022. /**
  107023. * @hidden
  107024. * Defines the actions happening during the evaluate sub mesh checks.
  107025. */
  107026. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  107027. /**
  107028. * @hidden
  107029. * Defines the actions happening during the active mesh stage.
  107030. */
  107031. _activeMeshStage: Stage<ActiveMeshStageAction>;
  107032. /**
  107033. * @hidden
  107034. * Defines the actions happening during the per camera render target step.
  107035. */
  107036. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  107037. /**
  107038. * @hidden
  107039. * Defines the actions happening just before the active camera is drawing.
  107040. */
  107041. _beforeCameraDrawStage: Stage<CameraStageAction>;
  107042. /**
  107043. * @hidden
  107044. * Defines the actions happening just before a render target is drawing.
  107045. */
  107046. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  107047. /**
  107048. * @hidden
  107049. * Defines the actions happening just before a rendering group is drawing.
  107050. */
  107051. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  107052. /**
  107053. * @hidden
  107054. * Defines the actions happening just before a mesh is drawing.
  107055. */
  107056. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  107057. /**
  107058. * @hidden
  107059. * Defines the actions happening just after a mesh has been drawn.
  107060. */
  107061. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  107062. /**
  107063. * @hidden
  107064. * Defines the actions happening just after a rendering group has been drawn.
  107065. */
  107066. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  107067. /**
  107068. * @hidden
  107069. * Defines the actions happening just after the active camera has been drawn.
  107070. */
  107071. _afterCameraDrawStage: Stage<CameraStageAction>;
  107072. /**
  107073. * @hidden
  107074. * Defines the actions happening just after a render target has been drawn.
  107075. */
  107076. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  107077. /**
  107078. * @hidden
  107079. * Defines the actions happening just after rendering all cameras and computing intersections.
  107080. */
  107081. _afterRenderStage: Stage<SimpleStageAction>;
  107082. /**
  107083. * @hidden
  107084. * Defines the actions happening when a pointer move event happens.
  107085. */
  107086. _pointerMoveStage: Stage<PointerMoveStageAction>;
  107087. /**
  107088. * @hidden
  107089. * Defines the actions happening when a pointer down event happens.
  107090. */
  107091. _pointerDownStage: Stage<PointerUpDownStageAction>;
  107092. /**
  107093. * @hidden
  107094. * Defines the actions happening when a pointer up event happens.
  107095. */
  107096. _pointerUpStage: Stage<PointerUpDownStageAction>;
  107097. /**
  107098. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  107099. */
  107100. private geometriesByUniqueId;
  107101. /**
  107102. * Creates a new Scene
  107103. * @param engine defines the engine to use to render this scene
  107104. * @param options defines the scene options
  107105. */
  107106. constructor(engine: Engine, options?: SceneOptions);
  107107. /**
  107108. * Gets a string idenfifying the name of the class
  107109. * @returns "Scene" string
  107110. */
  107111. getClassName(): string;
  107112. private _defaultMeshCandidates;
  107113. /**
  107114. * @hidden
  107115. */
  107116. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  107117. private _defaultSubMeshCandidates;
  107118. /**
  107119. * @hidden
  107120. */
  107121. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  107122. /**
  107123. * Sets the default candidate providers for the scene.
  107124. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  107125. * and getCollidingSubMeshCandidates to their default function
  107126. */
  107127. setDefaultCandidateProviders(): void;
  107128. /**
  107129. * Gets the mesh that is currently under the pointer
  107130. */
  107131. get meshUnderPointer(): Nullable<AbstractMesh>;
  107132. /**
  107133. * Gets or sets the current on-screen X position of the pointer
  107134. */
  107135. get pointerX(): number;
  107136. set pointerX(value: number);
  107137. /**
  107138. * Gets or sets the current on-screen Y position of the pointer
  107139. */
  107140. get pointerY(): number;
  107141. set pointerY(value: number);
  107142. /**
  107143. * Gets the cached material (ie. the latest rendered one)
  107144. * @returns the cached material
  107145. */
  107146. getCachedMaterial(): Nullable<Material>;
  107147. /**
  107148. * Gets the cached effect (ie. the latest rendered one)
  107149. * @returns the cached effect
  107150. */
  107151. getCachedEffect(): Nullable<Effect>;
  107152. /**
  107153. * Gets the cached visibility state (ie. the latest rendered one)
  107154. * @returns the cached visibility state
  107155. */
  107156. getCachedVisibility(): Nullable<number>;
  107157. /**
  107158. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  107159. * @param material defines the current material
  107160. * @param effect defines the current effect
  107161. * @param visibility defines the current visibility state
  107162. * @returns true if one parameter is not cached
  107163. */
  107164. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  107165. /**
  107166. * Gets the engine associated with the scene
  107167. * @returns an Engine
  107168. */
  107169. getEngine(): Engine;
  107170. /**
  107171. * Gets the total number of vertices rendered per frame
  107172. * @returns the total number of vertices rendered per frame
  107173. */
  107174. getTotalVertices(): number;
  107175. /**
  107176. * Gets the performance counter for total vertices
  107177. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  107178. */
  107179. get totalVerticesPerfCounter(): PerfCounter;
  107180. /**
  107181. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  107182. * @returns the total number of active indices rendered per frame
  107183. */
  107184. getActiveIndices(): number;
  107185. /**
  107186. * Gets the performance counter for active indices
  107187. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  107188. */
  107189. get totalActiveIndicesPerfCounter(): PerfCounter;
  107190. /**
  107191. * Gets the total number of active particles rendered per frame
  107192. * @returns the total number of active particles rendered per frame
  107193. */
  107194. getActiveParticles(): number;
  107195. /**
  107196. * Gets the performance counter for active particles
  107197. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  107198. */
  107199. get activeParticlesPerfCounter(): PerfCounter;
  107200. /**
  107201. * Gets the total number of active bones rendered per frame
  107202. * @returns the total number of active bones rendered per frame
  107203. */
  107204. getActiveBones(): number;
  107205. /**
  107206. * Gets the performance counter for active bones
  107207. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  107208. */
  107209. get activeBonesPerfCounter(): PerfCounter;
  107210. /**
  107211. * Gets the array of active meshes
  107212. * @returns an array of AbstractMesh
  107213. */
  107214. getActiveMeshes(): SmartArray<AbstractMesh>;
  107215. /**
  107216. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  107217. * @returns a number
  107218. */
  107219. getAnimationRatio(): number;
  107220. /**
  107221. * Gets an unique Id for the current render phase
  107222. * @returns a number
  107223. */
  107224. getRenderId(): number;
  107225. /**
  107226. * Gets an unique Id for the current frame
  107227. * @returns a number
  107228. */
  107229. getFrameId(): number;
  107230. /** Call this function if you want to manually increment the render Id*/
  107231. incrementRenderId(): void;
  107232. private _createUbo;
  107233. /**
  107234. * Use this method to simulate a pointer move on a mesh
  107235. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107236. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107237. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107238. * @returns the current scene
  107239. */
  107240. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  107241. /**
  107242. * Use this method to simulate a pointer down on a mesh
  107243. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107244. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107245. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107246. * @returns the current scene
  107247. */
  107248. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  107249. /**
  107250. * Use this method to simulate a pointer up on a mesh
  107251. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107252. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107253. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107254. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107255. * @returns the current scene
  107256. */
  107257. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  107258. /**
  107259. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107260. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107261. * @returns true if the pointer was captured
  107262. */
  107263. isPointerCaptured(pointerId?: number): boolean;
  107264. /**
  107265. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  107266. * @param attachUp defines if you want to attach events to pointerup
  107267. * @param attachDown defines if you want to attach events to pointerdown
  107268. * @param attachMove defines if you want to attach events to pointermove
  107269. */
  107270. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  107271. /** Detaches all event handlers*/
  107272. detachControl(): void;
  107273. /**
  107274. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  107275. * Delay loaded resources are not taking in account
  107276. * @return true if all required resources are ready
  107277. */
  107278. isReady(): boolean;
  107279. /** Resets all cached information relative to material (including effect and visibility) */
  107280. resetCachedMaterial(): void;
  107281. /**
  107282. * Registers a function to be called before every frame render
  107283. * @param func defines the function to register
  107284. */
  107285. registerBeforeRender(func: () => void): void;
  107286. /**
  107287. * Unregisters a function called before every frame render
  107288. * @param func defines the function to unregister
  107289. */
  107290. unregisterBeforeRender(func: () => void): void;
  107291. /**
  107292. * Registers a function to be called after every frame render
  107293. * @param func defines the function to register
  107294. */
  107295. registerAfterRender(func: () => void): void;
  107296. /**
  107297. * Unregisters a function called after every frame render
  107298. * @param func defines the function to unregister
  107299. */
  107300. unregisterAfterRender(func: () => void): void;
  107301. private _executeOnceBeforeRender;
  107302. /**
  107303. * The provided function will run before render once and will be disposed afterwards.
  107304. * A timeout delay can be provided so that the function will be executed in N ms.
  107305. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  107306. * @param func The function to be executed.
  107307. * @param timeout optional delay in ms
  107308. */
  107309. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  107310. /** @hidden */
  107311. _addPendingData(data: any): void;
  107312. /** @hidden */
  107313. _removePendingData(data: any): void;
  107314. /**
  107315. * Returns the number of items waiting to be loaded
  107316. * @returns the number of items waiting to be loaded
  107317. */
  107318. getWaitingItemsCount(): number;
  107319. /**
  107320. * Returns a boolean indicating if the scene is still loading data
  107321. */
  107322. get isLoading(): boolean;
  107323. /**
  107324. * Registers a function to be executed when the scene is ready
  107325. * @param {Function} func - the function to be executed
  107326. */
  107327. executeWhenReady(func: () => void): void;
  107328. /**
  107329. * Returns a promise that resolves when the scene is ready
  107330. * @returns A promise that resolves when the scene is ready
  107331. */
  107332. whenReadyAsync(): Promise<void>;
  107333. /** @hidden */
  107334. _checkIsReady(): void;
  107335. /**
  107336. * Gets all animatable attached to the scene
  107337. */
  107338. get animatables(): Animatable[];
  107339. /**
  107340. * Resets the last animation time frame.
  107341. * Useful to override when animations start running when loading a scene for the first time.
  107342. */
  107343. resetLastAnimationTimeFrame(): void;
  107344. /**
  107345. * Gets the current view matrix
  107346. * @returns a Matrix
  107347. */
  107348. getViewMatrix(): Matrix;
  107349. /**
  107350. * Gets the current projection matrix
  107351. * @returns a Matrix
  107352. */
  107353. getProjectionMatrix(): Matrix;
  107354. /**
  107355. * Gets the current transform matrix
  107356. * @returns a Matrix made of View * Projection
  107357. */
  107358. getTransformMatrix(): Matrix;
  107359. /**
  107360. * Sets the current transform matrix
  107361. * @param viewL defines the View matrix to use
  107362. * @param projectionL defines the Projection matrix to use
  107363. * @param viewR defines the right View matrix to use (if provided)
  107364. * @param projectionR defines the right Projection matrix to use (if provided)
  107365. */
  107366. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  107367. /**
  107368. * Gets the uniform buffer used to store scene data
  107369. * @returns a UniformBuffer
  107370. */
  107371. getSceneUniformBuffer(): UniformBuffer;
  107372. /**
  107373. * Gets an unique (relatively to the current scene) Id
  107374. * @returns an unique number for the scene
  107375. */
  107376. getUniqueId(): number;
  107377. /**
  107378. * Add a mesh to the list of scene's meshes
  107379. * @param newMesh defines the mesh to add
  107380. * @param recursive if all child meshes should also be added to the scene
  107381. */
  107382. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  107383. /**
  107384. * Remove a mesh for the list of scene's meshes
  107385. * @param toRemove defines the mesh to remove
  107386. * @param recursive if all child meshes should also be removed from the scene
  107387. * @returns the index where the mesh was in the mesh list
  107388. */
  107389. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  107390. /**
  107391. * Add a transform node to the list of scene's transform nodes
  107392. * @param newTransformNode defines the transform node to add
  107393. */
  107394. addTransformNode(newTransformNode: TransformNode): void;
  107395. /**
  107396. * Remove a transform node for the list of scene's transform nodes
  107397. * @param toRemove defines the transform node to remove
  107398. * @returns the index where the transform node was in the transform node list
  107399. */
  107400. removeTransformNode(toRemove: TransformNode): number;
  107401. /**
  107402. * Remove a skeleton for the list of scene's skeletons
  107403. * @param toRemove defines the skeleton to remove
  107404. * @returns the index where the skeleton was in the skeleton list
  107405. */
  107406. removeSkeleton(toRemove: Skeleton): number;
  107407. /**
  107408. * Remove a morph target for the list of scene's morph targets
  107409. * @param toRemove defines the morph target to remove
  107410. * @returns the index where the morph target was in the morph target list
  107411. */
  107412. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  107413. /**
  107414. * Remove a light for the list of scene's lights
  107415. * @param toRemove defines the light to remove
  107416. * @returns the index where the light was in the light list
  107417. */
  107418. removeLight(toRemove: Light): number;
  107419. /**
  107420. * Remove a camera for the list of scene's cameras
  107421. * @param toRemove defines the camera to remove
  107422. * @returns the index where the camera was in the camera list
  107423. */
  107424. removeCamera(toRemove: Camera): number;
  107425. /**
  107426. * Remove a particle system for the list of scene's particle systems
  107427. * @param toRemove defines the particle system to remove
  107428. * @returns the index where the particle system was in the particle system list
  107429. */
  107430. removeParticleSystem(toRemove: IParticleSystem): number;
  107431. /**
  107432. * Remove a animation for the list of scene's animations
  107433. * @param toRemove defines the animation to remove
  107434. * @returns the index where the animation was in the animation list
  107435. */
  107436. removeAnimation(toRemove: Animation): number;
  107437. /**
  107438. * Will stop the animation of the given target
  107439. * @param target - the target
  107440. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  107441. * @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)
  107442. */
  107443. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  107444. /**
  107445. * Removes the given animation group from this scene.
  107446. * @param toRemove The animation group to remove
  107447. * @returns The index of the removed animation group
  107448. */
  107449. removeAnimationGroup(toRemove: AnimationGroup): number;
  107450. /**
  107451. * Removes the given multi-material from this scene.
  107452. * @param toRemove The multi-material to remove
  107453. * @returns The index of the removed multi-material
  107454. */
  107455. removeMultiMaterial(toRemove: MultiMaterial): number;
  107456. /**
  107457. * Removes the given material from this scene.
  107458. * @param toRemove The material to remove
  107459. * @returns The index of the removed material
  107460. */
  107461. removeMaterial(toRemove: Material): number;
  107462. /**
  107463. * Removes the given action manager from this scene.
  107464. * @param toRemove The action manager to remove
  107465. * @returns The index of the removed action manager
  107466. */
  107467. removeActionManager(toRemove: AbstractActionManager): number;
  107468. /**
  107469. * Removes the given texture from this scene.
  107470. * @param toRemove The texture to remove
  107471. * @returns The index of the removed texture
  107472. */
  107473. removeTexture(toRemove: BaseTexture): number;
  107474. /**
  107475. * Adds the given light to this scene
  107476. * @param newLight The light to add
  107477. */
  107478. addLight(newLight: Light): void;
  107479. /**
  107480. * Sorts the list list based on light priorities
  107481. */
  107482. sortLightsByPriority(): void;
  107483. /**
  107484. * Adds the given camera to this scene
  107485. * @param newCamera The camera to add
  107486. */
  107487. addCamera(newCamera: Camera): void;
  107488. /**
  107489. * Adds the given skeleton to this scene
  107490. * @param newSkeleton The skeleton to add
  107491. */
  107492. addSkeleton(newSkeleton: Skeleton): void;
  107493. /**
  107494. * Adds the given particle system to this scene
  107495. * @param newParticleSystem The particle system to add
  107496. */
  107497. addParticleSystem(newParticleSystem: IParticleSystem): void;
  107498. /**
  107499. * Adds the given animation to this scene
  107500. * @param newAnimation The animation to add
  107501. */
  107502. addAnimation(newAnimation: Animation): void;
  107503. /**
  107504. * Adds the given animation group to this scene.
  107505. * @param newAnimationGroup The animation group to add
  107506. */
  107507. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  107508. /**
  107509. * Adds the given multi-material to this scene
  107510. * @param newMultiMaterial The multi-material to add
  107511. */
  107512. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  107513. /**
  107514. * Adds the given material to this scene
  107515. * @param newMaterial The material to add
  107516. */
  107517. addMaterial(newMaterial: Material): void;
  107518. /**
  107519. * Adds the given morph target to this scene
  107520. * @param newMorphTargetManager The morph target to add
  107521. */
  107522. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  107523. /**
  107524. * Adds the given geometry to this scene
  107525. * @param newGeometry The geometry to add
  107526. */
  107527. addGeometry(newGeometry: Geometry): void;
  107528. /**
  107529. * Adds the given action manager to this scene
  107530. * @param newActionManager The action manager to add
  107531. */
  107532. addActionManager(newActionManager: AbstractActionManager): void;
  107533. /**
  107534. * Adds the given texture to this scene.
  107535. * @param newTexture The texture to add
  107536. */
  107537. addTexture(newTexture: BaseTexture): void;
  107538. /**
  107539. * Switch active camera
  107540. * @param newCamera defines the new active camera
  107541. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  107542. */
  107543. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  107544. /**
  107545. * sets the active camera of the scene using its ID
  107546. * @param id defines the camera's ID
  107547. * @return the new active camera or null if none found.
  107548. */
  107549. setActiveCameraByID(id: string): Nullable<Camera>;
  107550. /**
  107551. * sets the active camera of the scene using its name
  107552. * @param name defines the camera's name
  107553. * @returns the new active camera or null if none found.
  107554. */
  107555. setActiveCameraByName(name: string): Nullable<Camera>;
  107556. /**
  107557. * get an animation group using its name
  107558. * @param name defines the material's name
  107559. * @return the animation group or null if none found.
  107560. */
  107561. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  107562. /**
  107563. * Get a material using its unique id
  107564. * @param uniqueId defines the material's unique id
  107565. * @return the material or null if none found.
  107566. */
  107567. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  107568. /**
  107569. * get a material using its id
  107570. * @param id defines the material's ID
  107571. * @return the material or null if none found.
  107572. */
  107573. getMaterialByID(id: string): Nullable<Material>;
  107574. /**
  107575. * Gets a the last added material using a given id
  107576. * @param id defines the material's ID
  107577. * @return the last material with the given id or null if none found.
  107578. */
  107579. getLastMaterialByID(id: string): Nullable<Material>;
  107580. /**
  107581. * Gets a material using its name
  107582. * @param name defines the material's name
  107583. * @return the material or null if none found.
  107584. */
  107585. getMaterialByName(name: string): Nullable<Material>;
  107586. /**
  107587. * Get a texture using its unique id
  107588. * @param uniqueId defines the texture's unique id
  107589. * @return the texture or null if none found.
  107590. */
  107591. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  107592. /**
  107593. * Gets a camera using its id
  107594. * @param id defines the id to look for
  107595. * @returns the camera or null if not found
  107596. */
  107597. getCameraByID(id: string): Nullable<Camera>;
  107598. /**
  107599. * Gets a camera using its unique id
  107600. * @param uniqueId defines the unique id to look for
  107601. * @returns the camera or null if not found
  107602. */
  107603. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  107604. /**
  107605. * Gets a camera using its name
  107606. * @param name defines the camera's name
  107607. * @return the camera or null if none found.
  107608. */
  107609. getCameraByName(name: string): Nullable<Camera>;
  107610. /**
  107611. * Gets a bone using its id
  107612. * @param id defines the bone's id
  107613. * @return the bone or null if not found
  107614. */
  107615. getBoneByID(id: string): Nullable<Bone>;
  107616. /**
  107617. * Gets a bone using its id
  107618. * @param name defines the bone's name
  107619. * @return the bone or null if not found
  107620. */
  107621. getBoneByName(name: string): Nullable<Bone>;
  107622. /**
  107623. * Gets a light node using its name
  107624. * @param name defines the the light's name
  107625. * @return the light or null if none found.
  107626. */
  107627. getLightByName(name: string): Nullable<Light>;
  107628. /**
  107629. * Gets a light node using its id
  107630. * @param id defines the light's id
  107631. * @return the light or null if none found.
  107632. */
  107633. getLightByID(id: string): Nullable<Light>;
  107634. /**
  107635. * Gets a light node using its scene-generated unique ID
  107636. * @param uniqueId defines the light's unique id
  107637. * @return the light or null if none found.
  107638. */
  107639. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  107640. /**
  107641. * Gets a particle system by id
  107642. * @param id defines the particle system id
  107643. * @return the corresponding system or null if none found
  107644. */
  107645. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  107646. /**
  107647. * Gets a geometry using its ID
  107648. * @param id defines the geometry's id
  107649. * @return the geometry or null if none found.
  107650. */
  107651. getGeometryByID(id: string): Nullable<Geometry>;
  107652. private _getGeometryByUniqueID;
  107653. /**
  107654. * Add a new geometry to this scene
  107655. * @param geometry defines the geometry to be added to the scene.
  107656. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  107657. * @return a boolean defining if the geometry was added or not
  107658. */
  107659. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  107660. /**
  107661. * Removes an existing geometry
  107662. * @param geometry defines the geometry to be removed from the scene
  107663. * @return a boolean defining if the geometry was removed or not
  107664. */
  107665. removeGeometry(geometry: Geometry): boolean;
  107666. /**
  107667. * Gets the list of geometries attached to the scene
  107668. * @returns an array of Geometry
  107669. */
  107670. getGeometries(): Geometry[];
  107671. /**
  107672. * Gets the first added mesh found of a given ID
  107673. * @param id defines the id to search for
  107674. * @return the mesh found or null if not found at all
  107675. */
  107676. getMeshByID(id: string): Nullable<AbstractMesh>;
  107677. /**
  107678. * Gets a list of meshes using their id
  107679. * @param id defines the id to search for
  107680. * @returns a list of meshes
  107681. */
  107682. getMeshesByID(id: string): Array<AbstractMesh>;
  107683. /**
  107684. * Gets the first added transform node found of a given ID
  107685. * @param id defines the id to search for
  107686. * @return the found transform node or null if not found at all.
  107687. */
  107688. getTransformNodeByID(id: string): Nullable<TransformNode>;
  107689. /**
  107690. * Gets a transform node with its auto-generated unique id
  107691. * @param uniqueId efines the unique id to search for
  107692. * @return the found transform node or null if not found at all.
  107693. */
  107694. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  107695. /**
  107696. * Gets a list of transform nodes using their id
  107697. * @param id defines the id to search for
  107698. * @returns a list of transform nodes
  107699. */
  107700. getTransformNodesByID(id: string): Array<TransformNode>;
  107701. /**
  107702. * Gets a mesh with its auto-generated unique id
  107703. * @param uniqueId defines the unique id to search for
  107704. * @return the found mesh or null if not found at all.
  107705. */
  107706. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  107707. /**
  107708. * Gets a the last added mesh using a given id
  107709. * @param id defines the id to search for
  107710. * @return the found mesh or null if not found at all.
  107711. */
  107712. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  107713. /**
  107714. * Gets a the last added node (Mesh, Camera, Light) using a given id
  107715. * @param id defines the id to search for
  107716. * @return the found node or null if not found at all
  107717. */
  107718. getLastEntryByID(id: string): Nullable<Node>;
  107719. /**
  107720. * Gets a node (Mesh, Camera, Light) using a given id
  107721. * @param id defines the id to search for
  107722. * @return the found node or null if not found at all
  107723. */
  107724. getNodeByID(id: string): Nullable<Node>;
  107725. /**
  107726. * Gets a node (Mesh, Camera, Light) using a given name
  107727. * @param name defines the name to search for
  107728. * @return the found node or null if not found at all.
  107729. */
  107730. getNodeByName(name: string): Nullable<Node>;
  107731. /**
  107732. * Gets a mesh using a given name
  107733. * @param name defines the name to search for
  107734. * @return the found mesh or null if not found at all.
  107735. */
  107736. getMeshByName(name: string): Nullable<AbstractMesh>;
  107737. /**
  107738. * Gets a transform node using a given name
  107739. * @param name defines the name to search for
  107740. * @return the found transform node or null if not found at all.
  107741. */
  107742. getTransformNodeByName(name: string): Nullable<TransformNode>;
  107743. /**
  107744. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  107745. * @param id defines the id to search for
  107746. * @return the found skeleton or null if not found at all.
  107747. */
  107748. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  107749. /**
  107750. * Gets a skeleton using a given auto generated unique id
  107751. * @param uniqueId defines the unique id to search for
  107752. * @return the found skeleton or null if not found at all.
  107753. */
  107754. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  107755. /**
  107756. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  107757. * @param id defines the id to search for
  107758. * @return the found skeleton or null if not found at all.
  107759. */
  107760. getSkeletonById(id: string): Nullable<Skeleton>;
  107761. /**
  107762. * Gets a skeleton using a given name
  107763. * @param name defines the name to search for
  107764. * @return the found skeleton or null if not found at all.
  107765. */
  107766. getSkeletonByName(name: string): Nullable<Skeleton>;
  107767. /**
  107768. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  107769. * @param id defines the id to search for
  107770. * @return the found morph target manager or null if not found at all.
  107771. */
  107772. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  107773. /**
  107774. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  107775. * @param id defines the id to search for
  107776. * @return the found morph target or null if not found at all.
  107777. */
  107778. getMorphTargetById(id: string): Nullable<MorphTarget>;
  107779. /**
  107780. * Gets a boolean indicating if the given mesh is active
  107781. * @param mesh defines the mesh to look for
  107782. * @returns true if the mesh is in the active list
  107783. */
  107784. isActiveMesh(mesh: AbstractMesh): boolean;
  107785. /**
  107786. * Return a unique id as a string which can serve as an identifier for the scene
  107787. */
  107788. get uid(): string;
  107789. /**
  107790. * Add an externaly attached data from its key.
  107791. * This method call will fail and return false, if such key already exists.
  107792. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  107793. * @param key the unique key that identifies the data
  107794. * @param data the data object to associate to the key for this Engine instance
  107795. * @return true if no such key were already present and the data was added successfully, false otherwise
  107796. */
  107797. addExternalData<T>(key: string, data: T): boolean;
  107798. /**
  107799. * Get an externaly attached data from its key
  107800. * @param key the unique key that identifies the data
  107801. * @return the associated data, if present (can be null), or undefined if not present
  107802. */
  107803. getExternalData<T>(key: string): Nullable<T>;
  107804. /**
  107805. * Get an externaly attached data from its key, create it using a factory if it's not already present
  107806. * @param key the unique key that identifies the data
  107807. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  107808. * @return the associated data, can be null if the factory returned null.
  107809. */
  107810. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  107811. /**
  107812. * Remove an externaly attached data from the Engine instance
  107813. * @param key the unique key that identifies the data
  107814. * @return true if the data was successfully removed, false if it doesn't exist
  107815. */
  107816. removeExternalData(key: string): boolean;
  107817. private _evaluateSubMesh;
  107818. /**
  107819. * Clear the processed materials smart array preventing retention point in material dispose.
  107820. */
  107821. freeProcessedMaterials(): void;
  107822. private _preventFreeActiveMeshesAndRenderingGroups;
  107823. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  107824. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  107825. * when disposing several meshes in a row or a hierarchy of meshes.
  107826. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  107827. */
  107828. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  107829. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  107830. /**
  107831. * Clear the active meshes smart array preventing retention point in mesh dispose.
  107832. */
  107833. freeActiveMeshes(): void;
  107834. /**
  107835. * Clear the info related to rendering groups preventing retention points during dispose.
  107836. */
  107837. freeRenderingGroups(): void;
  107838. /** @hidden */
  107839. _isInIntermediateRendering(): boolean;
  107840. /**
  107841. * Lambda returning the list of potentially active meshes.
  107842. */
  107843. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  107844. /**
  107845. * Lambda returning the list of potentially active sub meshes.
  107846. */
  107847. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  107848. /**
  107849. * Lambda returning the list of potentially intersecting sub meshes.
  107850. */
  107851. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  107852. /**
  107853. * Lambda returning the list of potentially colliding sub meshes.
  107854. */
  107855. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  107856. private _activeMeshesFrozen;
  107857. private _skipEvaluateActiveMeshesCompletely;
  107858. /**
  107859. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  107860. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  107861. * @returns the current scene
  107862. */
  107863. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  107864. /**
  107865. * Use this function to restart evaluating active meshes on every frame
  107866. * @returns the current scene
  107867. */
  107868. unfreezeActiveMeshes(): Scene;
  107869. private _evaluateActiveMeshes;
  107870. private _activeMesh;
  107871. /**
  107872. * Update the transform matrix to update from the current active camera
  107873. * @param force defines a boolean used to force the update even if cache is up to date
  107874. */
  107875. updateTransformMatrix(force?: boolean): void;
  107876. private _bindFrameBuffer;
  107877. /** @hidden */
  107878. _allowPostProcessClearColor: boolean;
  107879. /** @hidden */
  107880. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  107881. private _processSubCameras;
  107882. private _checkIntersections;
  107883. /** @hidden */
  107884. _advancePhysicsEngineStep(step: number): void;
  107885. /**
  107886. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  107887. */
  107888. getDeterministicFrameTime: () => number;
  107889. /** @hidden */
  107890. _animate(): void;
  107891. /** Execute all animations (for a frame) */
  107892. animate(): void;
  107893. /**
  107894. * Render the scene
  107895. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  107896. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  107897. */
  107898. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  107899. /**
  107900. * Freeze all materials
  107901. * A frozen material will not be updatable but should be faster to render
  107902. */
  107903. freezeMaterials(): void;
  107904. /**
  107905. * Unfreeze all materials
  107906. * A frozen material will not be updatable but should be faster to render
  107907. */
  107908. unfreezeMaterials(): void;
  107909. /**
  107910. * Releases all held ressources
  107911. */
  107912. dispose(): void;
  107913. /**
  107914. * Gets if the scene is already disposed
  107915. */
  107916. get isDisposed(): boolean;
  107917. /**
  107918. * Call this function to reduce memory footprint of the scene.
  107919. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  107920. */
  107921. clearCachedVertexData(): void;
  107922. /**
  107923. * This function will remove the local cached buffer data from texture.
  107924. * It will save memory but will prevent the texture from being rebuilt
  107925. */
  107926. cleanCachedTextureBuffer(): void;
  107927. /**
  107928. * Get the world extend vectors with an optional filter
  107929. *
  107930. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  107931. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  107932. */
  107933. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  107934. min: Vector3;
  107935. max: Vector3;
  107936. };
  107937. /**
  107938. * Creates a ray that can be used to pick in the scene
  107939. * @param x defines the x coordinate of the origin (on-screen)
  107940. * @param y defines the y coordinate of the origin (on-screen)
  107941. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107942. * @param camera defines the camera to use for the picking
  107943. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107944. * @returns a Ray
  107945. */
  107946. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  107947. /**
  107948. * Creates a ray that can be used to pick in the scene
  107949. * @param x defines the x coordinate of the origin (on-screen)
  107950. * @param y defines the y coordinate of the origin (on-screen)
  107951. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  107952. * @param result defines the ray where to store the picking ray
  107953. * @param camera defines the camera to use for the picking
  107954. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  107955. * @returns the current scene
  107956. */
  107957. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  107958. /**
  107959. * Creates a ray that can be used to pick in the scene
  107960. * @param x defines the x coordinate of the origin (on-screen)
  107961. * @param y defines the y coordinate of the origin (on-screen)
  107962. * @param camera defines the camera to use for the picking
  107963. * @returns a Ray
  107964. */
  107965. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  107966. /**
  107967. * Creates a ray that can be used to pick in the scene
  107968. * @param x defines the x coordinate of the origin (on-screen)
  107969. * @param y defines the y coordinate of the origin (on-screen)
  107970. * @param result defines the ray where to store the picking ray
  107971. * @param camera defines the camera to use for the picking
  107972. * @returns the current scene
  107973. */
  107974. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  107975. /** Launch a ray to try to pick a mesh in the scene
  107976. * @param x position on screen
  107977. * @param y position on screen
  107978. * @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
  107979. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  107980. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107981. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107982. * @returns a PickingInfo
  107983. */
  107984. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107985. /** Use the given ray to pick a mesh in the scene
  107986. * @param ray The ray to use to pick meshes
  107987. * @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
  107988. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  107989. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  107990. * @returns a PickingInfo
  107991. */
  107992. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  107993. /**
  107994. * Launch a ray to try to pick a mesh in the scene
  107995. * @param x X position on screen
  107996. * @param y Y position on screen
  107997. * @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
  107998. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  107999. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  108000. * @returns an array of PickingInfo
  108001. */
  108002. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  108003. /**
  108004. * Launch a ray to try to pick a mesh in the scene
  108005. * @param ray Ray to use
  108006. * @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
  108007. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  108008. * @returns an array of PickingInfo
  108009. */
  108010. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  108011. /**
  108012. * Force the value of meshUnderPointer
  108013. * @param mesh defines the mesh to use
  108014. */
  108015. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108016. /**
  108017. * Gets the mesh under the pointer
  108018. * @returns a Mesh or null if no mesh is under the pointer
  108019. */
  108020. getPointerOverMesh(): Nullable<AbstractMesh>;
  108021. /** @hidden */
  108022. _rebuildGeometries(): void;
  108023. /** @hidden */
  108024. _rebuildTextures(): void;
  108025. private _getByTags;
  108026. /**
  108027. * Get a list of meshes by tags
  108028. * @param tagsQuery defines the tags query to use
  108029. * @param forEach defines a predicate used to filter results
  108030. * @returns an array of Mesh
  108031. */
  108032. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  108033. /**
  108034. * Get a list of cameras by tags
  108035. * @param tagsQuery defines the tags query to use
  108036. * @param forEach defines a predicate used to filter results
  108037. * @returns an array of Camera
  108038. */
  108039. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  108040. /**
  108041. * Get a list of lights by tags
  108042. * @param tagsQuery defines the tags query to use
  108043. * @param forEach defines a predicate used to filter results
  108044. * @returns an array of Light
  108045. */
  108046. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  108047. /**
  108048. * Get a list of materials by tags
  108049. * @param tagsQuery defines the tags query to use
  108050. * @param forEach defines a predicate used to filter results
  108051. * @returns an array of Material
  108052. */
  108053. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  108054. /**
  108055. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  108056. * This allowed control for front to back rendering or reversly depending of the special needs.
  108057. *
  108058. * @param renderingGroupId The rendering group id corresponding to its index
  108059. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  108060. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  108061. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  108062. */
  108063. 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;
  108064. /**
  108065. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  108066. *
  108067. * @param renderingGroupId The rendering group id corresponding to its index
  108068. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108069. * @param depth Automatically clears depth between groups if true and autoClear is true.
  108070. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  108071. */
  108072. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  108073. /**
  108074. * Gets the current auto clear configuration for one rendering group of the rendering
  108075. * manager.
  108076. * @param index the rendering group index to get the information for
  108077. * @returns The auto clear setup for the requested rendering group
  108078. */
  108079. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  108080. private _blockMaterialDirtyMechanism;
  108081. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  108082. get blockMaterialDirtyMechanism(): boolean;
  108083. set blockMaterialDirtyMechanism(value: boolean);
  108084. /**
  108085. * Will flag all materials as dirty to trigger new shader compilation
  108086. * @param flag defines the flag used to specify which material part must be marked as dirty
  108087. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  108088. */
  108089. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  108090. /** @hidden */
  108091. _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;
  108092. /** @hidden */
  108093. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108094. /** @hidden */
  108095. _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;
  108096. /** @hidden */
  108097. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  108098. /** @hidden */
  108099. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  108100. /** @hidden */
  108101. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108102. }
  108103. }
  108104. declare module BABYLON {
  108105. /**
  108106. * Set of assets to keep when moving a scene into an asset container.
  108107. */
  108108. export class KeepAssets extends AbstractScene {
  108109. }
  108110. /**
  108111. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  108112. */
  108113. export class InstantiatedEntries {
  108114. /**
  108115. * List of new root nodes (eg. nodes with no parent)
  108116. */
  108117. rootNodes: TransformNode[];
  108118. /**
  108119. * List of new skeletons
  108120. */
  108121. skeletons: Skeleton[];
  108122. /**
  108123. * List of new animation groups
  108124. */
  108125. animationGroups: AnimationGroup[];
  108126. }
  108127. /**
  108128. * Container with a set of assets that can be added or removed from a scene.
  108129. */
  108130. export class AssetContainer extends AbstractScene {
  108131. /**
  108132. * The scene the AssetContainer belongs to.
  108133. */
  108134. scene: Scene;
  108135. /**
  108136. * Instantiates an AssetContainer.
  108137. * @param scene The scene the AssetContainer belongs to.
  108138. */
  108139. constructor(scene: Scene);
  108140. /**
  108141. * Instantiate or clone all meshes and add the new ones to the scene.
  108142. * Skeletons and animation groups will all be cloned
  108143. * @param nameFunction defines an optional function used to get new names for clones
  108144. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  108145. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  108146. */
  108147. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  108148. /**
  108149. * Adds all the assets from the container to the scene.
  108150. */
  108151. addAllToScene(): void;
  108152. /**
  108153. * Removes all the assets in the container from the scene
  108154. */
  108155. removeAllFromScene(): void;
  108156. /**
  108157. * Disposes all the assets in the container
  108158. */
  108159. dispose(): void;
  108160. private _moveAssets;
  108161. /**
  108162. * Removes all the assets contained in the scene and adds them to the container.
  108163. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  108164. */
  108165. moveAllFromScene(keepAssets?: KeepAssets): void;
  108166. /**
  108167. * 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.
  108168. * @returns the root mesh
  108169. */
  108170. createRootMesh(): Mesh;
  108171. /**
  108172. * Merge animations from this asset container into a scene
  108173. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108174. * @param animatables set of animatables to retarget to a node from the scene
  108175. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  108176. */
  108177. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  108178. }
  108179. }
  108180. declare module BABYLON {
  108181. /**
  108182. * Defines how the parser contract is defined.
  108183. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  108184. */
  108185. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  108186. /**
  108187. * Defines how the individual parser contract is defined.
  108188. * These parser can parse an individual asset
  108189. */
  108190. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  108191. /**
  108192. * Base class of the scene acting as a container for the different elements composing a scene.
  108193. * This class is dynamically extended by the different components of the scene increasing
  108194. * flexibility and reducing coupling
  108195. */
  108196. export abstract class AbstractScene {
  108197. /**
  108198. * Stores the list of available parsers in the application.
  108199. */
  108200. private static _BabylonFileParsers;
  108201. /**
  108202. * Stores the list of available individual parsers in the application.
  108203. */
  108204. private static _IndividualBabylonFileParsers;
  108205. /**
  108206. * Adds a parser in the list of available ones
  108207. * @param name Defines the name of the parser
  108208. * @param parser Defines the parser to add
  108209. */
  108210. static AddParser(name: string, parser: BabylonFileParser): void;
  108211. /**
  108212. * Gets a general parser from the list of avaialble ones
  108213. * @param name Defines the name of the parser
  108214. * @returns the requested parser or null
  108215. */
  108216. static GetParser(name: string): Nullable<BabylonFileParser>;
  108217. /**
  108218. * Adds n individual parser in the list of available ones
  108219. * @param name Defines the name of the parser
  108220. * @param parser Defines the parser to add
  108221. */
  108222. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  108223. /**
  108224. * Gets an individual parser from the list of avaialble ones
  108225. * @param name Defines the name of the parser
  108226. * @returns the requested parser or null
  108227. */
  108228. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  108229. /**
  108230. * Parser json data and populate both a scene and its associated container object
  108231. * @param jsonData Defines the data to parse
  108232. * @param scene Defines the scene to parse the data for
  108233. * @param container Defines the container attached to the parsing sequence
  108234. * @param rootUrl Defines the root url of the data
  108235. */
  108236. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  108237. /**
  108238. * Gets the list of root nodes (ie. nodes with no parent)
  108239. */
  108240. rootNodes: Node[];
  108241. /** All of the cameras added to this scene
  108242. * @see http://doc.babylonjs.com/babylon101/cameras
  108243. */
  108244. cameras: Camera[];
  108245. /**
  108246. * All of the lights added to this scene
  108247. * @see http://doc.babylonjs.com/babylon101/lights
  108248. */
  108249. lights: Light[];
  108250. /**
  108251. * All of the (abstract) meshes added to this scene
  108252. */
  108253. meshes: AbstractMesh[];
  108254. /**
  108255. * The list of skeletons added to the scene
  108256. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  108257. */
  108258. skeletons: Skeleton[];
  108259. /**
  108260. * All of the particle systems added to this scene
  108261. * @see http://doc.babylonjs.com/babylon101/particles
  108262. */
  108263. particleSystems: IParticleSystem[];
  108264. /**
  108265. * Gets a list of Animations associated with the scene
  108266. */
  108267. animations: Animation[];
  108268. /**
  108269. * All of the animation groups added to this scene
  108270. * @see http://doc.babylonjs.com/how_to/group
  108271. */
  108272. animationGroups: AnimationGroup[];
  108273. /**
  108274. * All of the multi-materials added to this scene
  108275. * @see http://doc.babylonjs.com/how_to/multi_materials
  108276. */
  108277. multiMaterials: MultiMaterial[];
  108278. /**
  108279. * All of the materials added to this scene
  108280. * In the context of a Scene, it is not supposed to be modified manually.
  108281. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  108282. * Note also that the order of the Material within the array is not significant and might change.
  108283. * @see http://doc.babylonjs.com/babylon101/materials
  108284. */
  108285. materials: Material[];
  108286. /**
  108287. * The list of morph target managers added to the scene
  108288. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  108289. */
  108290. morphTargetManagers: MorphTargetManager[];
  108291. /**
  108292. * The list of geometries used in the scene.
  108293. */
  108294. geometries: Geometry[];
  108295. /**
  108296. * All of the tranform nodes added to this scene
  108297. * In the context of a Scene, it is not supposed to be modified manually.
  108298. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  108299. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  108300. * @see http://doc.babylonjs.com/how_to/transformnode
  108301. */
  108302. transformNodes: TransformNode[];
  108303. /**
  108304. * ActionManagers available on the scene.
  108305. */
  108306. actionManagers: AbstractActionManager[];
  108307. /**
  108308. * Textures to keep.
  108309. */
  108310. textures: BaseTexture[];
  108311. /**
  108312. * Environment texture for the scene
  108313. */
  108314. environmentTexture: Nullable<BaseTexture>;
  108315. /**
  108316. * @returns all meshes, lights, cameras, transformNodes and bones
  108317. */
  108318. getNodes(): Array<Node>;
  108319. }
  108320. }
  108321. declare module BABYLON {
  108322. /**
  108323. * Interface used to define options for Sound class
  108324. */
  108325. export interface ISoundOptions {
  108326. /**
  108327. * Does the sound autoplay once loaded.
  108328. */
  108329. autoplay?: boolean;
  108330. /**
  108331. * Does the sound loop after it finishes playing once.
  108332. */
  108333. loop?: boolean;
  108334. /**
  108335. * Sound's volume
  108336. */
  108337. volume?: number;
  108338. /**
  108339. * Is it a spatial sound?
  108340. */
  108341. spatialSound?: boolean;
  108342. /**
  108343. * Maximum distance to hear that sound
  108344. */
  108345. maxDistance?: number;
  108346. /**
  108347. * Uses user defined attenuation function
  108348. */
  108349. useCustomAttenuation?: boolean;
  108350. /**
  108351. * Define the roll off factor of spatial sounds.
  108352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108353. */
  108354. rolloffFactor?: number;
  108355. /**
  108356. * Define the reference distance the sound should be heard perfectly.
  108357. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108358. */
  108359. refDistance?: number;
  108360. /**
  108361. * Define the distance attenuation model the sound will follow.
  108362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108363. */
  108364. distanceModel?: string;
  108365. /**
  108366. * Defines the playback speed (1 by default)
  108367. */
  108368. playbackRate?: number;
  108369. /**
  108370. * Defines if the sound is from a streaming source
  108371. */
  108372. streaming?: boolean;
  108373. /**
  108374. * Defines an optional length (in seconds) inside the sound file
  108375. */
  108376. length?: number;
  108377. /**
  108378. * Defines an optional offset (in seconds) inside the sound file
  108379. */
  108380. offset?: number;
  108381. /**
  108382. * If true, URLs will not be required to state the audio file codec to use.
  108383. */
  108384. skipCodecCheck?: boolean;
  108385. }
  108386. /**
  108387. * Defines a sound that can be played in the application.
  108388. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  108389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108390. */
  108391. export class Sound {
  108392. /**
  108393. * The name of the sound in the scene.
  108394. */
  108395. name: string;
  108396. /**
  108397. * Does the sound autoplay once loaded.
  108398. */
  108399. autoplay: boolean;
  108400. /**
  108401. * Does the sound loop after it finishes playing once.
  108402. */
  108403. loop: boolean;
  108404. /**
  108405. * Does the sound use a custom attenuation curve to simulate the falloff
  108406. * happening when the source gets further away from the camera.
  108407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  108408. */
  108409. useCustomAttenuation: boolean;
  108410. /**
  108411. * The sound track id this sound belongs to.
  108412. */
  108413. soundTrackId: number;
  108414. /**
  108415. * Is this sound currently played.
  108416. */
  108417. isPlaying: boolean;
  108418. /**
  108419. * Is this sound currently paused.
  108420. */
  108421. isPaused: boolean;
  108422. /**
  108423. * Does this sound enables spatial sound.
  108424. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108425. */
  108426. spatialSound: boolean;
  108427. /**
  108428. * Define the reference distance the sound should be heard perfectly.
  108429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108430. */
  108431. refDistance: number;
  108432. /**
  108433. * Define the roll off factor of spatial sounds.
  108434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108435. */
  108436. rolloffFactor: number;
  108437. /**
  108438. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  108439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108440. */
  108441. maxDistance: number;
  108442. /**
  108443. * Define the distance attenuation model the sound will follow.
  108444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108445. */
  108446. distanceModel: string;
  108447. /**
  108448. * @hidden
  108449. * Back Compat
  108450. **/
  108451. onended: () => any;
  108452. /**
  108453. * Observable event when the current playing sound finishes.
  108454. */
  108455. onEndedObservable: Observable<Sound>;
  108456. private _panningModel;
  108457. private _playbackRate;
  108458. private _streaming;
  108459. private _startTime;
  108460. private _startOffset;
  108461. private _position;
  108462. /** @hidden */
  108463. _positionInEmitterSpace: boolean;
  108464. private _localDirection;
  108465. private _volume;
  108466. private _isReadyToPlay;
  108467. private _isDirectional;
  108468. private _readyToPlayCallback;
  108469. private _audioBuffer;
  108470. private _soundSource;
  108471. private _streamingSource;
  108472. private _soundPanner;
  108473. private _soundGain;
  108474. private _inputAudioNode;
  108475. private _outputAudioNode;
  108476. private _coneInnerAngle;
  108477. private _coneOuterAngle;
  108478. private _coneOuterGain;
  108479. private _scene;
  108480. private _connectedTransformNode;
  108481. private _customAttenuationFunction;
  108482. private _registerFunc;
  108483. private _isOutputConnected;
  108484. private _htmlAudioElement;
  108485. private _urlType;
  108486. private _length?;
  108487. private _offset?;
  108488. /** @hidden */
  108489. static _SceneComponentInitialization: (scene: Scene) => void;
  108490. /**
  108491. * Create a sound and attach it to a scene
  108492. * @param name Name of your sound
  108493. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  108494. * @param scene defines the scene the sound belongs to
  108495. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  108496. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  108497. */
  108498. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  108499. /**
  108500. * Release the sound and its associated resources
  108501. */
  108502. dispose(): void;
  108503. /**
  108504. * Gets if the sounds is ready to be played or not.
  108505. * @returns true if ready, otherwise false
  108506. */
  108507. isReady(): boolean;
  108508. private _soundLoaded;
  108509. /**
  108510. * Sets the data of the sound from an audiobuffer
  108511. * @param audioBuffer The audioBuffer containing the data
  108512. */
  108513. setAudioBuffer(audioBuffer: AudioBuffer): void;
  108514. /**
  108515. * Updates the current sounds options such as maxdistance, loop...
  108516. * @param options A JSON object containing values named as the object properties
  108517. */
  108518. updateOptions(options: ISoundOptions): void;
  108519. private _createSpatialParameters;
  108520. private _updateSpatialParameters;
  108521. /**
  108522. * Switch the panning model to HRTF:
  108523. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  108524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108525. */
  108526. switchPanningModelToHRTF(): void;
  108527. /**
  108528. * Switch the panning model to Equal Power:
  108529. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  108530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108531. */
  108532. switchPanningModelToEqualPower(): void;
  108533. private _switchPanningModel;
  108534. /**
  108535. * Connect this sound to a sound track audio node like gain...
  108536. * @param soundTrackAudioNode the sound track audio node to connect to
  108537. */
  108538. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  108539. /**
  108540. * Transform this sound into a directional source
  108541. * @param coneInnerAngle Size of the inner cone in degree
  108542. * @param coneOuterAngle Size of the outer cone in degree
  108543. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  108544. */
  108545. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  108546. /**
  108547. * Gets or sets the inner angle for the directional cone.
  108548. */
  108549. get directionalConeInnerAngle(): number;
  108550. /**
  108551. * Gets or sets the inner angle for the directional cone.
  108552. */
  108553. set directionalConeInnerAngle(value: number);
  108554. /**
  108555. * Gets or sets the outer angle for the directional cone.
  108556. */
  108557. get directionalConeOuterAngle(): number;
  108558. /**
  108559. * Gets or sets the outer angle for the directional cone.
  108560. */
  108561. set directionalConeOuterAngle(value: number);
  108562. /**
  108563. * Sets the position of the emitter if spatial sound is enabled
  108564. * @param newPosition Defines the new posisiton
  108565. */
  108566. setPosition(newPosition: Vector3): void;
  108567. /**
  108568. * Sets the local direction of the emitter if spatial sound is enabled
  108569. * @param newLocalDirection Defines the new local direction
  108570. */
  108571. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  108572. private _updateDirection;
  108573. /** @hidden */
  108574. updateDistanceFromListener(): void;
  108575. /**
  108576. * Sets a new custom attenuation function for the sound.
  108577. * @param callback Defines the function used for the attenuation
  108578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  108579. */
  108580. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  108581. /**
  108582. * Play the sound
  108583. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  108584. * @param offset (optional) Start the sound at a specific time in seconds
  108585. * @param length (optional) Sound duration (in seconds)
  108586. */
  108587. play(time?: number, offset?: number, length?: number): void;
  108588. private _onended;
  108589. /**
  108590. * Stop the sound
  108591. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  108592. */
  108593. stop(time?: number): void;
  108594. /**
  108595. * Put the sound in pause
  108596. */
  108597. pause(): void;
  108598. /**
  108599. * Sets a dedicated volume for this sounds
  108600. * @param newVolume Define the new volume of the sound
  108601. * @param time Define time for gradual change to new volume
  108602. */
  108603. setVolume(newVolume: number, time?: number): void;
  108604. /**
  108605. * Set the sound play back rate
  108606. * @param newPlaybackRate Define the playback rate the sound should be played at
  108607. */
  108608. setPlaybackRate(newPlaybackRate: number): void;
  108609. /**
  108610. * Gets the volume of the sound.
  108611. * @returns the volume of the sound
  108612. */
  108613. getVolume(): number;
  108614. /**
  108615. * Attach the sound to a dedicated mesh
  108616. * @param transformNode The transform node to connect the sound with
  108617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  108618. */
  108619. attachToMesh(transformNode: TransformNode): void;
  108620. /**
  108621. * Detach the sound from the previously attached mesh
  108622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  108623. */
  108624. detachFromMesh(): void;
  108625. private _onRegisterAfterWorldMatrixUpdate;
  108626. /**
  108627. * Clone the current sound in the scene.
  108628. * @returns the new sound clone
  108629. */
  108630. clone(): Nullable<Sound>;
  108631. /**
  108632. * Gets the current underlying audio buffer containing the data
  108633. * @returns the audio buffer
  108634. */
  108635. getAudioBuffer(): Nullable<AudioBuffer>;
  108636. /**
  108637. * Serializes the Sound in a JSON representation
  108638. * @returns the JSON representation of the sound
  108639. */
  108640. serialize(): any;
  108641. /**
  108642. * Parse a JSON representation of a sound to innstantiate in a given scene
  108643. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  108644. * @param scene Define the scene the new parsed sound should be created in
  108645. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  108646. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  108647. * @returns the newly parsed sound
  108648. */
  108649. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  108650. }
  108651. }
  108652. declare module BABYLON {
  108653. /**
  108654. * This defines an action helpful to play a defined sound on a triggered action.
  108655. */
  108656. export class PlaySoundAction extends Action {
  108657. private _sound;
  108658. /**
  108659. * Instantiate the action
  108660. * @param triggerOptions defines the trigger options
  108661. * @param sound defines the sound to play
  108662. * @param condition defines the trigger related conditions
  108663. */
  108664. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  108665. /** @hidden */
  108666. _prepare(): void;
  108667. /**
  108668. * Execute the action and play the sound.
  108669. */
  108670. execute(): void;
  108671. /**
  108672. * Serializes the actions and its related information.
  108673. * @param parent defines the object to serialize in
  108674. * @returns the serialized object
  108675. */
  108676. serialize(parent: any): any;
  108677. }
  108678. /**
  108679. * This defines an action helpful to stop a defined sound on a triggered action.
  108680. */
  108681. export class StopSoundAction extends Action {
  108682. private _sound;
  108683. /**
  108684. * Instantiate the action
  108685. * @param triggerOptions defines the trigger options
  108686. * @param sound defines the sound to stop
  108687. * @param condition defines the trigger related conditions
  108688. */
  108689. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  108690. /** @hidden */
  108691. _prepare(): void;
  108692. /**
  108693. * Execute the action and stop the sound.
  108694. */
  108695. execute(): void;
  108696. /**
  108697. * Serializes the actions and its related information.
  108698. * @param parent defines the object to serialize in
  108699. * @returns the serialized object
  108700. */
  108701. serialize(parent: any): any;
  108702. }
  108703. }
  108704. declare module BABYLON {
  108705. /**
  108706. * This defines an action responsible to change the value of a property
  108707. * by interpolating between its current value and the newly set one once triggered.
  108708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108709. */
  108710. export class InterpolateValueAction extends Action {
  108711. /**
  108712. * Defines the path of the property where the value should be interpolated
  108713. */
  108714. propertyPath: string;
  108715. /**
  108716. * Defines the target value at the end of the interpolation.
  108717. */
  108718. value: any;
  108719. /**
  108720. * Defines the time it will take for the property to interpolate to the value.
  108721. */
  108722. duration: number;
  108723. /**
  108724. * Defines if the other scene animations should be stopped when the action has been triggered
  108725. */
  108726. stopOtherAnimations?: boolean;
  108727. /**
  108728. * Defines a callback raised once the interpolation animation has been done.
  108729. */
  108730. onInterpolationDone?: () => void;
  108731. /**
  108732. * Observable triggered once the interpolation animation has been done.
  108733. */
  108734. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  108735. private _target;
  108736. private _effectiveTarget;
  108737. private _property;
  108738. /**
  108739. * Instantiate the action
  108740. * @param triggerOptions defines the trigger options
  108741. * @param target defines the object containing the value to interpolate
  108742. * @param propertyPath defines the path to the property in the target object
  108743. * @param value defines the target value at the end of the interpolation
  108744. * @param duration deines the time it will take for the property to interpolate to the value.
  108745. * @param condition defines the trigger related conditions
  108746. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  108747. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  108748. */
  108749. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  108750. /** @hidden */
  108751. _prepare(): void;
  108752. /**
  108753. * Execute the action starts the value interpolation.
  108754. */
  108755. execute(): void;
  108756. /**
  108757. * Serializes the actions and its related information.
  108758. * @param parent defines the object to serialize in
  108759. * @returns the serialized object
  108760. */
  108761. serialize(parent: any): any;
  108762. }
  108763. }
  108764. declare module BABYLON {
  108765. /**
  108766. * Options allowed during the creation of a sound track.
  108767. */
  108768. export interface ISoundTrackOptions {
  108769. /**
  108770. * The volume the sound track should take during creation
  108771. */
  108772. volume?: number;
  108773. /**
  108774. * Define if the sound track is the main sound track of the scene
  108775. */
  108776. mainTrack?: boolean;
  108777. }
  108778. /**
  108779. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  108780. * It will be also used in a future release to apply effects on a specific track.
  108781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108782. */
  108783. export class SoundTrack {
  108784. /**
  108785. * The unique identifier of the sound track in the scene.
  108786. */
  108787. id: number;
  108788. /**
  108789. * The list of sounds included in the sound track.
  108790. */
  108791. soundCollection: Array<Sound>;
  108792. private _outputAudioNode;
  108793. private _scene;
  108794. private _connectedAnalyser;
  108795. private _options;
  108796. private _isInitialized;
  108797. /**
  108798. * Creates a new sound track.
  108799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  108800. * @param scene Define the scene the sound track belongs to
  108801. * @param options
  108802. */
  108803. constructor(scene: Scene, options?: ISoundTrackOptions);
  108804. private _initializeSoundTrackAudioGraph;
  108805. /**
  108806. * Release the sound track and its associated resources
  108807. */
  108808. dispose(): void;
  108809. /**
  108810. * Adds a sound to this sound track
  108811. * @param sound define the cound to add
  108812. * @ignoreNaming
  108813. */
  108814. AddSound(sound: Sound): void;
  108815. /**
  108816. * Removes a sound to this sound track
  108817. * @param sound define the cound to remove
  108818. * @ignoreNaming
  108819. */
  108820. RemoveSound(sound: Sound): void;
  108821. /**
  108822. * Set a global volume for the full sound track.
  108823. * @param newVolume Define the new volume of the sound track
  108824. */
  108825. setVolume(newVolume: number): void;
  108826. /**
  108827. * Switch the panning model to HRTF:
  108828. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  108829. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108830. */
  108831. switchPanningModelToHRTF(): void;
  108832. /**
  108833. * Switch the panning model to Equal Power:
  108834. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  108835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  108836. */
  108837. switchPanningModelToEqualPower(): void;
  108838. /**
  108839. * Connect the sound track to an audio analyser allowing some amazing
  108840. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  108841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  108842. * @param analyser The analyser to connect to the engine
  108843. */
  108844. connectToAnalyser(analyser: Analyser): void;
  108845. }
  108846. }
  108847. declare module BABYLON {
  108848. interface AbstractScene {
  108849. /**
  108850. * The list of sounds used in the scene.
  108851. */
  108852. sounds: Nullable<Array<Sound>>;
  108853. }
  108854. interface Scene {
  108855. /**
  108856. * @hidden
  108857. * Backing field
  108858. */
  108859. _mainSoundTrack: SoundTrack;
  108860. /**
  108861. * The main sound track played by the scene.
  108862. * It cotains your primary collection of sounds.
  108863. */
  108864. mainSoundTrack: SoundTrack;
  108865. /**
  108866. * The list of sound tracks added to the scene
  108867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108868. */
  108869. soundTracks: Nullable<Array<SoundTrack>>;
  108870. /**
  108871. * Gets a sound using a given name
  108872. * @param name defines the name to search for
  108873. * @return the found sound or null if not found at all.
  108874. */
  108875. getSoundByName(name: string): Nullable<Sound>;
  108876. /**
  108877. * Gets or sets if audio support is enabled
  108878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108879. */
  108880. audioEnabled: boolean;
  108881. /**
  108882. * Gets or sets if audio will be output to headphones
  108883. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108884. */
  108885. headphone: boolean;
  108886. /**
  108887. * Gets or sets custom audio listener position provider
  108888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108889. */
  108890. audioListenerPositionProvider: Nullable<() => Vector3>;
  108891. /**
  108892. * Gets or sets a refresh rate when using 3D audio positioning
  108893. */
  108894. audioPositioningRefreshRate: number;
  108895. }
  108896. /**
  108897. * Defines the sound scene component responsible to manage any sounds
  108898. * in a given scene.
  108899. */
  108900. export class AudioSceneComponent implements ISceneSerializableComponent {
  108901. /**
  108902. * The component name helpfull to identify the component in the list of scene components.
  108903. */
  108904. readonly name: string;
  108905. /**
  108906. * The scene the component belongs to.
  108907. */
  108908. scene: Scene;
  108909. private _audioEnabled;
  108910. /**
  108911. * Gets whether audio is enabled or not.
  108912. * Please use related enable/disable method to switch state.
  108913. */
  108914. get audioEnabled(): boolean;
  108915. private _headphone;
  108916. /**
  108917. * Gets whether audio is outputing to headphone or not.
  108918. * Please use the according Switch methods to change output.
  108919. */
  108920. get headphone(): boolean;
  108921. /**
  108922. * Gets or sets a refresh rate when using 3D audio positioning
  108923. */
  108924. audioPositioningRefreshRate: number;
  108925. private _audioListenerPositionProvider;
  108926. /**
  108927. * Gets the current audio listener position provider
  108928. */
  108929. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  108930. /**
  108931. * Sets a custom listener position for all sounds in the scene
  108932. * By default, this is the position of the first active camera
  108933. */
  108934. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  108935. /**
  108936. * Creates a new instance of the component for the given scene
  108937. * @param scene Defines the scene to register the component in
  108938. */
  108939. constructor(scene: Scene);
  108940. /**
  108941. * Registers the component in a given scene
  108942. */
  108943. register(): void;
  108944. /**
  108945. * Rebuilds the elements related to this component in case of
  108946. * context lost for instance.
  108947. */
  108948. rebuild(): void;
  108949. /**
  108950. * Serializes the component data to the specified json object
  108951. * @param serializationObject The object to serialize to
  108952. */
  108953. serialize(serializationObject: any): void;
  108954. /**
  108955. * Adds all the elements from the container to the scene
  108956. * @param container the container holding the elements
  108957. */
  108958. addFromContainer(container: AbstractScene): void;
  108959. /**
  108960. * Removes all the elements in the container from the scene
  108961. * @param container contains the elements to remove
  108962. * @param dispose if the removed element should be disposed (default: false)
  108963. */
  108964. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  108965. /**
  108966. * Disposes the component and the associated ressources.
  108967. */
  108968. dispose(): void;
  108969. /**
  108970. * Disables audio in the associated scene.
  108971. */
  108972. disableAudio(): void;
  108973. /**
  108974. * Enables audio in the associated scene.
  108975. */
  108976. enableAudio(): void;
  108977. /**
  108978. * Switch audio to headphone output.
  108979. */
  108980. switchAudioModeForHeadphones(): void;
  108981. /**
  108982. * Switch audio to normal speakers.
  108983. */
  108984. switchAudioModeForNormalSpeakers(): void;
  108985. private _cachedCameraDirection;
  108986. private _cachedCameraPosition;
  108987. private _lastCheck;
  108988. private _afterRender;
  108989. }
  108990. }
  108991. declare module BABYLON {
  108992. /**
  108993. * Wraps one or more Sound objects and selects one with random weight for playback.
  108994. */
  108995. export class WeightedSound {
  108996. /** When true a Sound will be selected and played when the current playing Sound completes. */
  108997. loop: boolean;
  108998. private _coneInnerAngle;
  108999. private _coneOuterAngle;
  109000. private _volume;
  109001. /** A Sound is currently playing. */
  109002. isPlaying: boolean;
  109003. /** A Sound is currently paused. */
  109004. isPaused: boolean;
  109005. private _sounds;
  109006. private _weights;
  109007. private _currentIndex?;
  109008. /**
  109009. * Creates a new WeightedSound from the list of sounds given.
  109010. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  109011. * @param sounds Array of Sounds that will be selected from.
  109012. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  109013. */
  109014. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  109015. /**
  109016. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  109017. */
  109018. get directionalConeInnerAngle(): number;
  109019. /**
  109020. * The size of cone in degress for a directional sound in which there will be no attenuation.
  109021. */
  109022. set directionalConeInnerAngle(value: number);
  109023. /**
  109024. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  109025. * Listener angles between innerAngle and outerAngle will falloff linearly.
  109026. */
  109027. get directionalConeOuterAngle(): number;
  109028. /**
  109029. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  109030. * Listener angles between innerAngle and outerAngle will falloff linearly.
  109031. */
  109032. set directionalConeOuterAngle(value: number);
  109033. /**
  109034. * Playback volume.
  109035. */
  109036. get volume(): number;
  109037. /**
  109038. * Playback volume.
  109039. */
  109040. set volume(value: number);
  109041. private _onended;
  109042. /**
  109043. * Suspend playback
  109044. */
  109045. pause(): void;
  109046. /**
  109047. * Stop playback
  109048. */
  109049. stop(): void;
  109050. /**
  109051. * Start playback.
  109052. * @param startOffset Position the clip head at a specific time in seconds.
  109053. */
  109054. play(startOffset?: number): void;
  109055. }
  109056. }
  109057. declare module BABYLON {
  109058. /**
  109059. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  109060. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109061. */
  109062. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  109063. /**
  109064. * Gets the name of the behavior.
  109065. */
  109066. get name(): string;
  109067. /**
  109068. * The easing function used by animations
  109069. */
  109070. static EasingFunction: BackEase;
  109071. /**
  109072. * The easing mode used by animations
  109073. */
  109074. static EasingMode: number;
  109075. /**
  109076. * The duration of the animation, in milliseconds
  109077. */
  109078. transitionDuration: number;
  109079. /**
  109080. * Length of the distance animated by the transition when lower radius is reached
  109081. */
  109082. lowerRadiusTransitionRange: number;
  109083. /**
  109084. * Length of the distance animated by the transition when upper radius is reached
  109085. */
  109086. upperRadiusTransitionRange: number;
  109087. private _autoTransitionRange;
  109088. /**
  109089. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  109090. */
  109091. get autoTransitionRange(): boolean;
  109092. /**
  109093. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  109094. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  109095. */
  109096. set autoTransitionRange(value: boolean);
  109097. private _attachedCamera;
  109098. private _onAfterCheckInputsObserver;
  109099. private _onMeshTargetChangedObserver;
  109100. /**
  109101. * Initializes the behavior.
  109102. */
  109103. init(): void;
  109104. /**
  109105. * Attaches the behavior to its arc rotate camera.
  109106. * @param camera Defines the camera to attach the behavior to
  109107. */
  109108. attach(camera: ArcRotateCamera): void;
  109109. /**
  109110. * Detaches the behavior from its current arc rotate camera.
  109111. */
  109112. detach(): void;
  109113. private _radiusIsAnimating;
  109114. private _radiusBounceTransition;
  109115. private _animatables;
  109116. private _cachedWheelPrecision;
  109117. /**
  109118. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  109119. * @param radiusLimit The limit to check against.
  109120. * @return Bool to indicate if at limit.
  109121. */
  109122. private _isRadiusAtLimit;
  109123. /**
  109124. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  109125. * @param radiusDelta The delta by which to animate to. Can be negative.
  109126. */
  109127. private _applyBoundRadiusAnimation;
  109128. /**
  109129. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  109130. */
  109131. protected _clearAnimationLocks(): void;
  109132. /**
  109133. * Stops and removes all animations that have been applied to the camera
  109134. */
  109135. stopAllAnimations(): void;
  109136. }
  109137. }
  109138. declare module BABYLON {
  109139. /**
  109140. * 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.
  109141. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109142. */
  109143. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  109144. /**
  109145. * Gets the name of the behavior.
  109146. */
  109147. get name(): string;
  109148. private _mode;
  109149. private _radiusScale;
  109150. private _positionScale;
  109151. private _defaultElevation;
  109152. private _elevationReturnTime;
  109153. private _elevationReturnWaitTime;
  109154. private _zoomStopsAnimation;
  109155. private _framingTime;
  109156. /**
  109157. * The easing function used by animations
  109158. */
  109159. static EasingFunction: ExponentialEase;
  109160. /**
  109161. * The easing mode used by animations
  109162. */
  109163. static EasingMode: number;
  109164. /**
  109165. * Sets the current mode used by the behavior
  109166. */
  109167. set mode(mode: number);
  109168. /**
  109169. * Gets current mode used by the behavior.
  109170. */
  109171. get mode(): number;
  109172. /**
  109173. * Sets the scale applied to the radius (1 by default)
  109174. */
  109175. set radiusScale(radius: number);
  109176. /**
  109177. * Gets the scale applied to the radius
  109178. */
  109179. get radiusScale(): number;
  109180. /**
  109181. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  109182. */
  109183. set positionScale(scale: number);
  109184. /**
  109185. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  109186. */
  109187. get positionScale(): number;
  109188. /**
  109189. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  109190. * behaviour is triggered, in radians.
  109191. */
  109192. set defaultElevation(elevation: number);
  109193. /**
  109194. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  109195. * behaviour is triggered, in radians.
  109196. */
  109197. get defaultElevation(): number;
  109198. /**
  109199. * Sets the time (in milliseconds) taken to return to the default beta position.
  109200. * Negative value indicates camera should not return to default.
  109201. */
  109202. set elevationReturnTime(speed: number);
  109203. /**
  109204. * Gets the time (in milliseconds) taken to return to the default beta position.
  109205. * Negative value indicates camera should not return to default.
  109206. */
  109207. get elevationReturnTime(): number;
  109208. /**
  109209. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  109210. */
  109211. set elevationReturnWaitTime(time: number);
  109212. /**
  109213. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  109214. */
  109215. get elevationReturnWaitTime(): number;
  109216. /**
  109217. * Sets the flag that indicates if user zooming should stop animation.
  109218. */
  109219. set zoomStopsAnimation(flag: boolean);
  109220. /**
  109221. * Gets the flag that indicates if user zooming should stop animation.
  109222. */
  109223. get zoomStopsAnimation(): boolean;
  109224. /**
  109225. * Sets the transition time when framing the mesh, in milliseconds
  109226. */
  109227. set framingTime(time: number);
  109228. /**
  109229. * Gets the transition time when framing the mesh, in milliseconds
  109230. */
  109231. get framingTime(): number;
  109232. /**
  109233. * Define if the behavior should automatically change the configured
  109234. * camera limits and sensibilities.
  109235. */
  109236. autoCorrectCameraLimitsAndSensibility: boolean;
  109237. private _onPrePointerObservableObserver;
  109238. private _onAfterCheckInputsObserver;
  109239. private _onMeshTargetChangedObserver;
  109240. private _attachedCamera;
  109241. private _isPointerDown;
  109242. private _lastInteractionTime;
  109243. /**
  109244. * Initializes the behavior.
  109245. */
  109246. init(): void;
  109247. /**
  109248. * Attaches the behavior to its arc rotate camera.
  109249. * @param camera Defines the camera to attach the behavior to
  109250. */
  109251. attach(camera: ArcRotateCamera): void;
  109252. /**
  109253. * Detaches the behavior from its current arc rotate camera.
  109254. */
  109255. detach(): void;
  109256. private _animatables;
  109257. private _betaIsAnimating;
  109258. private _betaTransition;
  109259. private _radiusTransition;
  109260. private _vectorTransition;
  109261. /**
  109262. * Targets the given mesh and updates zoom level accordingly.
  109263. * @param mesh The mesh to target.
  109264. * @param radius Optional. If a cached radius position already exists, overrides default.
  109265. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  109266. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  109267. * @param onAnimationEnd Callback triggered at the end of the framing animation
  109268. */
  109269. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  109270. /**
  109271. * Targets the given mesh with its children and updates zoom level accordingly.
  109272. * @param mesh The mesh to target.
  109273. * @param radius Optional. If a cached radius position already exists, overrides default.
  109274. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  109275. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  109276. * @param onAnimationEnd Callback triggered at the end of the framing animation
  109277. */
  109278. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  109279. /**
  109280. * Targets the given meshes with their children and updates zoom level accordingly.
  109281. * @param meshes The mesh to target.
  109282. * @param radius Optional. If a cached radius position already exists, overrides default.
  109283. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  109284. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  109285. * @param onAnimationEnd Callback triggered at the end of the framing animation
  109286. */
  109287. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  109288. /**
  109289. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  109290. * @param minimumWorld Determines the smaller position of the bounding box extend
  109291. * @param maximumWorld Determines the bigger position of the bounding box extend
  109292. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  109293. * @param onAnimationEnd Callback triggered at the end of the framing animation
  109294. */
  109295. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  109296. /**
  109297. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  109298. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  109299. * frustum width.
  109300. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  109301. * to fully enclose the mesh in the viewing frustum.
  109302. */
  109303. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  109304. /**
  109305. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  109306. * is automatically returned to its default position (expected to be above ground plane).
  109307. */
  109308. private _maintainCameraAboveGround;
  109309. /**
  109310. * Returns the frustum slope based on the canvas ratio and camera FOV
  109311. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  109312. */
  109313. private _getFrustumSlope;
  109314. /**
  109315. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  109316. */
  109317. private _clearAnimationLocks;
  109318. /**
  109319. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  109320. */
  109321. private _applyUserInteraction;
  109322. /**
  109323. * Stops and removes all animations that have been applied to the camera
  109324. */
  109325. stopAllAnimations(): void;
  109326. /**
  109327. * Gets a value indicating if the user is moving the camera
  109328. */
  109329. get isUserIsMoving(): boolean;
  109330. /**
  109331. * The camera can move all the way towards the mesh.
  109332. */
  109333. static IgnoreBoundsSizeMode: number;
  109334. /**
  109335. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  109336. */
  109337. static FitFrustumSidesMode: number;
  109338. }
  109339. }
  109340. declare module BABYLON {
  109341. /**
  109342. * Base class for Camera Pointer Inputs.
  109343. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  109344. * for example usage.
  109345. */
  109346. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  109347. /**
  109348. * Defines the camera the input is attached to.
  109349. */
  109350. abstract camera: Camera;
  109351. /**
  109352. * Whether keyboard modifier keys are pressed at time of last mouse event.
  109353. */
  109354. protected _altKey: boolean;
  109355. protected _ctrlKey: boolean;
  109356. protected _metaKey: boolean;
  109357. protected _shiftKey: boolean;
  109358. /**
  109359. * Which mouse buttons were pressed at time of last mouse event.
  109360. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  109361. */
  109362. protected _buttonsPressed: number;
  109363. /**
  109364. * Defines the buttons associated with the input to handle camera move.
  109365. */
  109366. buttons: number[];
  109367. /**
  109368. * Attach the input controls to a specific dom element to get the input from.
  109369. * @param element Defines the element the controls should be listened from
  109370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109371. */
  109372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109373. /**
  109374. * Detach the current controls from the specified dom element.
  109375. * @param element Defines the element to stop listening the inputs from
  109376. */
  109377. detachControl(element: Nullable<HTMLElement>): void;
  109378. /**
  109379. * Gets the class name of the current input.
  109380. * @returns the class name
  109381. */
  109382. getClassName(): string;
  109383. /**
  109384. * Get the friendly name associated with the input class.
  109385. * @returns the input friendly name
  109386. */
  109387. getSimpleName(): string;
  109388. /**
  109389. * Called on pointer POINTERDOUBLETAP event.
  109390. * Override this method to provide functionality on POINTERDOUBLETAP event.
  109391. */
  109392. protected onDoubleTap(type: string): void;
  109393. /**
  109394. * Called on pointer POINTERMOVE event if only a single touch is active.
  109395. * Override this method to provide functionality.
  109396. */
  109397. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  109398. /**
  109399. * Called on pointer POINTERMOVE event if multiple touches are active.
  109400. * Override this method to provide functionality.
  109401. */
  109402. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  109403. /**
  109404. * Called on JS contextmenu event.
  109405. * Override this method to provide functionality.
  109406. */
  109407. protected onContextMenu(evt: PointerEvent): void;
  109408. /**
  109409. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  109410. * press.
  109411. * Override this method to provide functionality.
  109412. */
  109413. protected onButtonDown(evt: PointerEvent): void;
  109414. /**
  109415. * Called each time a new POINTERUP event occurs. Ie, for each button
  109416. * release.
  109417. * Override this method to provide functionality.
  109418. */
  109419. protected onButtonUp(evt: PointerEvent): void;
  109420. /**
  109421. * Called when window becomes inactive.
  109422. * Override this method to provide functionality.
  109423. */
  109424. protected onLostFocus(): void;
  109425. private _pointerInput;
  109426. private _observer;
  109427. private _onLostFocus;
  109428. private pointA;
  109429. private pointB;
  109430. }
  109431. }
  109432. declare module BABYLON {
  109433. /**
  109434. * Manage the pointers inputs to control an arc rotate camera.
  109435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109436. */
  109437. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  109438. /**
  109439. * Defines the camera the input is attached to.
  109440. */
  109441. camera: ArcRotateCamera;
  109442. /**
  109443. * Gets the class name of the current input.
  109444. * @returns the class name
  109445. */
  109446. getClassName(): string;
  109447. /**
  109448. * Defines the buttons associated with the input to handle camera move.
  109449. */
  109450. buttons: number[];
  109451. /**
  109452. * Defines the pointer angular sensibility along the X axis or how fast is
  109453. * the camera rotating.
  109454. */
  109455. angularSensibilityX: number;
  109456. /**
  109457. * Defines the pointer angular sensibility along the Y axis or how fast is
  109458. * the camera rotating.
  109459. */
  109460. angularSensibilityY: number;
  109461. /**
  109462. * Defines the pointer pinch precision or how fast is the camera zooming.
  109463. */
  109464. pinchPrecision: number;
  109465. /**
  109466. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  109467. * from 0.
  109468. * It defines the percentage of current camera.radius to use as delta when
  109469. * pinch zoom is used.
  109470. */
  109471. pinchDeltaPercentage: number;
  109472. /**
  109473. * Defines the pointer panning sensibility or how fast is the camera moving.
  109474. */
  109475. panningSensibility: number;
  109476. /**
  109477. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  109478. */
  109479. multiTouchPanning: boolean;
  109480. /**
  109481. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  109482. * zoom (pinch) through multitouch.
  109483. */
  109484. multiTouchPanAndZoom: boolean;
  109485. /**
  109486. * Revers pinch action direction.
  109487. */
  109488. pinchInwards: boolean;
  109489. private _isPanClick;
  109490. private _twoFingerActivityCount;
  109491. private _isPinching;
  109492. /**
  109493. * Called on pointer POINTERMOVE event if only a single touch is active.
  109494. */
  109495. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  109496. /**
  109497. * Called on pointer POINTERDOUBLETAP event.
  109498. */
  109499. protected onDoubleTap(type: string): void;
  109500. /**
  109501. * Called on pointer POINTERMOVE event if multiple touches are active.
  109502. */
  109503. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  109504. /**
  109505. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  109506. * press.
  109507. */
  109508. protected onButtonDown(evt: PointerEvent): void;
  109509. /**
  109510. * Called each time a new POINTERUP event occurs. Ie, for each button
  109511. * release.
  109512. */
  109513. protected onButtonUp(evt: PointerEvent): void;
  109514. /**
  109515. * Called when window becomes inactive.
  109516. */
  109517. protected onLostFocus(): void;
  109518. }
  109519. }
  109520. declare module BABYLON {
  109521. /**
  109522. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  109523. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109524. */
  109525. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  109526. /**
  109527. * Defines the camera the input is attached to.
  109528. */
  109529. camera: ArcRotateCamera;
  109530. /**
  109531. * Defines the list of key codes associated with the up action (increase alpha)
  109532. */
  109533. keysUp: number[];
  109534. /**
  109535. * Defines the list of key codes associated with the down action (decrease alpha)
  109536. */
  109537. keysDown: number[];
  109538. /**
  109539. * Defines the list of key codes associated with the left action (increase beta)
  109540. */
  109541. keysLeft: number[];
  109542. /**
  109543. * Defines the list of key codes associated with the right action (decrease beta)
  109544. */
  109545. keysRight: number[];
  109546. /**
  109547. * Defines the list of key codes associated with the reset action.
  109548. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  109549. */
  109550. keysReset: number[];
  109551. /**
  109552. * Defines the panning sensibility of the inputs.
  109553. * (How fast is the camera paning)
  109554. */
  109555. panningSensibility: number;
  109556. /**
  109557. * Defines the zooming sensibility of the inputs.
  109558. * (How fast is the camera zooming)
  109559. */
  109560. zoomingSensibility: number;
  109561. /**
  109562. * Defines wether maintaining the alt key down switch the movement mode from
  109563. * orientation to zoom.
  109564. */
  109565. useAltToZoom: boolean;
  109566. /**
  109567. * Rotation speed of the camera
  109568. */
  109569. angularSpeed: number;
  109570. private _keys;
  109571. private _ctrlPressed;
  109572. private _altPressed;
  109573. private _onCanvasBlurObserver;
  109574. private _onKeyboardObserver;
  109575. private _engine;
  109576. private _scene;
  109577. /**
  109578. * Attach the input controls to a specific dom element to get the input from.
  109579. * @param element Defines the element the controls should be listened from
  109580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109581. */
  109582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109583. /**
  109584. * Detach the current controls from the specified dom element.
  109585. * @param element Defines the element to stop listening the inputs from
  109586. */
  109587. detachControl(element: Nullable<HTMLElement>): void;
  109588. /**
  109589. * Update the current camera state depending on the inputs that have been used this frame.
  109590. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  109591. */
  109592. checkInputs(): void;
  109593. /**
  109594. * Gets the class name of the current intput.
  109595. * @returns the class name
  109596. */
  109597. getClassName(): string;
  109598. /**
  109599. * Get the friendly name associated with the input class.
  109600. * @returns the input friendly name
  109601. */
  109602. getSimpleName(): string;
  109603. }
  109604. }
  109605. declare module BABYLON {
  109606. /**
  109607. * Manage the mouse wheel inputs to control an arc rotate camera.
  109608. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109609. */
  109610. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  109611. /**
  109612. * Defines the camera the input is attached to.
  109613. */
  109614. camera: ArcRotateCamera;
  109615. /**
  109616. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  109617. */
  109618. wheelPrecision: number;
  109619. /**
  109620. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  109621. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  109622. */
  109623. wheelDeltaPercentage: number;
  109624. private _wheel;
  109625. private _observer;
  109626. private computeDeltaFromMouseWheelLegacyEvent;
  109627. /**
  109628. * Attach the input controls to a specific dom element to get the input from.
  109629. * @param element Defines the element the controls should be listened from
  109630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109631. */
  109632. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109633. /**
  109634. * Detach the current controls from the specified dom element.
  109635. * @param element Defines the element to stop listening the inputs from
  109636. */
  109637. detachControl(element: Nullable<HTMLElement>): void;
  109638. /**
  109639. * Gets the class name of the current intput.
  109640. * @returns the class name
  109641. */
  109642. getClassName(): string;
  109643. /**
  109644. * Get the friendly name associated with the input class.
  109645. * @returns the input friendly name
  109646. */
  109647. getSimpleName(): string;
  109648. }
  109649. }
  109650. declare module BABYLON {
  109651. /**
  109652. * Default Inputs manager for the ArcRotateCamera.
  109653. * It groups all the default supported inputs for ease of use.
  109654. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  109655. */
  109656. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  109657. /**
  109658. * Instantiates a new ArcRotateCameraInputsManager.
  109659. * @param camera Defines the camera the inputs belong to
  109660. */
  109661. constructor(camera: ArcRotateCamera);
  109662. /**
  109663. * Add mouse wheel input support to the input manager.
  109664. * @returns the current input manager
  109665. */
  109666. addMouseWheel(): ArcRotateCameraInputsManager;
  109667. /**
  109668. * Add pointers input support to the input manager.
  109669. * @returns the current input manager
  109670. */
  109671. addPointers(): ArcRotateCameraInputsManager;
  109672. /**
  109673. * Add keyboard input support to the input manager.
  109674. * @returns the current input manager
  109675. */
  109676. addKeyboard(): ArcRotateCameraInputsManager;
  109677. }
  109678. }
  109679. declare module BABYLON {
  109680. /**
  109681. * This represents an orbital type of camera.
  109682. *
  109683. * 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.
  109684. * 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.
  109685. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  109686. */
  109687. export class ArcRotateCamera extends TargetCamera {
  109688. /**
  109689. * Defines the rotation angle of the camera along the longitudinal axis.
  109690. */
  109691. alpha: number;
  109692. /**
  109693. * Defines the rotation angle of the camera along the latitudinal axis.
  109694. */
  109695. beta: number;
  109696. /**
  109697. * Defines the radius of the camera from it s target point.
  109698. */
  109699. radius: number;
  109700. protected _target: Vector3;
  109701. protected _targetHost: Nullable<AbstractMesh>;
  109702. /**
  109703. * Defines the target point of the camera.
  109704. * The camera looks towards it form the radius distance.
  109705. */
  109706. get target(): Vector3;
  109707. set target(value: Vector3);
  109708. /**
  109709. * Define the current local position of the camera in the scene
  109710. */
  109711. get position(): Vector3;
  109712. set position(newPosition: Vector3);
  109713. protected _upVector: Vector3;
  109714. protected _upToYMatrix: Matrix;
  109715. protected _YToUpMatrix: Matrix;
  109716. /**
  109717. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  109718. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  109719. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  109720. */
  109721. set upVector(vec: Vector3);
  109722. get upVector(): Vector3;
  109723. /**
  109724. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  109725. */
  109726. setMatUp(): void;
  109727. /**
  109728. * Current inertia value on the longitudinal axis.
  109729. * The bigger this number the longer it will take for the camera to stop.
  109730. */
  109731. inertialAlphaOffset: number;
  109732. /**
  109733. * Current inertia value on the latitudinal axis.
  109734. * The bigger this number the longer it will take for the camera to stop.
  109735. */
  109736. inertialBetaOffset: number;
  109737. /**
  109738. * Current inertia value on the radius axis.
  109739. * The bigger this number the longer it will take for the camera to stop.
  109740. */
  109741. inertialRadiusOffset: number;
  109742. /**
  109743. * Minimum allowed angle on the longitudinal axis.
  109744. * This can help limiting how the Camera is able to move in the scene.
  109745. */
  109746. lowerAlphaLimit: Nullable<number>;
  109747. /**
  109748. * Maximum allowed angle on the longitudinal axis.
  109749. * This can help limiting how the Camera is able to move in the scene.
  109750. */
  109751. upperAlphaLimit: Nullable<number>;
  109752. /**
  109753. * Minimum allowed angle on the latitudinal axis.
  109754. * This can help limiting how the Camera is able to move in the scene.
  109755. */
  109756. lowerBetaLimit: number;
  109757. /**
  109758. * Maximum allowed angle on the latitudinal axis.
  109759. * This can help limiting how the Camera is able to move in the scene.
  109760. */
  109761. upperBetaLimit: number;
  109762. /**
  109763. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  109764. * This can help limiting how the Camera is able to move in the scene.
  109765. */
  109766. lowerRadiusLimit: Nullable<number>;
  109767. /**
  109768. * Maximum allowed distance of the camera to the target (The camera can not get further).
  109769. * This can help limiting how the Camera is able to move in the scene.
  109770. */
  109771. upperRadiusLimit: Nullable<number>;
  109772. /**
  109773. * Defines the current inertia value used during panning of the camera along the X axis.
  109774. */
  109775. inertialPanningX: number;
  109776. /**
  109777. * Defines the current inertia value used during panning of the camera along the Y axis.
  109778. */
  109779. inertialPanningY: number;
  109780. /**
  109781. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  109782. * Basically if your fingers moves away from more than this distance you will be considered
  109783. * in pinch mode.
  109784. */
  109785. pinchToPanMaxDistance: number;
  109786. /**
  109787. * Defines the maximum distance the camera can pan.
  109788. * This could help keeping the cammera always in your scene.
  109789. */
  109790. panningDistanceLimit: Nullable<number>;
  109791. /**
  109792. * Defines the target of the camera before paning.
  109793. */
  109794. panningOriginTarget: Vector3;
  109795. /**
  109796. * Defines the value of the inertia used during panning.
  109797. * 0 would mean stop inertia and one would mean no decelleration at all.
  109798. */
  109799. panningInertia: number;
  109800. /**
  109801. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  109802. */
  109803. get angularSensibilityX(): number;
  109804. set angularSensibilityX(value: number);
  109805. /**
  109806. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  109807. */
  109808. get angularSensibilityY(): number;
  109809. set angularSensibilityY(value: number);
  109810. /**
  109811. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  109812. */
  109813. get pinchPrecision(): number;
  109814. set pinchPrecision(value: number);
  109815. /**
  109816. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  109817. * It will be used instead of pinchDeltaPrecision if different from 0.
  109818. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109819. */
  109820. get pinchDeltaPercentage(): number;
  109821. set pinchDeltaPercentage(value: number);
  109822. /**
  109823. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  109824. */
  109825. get panningSensibility(): number;
  109826. set panningSensibility(value: number);
  109827. /**
  109828. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  109829. */
  109830. get keysUp(): number[];
  109831. set keysUp(value: number[]);
  109832. /**
  109833. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  109834. */
  109835. get keysDown(): number[];
  109836. set keysDown(value: number[]);
  109837. /**
  109838. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  109839. */
  109840. get keysLeft(): number[];
  109841. set keysLeft(value: number[]);
  109842. /**
  109843. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  109844. */
  109845. get keysRight(): number[];
  109846. set keysRight(value: number[]);
  109847. /**
  109848. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  109849. */
  109850. get wheelPrecision(): number;
  109851. set wheelPrecision(value: number);
  109852. /**
  109853. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  109854. * It will be used instead of pinchDeltaPrecision if different from 0.
  109855. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  109856. */
  109857. get wheelDeltaPercentage(): number;
  109858. set wheelDeltaPercentage(value: number);
  109859. /**
  109860. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  109861. */
  109862. zoomOnFactor: number;
  109863. /**
  109864. * Defines a screen offset for the camera position.
  109865. */
  109866. targetScreenOffset: Vector2;
  109867. /**
  109868. * Allows the camera to be completely reversed.
  109869. * If false the camera can not arrive upside down.
  109870. */
  109871. allowUpsideDown: boolean;
  109872. /**
  109873. * Define if double tap/click is used to restore the previously saved state of the camera.
  109874. */
  109875. useInputToRestoreState: boolean;
  109876. /** @hidden */
  109877. _viewMatrix: Matrix;
  109878. /** @hidden */
  109879. _useCtrlForPanning: boolean;
  109880. /** @hidden */
  109881. _panningMouseButton: number;
  109882. /**
  109883. * Defines the input associated to the camera.
  109884. */
  109885. inputs: ArcRotateCameraInputsManager;
  109886. /** @hidden */
  109887. _reset: () => void;
  109888. /**
  109889. * Defines the allowed panning axis.
  109890. */
  109891. panningAxis: Vector3;
  109892. protected _localDirection: Vector3;
  109893. protected _transformedDirection: Vector3;
  109894. private _bouncingBehavior;
  109895. /**
  109896. * Gets the bouncing behavior of the camera if it has been enabled.
  109897. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109898. */
  109899. get bouncingBehavior(): Nullable<BouncingBehavior>;
  109900. /**
  109901. * Defines if the bouncing behavior of the camera is enabled on the camera.
  109902. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  109903. */
  109904. get useBouncingBehavior(): boolean;
  109905. set useBouncingBehavior(value: boolean);
  109906. private _framingBehavior;
  109907. /**
  109908. * Gets the framing behavior of the camera if it has been enabled.
  109909. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109910. */
  109911. get framingBehavior(): Nullable<FramingBehavior>;
  109912. /**
  109913. * Defines if the framing behavior of the camera is enabled on the camera.
  109914. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  109915. */
  109916. get useFramingBehavior(): boolean;
  109917. set useFramingBehavior(value: boolean);
  109918. private _autoRotationBehavior;
  109919. /**
  109920. * Gets the auto rotation behavior of the camera if it has been enabled.
  109921. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109922. */
  109923. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  109924. /**
  109925. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  109926. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  109927. */
  109928. get useAutoRotationBehavior(): boolean;
  109929. set useAutoRotationBehavior(value: boolean);
  109930. /**
  109931. * Observable triggered when the mesh target has been changed on the camera.
  109932. */
  109933. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  109934. /**
  109935. * Event raised when the camera is colliding with a mesh.
  109936. */
  109937. onCollide: (collidedMesh: AbstractMesh) => void;
  109938. /**
  109939. * Defines whether the camera should check collision with the objects oh the scene.
  109940. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  109941. */
  109942. checkCollisions: boolean;
  109943. /**
  109944. * Defines the collision radius of the camera.
  109945. * This simulates a sphere around the camera.
  109946. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  109947. */
  109948. collisionRadius: Vector3;
  109949. protected _collider: Collider;
  109950. protected _previousPosition: Vector3;
  109951. protected _collisionVelocity: Vector3;
  109952. protected _newPosition: Vector3;
  109953. protected _previousAlpha: number;
  109954. protected _previousBeta: number;
  109955. protected _previousRadius: number;
  109956. protected _collisionTriggered: boolean;
  109957. protected _targetBoundingCenter: Nullable<Vector3>;
  109958. private _computationVector;
  109959. /**
  109960. * Instantiates a new ArcRotateCamera in a given scene
  109961. * @param name Defines the name of the camera
  109962. * @param alpha Defines the camera rotation along the logitudinal axis
  109963. * @param beta Defines the camera rotation along the latitudinal axis
  109964. * @param radius Defines the camera distance from its target
  109965. * @param target Defines the camera target
  109966. * @param scene Defines the scene the camera belongs to
  109967. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  109968. */
  109969. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109970. /** @hidden */
  109971. _initCache(): void;
  109972. /** @hidden */
  109973. _updateCache(ignoreParentClass?: boolean): void;
  109974. protected _getTargetPosition(): Vector3;
  109975. private _storedAlpha;
  109976. private _storedBeta;
  109977. private _storedRadius;
  109978. private _storedTarget;
  109979. private _storedTargetScreenOffset;
  109980. /**
  109981. * Stores the current state of the camera (alpha, beta, radius and target)
  109982. * @returns the camera itself
  109983. */
  109984. storeState(): Camera;
  109985. /**
  109986. * @hidden
  109987. * Restored camera state. You must call storeState() first
  109988. */
  109989. _restoreStateValues(): boolean;
  109990. /** @hidden */
  109991. _isSynchronizedViewMatrix(): boolean;
  109992. /**
  109993. * Attached controls to the current camera.
  109994. * @param element Defines the element the controls should be listened from
  109995. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109996. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  109997. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  109998. */
  109999. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  110000. /**
  110001. * Detach the current controls from the camera.
  110002. * The camera will stop reacting to inputs.
  110003. * @param element Defines the element to stop listening the inputs from
  110004. */
  110005. detachControl(element: HTMLElement): void;
  110006. /** @hidden */
  110007. _checkInputs(): void;
  110008. protected _checkLimits(): void;
  110009. /**
  110010. * Rebuilds angles (alpha, beta) and radius from the give position and target
  110011. */
  110012. rebuildAnglesAndRadius(): void;
  110013. /**
  110014. * Use a position to define the current camera related information like alpha, beta and radius
  110015. * @param position Defines the position to set the camera at
  110016. */
  110017. setPosition(position: Vector3): void;
  110018. /**
  110019. * Defines the target the camera should look at.
  110020. * This will automatically adapt alpha beta and radius to fit within the new target.
  110021. * @param target Defines the new target as a Vector or a mesh
  110022. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  110023. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  110024. */
  110025. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  110026. /** @hidden */
  110027. _getViewMatrix(): Matrix;
  110028. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  110029. /**
  110030. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  110031. * @param meshes Defines the mesh to zoom on
  110032. * @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)
  110033. */
  110034. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  110035. /**
  110036. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  110037. * The target will be changed but the radius
  110038. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  110039. * @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)
  110040. */
  110041. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  110042. min: Vector3;
  110043. max: Vector3;
  110044. distance: number;
  110045. }, doNotUpdateMaxZ?: boolean): void;
  110046. /**
  110047. * @override
  110048. * Override Camera.createRigCamera
  110049. */
  110050. createRigCamera(name: string, cameraIndex: number): Camera;
  110051. /**
  110052. * @hidden
  110053. * @override
  110054. * Override Camera._updateRigCameras
  110055. */
  110056. _updateRigCameras(): void;
  110057. /**
  110058. * Destroy the camera and release the current resources hold by it.
  110059. */
  110060. dispose(): void;
  110061. /**
  110062. * Gets the current object class name.
  110063. * @return the class name
  110064. */
  110065. getClassName(): string;
  110066. }
  110067. }
  110068. declare module BABYLON {
  110069. /**
  110070. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  110071. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  110072. */
  110073. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  110074. /**
  110075. * Gets the name of the behavior.
  110076. */
  110077. get name(): string;
  110078. private _zoomStopsAnimation;
  110079. private _idleRotationSpeed;
  110080. private _idleRotationWaitTime;
  110081. private _idleRotationSpinupTime;
  110082. /**
  110083. * Sets the flag that indicates if user zooming should stop animation.
  110084. */
  110085. set zoomStopsAnimation(flag: boolean);
  110086. /**
  110087. * Gets the flag that indicates if user zooming should stop animation.
  110088. */
  110089. get zoomStopsAnimation(): boolean;
  110090. /**
  110091. * Sets the default speed at which the camera rotates around the model.
  110092. */
  110093. set idleRotationSpeed(speed: number);
  110094. /**
  110095. * Gets the default speed at which the camera rotates around the model.
  110096. */
  110097. get idleRotationSpeed(): number;
  110098. /**
  110099. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  110100. */
  110101. set idleRotationWaitTime(time: number);
  110102. /**
  110103. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  110104. */
  110105. get idleRotationWaitTime(): number;
  110106. /**
  110107. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  110108. */
  110109. set idleRotationSpinupTime(time: number);
  110110. /**
  110111. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  110112. */
  110113. get idleRotationSpinupTime(): number;
  110114. /**
  110115. * Gets a value indicating if the camera is currently rotating because of this behavior
  110116. */
  110117. get rotationInProgress(): boolean;
  110118. private _onPrePointerObservableObserver;
  110119. private _onAfterCheckInputsObserver;
  110120. private _attachedCamera;
  110121. private _isPointerDown;
  110122. private _lastFrameTime;
  110123. private _lastInteractionTime;
  110124. private _cameraRotationSpeed;
  110125. /**
  110126. * Initializes the behavior.
  110127. */
  110128. init(): void;
  110129. /**
  110130. * Attaches the behavior to its arc rotate camera.
  110131. * @param camera Defines the camera to attach the behavior to
  110132. */
  110133. attach(camera: ArcRotateCamera): void;
  110134. /**
  110135. * Detaches the behavior from its current arc rotate camera.
  110136. */
  110137. detach(): void;
  110138. /**
  110139. * Returns true if user is scrolling.
  110140. * @return true if user is scrolling.
  110141. */
  110142. private _userIsZooming;
  110143. private _lastFrameRadius;
  110144. private _shouldAnimationStopForInteraction;
  110145. /**
  110146. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  110147. */
  110148. private _applyUserInteraction;
  110149. private _userIsMoving;
  110150. }
  110151. }
  110152. declare module BABYLON {
  110153. /**
  110154. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  110155. */
  110156. export class AttachToBoxBehavior implements Behavior<Mesh> {
  110157. private ui;
  110158. /**
  110159. * The name of the behavior
  110160. */
  110161. name: string;
  110162. /**
  110163. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  110164. */
  110165. distanceAwayFromFace: number;
  110166. /**
  110167. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  110168. */
  110169. distanceAwayFromBottomOfFace: number;
  110170. private _faceVectors;
  110171. private _target;
  110172. private _scene;
  110173. private _onRenderObserver;
  110174. private _tmpMatrix;
  110175. private _tmpVector;
  110176. /**
  110177. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  110178. * @param ui The transform node that should be attched to the mesh
  110179. */
  110180. constructor(ui: TransformNode);
  110181. /**
  110182. * Initializes the behavior
  110183. */
  110184. init(): void;
  110185. private _closestFace;
  110186. private _zeroVector;
  110187. private _lookAtTmpMatrix;
  110188. private _lookAtToRef;
  110189. /**
  110190. * Attaches the AttachToBoxBehavior to the passed in mesh
  110191. * @param target The mesh that the specified node will be attached to
  110192. */
  110193. attach(target: Mesh): void;
  110194. /**
  110195. * Detaches the behavior from the mesh
  110196. */
  110197. detach(): void;
  110198. }
  110199. }
  110200. declare module BABYLON {
  110201. /**
  110202. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  110203. */
  110204. export class FadeInOutBehavior implements Behavior<Mesh> {
  110205. /**
  110206. * Time in milliseconds to delay before fading in (Default: 0)
  110207. */
  110208. delay: number;
  110209. /**
  110210. * Time in milliseconds for the mesh to fade in (Default: 300)
  110211. */
  110212. fadeInTime: number;
  110213. private _millisecondsPerFrame;
  110214. private _hovered;
  110215. private _hoverValue;
  110216. private _ownerNode;
  110217. /**
  110218. * Instatiates the FadeInOutBehavior
  110219. */
  110220. constructor();
  110221. /**
  110222. * The name of the behavior
  110223. */
  110224. get name(): string;
  110225. /**
  110226. * Initializes the behavior
  110227. */
  110228. init(): void;
  110229. /**
  110230. * Attaches the fade behavior on the passed in mesh
  110231. * @param ownerNode The mesh that will be faded in/out once attached
  110232. */
  110233. attach(ownerNode: Mesh): void;
  110234. /**
  110235. * Detaches the behavior from the mesh
  110236. */
  110237. detach(): void;
  110238. /**
  110239. * Triggers the mesh to begin fading in or out
  110240. * @param value if the object should fade in or out (true to fade in)
  110241. */
  110242. fadeIn(value: boolean): void;
  110243. private _update;
  110244. private _setAllVisibility;
  110245. }
  110246. }
  110247. declare module BABYLON {
  110248. /**
  110249. * Class containing a set of static utilities functions for managing Pivots
  110250. * @hidden
  110251. */
  110252. export class PivotTools {
  110253. private static _PivotCached;
  110254. private static _OldPivotPoint;
  110255. private static _PivotTranslation;
  110256. private static _PivotTmpVector;
  110257. /** @hidden */
  110258. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  110259. /** @hidden */
  110260. static _RestorePivotPoint(mesh: AbstractMesh): void;
  110261. }
  110262. }
  110263. declare module BABYLON {
  110264. /**
  110265. * Class containing static functions to help procedurally build meshes
  110266. */
  110267. export class PlaneBuilder {
  110268. /**
  110269. * Creates a plane mesh
  110270. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110271. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110272. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110276. * @param name defines the name of the mesh
  110277. * @param options defines the options used to create the mesh
  110278. * @param scene defines the hosting scene
  110279. * @returns the plane mesh
  110280. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110281. */
  110282. static CreatePlane(name: string, options: {
  110283. size?: number;
  110284. width?: number;
  110285. height?: number;
  110286. sideOrientation?: number;
  110287. frontUVs?: Vector4;
  110288. backUVs?: Vector4;
  110289. updatable?: boolean;
  110290. sourcePlane?: Plane;
  110291. }, scene?: Nullable<Scene>): Mesh;
  110292. }
  110293. }
  110294. declare module BABYLON {
  110295. /**
  110296. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  110297. */
  110298. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  110299. private static _AnyMouseID;
  110300. /**
  110301. * Abstract mesh the behavior is set on
  110302. */
  110303. attachedNode: AbstractMesh;
  110304. private _dragPlane;
  110305. private _scene;
  110306. private _pointerObserver;
  110307. private _beforeRenderObserver;
  110308. private static _planeScene;
  110309. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  110310. /**
  110311. * 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)
  110312. */
  110313. maxDragAngle: number;
  110314. /**
  110315. * @hidden
  110316. */
  110317. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  110318. /**
  110319. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  110320. */
  110321. currentDraggingPointerID: number;
  110322. /**
  110323. * The last position where the pointer hit the drag plane in world space
  110324. */
  110325. lastDragPosition: Vector3;
  110326. /**
  110327. * If the behavior is currently in a dragging state
  110328. */
  110329. dragging: boolean;
  110330. /**
  110331. * 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)
  110332. */
  110333. dragDeltaRatio: number;
  110334. /**
  110335. * If the drag plane orientation should be updated during the dragging (Default: true)
  110336. */
  110337. updateDragPlane: boolean;
  110338. private _debugMode;
  110339. private _moving;
  110340. /**
  110341. * Fires each time the attached mesh is dragged with the pointer
  110342. * * delta between last drag position and current drag position in world space
  110343. * * dragDistance along the drag axis
  110344. * * dragPlaneNormal normal of the current drag plane used during the drag
  110345. * * dragPlanePoint in world space where the drag intersects the drag plane
  110346. */
  110347. onDragObservable: Observable<{
  110348. delta: Vector3;
  110349. dragPlanePoint: Vector3;
  110350. dragPlaneNormal: Vector3;
  110351. dragDistance: number;
  110352. pointerId: number;
  110353. }>;
  110354. /**
  110355. * Fires each time a drag begins (eg. mouse down on mesh)
  110356. */
  110357. onDragStartObservable: Observable<{
  110358. dragPlanePoint: Vector3;
  110359. pointerId: number;
  110360. }>;
  110361. /**
  110362. * Fires each time a drag ends (eg. mouse release after drag)
  110363. */
  110364. onDragEndObservable: Observable<{
  110365. dragPlanePoint: Vector3;
  110366. pointerId: number;
  110367. }>;
  110368. /**
  110369. * If the attached mesh should be moved when dragged
  110370. */
  110371. moveAttached: boolean;
  110372. /**
  110373. * If the drag behavior will react to drag events (Default: true)
  110374. */
  110375. enabled: boolean;
  110376. /**
  110377. * If pointer events should start and release the drag (Default: true)
  110378. */
  110379. startAndReleaseDragOnPointerEvents: boolean;
  110380. /**
  110381. * If camera controls should be detached during the drag
  110382. */
  110383. detachCameraControls: boolean;
  110384. /**
  110385. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  110386. */
  110387. useObjectOrientationForDragging: boolean;
  110388. private _options;
  110389. /**
  110390. * Gets the options used by the behavior
  110391. */
  110392. get options(): {
  110393. dragAxis?: Vector3;
  110394. dragPlaneNormal?: Vector3;
  110395. };
  110396. /**
  110397. * Sets the options used by the behavior
  110398. */
  110399. set options(options: {
  110400. dragAxis?: Vector3;
  110401. dragPlaneNormal?: Vector3;
  110402. });
  110403. /**
  110404. * Creates a pointer drag behavior that can be attached to a mesh
  110405. * @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)
  110406. */
  110407. constructor(options?: {
  110408. dragAxis?: Vector3;
  110409. dragPlaneNormal?: Vector3;
  110410. });
  110411. /**
  110412. * Predicate to determine if it is valid to move the object to a new position when it is moved
  110413. */
  110414. validateDrag: (targetPosition: Vector3) => boolean;
  110415. /**
  110416. * The name of the behavior
  110417. */
  110418. get name(): string;
  110419. /**
  110420. * Initializes the behavior
  110421. */
  110422. init(): void;
  110423. private _tmpVector;
  110424. private _alternatePickedPoint;
  110425. private _worldDragAxis;
  110426. private _targetPosition;
  110427. private _attachedElement;
  110428. /**
  110429. * Attaches the drag behavior the passed in mesh
  110430. * @param ownerNode The mesh that will be dragged around once attached
  110431. * @param predicate Predicate to use for pick filtering
  110432. */
  110433. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  110434. /**
  110435. * Force relase the drag action by code.
  110436. */
  110437. releaseDrag(): void;
  110438. private _startDragRay;
  110439. private _lastPointerRay;
  110440. /**
  110441. * Simulates the start of a pointer drag event on the behavior
  110442. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  110443. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  110444. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  110445. */
  110446. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  110447. private _startDrag;
  110448. private _dragDelta;
  110449. private _moveDrag;
  110450. private _pickWithRayOnDragPlane;
  110451. private _pointA;
  110452. private _pointB;
  110453. private _pointC;
  110454. private _lineA;
  110455. private _lineB;
  110456. private _localAxis;
  110457. private _lookAt;
  110458. private _updateDragPlanePosition;
  110459. /**
  110460. * Detaches the behavior from the mesh
  110461. */
  110462. detach(): void;
  110463. }
  110464. }
  110465. declare module BABYLON {
  110466. /**
  110467. * A behavior that when attached to a mesh will allow the mesh to be scaled
  110468. */
  110469. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  110470. private _dragBehaviorA;
  110471. private _dragBehaviorB;
  110472. private _startDistance;
  110473. private _initialScale;
  110474. private _targetScale;
  110475. private _ownerNode;
  110476. private _sceneRenderObserver;
  110477. /**
  110478. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  110479. */
  110480. constructor();
  110481. /**
  110482. * The name of the behavior
  110483. */
  110484. get name(): string;
  110485. /**
  110486. * Initializes the behavior
  110487. */
  110488. init(): void;
  110489. private _getCurrentDistance;
  110490. /**
  110491. * Attaches the scale behavior the passed in mesh
  110492. * @param ownerNode The mesh that will be scaled around once attached
  110493. */
  110494. attach(ownerNode: Mesh): void;
  110495. /**
  110496. * Detaches the behavior from the mesh
  110497. */
  110498. detach(): void;
  110499. }
  110500. }
  110501. declare module BABYLON {
  110502. /**
  110503. * 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
  110504. */
  110505. export class SixDofDragBehavior implements Behavior<Mesh> {
  110506. private static _virtualScene;
  110507. private _ownerNode;
  110508. private _sceneRenderObserver;
  110509. private _scene;
  110510. private _targetPosition;
  110511. private _virtualOriginMesh;
  110512. private _virtualDragMesh;
  110513. private _pointerObserver;
  110514. private _moving;
  110515. private _startingOrientation;
  110516. /**
  110517. * 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)
  110518. */
  110519. private zDragFactor;
  110520. /**
  110521. * If the object should rotate to face the drag origin
  110522. */
  110523. rotateDraggedObject: boolean;
  110524. /**
  110525. * If the behavior is currently in a dragging state
  110526. */
  110527. dragging: boolean;
  110528. /**
  110529. * 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)
  110530. */
  110531. dragDeltaRatio: number;
  110532. /**
  110533. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  110534. */
  110535. currentDraggingPointerID: number;
  110536. /**
  110537. * If camera controls should be detached during the drag
  110538. */
  110539. detachCameraControls: boolean;
  110540. /**
  110541. * Fires each time a drag starts
  110542. */
  110543. onDragStartObservable: Observable<{}>;
  110544. /**
  110545. * Fires each time a drag ends (eg. mouse release after drag)
  110546. */
  110547. onDragEndObservable: Observable<{}>;
  110548. /**
  110549. * 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
  110550. */
  110551. constructor();
  110552. /**
  110553. * The name of the behavior
  110554. */
  110555. get name(): string;
  110556. /**
  110557. * Initializes the behavior
  110558. */
  110559. init(): void;
  110560. /**
  110561. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  110562. */
  110563. private get _pointerCamera();
  110564. /**
  110565. * Attaches the scale behavior the passed in mesh
  110566. * @param ownerNode The mesh that will be scaled around once attached
  110567. */
  110568. attach(ownerNode: Mesh): void;
  110569. /**
  110570. * Detaches the behavior from the mesh
  110571. */
  110572. detach(): void;
  110573. }
  110574. }
  110575. declare module BABYLON {
  110576. /**
  110577. * Class used to apply inverse kinematics to bones
  110578. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  110579. */
  110580. export class BoneIKController {
  110581. private static _tmpVecs;
  110582. private static _tmpQuat;
  110583. private static _tmpMats;
  110584. /**
  110585. * Gets or sets the target mesh
  110586. */
  110587. targetMesh: AbstractMesh;
  110588. /** Gets or sets the mesh used as pole */
  110589. poleTargetMesh: AbstractMesh;
  110590. /**
  110591. * Gets or sets the bone used as pole
  110592. */
  110593. poleTargetBone: Nullable<Bone>;
  110594. /**
  110595. * Gets or sets the target position
  110596. */
  110597. targetPosition: Vector3;
  110598. /**
  110599. * Gets or sets the pole target position
  110600. */
  110601. poleTargetPosition: Vector3;
  110602. /**
  110603. * Gets or sets the pole target local offset
  110604. */
  110605. poleTargetLocalOffset: Vector3;
  110606. /**
  110607. * Gets or sets the pole angle
  110608. */
  110609. poleAngle: number;
  110610. /**
  110611. * Gets or sets the mesh associated with the controller
  110612. */
  110613. mesh: AbstractMesh;
  110614. /**
  110615. * 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)
  110616. */
  110617. slerpAmount: number;
  110618. private _bone1Quat;
  110619. private _bone1Mat;
  110620. private _bone2Ang;
  110621. private _bone1;
  110622. private _bone2;
  110623. private _bone1Length;
  110624. private _bone2Length;
  110625. private _maxAngle;
  110626. private _maxReach;
  110627. private _rightHandedSystem;
  110628. private _bendAxis;
  110629. private _slerping;
  110630. private _adjustRoll;
  110631. /**
  110632. * Gets or sets maximum allowed angle
  110633. */
  110634. get maxAngle(): number;
  110635. set maxAngle(value: number);
  110636. /**
  110637. * Creates a new BoneIKController
  110638. * @param mesh defines the mesh to control
  110639. * @param bone defines the bone to control
  110640. * @param options defines options to set up the controller
  110641. */
  110642. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  110643. targetMesh?: AbstractMesh;
  110644. poleTargetMesh?: AbstractMesh;
  110645. poleTargetBone?: Bone;
  110646. poleTargetLocalOffset?: Vector3;
  110647. poleAngle?: number;
  110648. bendAxis?: Vector3;
  110649. maxAngle?: number;
  110650. slerpAmount?: number;
  110651. });
  110652. private _setMaxAngle;
  110653. /**
  110654. * Force the controller to update the bones
  110655. */
  110656. update(): void;
  110657. }
  110658. }
  110659. declare module BABYLON {
  110660. /**
  110661. * Class used to make a bone look toward a point in space
  110662. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  110663. */
  110664. export class BoneLookController {
  110665. private static _tmpVecs;
  110666. private static _tmpQuat;
  110667. private static _tmpMats;
  110668. /**
  110669. * The target Vector3 that the bone will look at
  110670. */
  110671. target: Vector3;
  110672. /**
  110673. * The mesh that the bone is attached to
  110674. */
  110675. mesh: AbstractMesh;
  110676. /**
  110677. * The bone that will be looking to the target
  110678. */
  110679. bone: Bone;
  110680. /**
  110681. * The up axis of the coordinate system that is used when the bone is rotated
  110682. */
  110683. upAxis: Vector3;
  110684. /**
  110685. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  110686. */
  110687. upAxisSpace: Space;
  110688. /**
  110689. * Used to make an adjustment to the yaw of the bone
  110690. */
  110691. adjustYaw: number;
  110692. /**
  110693. * Used to make an adjustment to the pitch of the bone
  110694. */
  110695. adjustPitch: number;
  110696. /**
  110697. * Used to make an adjustment to the roll of the bone
  110698. */
  110699. adjustRoll: number;
  110700. /**
  110701. * 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)
  110702. */
  110703. slerpAmount: number;
  110704. private _minYaw;
  110705. private _maxYaw;
  110706. private _minPitch;
  110707. private _maxPitch;
  110708. private _minYawSin;
  110709. private _minYawCos;
  110710. private _maxYawSin;
  110711. private _maxYawCos;
  110712. private _midYawConstraint;
  110713. private _minPitchTan;
  110714. private _maxPitchTan;
  110715. private _boneQuat;
  110716. private _slerping;
  110717. private _transformYawPitch;
  110718. private _transformYawPitchInv;
  110719. private _firstFrameSkipped;
  110720. private _yawRange;
  110721. private _fowardAxis;
  110722. /**
  110723. * Gets or sets the minimum yaw angle that the bone can look to
  110724. */
  110725. get minYaw(): number;
  110726. set minYaw(value: number);
  110727. /**
  110728. * Gets or sets the maximum yaw angle that the bone can look to
  110729. */
  110730. get maxYaw(): number;
  110731. set maxYaw(value: number);
  110732. /**
  110733. * Gets or sets the minimum pitch angle that the bone can look to
  110734. */
  110735. get minPitch(): number;
  110736. set minPitch(value: number);
  110737. /**
  110738. * Gets or sets the maximum pitch angle that the bone can look to
  110739. */
  110740. get maxPitch(): number;
  110741. set maxPitch(value: number);
  110742. /**
  110743. * Create a BoneLookController
  110744. * @param mesh the mesh that the bone belongs to
  110745. * @param bone the bone that will be looking to the target
  110746. * @param target the target Vector3 to look at
  110747. * @param options optional settings:
  110748. * * maxYaw: the maximum angle the bone will yaw to
  110749. * * minYaw: the minimum angle the bone will yaw to
  110750. * * maxPitch: the maximum angle the bone will pitch to
  110751. * * minPitch: the minimum angle the bone will yaw to
  110752. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  110753. * * upAxis: the up axis of the coordinate system
  110754. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  110755. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  110756. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  110757. * * adjustYaw: used to make an adjustment to the yaw of the bone
  110758. * * adjustPitch: used to make an adjustment to the pitch of the bone
  110759. * * adjustRoll: used to make an adjustment to the roll of the bone
  110760. **/
  110761. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  110762. maxYaw?: number;
  110763. minYaw?: number;
  110764. maxPitch?: number;
  110765. minPitch?: number;
  110766. slerpAmount?: number;
  110767. upAxis?: Vector3;
  110768. upAxisSpace?: Space;
  110769. yawAxis?: Vector3;
  110770. pitchAxis?: Vector3;
  110771. adjustYaw?: number;
  110772. adjustPitch?: number;
  110773. adjustRoll?: number;
  110774. });
  110775. /**
  110776. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  110777. */
  110778. update(): void;
  110779. private _getAngleDiff;
  110780. private _getAngleBetween;
  110781. private _isAngleBetween;
  110782. }
  110783. }
  110784. declare module BABYLON {
  110785. /**
  110786. * Manage the gamepad inputs to control an arc rotate camera.
  110787. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110788. */
  110789. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  110790. /**
  110791. * Defines the camera the input is attached to.
  110792. */
  110793. camera: ArcRotateCamera;
  110794. /**
  110795. * Defines the gamepad the input is gathering event from.
  110796. */
  110797. gamepad: Nullable<Gamepad>;
  110798. /**
  110799. * Defines the gamepad rotation sensiblity.
  110800. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  110801. */
  110802. gamepadRotationSensibility: number;
  110803. /**
  110804. * Defines the gamepad move sensiblity.
  110805. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  110806. */
  110807. gamepadMoveSensibility: number;
  110808. private _yAxisScale;
  110809. /**
  110810. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  110811. */
  110812. get invertYAxis(): boolean;
  110813. set invertYAxis(value: boolean);
  110814. private _onGamepadConnectedObserver;
  110815. private _onGamepadDisconnectedObserver;
  110816. /**
  110817. * Attach the input controls to a specific dom element to get the input from.
  110818. * @param element Defines the element the controls should be listened from
  110819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110820. */
  110821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110822. /**
  110823. * Detach the current controls from the specified dom element.
  110824. * @param element Defines the element to stop listening the inputs from
  110825. */
  110826. detachControl(element: Nullable<HTMLElement>): void;
  110827. /**
  110828. * Update the current camera state depending on the inputs that have been used this frame.
  110829. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110830. */
  110831. checkInputs(): void;
  110832. /**
  110833. * Gets the class name of the current intput.
  110834. * @returns the class name
  110835. */
  110836. getClassName(): string;
  110837. /**
  110838. * Get the friendly name associated with the input class.
  110839. * @returns the input friendly name
  110840. */
  110841. getSimpleName(): string;
  110842. }
  110843. }
  110844. declare module BABYLON {
  110845. interface ArcRotateCameraInputsManager {
  110846. /**
  110847. * Add orientation input support to the input manager.
  110848. * @returns the current input manager
  110849. */
  110850. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  110851. }
  110852. /**
  110853. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  110854. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110855. */
  110856. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  110857. /**
  110858. * Defines the camera the input is attached to.
  110859. */
  110860. camera: ArcRotateCamera;
  110861. /**
  110862. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  110863. */
  110864. alphaCorrection: number;
  110865. /**
  110866. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  110867. */
  110868. gammaCorrection: number;
  110869. private _alpha;
  110870. private _gamma;
  110871. private _dirty;
  110872. private _deviceOrientationHandler;
  110873. /**
  110874. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  110875. */
  110876. constructor();
  110877. /**
  110878. * Attach the input controls to a specific dom element to get the input from.
  110879. * @param element Defines the element the controls should be listened from
  110880. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110881. */
  110882. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110883. /** @hidden */
  110884. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  110885. /**
  110886. * Update the current camera state depending on the inputs that have been used this frame.
  110887. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  110888. */
  110889. checkInputs(): void;
  110890. /**
  110891. * Detach the current controls from the specified dom element.
  110892. * @param element Defines the element to stop listening the inputs from
  110893. */
  110894. detachControl(element: Nullable<HTMLElement>): void;
  110895. /**
  110896. * Gets the class name of the current intput.
  110897. * @returns the class name
  110898. */
  110899. getClassName(): string;
  110900. /**
  110901. * Get the friendly name associated with the input class.
  110902. * @returns the input friendly name
  110903. */
  110904. getSimpleName(): string;
  110905. }
  110906. }
  110907. declare module BABYLON {
  110908. /**
  110909. * Listen to mouse events to control the camera.
  110910. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110911. */
  110912. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  110913. /**
  110914. * Defines the camera the input is attached to.
  110915. */
  110916. camera: FlyCamera;
  110917. /**
  110918. * Defines if touch is enabled. (Default is true.)
  110919. */
  110920. touchEnabled: boolean;
  110921. /**
  110922. * Defines the buttons associated with the input to handle camera rotation.
  110923. */
  110924. buttons: number[];
  110925. /**
  110926. * Assign buttons for Yaw control.
  110927. */
  110928. buttonsYaw: number[];
  110929. /**
  110930. * Assign buttons for Pitch control.
  110931. */
  110932. buttonsPitch: number[];
  110933. /**
  110934. * Assign buttons for Roll control.
  110935. */
  110936. buttonsRoll: number[];
  110937. /**
  110938. * Detect if any button is being pressed while mouse is moved.
  110939. * -1 = Mouse locked.
  110940. * 0 = Left button.
  110941. * 1 = Middle Button.
  110942. * 2 = Right Button.
  110943. */
  110944. activeButton: number;
  110945. /**
  110946. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  110947. * Higher values reduce its sensitivity.
  110948. */
  110949. angularSensibility: number;
  110950. private _mousemoveCallback;
  110951. private _observer;
  110952. private _rollObserver;
  110953. private previousPosition;
  110954. private noPreventDefault;
  110955. private element;
  110956. /**
  110957. * Listen to mouse events to control the camera.
  110958. * @param touchEnabled Define if touch is enabled. (Default is true.)
  110959. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110960. */
  110961. constructor(touchEnabled?: boolean);
  110962. /**
  110963. * Attach the mouse control to the HTML DOM element.
  110964. * @param element Defines the element that listens to the input events.
  110965. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  110966. */
  110967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110968. /**
  110969. * Detach the current controls from the specified dom element.
  110970. * @param element Defines the element to stop listening the inputs from
  110971. */
  110972. detachControl(element: Nullable<HTMLElement>): void;
  110973. /**
  110974. * Gets the class name of the current input.
  110975. * @returns the class name.
  110976. */
  110977. getClassName(): string;
  110978. /**
  110979. * Get the friendly name associated with the input class.
  110980. * @returns the input's friendly name.
  110981. */
  110982. getSimpleName(): string;
  110983. private _pointerInput;
  110984. private _onMouseMove;
  110985. /**
  110986. * Rotate camera by mouse offset.
  110987. */
  110988. private rotateCamera;
  110989. }
  110990. }
  110991. declare module BABYLON {
  110992. /**
  110993. * Default Inputs manager for the FlyCamera.
  110994. * It groups all the default supported inputs for ease of use.
  110995. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  110996. */
  110997. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  110998. /**
  110999. * Instantiates a new FlyCameraInputsManager.
  111000. * @param camera Defines the camera the inputs belong to.
  111001. */
  111002. constructor(camera: FlyCamera);
  111003. /**
  111004. * Add keyboard input support to the input manager.
  111005. * @returns the new FlyCameraKeyboardMoveInput().
  111006. */
  111007. addKeyboard(): FlyCameraInputsManager;
  111008. /**
  111009. * Add mouse input support to the input manager.
  111010. * @param touchEnabled Enable touch screen support.
  111011. * @returns the new FlyCameraMouseInput().
  111012. */
  111013. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  111014. }
  111015. }
  111016. declare module BABYLON {
  111017. /**
  111018. * This is a flying camera, designed for 3D movement and rotation in all directions,
  111019. * such as in a 3D Space Shooter or a Flight Simulator.
  111020. */
  111021. export class FlyCamera extends TargetCamera {
  111022. /**
  111023. * Define the collision ellipsoid of the camera.
  111024. * This is helpful for simulating a camera body, like a player's body.
  111025. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  111026. */
  111027. ellipsoid: Vector3;
  111028. /**
  111029. * Define an offset for the position of the ellipsoid around the camera.
  111030. * This can be helpful if the camera is attached away from the player's body center,
  111031. * such as at its head.
  111032. */
  111033. ellipsoidOffset: Vector3;
  111034. /**
  111035. * Enable or disable collisions of the camera with the rest of the scene objects.
  111036. */
  111037. checkCollisions: boolean;
  111038. /**
  111039. * Enable or disable gravity on the camera.
  111040. */
  111041. applyGravity: boolean;
  111042. /**
  111043. * Define the current direction the camera is moving to.
  111044. */
  111045. cameraDirection: Vector3;
  111046. /**
  111047. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  111048. * This overrides and empties cameraRotation.
  111049. */
  111050. rotationQuaternion: Quaternion;
  111051. /**
  111052. * Track Roll to maintain the wanted Rolling when looking around.
  111053. */
  111054. _trackRoll: number;
  111055. /**
  111056. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  111057. */
  111058. rollCorrect: number;
  111059. /**
  111060. * Mimic a banked turn, Rolling the camera when Yawing.
  111061. * It's recommended to use rollCorrect = 10 for faster banking correction.
  111062. */
  111063. bankedTurn: boolean;
  111064. /**
  111065. * Limit in radians for how much Roll banking will add. (Default: 90°)
  111066. */
  111067. bankedTurnLimit: number;
  111068. /**
  111069. * Value of 0 disables the banked Roll.
  111070. * Value of 1 is equal to the Yaw angle in radians.
  111071. */
  111072. bankedTurnMultiplier: number;
  111073. /**
  111074. * The inputs manager loads all the input sources, such as keyboard and mouse.
  111075. */
  111076. inputs: FlyCameraInputsManager;
  111077. /**
  111078. * Gets the input sensibility for mouse input.
  111079. * Higher values reduce sensitivity.
  111080. */
  111081. get angularSensibility(): number;
  111082. /**
  111083. * Sets the input sensibility for a mouse input.
  111084. * Higher values reduce sensitivity.
  111085. */
  111086. set angularSensibility(value: number);
  111087. /**
  111088. * Get the keys for camera movement forward.
  111089. */
  111090. get keysForward(): number[];
  111091. /**
  111092. * Set the keys for camera movement forward.
  111093. */
  111094. set keysForward(value: number[]);
  111095. /**
  111096. * Get the keys for camera movement backward.
  111097. */
  111098. get keysBackward(): number[];
  111099. set keysBackward(value: number[]);
  111100. /**
  111101. * Get the keys for camera movement up.
  111102. */
  111103. get keysUp(): number[];
  111104. /**
  111105. * Set the keys for camera movement up.
  111106. */
  111107. set keysUp(value: number[]);
  111108. /**
  111109. * Get the keys for camera movement down.
  111110. */
  111111. get keysDown(): number[];
  111112. /**
  111113. * Set the keys for camera movement down.
  111114. */
  111115. set keysDown(value: number[]);
  111116. /**
  111117. * Get the keys for camera movement left.
  111118. */
  111119. get keysLeft(): number[];
  111120. /**
  111121. * Set the keys for camera movement left.
  111122. */
  111123. set keysLeft(value: number[]);
  111124. /**
  111125. * Set the keys for camera movement right.
  111126. */
  111127. get keysRight(): number[];
  111128. /**
  111129. * Set the keys for camera movement right.
  111130. */
  111131. set keysRight(value: number[]);
  111132. /**
  111133. * Event raised when the camera collides with a mesh in the scene.
  111134. */
  111135. onCollide: (collidedMesh: AbstractMesh) => void;
  111136. private _collider;
  111137. private _needMoveForGravity;
  111138. private _oldPosition;
  111139. private _diffPosition;
  111140. private _newPosition;
  111141. /** @hidden */
  111142. _localDirection: Vector3;
  111143. /** @hidden */
  111144. _transformedDirection: Vector3;
  111145. /**
  111146. * Instantiates a FlyCamera.
  111147. * This is a flying camera, designed for 3D movement and rotation in all directions,
  111148. * such as in a 3D Space Shooter or a Flight Simulator.
  111149. * @param name Define the name of the camera in the scene.
  111150. * @param position Define the starting position of the camera in the scene.
  111151. * @param scene Define the scene the camera belongs to.
  111152. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  111153. */
  111154. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  111155. /**
  111156. * Attach a control to the HTML DOM element.
  111157. * @param element Defines the element that listens to the input events.
  111158. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  111159. */
  111160. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111161. /**
  111162. * Detach a control from the HTML DOM element.
  111163. * The camera will stop reacting to that input.
  111164. * @param element Defines the element that listens to the input events.
  111165. */
  111166. detachControl(element: HTMLElement): void;
  111167. private _collisionMask;
  111168. /**
  111169. * Get the mask that the camera ignores in collision events.
  111170. */
  111171. get collisionMask(): number;
  111172. /**
  111173. * Set the mask that the camera ignores in collision events.
  111174. */
  111175. set collisionMask(mask: number);
  111176. /** @hidden */
  111177. _collideWithWorld(displacement: Vector3): void;
  111178. /** @hidden */
  111179. private _onCollisionPositionChange;
  111180. /** @hidden */
  111181. _checkInputs(): void;
  111182. /** @hidden */
  111183. _decideIfNeedsToMove(): boolean;
  111184. /** @hidden */
  111185. _updatePosition(): void;
  111186. /**
  111187. * Restore the Roll to its target value at the rate specified.
  111188. * @param rate - Higher means slower restoring.
  111189. * @hidden
  111190. */
  111191. restoreRoll(rate: number): void;
  111192. /**
  111193. * Destroy the camera and release the current resources held by it.
  111194. */
  111195. dispose(): void;
  111196. /**
  111197. * Get the current object class name.
  111198. * @returns the class name.
  111199. */
  111200. getClassName(): string;
  111201. }
  111202. }
  111203. declare module BABYLON {
  111204. /**
  111205. * Listen to keyboard events to control the camera.
  111206. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111207. */
  111208. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  111209. /**
  111210. * Defines the camera the input is attached to.
  111211. */
  111212. camera: FlyCamera;
  111213. /**
  111214. * The list of keyboard keys used to control the forward move of the camera.
  111215. */
  111216. keysForward: number[];
  111217. /**
  111218. * The list of keyboard keys used to control the backward move of the camera.
  111219. */
  111220. keysBackward: number[];
  111221. /**
  111222. * The list of keyboard keys used to control the forward move of the camera.
  111223. */
  111224. keysUp: number[];
  111225. /**
  111226. * The list of keyboard keys used to control the backward move of the camera.
  111227. */
  111228. keysDown: number[];
  111229. /**
  111230. * The list of keyboard keys used to control the right strafe move of the camera.
  111231. */
  111232. keysRight: number[];
  111233. /**
  111234. * The list of keyboard keys used to control the left strafe move of the camera.
  111235. */
  111236. keysLeft: number[];
  111237. private _keys;
  111238. private _onCanvasBlurObserver;
  111239. private _onKeyboardObserver;
  111240. private _engine;
  111241. private _scene;
  111242. /**
  111243. * Attach the input controls to a specific dom element to get the input from.
  111244. * @param element Defines the element the controls should be listened from
  111245. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111246. */
  111247. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111248. /**
  111249. * Detach the current controls from the specified dom element.
  111250. * @param element Defines the element to stop listening the inputs from
  111251. */
  111252. detachControl(element: Nullable<HTMLElement>): void;
  111253. /**
  111254. * Gets the class name of the current intput.
  111255. * @returns the class name
  111256. */
  111257. getClassName(): string;
  111258. /** @hidden */
  111259. _onLostFocus(e: FocusEvent): void;
  111260. /**
  111261. * Get the friendly name associated with the input class.
  111262. * @returns the input friendly name
  111263. */
  111264. getSimpleName(): string;
  111265. /**
  111266. * Update the current camera state depending on the inputs that have been used this frame.
  111267. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111268. */
  111269. checkInputs(): void;
  111270. }
  111271. }
  111272. declare module BABYLON {
  111273. /**
  111274. * Manage the mouse wheel inputs to control a follow camera.
  111275. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111276. */
  111277. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  111278. /**
  111279. * Defines the camera the input is attached to.
  111280. */
  111281. camera: FollowCamera;
  111282. /**
  111283. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  111284. */
  111285. axisControlRadius: boolean;
  111286. /**
  111287. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  111288. */
  111289. axisControlHeight: boolean;
  111290. /**
  111291. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  111292. */
  111293. axisControlRotation: boolean;
  111294. /**
  111295. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  111296. * relation to mouseWheel events.
  111297. */
  111298. wheelPrecision: number;
  111299. /**
  111300. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111301. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111302. */
  111303. wheelDeltaPercentage: number;
  111304. private _wheel;
  111305. private _observer;
  111306. /**
  111307. * Attach the input controls to a specific dom element to get the input from.
  111308. * @param element Defines the element the controls should be listened from
  111309. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111310. */
  111311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111312. /**
  111313. * Detach the current controls from the specified dom element.
  111314. * @param element Defines the element to stop listening the inputs from
  111315. */
  111316. detachControl(element: Nullable<HTMLElement>): void;
  111317. /**
  111318. * Gets the class name of the current intput.
  111319. * @returns the class name
  111320. */
  111321. getClassName(): string;
  111322. /**
  111323. * Get the friendly name associated with the input class.
  111324. * @returns the input friendly name
  111325. */
  111326. getSimpleName(): string;
  111327. }
  111328. }
  111329. declare module BABYLON {
  111330. /**
  111331. * Manage the pointers inputs to control an follow camera.
  111332. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111333. */
  111334. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  111335. /**
  111336. * Defines the camera the input is attached to.
  111337. */
  111338. camera: FollowCamera;
  111339. /**
  111340. * Gets the class name of the current input.
  111341. * @returns the class name
  111342. */
  111343. getClassName(): string;
  111344. /**
  111345. * Defines the pointer angular sensibility along the X axis or how fast is
  111346. * the camera rotating.
  111347. * A negative number will reverse the axis direction.
  111348. */
  111349. angularSensibilityX: number;
  111350. /**
  111351. * Defines the pointer angular sensibility along the Y axis or how fast is
  111352. * the camera rotating.
  111353. * A negative number will reverse the axis direction.
  111354. */
  111355. angularSensibilityY: number;
  111356. /**
  111357. * Defines the pointer pinch precision or how fast is the camera zooming.
  111358. * A negative number will reverse the axis direction.
  111359. */
  111360. pinchPrecision: number;
  111361. /**
  111362. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111363. * from 0.
  111364. * It defines the percentage of current camera.radius to use as delta when
  111365. * pinch zoom is used.
  111366. */
  111367. pinchDeltaPercentage: number;
  111368. /**
  111369. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  111370. */
  111371. axisXControlRadius: boolean;
  111372. /**
  111373. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  111374. */
  111375. axisXControlHeight: boolean;
  111376. /**
  111377. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  111378. */
  111379. axisXControlRotation: boolean;
  111380. /**
  111381. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  111382. */
  111383. axisYControlRadius: boolean;
  111384. /**
  111385. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  111386. */
  111387. axisYControlHeight: boolean;
  111388. /**
  111389. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  111390. */
  111391. axisYControlRotation: boolean;
  111392. /**
  111393. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  111394. */
  111395. axisPinchControlRadius: boolean;
  111396. /**
  111397. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  111398. */
  111399. axisPinchControlHeight: boolean;
  111400. /**
  111401. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  111402. */
  111403. axisPinchControlRotation: boolean;
  111404. /**
  111405. * Log error messages if basic misconfiguration has occurred.
  111406. */
  111407. warningEnable: boolean;
  111408. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111409. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111410. private _warningCounter;
  111411. private _warning;
  111412. }
  111413. }
  111414. declare module BABYLON {
  111415. /**
  111416. * Default Inputs manager for the FollowCamera.
  111417. * It groups all the default supported inputs for ease of use.
  111418. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111419. */
  111420. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  111421. /**
  111422. * Instantiates a new FollowCameraInputsManager.
  111423. * @param camera Defines the camera the inputs belong to
  111424. */
  111425. constructor(camera: FollowCamera);
  111426. /**
  111427. * Add keyboard input support to the input manager.
  111428. * @returns the current input manager
  111429. */
  111430. addKeyboard(): FollowCameraInputsManager;
  111431. /**
  111432. * Add mouse wheel input support to the input manager.
  111433. * @returns the current input manager
  111434. */
  111435. addMouseWheel(): FollowCameraInputsManager;
  111436. /**
  111437. * Add pointers input support to the input manager.
  111438. * @returns the current input manager
  111439. */
  111440. addPointers(): FollowCameraInputsManager;
  111441. /**
  111442. * Add orientation input support to the input manager.
  111443. * @returns the current input manager
  111444. */
  111445. addVRDeviceOrientation(): FollowCameraInputsManager;
  111446. }
  111447. }
  111448. declare module BABYLON {
  111449. /**
  111450. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  111451. * an arc rotate version arcFollowCamera are available.
  111452. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  111453. */
  111454. export class FollowCamera extends TargetCamera {
  111455. /**
  111456. * Distance the follow camera should follow an object at
  111457. */
  111458. radius: number;
  111459. /**
  111460. * Minimum allowed distance of the camera to the axis of rotation
  111461. * (The camera can not get closer).
  111462. * This can help limiting how the Camera is able to move in the scene.
  111463. */
  111464. lowerRadiusLimit: Nullable<number>;
  111465. /**
  111466. * Maximum allowed distance of the camera to the axis of rotation
  111467. * (The camera can not get further).
  111468. * This can help limiting how the Camera is able to move in the scene.
  111469. */
  111470. upperRadiusLimit: Nullable<number>;
  111471. /**
  111472. * Define a rotation offset between the camera and the object it follows
  111473. */
  111474. rotationOffset: number;
  111475. /**
  111476. * Minimum allowed angle to camera position relative to target object.
  111477. * This can help limiting how the Camera is able to move in the scene.
  111478. */
  111479. lowerRotationOffsetLimit: Nullable<number>;
  111480. /**
  111481. * Maximum allowed angle to camera position relative to target object.
  111482. * This can help limiting how the Camera is able to move in the scene.
  111483. */
  111484. upperRotationOffsetLimit: Nullable<number>;
  111485. /**
  111486. * Define a height offset between the camera and the object it follows.
  111487. * It can help following an object from the top (like a car chaing a plane)
  111488. */
  111489. heightOffset: number;
  111490. /**
  111491. * Minimum allowed height of camera position relative to target object.
  111492. * This can help limiting how the Camera is able to move in the scene.
  111493. */
  111494. lowerHeightOffsetLimit: Nullable<number>;
  111495. /**
  111496. * Maximum allowed height of camera position relative to target object.
  111497. * This can help limiting how the Camera is able to move in the scene.
  111498. */
  111499. upperHeightOffsetLimit: Nullable<number>;
  111500. /**
  111501. * Define how fast the camera can accelerate to follow it s target.
  111502. */
  111503. cameraAcceleration: number;
  111504. /**
  111505. * Define the speed limit of the camera following an object.
  111506. */
  111507. maxCameraSpeed: number;
  111508. /**
  111509. * Define the target of the camera.
  111510. */
  111511. lockedTarget: Nullable<AbstractMesh>;
  111512. /**
  111513. * Defines the input associated with the camera.
  111514. */
  111515. inputs: FollowCameraInputsManager;
  111516. /**
  111517. * Instantiates the follow camera.
  111518. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  111519. * @param name Define the name of the camera in the scene
  111520. * @param position Define the position of the camera
  111521. * @param scene Define the scene the camera belong to
  111522. * @param lockedTarget Define the target of the camera
  111523. */
  111524. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  111525. private _follow;
  111526. /**
  111527. * Attached controls to the current camera.
  111528. * @param element Defines the element the controls should be listened from
  111529. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111530. */
  111531. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111532. /**
  111533. * Detach the current controls from the camera.
  111534. * The camera will stop reacting to inputs.
  111535. * @param element Defines the element to stop listening the inputs from
  111536. */
  111537. detachControl(element: HTMLElement): void;
  111538. /** @hidden */
  111539. _checkInputs(): void;
  111540. private _checkLimits;
  111541. /**
  111542. * Gets the camera class name.
  111543. * @returns the class name
  111544. */
  111545. getClassName(): string;
  111546. }
  111547. /**
  111548. * Arc Rotate version of the follow camera.
  111549. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  111550. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  111551. */
  111552. export class ArcFollowCamera extends TargetCamera {
  111553. /** The longitudinal angle of the camera */
  111554. alpha: number;
  111555. /** The latitudinal angle of the camera */
  111556. beta: number;
  111557. /** The radius of the camera from its target */
  111558. radius: number;
  111559. /** Define the camera target (the messh it should follow) */
  111560. target: Nullable<AbstractMesh>;
  111561. private _cartesianCoordinates;
  111562. /**
  111563. * Instantiates a new ArcFollowCamera
  111564. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  111565. * @param name Define the name of the camera
  111566. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  111567. * @param beta Define the rotation angle of the camera around the elevation axis
  111568. * @param radius Define the radius of the camera from its target point
  111569. * @param target Define the target of the camera
  111570. * @param scene Define the scene the camera belongs to
  111571. */
  111572. constructor(name: string,
  111573. /** The longitudinal angle of the camera */
  111574. alpha: number,
  111575. /** The latitudinal angle of the camera */
  111576. beta: number,
  111577. /** The radius of the camera from its target */
  111578. radius: number,
  111579. /** Define the camera target (the messh it should follow) */
  111580. target: Nullable<AbstractMesh>, scene: Scene);
  111581. private _follow;
  111582. /** @hidden */
  111583. _checkInputs(): void;
  111584. /**
  111585. * Returns the class name of the object.
  111586. * It is mostly used internally for serialization purposes.
  111587. */
  111588. getClassName(): string;
  111589. }
  111590. }
  111591. declare module BABYLON {
  111592. /**
  111593. * Manage the keyboard inputs to control the movement of a follow camera.
  111594. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111595. */
  111596. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  111597. /**
  111598. * Defines the camera the input is attached to.
  111599. */
  111600. camera: FollowCamera;
  111601. /**
  111602. * Defines the list of key codes associated with the up action (increase heightOffset)
  111603. */
  111604. keysHeightOffsetIncr: number[];
  111605. /**
  111606. * Defines the list of key codes associated with the down action (decrease heightOffset)
  111607. */
  111608. keysHeightOffsetDecr: number[];
  111609. /**
  111610. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  111611. */
  111612. keysHeightOffsetModifierAlt: boolean;
  111613. /**
  111614. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  111615. */
  111616. keysHeightOffsetModifierCtrl: boolean;
  111617. /**
  111618. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  111619. */
  111620. keysHeightOffsetModifierShift: boolean;
  111621. /**
  111622. * Defines the list of key codes associated with the left action (increase rotationOffset)
  111623. */
  111624. keysRotationOffsetIncr: number[];
  111625. /**
  111626. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  111627. */
  111628. keysRotationOffsetDecr: number[];
  111629. /**
  111630. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  111631. */
  111632. keysRotationOffsetModifierAlt: boolean;
  111633. /**
  111634. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  111635. */
  111636. keysRotationOffsetModifierCtrl: boolean;
  111637. /**
  111638. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  111639. */
  111640. keysRotationOffsetModifierShift: boolean;
  111641. /**
  111642. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  111643. */
  111644. keysRadiusIncr: number[];
  111645. /**
  111646. * Defines the list of key codes associated with the zoom-out action (increase radius)
  111647. */
  111648. keysRadiusDecr: number[];
  111649. /**
  111650. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  111651. */
  111652. keysRadiusModifierAlt: boolean;
  111653. /**
  111654. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  111655. */
  111656. keysRadiusModifierCtrl: boolean;
  111657. /**
  111658. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  111659. */
  111660. keysRadiusModifierShift: boolean;
  111661. /**
  111662. * Defines the rate of change of heightOffset.
  111663. */
  111664. heightSensibility: number;
  111665. /**
  111666. * Defines the rate of change of rotationOffset.
  111667. */
  111668. rotationSensibility: number;
  111669. /**
  111670. * Defines the rate of change of radius.
  111671. */
  111672. radiusSensibility: number;
  111673. private _keys;
  111674. private _ctrlPressed;
  111675. private _altPressed;
  111676. private _shiftPressed;
  111677. private _onCanvasBlurObserver;
  111678. private _onKeyboardObserver;
  111679. private _engine;
  111680. private _scene;
  111681. /**
  111682. * Attach the input controls to a specific dom element to get the input from.
  111683. * @param element Defines the element the controls should be listened from
  111684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111685. */
  111686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111687. /**
  111688. * Detach the current controls from the specified dom element.
  111689. * @param element Defines the element to stop listening the inputs from
  111690. */
  111691. detachControl(element: Nullable<HTMLElement>): void;
  111692. /**
  111693. * Update the current camera state depending on the inputs that have been used this frame.
  111694. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111695. */
  111696. checkInputs(): void;
  111697. /**
  111698. * Gets the class name of the current input.
  111699. * @returns the class name
  111700. */
  111701. getClassName(): string;
  111702. /**
  111703. * Get the friendly name associated with the input class.
  111704. * @returns the input friendly name
  111705. */
  111706. getSimpleName(): string;
  111707. /**
  111708. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  111709. * allow modification of the heightOffset value.
  111710. */
  111711. private _modifierHeightOffset;
  111712. /**
  111713. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  111714. * allow modification of the rotationOffset value.
  111715. */
  111716. private _modifierRotationOffset;
  111717. /**
  111718. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  111719. * allow modification of the radius value.
  111720. */
  111721. private _modifierRadius;
  111722. }
  111723. }
  111724. declare module BABYLON {
  111725. interface FreeCameraInputsManager {
  111726. /**
  111727. * @hidden
  111728. */
  111729. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  111730. /**
  111731. * Add orientation input support to the input manager.
  111732. * @returns the current input manager
  111733. */
  111734. addDeviceOrientation(): FreeCameraInputsManager;
  111735. }
  111736. /**
  111737. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  111738. * Screen rotation is taken into account.
  111739. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111740. */
  111741. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  111742. private _camera;
  111743. private _screenOrientationAngle;
  111744. private _constantTranform;
  111745. private _screenQuaternion;
  111746. private _alpha;
  111747. private _beta;
  111748. private _gamma;
  111749. /**
  111750. * Can be used to detect if a device orientation sensor is available on a device
  111751. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  111752. * @returns a promise that will resolve on orientation change
  111753. */
  111754. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  111755. /**
  111756. * @hidden
  111757. */
  111758. _onDeviceOrientationChangedObservable: Observable<void>;
  111759. /**
  111760. * Instantiates a new input
  111761. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111762. */
  111763. constructor();
  111764. /**
  111765. * Define the camera controlled by the input.
  111766. */
  111767. get camera(): FreeCamera;
  111768. set camera(camera: FreeCamera);
  111769. /**
  111770. * Attach the input controls to a specific dom element to get the input from.
  111771. * @param element Defines the element the controls should be listened from
  111772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111773. */
  111774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111775. private _orientationChanged;
  111776. private _deviceOrientation;
  111777. /**
  111778. * Detach the current controls from the specified dom element.
  111779. * @param element Defines the element to stop listening the inputs from
  111780. */
  111781. detachControl(element: Nullable<HTMLElement>): void;
  111782. /**
  111783. * Update the current camera state depending on the inputs that have been used this frame.
  111784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111785. */
  111786. checkInputs(): void;
  111787. /**
  111788. * Gets the class name of the current intput.
  111789. * @returns the class name
  111790. */
  111791. getClassName(): string;
  111792. /**
  111793. * Get the friendly name associated with the input class.
  111794. * @returns the input friendly name
  111795. */
  111796. getSimpleName(): string;
  111797. }
  111798. }
  111799. declare module BABYLON {
  111800. /**
  111801. * Manage the gamepad inputs to control a free camera.
  111802. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111803. */
  111804. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  111805. /**
  111806. * Define the camera the input is attached to.
  111807. */
  111808. camera: FreeCamera;
  111809. /**
  111810. * Define the Gamepad controlling the input
  111811. */
  111812. gamepad: Nullable<Gamepad>;
  111813. /**
  111814. * Defines the gamepad rotation sensiblity.
  111815. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  111816. */
  111817. gamepadAngularSensibility: number;
  111818. /**
  111819. * Defines the gamepad move sensiblity.
  111820. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  111821. */
  111822. gamepadMoveSensibility: number;
  111823. private _yAxisScale;
  111824. /**
  111825. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  111826. */
  111827. get invertYAxis(): boolean;
  111828. set invertYAxis(value: boolean);
  111829. private _onGamepadConnectedObserver;
  111830. private _onGamepadDisconnectedObserver;
  111831. private _cameraTransform;
  111832. private _deltaTransform;
  111833. private _vector3;
  111834. private _vector2;
  111835. /**
  111836. * Attach the input controls to a specific dom element to get the input from.
  111837. * @param element Defines the element the controls should be listened from
  111838. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111839. */
  111840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111841. /**
  111842. * Detach the current controls from the specified dom element.
  111843. * @param element Defines the element to stop listening the inputs from
  111844. */
  111845. detachControl(element: Nullable<HTMLElement>): void;
  111846. /**
  111847. * Update the current camera state depending on the inputs that have been used this frame.
  111848. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111849. */
  111850. checkInputs(): void;
  111851. /**
  111852. * Gets the class name of the current intput.
  111853. * @returns the class name
  111854. */
  111855. getClassName(): string;
  111856. /**
  111857. * Get the friendly name associated with the input class.
  111858. * @returns the input friendly name
  111859. */
  111860. getSimpleName(): string;
  111861. }
  111862. }
  111863. declare module BABYLON {
  111864. /**
  111865. * Defines the potential axis of a Joystick
  111866. */
  111867. export enum JoystickAxis {
  111868. /** X axis */
  111869. X = 0,
  111870. /** Y axis */
  111871. Y = 1,
  111872. /** Z axis */
  111873. Z = 2
  111874. }
  111875. /**
  111876. * Class used to define virtual joystick (used in touch mode)
  111877. */
  111878. export class VirtualJoystick {
  111879. /**
  111880. * Gets or sets a boolean indicating that left and right values must be inverted
  111881. */
  111882. reverseLeftRight: boolean;
  111883. /**
  111884. * Gets or sets a boolean indicating that up and down values must be inverted
  111885. */
  111886. reverseUpDown: boolean;
  111887. /**
  111888. * Gets the offset value for the position (ie. the change of the position value)
  111889. */
  111890. deltaPosition: Vector3;
  111891. /**
  111892. * Gets a boolean indicating if the virtual joystick was pressed
  111893. */
  111894. pressed: boolean;
  111895. /**
  111896. * Canvas the virtual joystick will render onto, default z-index of this is 5
  111897. */
  111898. static Canvas: Nullable<HTMLCanvasElement>;
  111899. private static _globalJoystickIndex;
  111900. private static vjCanvasContext;
  111901. private static vjCanvasWidth;
  111902. private static vjCanvasHeight;
  111903. private static halfWidth;
  111904. private _action;
  111905. private _axisTargetedByLeftAndRight;
  111906. private _axisTargetedByUpAndDown;
  111907. private _joystickSensibility;
  111908. private _inversedSensibility;
  111909. private _joystickPointerID;
  111910. private _joystickColor;
  111911. private _joystickPointerPos;
  111912. private _joystickPreviousPointerPos;
  111913. private _joystickPointerStartPos;
  111914. private _deltaJoystickVector;
  111915. private _leftJoystick;
  111916. private _touches;
  111917. private _onPointerDownHandlerRef;
  111918. private _onPointerMoveHandlerRef;
  111919. private _onPointerUpHandlerRef;
  111920. private _onResize;
  111921. /**
  111922. * Creates a new virtual joystick
  111923. * @param leftJoystick defines that the joystick is for left hand (false by default)
  111924. */
  111925. constructor(leftJoystick?: boolean);
  111926. /**
  111927. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  111928. * @param newJoystickSensibility defines the new sensibility
  111929. */
  111930. setJoystickSensibility(newJoystickSensibility: number): void;
  111931. private _onPointerDown;
  111932. private _onPointerMove;
  111933. private _onPointerUp;
  111934. /**
  111935. * Change the color of the virtual joystick
  111936. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  111937. */
  111938. setJoystickColor(newColor: string): void;
  111939. /**
  111940. * Defines a callback to call when the joystick is touched
  111941. * @param action defines the callback
  111942. */
  111943. setActionOnTouch(action: () => any): void;
  111944. /**
  111945. * Defines which axis you'd like to control for left & right
  111946. * @param axis defines the axis to use
  111947. */
  111948. setAxisForLeftRight(axis: JoystickAxis): void;
  111949. /**
  111950. * Defines which axis you'd like to control for up & down
  111951. * @param axis defines the axis to use
  111952. */
  111953. setAxisForUpDown(axis: JoystickAxis): void;
  111954. private _drawVirtualJoystick;
  111955. /**
  111956. * Release internal HTML canvas
  111957. */
  111958. releaseCanvas(): void;
  111959. }
  111960. }
  111961. declare module BABYLON {
  111962. interface FreeCameraInputsManager {
  111963. /**
  111964. * Add virtual joystick input support to the input manager.
  111965. * @returns the current input manager
  111966. */
  111967. addVirtualJoystick(): FreeCameraInputsManager;
  111968. }
  111969. /**
  111970. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  111971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111972. */
  111973. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  111974. /**
  111975. * Defines the camera the input is attached to.
  111976. */
  111977. camera: FreeCamera;
  111978. private _leftjoystick;
  111979. private _rightjoystick;
  111980. /**
  111981. * Gets the left stick of the virtual joystick.
  111982. * @returns The virtual Joystick
  111983. */
  111984. getLeftJoystick(): VirtualJoystick;
  111985. /**
  111986. * Gets the right stick of the virtual joystick.
  111987. * @returns The virtual Joystick
  111988. */
  111989. getRightJoystick(): VirtualJoystick;
  111990. /**
  111991. * Update the current camera state depending on the inputs that have been used this frame.
  111992. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111993. */
  111994. checkInputs(): void;
  111995. /**
  111996. * Attach the input controls to a specific dom element to get the input from.
  111997. * @param element Defines the element the controls should be listened from
  111998. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111999. */
  112000. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112001. /**
  112002. * Detach the current controls from the specified dom element.
  112003. * @param element Defines the element to stop listening the inputs from
  112004. */
  112005. detachControl(element: Nullable<HTMLElement>): void;
  112006. /**
  112007. * Gets the class name of the current intput.
  112008. * @returns the class name
  112009. */
  112010. getClassName(): string;
  112011. /**
  112012. * Get the friendly name associated with the input class.
  112013. * @returns the input friendly name
  112014. */
  112015. getSimpleName(): string;
  112016. }
  112017. }
  112018. declare module BABYLON {
  112019. /**
  112020. * This represents a FPS type of camera controlled by touch.
  112021. * This is like a universal camera minus the Gamepad controls.
  112022. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112023. */
  112024. export class TouchCamera extends FreeCamera {
  112025. /**
  112026. * Defines the touch sensibility for rotation.
  112027. * The higher the faster.
  112028. */
  112029. get touchAngularSensibility(): number;
  112030. set touchAngularSensibility(value: number);
  112031. /**
  112032. * Defines the touch sensibility for move.
  112033. * The higher the faster.
  112034. */
  112035. get touchMoveSensibility(): number;
  112036. set touchMoveSensibility(value: number);
  112037. /**
  112038. * Instantiates a new touch camera.
  112039. * This represents a FPS type of camera controlled by touch.
  112040. * This is like a universal camera minus the Gamepad controls.
  112041. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112042. * @param name Define the name of the camera in the scene
  112043. * @param position Define the start position of the camera in the scene
  112044. * @param scene Define the scene the camera belongs to
  112045. */
  112046. constructor(name: string, position: Vector3, scene: Scene);
  112047. /**
  112048. * Gets the current object class name.
  112049. * @return the class name
  112050. */
  112051. getClassName(): string;
  112052. /** @hidden */
  112053. _setupInputs(): void;
  112054. }
  112055. }
  112056. declare module BABYLON {
  112057. /**
  112058. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  112059. * being tilted forward or back and left or right.
  112060. */
  112061. export class DeviceOrientationCamera extends FreeCamera {
  112062. private _initialQuaternion;
  112063. private _quaternionCache;
  112064. private _tmpDragQuaternion;
  112065. private _disablePointerInputWhenUsingDeviceOrientation;
  112066. /**
  112067. * Creates a new device orientation camera
  112068. * @param name The name of the camera
  112069. * @param position The start position camera
  112070. * @param scene The scene the camera belongs to
  112071. */
  112072. constructor(name: string, position: Vector3, scene: Scene);
  112073. /**
  112074. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  112075. */
  112076. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  112077. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  112078. private _dragFactor;
  112079. /**
  112080. * Enabled turning on the y axis when the orientation sensor is active
  112081. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  112082. */
  112083. enableHorizontalDragging(dragFactor?: number): void;
  112084. /**
  112085. * Gets the current instance class name ("DeviceOrientationCamera").
  112086. * This helps avoiding instanceof at run time.
  112087. * @returns the class name
  112088. */
  112089. getClassName(): string;
  112090. /**
  112091. * @hidden
  112092. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  112093. */
  112094. _checkInputs(): void;
  112095. /**
  112096. * Reset the camera to its default orientation on the specified axis only.
  112097. * @param axis The axis to reset
  112098. */
  112099. resetToCurrentRotation(axis?: Axis): void;
  112100. }
  112101. }
  112102. declare module BABYLON {
  112103. /**
  112104. * Defines supported buttons for XBox360 compatible gamepads
  112105. */
  112106. export enum Xbox360Button {
  112107. /** A */
  112108. A = 0,
  112109. /** B */
  112110. B = 1,
  112111. /** X */
  112112. X = 2,
  112113. /** Y */
  112114. Y = 3,
  112115. /** Start */
  112116. Start = 4,
  112117. /** Back */
  112118. Back = 5,
  112119. /** Left button */
  112120. LB = 6,
  112121. /** Right button */
  112122. RB = 7,
  112123. /** Left stick */
  112124. LeftStick = 8,
  112125. /** Right stick */
  112126. RightStick = 9
  112127. }
  112128. /** Defines values for XBox360 DPad */
  112129. export enum Xbox360Dpad {
  112130. /** Up */
  112131. Up = 0,
  112132. /** Down */
  112133. Down = 1,
  112134. /** Left */
  112135. Left = 2,
  112136. /** Right */
  112137. Right = 3
  112138. }
  112139. /**
  112140. * Defines a XBox360 gamepad
  112141. */
  112142. export class Xbox360Pad extends Gamepad {
  112143. private _leftTrigger;
  112144. private _rightTrigger;
  112145. private _onlefttriggerchanged;
  112146. private _onrighttriggerchanged;
  112147. private _onbuttondown;
  112148. private _onbuttonup;
  112149. private _ondpaddown;
  112150. private _ondpadup;
  112151. /** Observable raised when a button is pressed */
  112152. onButtonDownObservable: Observable<Xbox360Button>;
  112153. /** Observable raised when a button is released */
  112154. onButtonUpObservable: Observable<Xbox360Button>;
  112155. /** Observable raised when a pad is pressed */
  112156. onPadDownObservable: Observable<Xbox360Dpad>;
  112157. /** Observable raised when a pad is released */
  112158. onPadUpObservable: Observable<Xbox360Dpad>;
  112159. private _buttonA;
  112160. private _buttonB;
  112161. private _buttonX;
  112162. private _buttonY;
  112163. private _buttonBack;
  112164. private _buttonStart;
  112165. private _buttonLB;
  112166. private _buttonRB;
  112167. private _buttonLeftStick;
  112168. private _buttonRightStick;
  112169. private _dPadUp;
  112170. private _dPadDown;
  112171. private _dPadLeft;
  112172. private _dPadRight;
  112173. private _isXboxOnePad;
  112174. /**
  112175. * Creates a new XBox360 gamepad object
  112176. * @param id defines the id of this gamepad
  112177. * @param index defines its index
  112178. * @param gamepad defines the internal HTML gamepad object
  112179. * @param xboxOne defines if it is a XBox One gamepad
  112180. */
  112181. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  112182. /**
  112183. * Defines the callback to call when left trigger is pressed
  112184. * @param callback defines the callback to use
  112185. */
  112186. onlefttriggerchanged(callback: (value: number) => void): void;
  112187. /**
  112188. * Defines the callback to call when right trigger is pressed
  112189. * @param callback defines the callback to use
  112190. */
  112191. onrighttriggerchanged(callback: (value: number) => void): void;
  112192. /**
  112193. * Gets the left trigger value
  112194. */
  112195. get leftTrigger(): number;
  112196. /**
  112197. * Sets the left trigger value
  112198. */
  112199. set leftTrigger(newValue: number);
  112200. /**
  112201. * Gets the right trigger value
  112202. */
  112203. get rightTrigger(): number;
  112204. /**
  112205. * Sets the right trigger value
  112206. */
  112207. set rightTrigger(newValue: number);
  112208. /**
  112209. * Defines the callback to call when a button is pressed
  112210. * @param callback defines the callback to use
  112211. */
  112212. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  112213. /**
  112214. * Defines the callback to call when a button is released
  112215. * @param callback defines the callback to use
  112216. */
  112217. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  112218. /**
  112219. * Defines the callback to call when a pad is pressed
  112220. * @param callback defines the callback to use
  112221. */
  112222. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  112223. /**
  112224. * Defines the callback to call when a pad is released
  112225. * @param callback defines the callback to use
  112226. */
  112227. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  112228. private _setButtonValue;
  112229. private _setDPadValue;
  112230. /**
  112231. * Gets the value of the `A` button
  112232. */
  112233. get buttonA(): number;
  112234. /**
  112235. * Sets the value of the `A` button
  112236. */
  112237. set buttonA(value: number);
  112238. /**
  112239. * Gets the value of the `B` button
  112240. */
  112241. get buttonB(): number;
  112242. /**
  112243. * Sets the value of the `B` button
  112244. */
  112245. set buttonB(value: number);
  112246. /**
  112247. * Gets the value of the `X` button
  112248. */
  112249. get buttonX(): number;
  112250. /**
  112251. * Sets the value of the `X` button
  112252. */
  112253. set buttonX(value: number);
  112254. /**
  112255. * Gets the value of the `Y` button
  112256. */
  112257. get buttonY(): number;
  112258. /**
  112259. * Sets the value of the `Y` button
  112260. */
  112261. set buttonY(value: number);
  112262. /**
  112263. * Gets the value of the `Start` button
  112264. */
  112265. get buttonStart(): number;
  112266. /**
  112267. * Sets the value of the `Start` button
  112268. */
  112269. set buttonStart(value: number);
  112270. /**
  112271. * Gets the value of the `Back` button
  112272. */
  112273. get buttonBack(): number;
  112274. /**
  112275. * Sets the value of the `Back` button
  112276. */
  112277. set buttonBack(value: number);
  112278. /**
  112279. * Gets the value of the `Left` button
  112280. */
  112281. get buttonLB(): number;
  112282. /**
  112283. * Sets the value of the `Left` button
  112284. */
  112285. set buttonLB(value: number);
  112286. /**
  112287. * Gets the value of the `Right` button
  112288. */
  112289. get buttonRB(): number;
  112290. /**
  112291. * Sets the value of the `Right` button
  112292. */
  112293. set buttonRB(value: number);
  112294. /**
  112295. * Gets the value of the Left joystick
  112296. */
  112297. get buttonLeftStick(): number;
  112298. /**
  112299. * Sets the value of the Left joystick
  112300. */
  112301. set buttonLeftStick(value: number);
  112302. /**
  112303. * Gets the value of the Right joystick
  112304. */
  112305. get buttonRightStick(): number;
  112306. /**
  112307. * Sets the value of the Right joystick
  112308. */
  112309. set buttonRightStick(value: number);
  112310. /**
  112311. * Gets the value of D-pad up
  112312. */
  112313. get dPadUp(): number;
  112314. /**
  112315. * Sets the value of D-pad up
  112316. */
  112317. set dPadUp(value: number);
  112318. /**
  112319. * Gets the value of D-pad down
  112320. */
  112321. get dPadDown(): number;
  112322. /**
  112323. * Sets the value of D-pad down
  112324. */
  112325. set dPadDown(value: number);
  112326. /**
  112327. * Gets the value of D-pad left
  112328. */
  112329. get dPadLeft(): number;
  112330. /**
  112331. * Sets the value of D-pad left
  112332. */
  112333. set dPadLeft(value: number);
  112334. /**
  112335. * Gets the value of D-pad right
  112336. */
  112337. get dPadRight(): number;
  112338. /**
  112339. * Sets the value of D-pad right
  112340. */
  112341. set dPadRight(value: number);
  112342. /**
  112343. * Force the gamepad to synchronize with device values
  112344. */
  112345. update(): void;
  112346. /**
  112347. * Disposes the gamepad
  112348. */
  112349. dispose(): void;
  112350. }
  112351. }
  112352. declare module BABYLON {
  112353. /**
  112354. * Defines supported buttons for DualShock compatible gamepads
  112355. */
  112356. export enum DualShockButton {
  112357. /** Cross */
  112358. Cross = 0,
  112359. /** Circle */
  112360. Circle = 1,
  112361. /** Square */
  112362. Square = 2,
  112363. /** Triangle */
  112364. Triangle = 3,
  112365. /** Options */
  112366. Options = 4,
  112367. /** Share */
  112368. Share = 5,
  112369. /** L1 */
  112370. L1 = 6,
  112371. /** R1 */
  112372. R1 = 7,
  112373. /** Left stick */
  112374. LeftStick = 8,
  112375. /** Right stick */
  112376. RightStick = 9
  112377. }
  112378. /** Defines values for DualShock DPad */
  112379. export enum DualShockDpad {
  112380. /** Up */
  112381. Up = 0,
  112382. /** Down */
  112383. Down = 1,
  112384. /** Left */
  112385. Left = 2,
  112386. /** Right */
  112387. Right = 3
  112388. }
  112389. /**
  112390. * Defines a DualShock gamepad
  112391. */
  112392. export class DualShockPad extends Gamepad {
  112393. private _leftTrigger;
  112394. private _rightTrigger;
  112395. private _onlefttriggerchanged;
  112396. private _onrighttriggerchanged;
  112397. private _onbuttondown;
  112398. private _onbuttonup;
  112399. private _ondpaddown;
  112400. private _ondpadup;
  112401. /** Observable raised when a button is pressed */
  112402. onButtonDownObservable: Observable<DualShockButton>;
  112403. /** Observable raised when a button is released */
  112404. onButtonUpObservable: Observable<DualShockButton>;
  112405. /** Observable raised when a pad is pressed */
  112406. onPadDownObservable: Observable<DualShockDpad>;
  112407. /** Observable raised when a pad is released */
  112408. onPadUpObservable: Observable<DualShockDpad>;
  112409. private _buttonCross;
  112410. private _buttonCircle;
  112411. private _buttonSquare;
  112412. private _buttonTriangle;
  112413. private _buttonShare;
  112414. private _buttonOptions;
  112415. private _buttonL1;
  112416. private _buttonR1;
  112417. private _buttonLeftStick;
  112418. private _buttonRightStick;
  112419. private _dPadUp;
  112420. private _dPadDown;
  112421. private _dPadLeft;
  112422. private _dPadRight;
  112423. /**
  112424. * Creates a new DualShock gamepad object
  112425. * @param id defines the id of this gamepad
  112426. * @param index defines its index
  112427. * @param gamepad defines the internal HTML gamepad object
  112428. */
  112429. constructor(id: string, index: number, gamepad: any);
  112430. /**
  112431. * Defines the callback to call when left trigger is pressed
  112432. * @param callback defines the callback to use
  112433. */
  112434. onlefttriggerchanged(callback: (value: number) => void): void;
  112435. /**
  112436. * Defines the callback to call when right trigger is pressed
  112437. * @param callback defines the callback to use
  112438. */
  112439. onrighttriggerchanged(callback: (value: number) => void): void;
  112440. /**
  112441. * Gets the left trigger value
  112442. */
  112443. get leftTrigger(): number;
  112444. /**
  112445. * Sets the left trigger value
  112446. */
  112447. set leftTrigger(newValue: number);
  112448. /**
  112449. * Gets the right trigger value
  112450. */
  112451. get rightTrigger(): number;
  112452. /**
  112453. * Sets the right trigger value
  112454. */
  112455. set rightTrigger(newValue: number);
  112456. /**
  112457. * Defines the callback to call when a button is pressed
  112458. * @param callback defines the callback to use
  112459. */
  112460. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  112461. /**
  112462. * Defines the callback to call when a button is released
  112463. * @param callback defines the callback to use
  112464. */
  112465. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  112466. /**
  112467. * Defines the callback to call when a pad is pressed
  112468. * @param callback defines the callback to use
  112469. */
  112470. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  112471. /**
  112472. * Defines the callback to call when a pad is released
  112473. * @param callback defines the callback to use
  112474. */
  112475. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  112476. private _setButtonValue;
  112477. private _setDPadValue;
  112478. /**
  112479. * Gets the value of the `Cross` button
  112480. */
  112481. get buttonCross(): number;
  112482. /**
  112483. * Sets the value of the `Cross` button
  112484. */
  112485. set buttonCross(value: number);
  112486. /**
  112487. * Gets the value of the `Circle` button
  112488. */
  112489. get buttonCircle(): number;
  112490. /**
  112491. * Sets the value of the `Circle` button
  112492. */
  112493. set buttonCircle(value: number);
  112494. /**
  112495. * Gets the value of the `Square` button
  112496. */
  112497. get buttonSquare(): number;
  112498. /**
  112499. * Sets the value of the `Square` button
  112500. */
  112501. set buttonSquare(value: number);
  112502. /**
  112503. * Gets the value of the `Triangle` button
  112504. */
  112505. get buttonTriangle(): number;
  112506. /**
  112507. * Sets the value of the `Triangle` button
  112508. */
  112509. set buttonTriangle(value: number);
  112510. /**
  112511. * Gets the value of the `Options` button
  112512. */
  112513. get buttonOptions(): number;
  112514. /**
  112515. * Sets the value of the `Options` button
  112516. */
  112517. set buttonOptions(value: number);
  112518. /**
  112519. * Gets the value of the `Share` button
  112520. */
  112521. get buttonShare(): number;
  112522. /**
  112523. * Sets the value of the `Share` button
  112524. */
  112525. set buttonShare(value: number);
  112526. /**
  112527. * Gets the value of the `L1` button
  112528. */
  112529. get buttonL1(): number;
  112530. /**
  112531. * Sets the value of the `L1` button
  112532. */
  112533. set buttonL1(value: number);
  112534. /**
  112535. * Gets the value of the `R1` button
  112536. */
  112537. get buttonR1(): number;
  112538. /**
  112539. * Sets the value of the `R1` button
  112540. */
  112541. set buttonR1(value: number);
  112542. /**
  112543. * Gets the value of the Left joystick
  112544. */
  112545. get buttonLeftStick(): number;
  112546. /**
  112547. * Sets the value of the Left joystick
  112548. */
  112549. set buttonLeftStick(value: number);
  112550. /**
  112551. * Gets the value of the Right joystick
  112552. */
  112553. get buttonRightStick(): number;
  112554. /**
  112555. * Sets the value of the Right joystick
  112556. */
  112557. set buttonRightStick(value: number);
  112558. /**
  112559. * Gets the value of D-pad up
  112560. */
  112561. get dPadUp(): number;
  112562. /**
  112563. * Sets the value of D-pad up
  112564. */
  112565. set dPadUp(value: number);
  112566. /**
  112567. * Gets the value of D-pad down
  112568. */
  112569. get dPadDown(): number;
  112570. /**
  112571. * Sets the value of D-pad down
  112572. */
  112573. set dPadDown(value: number);
  112574. /**
  112575. * Gets the value of D-pad left
  112576. */
  112577. get dPadLeft(): number;
  112578. /**
  112579. * Sets the value of D-pad left
  112580. */
  112581. set dPadLeft(value: number);
  112582. /**
  112583. * Gets the value of D-pad right
  112584. */
  112585. get dPadRight(): number;
  112586. /**
  112587. * Sets the value of D-pad right
  112588. */
  112589. set dPadRight(value: number);
  112590. /**
  112591. * Force the gamepad to synchronize with device values
  112592. */
  112593. update(): void;
  112594. /**
  112595. * Disposes the gamepad
  112596. */
  112597. dispose(): void;
  112598. }
  112599. }
  112600. declare module BABYLON {
  112601. /**
  112602. * Manager for handling gamepads
  112603. */
  112604. export class GamepadManager {
  112605. private _scene?;
  112606. private _babylonGamepads;
  112607. private _oneGamepadConnected;
  112608. /** @hidden */
  112609. _isMonitoring: boolean;
  112610. private _gamepadEventSupported;
  112611. private _gamepadSupport?;
  112612. /**
  112613. * observable to be triggered when the gamepad controller has been connected
  112614. */
  112615. onGamepadConnectedObservable: Observable<Gamepad>;
  112616. /**
  112617. * observable to be triggered when the gamepad controller has been disconnected
  112618. */
  112619. onGamepadDisconnectedObservable: Observable<Gamepad>;
  112620. private _onGamepadConnectedEvent;
  112621. private _onGamepadDisconnectedEvent;
  112622. /**
  112623. * Initializes the gamepad manager
  112624. * @param _scene BabylonJS scene
  112625. */
  112626. constructor(_scene?: Scene | undefined);
  112627. /**
  112628. * The gamepads in the game pad manager
  112629. */
  112630. get gamepads(): Gamepad[];
  112631. /**
  112632. * Get the gamepad controllers based on type
  112633. * @param type The type of gamepad controller
  112634. * @returns Nullable gamepad
  112635. */
  112636. getGamepadByType(type?: number): Nullable<Gamepad>;
  112637. /**
  112638. * Disposes the gamepad manager
  112639. */
  112640. dispose(): void;
  112641. private _addNewGamepad;
  112642. private _startMonitoringGamepads;
  112643. private _stopMonitoringGamepads;
  112644. /** @hidden */
  112645. _checkGamepadsStatus(): void;
  112646. private _updateGamepadObjects;
  112647. }
  112648. }
  112649. declare module BABYLON {
  112650. interface Scene {
  112651. /** @hidden */
  112652. _gamepadManager: Nullable<GamepadManager>;
  112653. /**
  112654. * Gets the gamepad manager associated with the scene
  112655. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  112656. */
  112657. gamepadManager: GamepadManager;
  112658. }
  112659. /**
  112660. * Interface representing a free camera inputs manager
  112661. */
  112662. interface FreeCameraInputsManager {
  112663. /**
  112664. * Adds gamepad input support to the FreeCameraInputsManager.
  112665. * @returns the FreeCameraInputsManager
  112666. */
  112667. addGamepad(): FreeCameraInputsManager;
  112668. }
  112669. /**
  112670. * Interface representing an arc rotate camera inputs manager
  112671. */
  112672. interface ArcRotateCameraInputsManager {
  112673. /**
  112674. * Adds gamepad input support to the ArcRotateCamera InputManager.
  112675. * @returns the camera inputs manager
  112676. */
  112677. addGamepad(): ArcRotateCameraInputsManager;
  112678. }
  112679. /**
  112680. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  112681. */
  112682. export class GamepadSystemSceneComponent implements ISceneComponent {
  112683. /**
  112684. * The component name helpfull to identify the component in the list of scene components.
  112685. */
  112686. readonly name: string;
  112687. /**
  112688. * The scene the component belongs to.
  112689. */
  112690. scene: Scene;
  112691. /**
  112692. * Creates a new instance of the component for the given scene
  112693. * @param scene Defines the scene to register the component in
  112694. */
  112695. constructor(scene: Scene);
  112696. /**
  112697. * Registers the component in a given scene
  112698. */
  112699. register(): void;
  112700. /**
  112701. * Rebuilds the elements related to this component in case of
  112702. * context lost for instance.
  112703. */
  112704. rebuild(): void;
  112705. /**
  112706. * Disposes the component and the associated ressources
  112707. */
  112708. dispose(): void;
  112709. private _beforeCameraUpdate;
  112710. }
  112711. }
  112712. declare module BABYLON {
  112713. /**
  112714. * 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,
  112715. * which still works and will still be found in many Playgrounds.
  112716. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112717. */
  112718. export class UniversalCamera extends TouchCamera {
  112719. /**
  112720. * Defines the gamepad rotation sensiblity.
  112721. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112722. */
  112723. get gamepadAngularSensibility(): number;
  112724. set gamepadAngularSensibility(value: number);
  112725. /**
  112726. * Defines the gamepad move sensiblity.
  112727. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112728. */
  112729. get gamepadMoveSensibility(): number;
  112730. set gamepadMoveSensibility(value: number);
  112731. /**
  112732. * 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,
  112733. * which still works and will still be found in many Playgrounds.
  112734. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112735. * @param name Define the name of the camera in the scene
  112736. * @param position Define the start position of the camera in the scene
  112737. * @param scene Define the scene the camera belongs to
  112738. */
  112739. constructor(name: string, position: Vector3, scene: Scene);
  112740. /**
  112741. * Gets the current object class name.
  112742. * @return the class name
  112743. */
  112744. getClassName(): string;
  112745. }
  112746. }
  112747. declare module BABYLON {
  112748. /**
  112749. * This represents a FPS type of camera. This is only here for back compat purpose.
  112750. * Please use the UniversalCamera instead as both are identical.
  112751. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112752. */
  112753. export class GamepadCamera extends UniversalCamera {
  112754. /**
  112755. * Instantiates a new Gamepad Camera
  112756. * This represents a FPS type of camera. This is only here for back compat purpose.
  112757. * Please use the UniversalCamera instead as both are identical.
  112758. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  112759. * @param name Define the name of the camera in the scene
  112760. * @param position Define the start position of the camera in the scene
  112761. * @param scene Define the scene the camera belongs to
  112762. */
  112763. constructor(name: string, position: Vector3, scene: Scene);
  112764. /**
  112765. * Gets the current object class name.
  112766. * @return the class name
  112767. */
  112768. getClassName(): string;
  112769. }
  112770. }
  112771. declare module BABYLON {
  112772. /** @hidden */
  112773. export var passPixelShader: {
  112774. name: string;
  112775. shader: string;
  112776. };
  112777. }
  112778. declare module BABYLON {
  112779. /** @hidden */
  112780. export var passCubePixelShader: {
  112781. name: string;
  112782. shader: string;
  112783. };
  112784. }
  112785. declare module BABYLON {
  112786. /**
  112787. * PassPostProcess which produces an output the same as it's input
  112788. */
  112789. export class PassPostProcess extends PostProcess {
  112790. /**
  112791. * Creates the PassPostProcess
  112792. * @param name The name of the effect.
  112793. * @param options The required width/height ratio to downsize to before computing the render pass.
  112794. * @param camera The camera to apply the render pass to.
  112795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112796. * @param engine The engine which the post process will be applied. (default: current engine)
  112797. * @param reusable If the post process can be reused on the same frame. (default: false)
  112798. * @param textureType The type of texture to be used when performing the post processing.
  112799. * @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)
  112800. */
  112801. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112802. }
  112803. /**
  112804. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  112805. */
  112806. export class PassCubePostProcess extends PostProcess {
  112807. private _face;
  112808. /**
  112809. * Gets or sets the cube face to display.
  112810. * * 0 is +X
  112811. * * 1 is -X
  112812. * * 2 is +Y
  112813. * * 3 is -Y
  112814. * * 4 is +Z
  112815. * * 5 is -Z
  112816. */
  112817. get face(): number;
  112818. set face(value: number);
  112819. /**
  112820. * Creates the PassCubePostProcess
  112821. * @param name The name of the effect.
  112822. * @param options The required width/height ratio to downsize to before computing the render pass.
  112823. * @param camera The camera to apply the render pass to.
  112824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112825. * @param engine The engine which the post process will be applied. (default: current engine)
  112826. * @param reusable If the post process can be reused on the same frame. (default: false)
  112827. * @param textureType The type of texture to be used when performing the post processing.
  112828. * @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)
  112829. */
  112830. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112831. }
  112832. }
  112833. declare module BABYLON {
  112834. /** @hidden */
  112835. export var anaglyphPixelShader: {
  112836. name: string;
  112837. shader: string;
  112838. };
  112839. }
  112840. declare module BABYLON {
  112841. /**
  112842. * Postprocess used to generate anaglyphic rendering
  112843. */
  112844. export class AnaglyphPostProcess extends PostProcess {
  112845. private _passedProcess;
  112846. /**
  112847. * Creates a new AnaglyphPostProcess
  112848. * @param name defines postprocess name
  112849. * @param options defines creation options or target ratio scale
  112850. * @param rigCameras defines cameras using this postprocess
  112851. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  112852. * @param engine defines hosting engine
  112853. * @param reusable defines if the postprocess will be reused multiple times per frame
  112854. */
  112855. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  112856. }
  112857. }
  112858. declare module BABYLON {
  112859. /**
  112860. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  112861. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112862. */
  112863. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  112864. /**
  112865. * Creates a new AnaglyphArcRotateCamera
  112866. * @param name defines camera name
  112867. * @param alpha defines alpha angle (in radians)
  112868. * @param beta defines beta angle (in radians)
  112869. * @param radius defines radius
  112870. * @param target defines camera target
  112871. * @param interaxialDistance defines distance between each color axis
  112872. * @param scene defines the hosting scene
  112873. */
  112874. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  112875. /**
  112876. * Gets camera class name
  112877. * @returns AnaglyphArcRotateCamera
  112878. */
  112879. getClassName(): string;
  112880. }
  112881. }
  112882. declare module BABYLON {
  112883. /**
  112884. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  112885. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112886. */
  112887. export class AnaglyphFreeCamera extends FreeCamera {
  112888. /**
  112889. * Creates a new AnaglyphFreeCamera
  112890. * @param name defines camera name
  112891. * @param position defines initial position
  112892. * @param interaxialDistance defines distance between each color axis
  112893. * @param scene defines the hosting scene
  112894. */
  112895. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112896. /**
  112897. * Gets camera class name
  112898. * @returns AnaglyphFreeCamera
  112899. */
  112900. getClassName(): string;
  112901. }
  112902. }
  112903. declare module BABYLON {
  112904. /**
  112905. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  112906. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112907. */
  112908. export class AnaglyphGamepadCamera extends GamepadCamera {
  112909. /**
  112910. * Creates a new AnaglyphGamepadCamera
  112911. * @param name defines camera name
  112912. * @param position defines initial position
  112913. * @param interaxialDistance defines distance between each color axis
  112914. * @param scene defines the hosting scene
  112915. */
  112916. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112917. /**
  112918. * Gets camera class name
  112919. * @returns AnaglyphGamepadCamera
  112920. */
  112921. getClassName(): string;
  112922. }
  112923. }
  112924. declare module BABYLON {
  112925. /**
  112926. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  112927. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  112928. */
  112929. export class AnaglyphUniversalCamera extends UniversalCamera {
  112930. /**
  112931. * Creates a new AnaglyphUniversalCamera
  112932. * @param name defines camera name
  112933. * @param position defines initial position
  112934. * @param interaxialDistance defines distance between each color axis
  112935. * @param scene defines the hosting scene
  112936. */
  112937. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  112938. /**
  112939. * Gets camera class name
  112940. * @returns AnaglyphUniversalCamera
  112941. */
  112942. getClassName(): string;
  112943. }
  112944. }
  112945. declare module BABYLON {
  112946. /** @hidden */
  112947. export var stereoscopicInterlacePixelShader: {
  112948. name: string;
  112949. shader: string;
  112950. };
  112951. }
  112952. declare module BABYLON {
  112953. /**
  112954. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  112955. */
  112956. export class StereoscopicInterlacePostProcess extends PostProcess {
  112957. private _stepSize;
  112958. private _passedProcess;
  112959. /**
  112960. * Initializes a StereoscopicInterlacePostProcess
  112961. * @param name The name of the effect.
  112962. * @param rigCameras The rig cameras to be appled to the post process
  112963. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  112964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112965. * @param engine The engine which the post process will be applied. (default: current engine)
  112966. * @param reusable If the post process can be reused on the same frame. (default: false)
  112967. */
  112968. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112969. }
  112970. }
  112971. declare module BABYLON {
  112972. /**
  112973. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  112974. * @see http://doc.babylonjs.com/features/cameras
  112975. */
  112976. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  112977. /**
  112978. * Creates a new StereoscopicArcRotateCamera
  112979. * @param name defines camera name
  112980. * @param alpha defines alpha angle (in radians)
  112981. * @param beta defines beta angle (in radians)
  112982. * @param radius defines radius
  112983. * @param target defines camera target
  112984. * @param interaxialDistance defines distance between each color axis
  112985. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  112986. * @param scene defines the hosting scene
  112987. */
  112988. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  112989. /**
  112990. * Gets camera class name
  112991. * @returns StereoscopicArcRotateCamera
  112992. */
  112993. getClassName(): string;
  112994. }
  112995. }
  112996. declare module BABYLON {
  112997. /**
  112998. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  112999. * @see http://doc.babylonjs.com/features/cameras
  113000. */
  113001. export class StereoscopicFreeCamera extends FreeCamera {
  113002. /**
  113003. * Creates a new StereoscopicFreeCamera
  113004. * @param name defines camera name
  113005. * @param position defines initial position
  113006. * @param interaxialDistance defines distance between each color axis
  113007. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  113008. * @param scene defines the hosting scene
  113009. */
  113010. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  113011. /**
  113012. * Gets camera class name
  113013. * @returns StereoscopicFreeCamera
  113014. */
  113015. getClassName(): string;
  113016. }
  113017. }
  113018. declare module BABYLON {
  113019. /**
  113020. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  113021. * @see http://doc.babylonjs.com/features/cameras
  113022. */
  113023. export class StereoscopicGamepadCamera extends GamepadCamera {
  113024. /**
  113025. * Creates a new StereoscopicGamepadCamera
  113026. * @param name defines camera name
  113027. * @param position defines initial position
  113028. * @param interaxialDistance defines distance between each color axis
  113029. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  113030. * @param scene defines the hosting scene
  113031. */
  113032. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  113033. /**
  113034. * Gets camera class name
  113035. * @returns StereoscopicGamepadCamera
  113036. */
  113037. getClassName(): string;
  113038. }
  113039. }
  113040. declare module BABYLON {
  113041. /**
  113042. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  113043. * @see http://doc.babylonjs.com/features/cameras
  113044. */
  113045. export class StereoscopicUniversalCamera extends UniversalCamera {
  113046. /**
  113047. * Creates a new StereoscopicUniversalCamera
  113048. * @param name defines camera name
  113049. * @param position defines initial position
  113050. * @param interaxialDistance defines distance between each color axis
  113051. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  113052. * @param scene defines the hosting scene
  113053. */
  113054. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  113055. /**
  113056. * Gets camera class name
  113057. * @returns StereoscopicUniversalCamera
  113058. */
  113059. getClassName(): string;
  113060. }
  113061. }
  113062. declare module BABYLON {
  113063. /**
  113064. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  113065. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  113066. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  113067. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  113068. */
  113069. export class VirtualJoysticksCamera extends FreeCamera {
  113070. /**
  113071. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  113072. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  113073. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  113074. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  113075. * @param name Define the name of the camera in the scene
  113076. * @param position Define the start position of the camera in the scene
  113077. * @param scene Define the scene the camera belongs to
  113078. */
  113079. constructor(name: string, position: Vector3, scene: Scene);
  113080. /**
  113081. * Gets the current object class name.
  113082. * @return the class name
  113083. */
  113084. getClassName(): string;
  113085. }
  113086. }
  113087. declare module BABYLON {
  113088. /**
  113089. * This represents all the required metrics to create a VR camera.
  113090. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  113091. */
  113092. export class VRCameraMetrics {
  113093. /**
  113094. * Define the horizontal resolution off the screen.
  113095. */
  113096. hResolution: number;
  113097. /**
  113098. * Define the vertical resolution off the screen.
  113099. */
  113100. vResolution: number;
  113101. /**
  113102. * Define the horizontal screen size.
  113103. */
  113104. hScreenSize: number;
  113105. /**
  113106. * Define the vertical screen size.
  113107. */
  113108. vScreenSize: number;
  113109. /**
  113110. * Define the vertical screen center position.
  113111. */
  113112. vScreenCenter: number;
  113113. /**
  113114. * Define the distance of the eyes to the screen.
  113115. */
  113116. eyeToScreenDistance: number;
  113117. /**
  113118. * Define the distance between both lenses
  113119. */
  113120. lensSeparationDistance: number;
  113121. /**
  113122. * Define the distance between both viewer's eyes.
  113123. */
  113124. interpupillaryDistance: number;
  113125. /**
  113126. * Define the distortion factor of the VR postprocess.
  113127. * Please, touch with care.
  113128. */
  113129. distortionK: number[];
  113130. /**
  113131. * Define the chromatic aberration correction factors for the VR post process.
  113132. */
  113133. chromaAbCorrection: number[];
  113134. /**
  113135. * Define the scale factor of the post process.
  113136. * The smaller the better but the slower.
  113137. */
  113138. postProcessScaleFactor: number;
  113139. /**
  113140. * Define an offset for the lens center.
  113141. */
  113142. lensCenterOffset: number;
  113143. /**
  113144. * Define if the current vr camera should compensate the distortion of the lense or not.
  113145. */
  113146. compensateDistortion: boolean;
  113147. /**
  113148. * Defines if multiview should be enabled when rendering (Default: false)
  113149. */
  113150. multiviewEnabled: boolean;
  113151. /**
  113152. * Gets the rendering aspect ratio based on the provided resolutions.
  113153. */
  113154. get aspectRatio(): number;
  113155. /**
  113156. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  113157. */
  113158. get aspectRatioFov(): number;
  113159. /**
  113160. * @hidden
  113161. */
  113162. get leftHMatrix(): Matrix;
  113163. /**
  113164. * @hidden
  113165. */
  113166. get rightHMatrix(): Matrix;
  113167. /**
  113168. * @hidden
  113169. */
  113170. get leftPreViewMatrix(): Matrix;
  113171. /**
  113172. * @hidden
  113173. */
  113174. get rightPreViewMatrix(): Matrix;
  113175. /**
  113176. * Get the default VRMetrics based on the most generic setup.
  113177. * @returns the default vr metrics
  113178. */
  113179. static GetDefault(): VRCameraMetrics;
  113180. }
  113181. }
  113182. declare module BABYLON {
  113183. /** @hidden */
  113184. export var vrDistortionCorrectionPixelShader: {
  113185. name: string;
  113186. shader: string;
  113187. };
  113188. }
  113189. declare module BABYLON {
  113190. /**
  113191. * VRDistortionCorrectionPostProcess used for mobile VR
  113192. */
  113193. export class VRDistortionCorrectionPostProcess extends PostProcess {
  113194. private _isRightEye;
  113195. private _distortionFactors;
  113196. private _postProcessScaleFactor;
  113197. private _lensCenterOffset;
  113198. private _scaleIn;
  113199. private _scaleFactor;
  113200. private _lensCenter;
  113201. /**
  113202. * Initializes the VRDistortionCorrectionPostProcess
  113203. * @param name The name of the effect.
  113204. * @param camera The camera to apply the render pass to.
  113205. * @param isRightEye If this is for the right eye distortion
  113206. * @param vrMetrics All the required metrics for the VR camera
  113207. */
  113208. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  113209. }
  113210. }
  113211. declare module BABYLON {
  113212. /**
  113213. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  113214. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  113215. */
  113216. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  113217. /**
  113218. * Creates a new VRDeviceOrientationArcRotateCamera
  113219. * @param name defines camera name
  113220. * @param alpha defines the camera rotation along the logitudinal axis
  113221. * @param beta defines the camera rotation along the latitudinal axis
  113222. * @param radius defines the camera distance from its target
  113223. * @param target defines the camera target
  113224. * @param scene defines the scene the camera belongs to
  113225. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  113226. * @param vrCameraMetrics defines the vr metrics associated to the camera
  113227. */
  113228. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  113229. /**
  113230. * Gets camera class name
  113231. * @returns VRDeviceOrientationArcRotateCamera
  113232. */
  113233. getClassName(): string;
  113234. }
  113235. }
  113236. declare module BABYLON {
  113237. /**
  113238. * Camera used to simulate VR rendering (based on FreeCamera)
  113239. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  113240. */
  113241. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  113242. /**
  113243. * Creates a new VRDeviceOrientationFreeCamera
  113244. * @param name defines camera name
  113245. * @param position defines the start position of the camera
  113246. * @param scene defines the scene the camera belongs to
  113247. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  113248. * @param vrCameraMetrics defines the vr metrics associated to the camera
  113249. */
  113250. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  113251. /**
  113252. * Gets camera class name
  113253. * @returns VRDeviceOrientationFreeCamera
  113254. */
  113255. getClassName(): string;
  113256. }
  113257. }
  113258. declare module BABYLON {
  113259. /**
  113260. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  113261. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  113262. */
  113263. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  113264. /**
  113265. * Creates a new VRDeviceOrientationGamepadCamera
  113266. * @param name defines camera name
  113267. * @param position defines the start position of the camera
  113268. * @param scene defines the scene the camera belongs to
  113269. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  113270. * @param vrCameraMetrics defines the vr metrics associated to the camera
  113271. */
  113272. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  113273. /**
  113274. * Gets camera class name
  113275. * @returns VRDeviceOrientationGamepadCamera
  113276. */
  113277. getClassName(): string;
  113278. }
  113279. }
  113280. declare module BABYLON {
  113281. /** @hidden */
  113282. export var imageProcessingPixelShader: {
  113283. name: string;
  113284. shader: string;
  113285. };
  113286. }
  113287. declare module BABYLON {
  113288. /**
  113289. * ImageProcessingPostProcess
  113290. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  113291. */
  113292. export class ImageProcessingPostProcess extends PostProcess {
  113293. /**
  113294. * Default configuration related to image processing available in the PBR Material.
  113295. */
  113296. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113297. /**
  113298. * Gets the image processing configuration used either in this material.
  113299. */
  113300. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  113301. /**
  113302. * Sets the Default image processing configuration used either in the this material.
  113303. *
  113304. * If sets to null, the scene one is in use.
  113305. */
  113306. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  113307. /**
  113308. * Keep track of the image processing observer to allow dispose and replace.
  113309. */
  113310. private _imageProcessingObserver;
  113311. /**
  113312. * Attaches a new image processing configuration to the PBR Material.
  113313. * @param configuration
  113314. */
  113315. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  113316. /**
  113317. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  113318. */
  113319. get colorCurves(): Nullable<ColorCurves>;
  113320. /**
  113321. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  113322. */
  113323. set colorCurves(value: Nullable<ColorCurves>);
  113324. /**
  113325. * Gets wether the color curves effect is enabled.
  113326. */
  113327. get colorCurvesEnabled(): boolean;
  113328. /**
  113329. * Sets wether the color curves effect is enabled.
  113330. */
  113331. set colorCurvesEnabled(value: boolean);
  113332. /**
  113333. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  113334. */
  113335. get colorGradingTexture(): Nullable<BaseTexture>;
  113336. /**
  113337. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  113338. */
  113339. set colorGradingTexture(value: Nullable<BaseTexture>);
  113340. /**
  113341. * Gets wether the color grading effect is enabled.
  113342. */
  113343. get colorGradingEnabled(): boolean;
  113344. /**
  113345. * Gets wether the color grading effect is enabled.
  113346. */
  113347. set colorGradingEnabled(value: boolean);
  113348. /**
  113349. * Gets exposure used in the effect.
  113350. */
  113351. get exposure(): number;
  113352. /**
  113353. * Sets exposure used in the effect.
  113354. */
  113355. set exposure(value: number);
  113356. /**
  113357. * Gets wether tonemapping is enabled or not.
  113358. */
  113359. get toneMappingEnabled(): boolean;
  113360. /**
  113361. * Sets wether tonemapping is enabled or not
  113362. */
  113363. set toneMappingEnabled(value: boolean);
  113364. /**
  113365. * Gets the type of tone mapping effect.
  113366. */
  113367. get toneMappingType(): number;
  113368. /**
  113369. * Sets the type of tone mapping effect.
  113370. */
  113371. set toneMappingType(value: number);
  113372. /**
  113373. * Gets contrast used in the effect.
  113374. */
  113375. get contrast(): number;
  113376. /**
  113377. * Sets contrast used in the effect.
  113378. */
  113379. set contrast(value: number);
  113380. /**
  113381. * Gets Vignette stretch size.
  113382. */
  113383. get vignetteStretch(): number;
  113384. /**
  113385. * Sets Vignette stretch size.
  113386. */
  113387. set vignetteStretch(value: number);
  113388. /**
  113389. * Gets Vignette centre X Offset.
  113390. */
  113391. get vignetteCentreX(): number;
  113392. /**
  113393. * Sets Vignette centre X Offset.
  113394. */
  113395. set vignetteCentreX(value: number);
  113396. /**
  113397. * Gets Vignette centre Y Offset.
  113398. */
  113399. get vignetteCentreY(): number;
  113400. /**
  113401. * Sets Vignette centre Y Offset.
  113402. */
  113403. set vignetteCentreY(value: number);
  113404. /**
  113405. * Gets Vignette weight or intensity of the vignette effect.
  113406. */
  113407. get vignetteWeight(): number;
  113408. /**
  113409. * Sets Vignette weight or intensity of the vignette effect.
  113410. */
  113411. set vignetteWeight(value: number);
  113412. /**
  113413. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  113414. * if vignetteEnabled is set to true.
  113415. */
  113416. get vignetteColor(): Color4;
  113417. /**
  113418. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  113419. * if vignetteEnabled is set to true.
  113420. */
  113421. set vignetteColor(value: Color4);
  113422. /**
  113423. * Gets Camera field of view used by the Vignette effect.
  113424. */
  113425. get vignetteCameraFov(): number;
  113426. /**
  113427. * Sets Camera field of view used by the Vignette effect.
  113428. */
  113429. set vignetteCameraFov(value: number);
  113430. /**
  113431. * Gets the vignette blend mode allowing different kind of effect.
  113432. */
  113433. get vignetteBlendMode(): number;
  113434. /**
  113435. * Sets the vignette blend mode allowing different kind of effect.
  113436. */
  113437. set vignetteBlendMode(value: number);
  113438. /**
  113439. * Gets wether the vignette effect is enabled.
  113440. */
  113441. get vignetteEnabled(): boolean;
  113442. /**
  113443. * Sets wether the vignette effect is enabled.
  113444. */
  113445. set vignetteEnabled(value: boolean);
  113446. private _fromLinearSpace;
  113447. /**
  113448. * Gets wether the input of the processing is in Gamma or Linear Space.
  113449. */
  113450. get fromLinearSpace(): boolean;
  113451. /**
  113452. * Sets wether the input of the processing is in Gamma or Linear Space.
  113453. */
  113454. set fromLinearSpace(value: boolean);
  113455. /**
  113456. * Defines cache preventing GC.
  113457. */
  113458. private _defines;
  113459. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  113460. /**
  113461. * "ImageProcessingPostProcess"
  113462. * @returns "ImageProcessingPostProcess"
  113463. */
  113464. getClassName(): string;
  113465. protected _updateParameters(): void;
  113466. dispose(camera?: Camera): void;
  113467. }
  113468. }
  113469. declare module BABYLON {
  113470. /**
  113471. * Class containing static functions to help procedurally build meshes
  113472. */
  113473. export class GroundBuilder {
  113474. /**
  113475. * Creates a ground mesh
  113476. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  113477. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  113478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113479. * @param name defines the name of the mesh
  113480. * @param options defines the options used to create the mesh
  113481. * @param scene defines the hosting scene
  113482. * @returns the ground mesh
  113483. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  113484. */
  113485. static CreateGround(name: string, options: {
  113486. width?: number;
  113487. height?: number;
  113488. subdivisions?: number;
  113489. subdivisionsX?: number;
  113490. subdivisionsY?: number;
  113491. updatable?: boolean;
  113492. }, scene: any): Mesh;
  113493. /**
  113494. * Creates a tiled ground mesh
  113495. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  113496. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  113497. * * 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
  113498. * * 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
  113499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113500. * @param name defines the name of the mesh
  113501. * @param options defines the options used to create the mesh
  113502. * @param scene defines the hosting scene
  113503. * @returns the tiled ground mesh
  113504. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  113505. */
  113506. static CreateTiledGround(name: string, options: {
  113507. xmin: number;
  113508. zmin: number;
  113509. xmax: number;
  113510. zmax: number;
  113511. subdivisions?: {
  113512. w: number;
  113513. h: number;
  113514. };
  113515. precision?: {
  113516. w: number;
  113517. h: number;
  113518. };
  113519. updatable?: boolean;
  113520. }, scene?: Nullable<Scene>): Mesh;
  113521. /**
  113522. * Creates a ground mesh from a height map
  113523. * * The parameter `url` sets the URL of the height map image resource.
  113524. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  113525. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  113526. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  113527. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  113528. * * 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.
  113529. * * 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).
  113530. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  113531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113532. * @param name defines the name of the mesh
  113533. * @param url defines the url to the height map
  113534. * @param options defines the options used to create the mesh
  113535. * @param scene defines the hosting scene
  113536. * @returns the ground mesh
  113537. * @see https://doc.babylonjs.com/babylon101/height_map
  113538. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  113539. */
  113540. static CreateGroundFromHeightMap(name: string, url: string, options: {
  113541. width?: number;
  113542. height?: number;
  113543. subdivisions?: number;
  113544. minHeight?: number;
  113545. maxHeight?: number;
  113546. colorFilter?: Color3;
  113547. alphaFilter?: number;
  113548. updatable?: boolean;
  113549. onReady?: (mesh: GroundMesh) => void;
  113550. }, scene?: Nullable<Scene>): GroundMesh;
  113551. }
  113552. }
  113553. declare module BABYLON {
  113554. /**
  113555. * Class containing static functions to help procedurally build meshes
  113556. */
  113557. export class TorusBuilder {
  113558. /**
  113559. * Creates a torus mesh
  113560. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  113561. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  113562. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  113563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113566. * @param name defines the name of the mesh
  113567. * @param options defines the options used to create the mesh
  113568. * @param scene defines the hosting scene
  113569. * @returns the torus mesh
  113570. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  113571. */
  113572. static CreateTorus(name: string, options: {
  113573. diameter?: number;
  113574. thickness?: number;
  113575. tessellation?: number;
  113576. updatable?: boolean;
  113577. sideOrientation?: number;
  113578. frontUVs?: Vector4;
  113579. backUVs?: Vector4;
  113580. }, scene: any): Mesh;
  113581. }
  113582. }
  113583. declare module BABYLON {
  113584. /**
  113585. * Class containing static functions to help procedurally build meshes
  113586. */
  113587. export class CylinderBuilder {
  113588. /**
  113589. * Creates a cylinder or a cone mesh
  113590. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  113591. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  113592. * * 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.
  113593. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  113594. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  113595. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  113596. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  113597. * * 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).
  113598. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  113599. * * 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).
  113600. * * 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
  113601. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  113602. * * 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
  113603. * * 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.
  113604. * * If `enclose` is false, a ring surface is one element.
  113605. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  113606. * * 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
  113607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113610. * @param name defines the name of the mesh
  113611. * @param options defines the options used to create the mesh
  113612. * @param scene defines the hosting scene
  113613. * @returns the cylinder mesh
  113614. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  113615. */
  113616. static CreateCylinder(name: string, options: {
  113617. height?: number;
  113618. diameterTop?: number;
  113619. diameterBottom?: number;
  113620. diameter?: number;
  113621. tessellation?: number;
  113622. subdivisions?: number;
  113623. arc?: number;
  113624. faceColors?: Color4[];
  113625. faceUV?: Vector4[];
  113626. updatable?: boolean;
  113627. hasRings?: boolean;
  113628. enclose?: boolean;
  113629. cap?: number;
  113630. sideOrientation?: number;
  113631. frontUVs?: Vector4;
  113632. backUVs?: Vector4;
  113633. }, scene: any): Mesh;
  113634. }
  113635. }
  113636. declare module BABYLON {
  113637. /**
  113638. * States of the webXR experience
  113639. */
  113640. export enum WebXRState {
  113641. /**
  113642. * Transitioning to being in XR mode
  113643. */
  113644. ENTERING_XR = 0,
  113645. /**
  113646. * Transitioning to non XR mode
  113647. */
  113648. EXITING_XR = 1,
  113649. /**
  113650. * In XR mode and presenting
  113651. */
  113652. IN_XR = 2,
  113653. /**
  113654. * Not entered XR mode
  113655. */
  113656. NOT_IN_XR = 3
  113657. }
  113658. /**
  113659. * Abstraction of the XR render target
  113660. */
  113661. export interface WebXRRenderTarget extends IDisposable {
  113662. /**
  113663. * xrpresent context of the canvas which can be used to display/mirror xr content
  113664. */
  113665. canvasContext: WebGLRenderingContext;
  113666. /**
  113667. * xr layer for the canvas
  113668. */
  113669. xrLayer: Nullable<XRWebGLLayer>;
  113670. /**
  113671. * Initializes the xr layer for the session
  113672. * @param xrSession xr session
  113673. * @returns a promise that will resolve once the XR Layer has been created
  113674. */
  113675. initializeXRLayerAsync(xrSession: XRSession): Promise<void>;
  113676. }
  113677. }
  113678. declare module BABYLON {
  113679. /**
  113680. * COnfiguration object for WebXR output canvas
  113681. */
  113682. export class WebXRManagedOutputCanvasOptions {
  113683. /**
  113684. * Options for this XR Layer output
  113685. */
  113686. canvasOptions: XRWebGLLayerOptions;
  113687. /**
  113688. * CSS styling for a newly created canvas (if not provided)
  113689. */
  113690. newCanvasCssStyle?: string;
  113691. /**
  113692. * Get the default values of the configuration object
  113693. * @returns default values of this configuration object
  113694. */
  113695. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  113696. }
  113697. /**
  113698. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  113699. */
  113700. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  113701. private configuration;
  113702. private _engine;
  113703. private _canvas;
  113704. /**
  113705. * xrpresent context of the canvas which can be used to display/mirror xr content
  113706. */
  113707. canvasContext: WebGLRenderingContext;
  113708. /**
  113709. * xr layer for the canvas
  113710. */
  113711. xrLayer: Nullable<XRWebGLLayer>;
  113712. /**
  113713. * Initializes the xr layer for the session
  113714. * @param xrSession xr session
  113715. * @returns a promise that will resolve once the XR Layer has been created
  113716. */
  113717. initializeXRLayerAsync(xrSession: any): any;
  113718. /**
  113719. * Initializes the canvas to be added/removed upon entering/exiting xr
  113720. * @param engine the Babylon engine
  113721. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  113722. * @param onStateChangedObservable the mechanism by which the canvas will be added/removed based on XR state
  113723. * @param configuration optional configuration for this canvas output. defaults will be used if not provided
  113724. */
  113725. constructor(engine: ThinEngine, canvas?: HTMLCanvasElement, onStateChangedObservable?: Observable<WebXRState>, configuration?: WebXRManagedOutputCanvasOptions);
  113726. /**
  113727. * Disposes of the object
  113728. */
  113729. dispose(): void;
  113730. private _setManagedOutputCanvas;
  113731. private _addCanvas;
  113732. private _removeCanvas;
  113733. }
  113734. }
  113735. declare module BABYLON {
  113736. /**
  113737. * Manages an XRSession to work with Babylon's engine
  113738. * @see https://doc.babylonjs.com/how_to/webxr
  113739. */
  113740. export class WebXRSessionManager implements IDisposable {
  113741. /** The scene which the session should be created for */
  113742. scene: Scene;
  113743. /**
  113744. * Fires every time a new xrFrame arrives which can be used to update the camera
  113745. */
  113746. onXRFrameObservable: Observable<XRFrame>;
  113747. /**
  113748. * Fires when the xr session is ended either by the device or manually done
  113749. */
  113750. onXRSessionEnded: Observable<any>;
  113751. /**
  113752. * Fires when the xr session is ended either by the device or manually done
  113753. */
  113754. onXRSessionInit: Observable<XRSession>;
  113755. /**
  113756. * Underlying xr session
  113757. */
  113758. session: XRSession;
  113759. /**
  113760. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  113761. * or get the offset the player is currently at.
  113762. */
  113763. viewerReferenceSpace: XRReferenceSpace;
  113764. /**
  113765. * The current reference space used in this session. This reference space can constantly change!
  113766. * It is mainly used to offset the camera's position.
  113767. */
  113768. referenceSpace: XRReferenceSpace;
  113769. /**
  113770. * The base reference space from which the session started. good if you want to reset your
  113771. * reference space
  113772. */
  113773. baseReferenceSpace: XRReferenceSpace;
  113774. /**
  113775. * Used just in case of a failure to initialize an immersive session.
  113776. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  113777. */
  113778. defaultHeightCompensation: number;
  113779. /**
  113780. * Current XR frame
  113781. */
  113782. currentFrame: Nullable<XRFrame>;
  113783. /** WebXR timestamp updated every frame */
  113784. currentTimestamp: number;
  113785. private _xrNavigator;
  113786. private baseLayer;
  113787. private _rttProvider;
  113788. private _sessionEnded;
  113789. /**
  113790. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  113791. * @param scene The scene which the session should be created for
  113792. */
  113793. constructor(
  113794. /** The scene which the session should be created for */
  113795. scene: Scene);
  113796. /**
  113797. * Initializes the manager
  113798. * After initialization enterXR can be called to start an XR session
  113799. * @returns Promise which resolves after it is initialized
  113800. */
  113801. initializeAsync(): Promise<void>;
  113802. /**
  113803. * Initializes an xr session
  113804. * @param xrSessionMode mode to initialize
  113805. * @param optionalFeatures defines optional values to pass to the session builder
  113806. * @returns a promise which will resolve once the session has been initialized
  113807. */
  113808. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  113809. /**
  113810. * Sets the reference space on the xr session
  113811. * @param referenceSpace space to set
  113812. * @returns a promise that will resolve once the reference space has been set
  113813. */
  113814. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  113815. /**
  113816. * Updates the render state of the session
  113817. * @param state state to set
  113818. * @returns a promise that resolves once the render state has been updated
  113819. */
  113820. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  113821. /**
  113822. * Starts rendering to the xr layer
  113823. * @returns a promise that will resolve once rendering has started
  113824. */
  113825. startRenderingToXRAsync(): Promise<void>;
  113826. /**
  113827. * Gets the correct render target texture to be rendered this frame for this eye
  113828. * @param eye the eye for which to get the render target
  113829. * @returns the render target for the specified eye
  113830. */
  113831. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  113832. /**
  113833. * Stops the xrSession and restores the renderloop
  113834. * @returns Promise which resolves after it exits XR
  113835. */
  113836. exitXRAsync(): Promise<void>;
  113837. /**
  113838. * Checks if a session would be supported for the creation options specified
  113839. * @param sessionMode session mode to check if supported eg. immersive-vr
  113840. * @returns true if supported
  113841. */
  113842. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113843. /**
  113844. * Creates a WebXRRenderTarget object for the XR session
  113845. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  113846. * @param options optional options to provide when creating a new render target
  113847. * @returns a WebXR render target to which the session can render
  113848. */
  113849. getWebXRRenderTarget(onStateChangedObservable?: Observable<WebXRState>, options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  113850. /**
  113851. * @hidden
  113852. * Converts the render layer of xrSession to a render target
  113853. * @param session session to create render target for
  113854. * @param scene scene the new render target should be created for
  113855. * @param baseLayer the webgl layer to create the render target for
  113856. */
  113857. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  113858. /**
  113859. * Disposes of the session manager
  113860. */
  113861. dispose(): void;
  113862. /**
  113863. * Gets a promise returning true when fullfiled if the given session mode is supported
  113864. * @param sessionMode defines the session to test
  113865. * @returns a promise
  113866. */
  113867. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  113868. }
  113869. }
  113870. declare module BABYLON {
  113871. /**
  113872. * WebXR Camera which holds the views for the xrSession
  113873. * @see https://doc.babylonjs.com/how_to/webxr
  113874. */
  113875. export class WebXRCamera extends FreeCamera {
  113876. private _xrSessionManager;
  113877. /**
  113878. * Is the camera in debug mode. Used when using an emulator
  113879. */
  113880. debugMode: boolean;
  113881. private _firstFrame;
  113882. private _referencedPosition;
  113883. private _referenceQuaternion;
  113884. private _xrInvPositionCache;
  113885. private _xrInvQuaternionCache;
  113886. /**
  113887. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  113888. * @param name the name of the camera
  113889. * @param scene the scene to add the camera to
  113890. */
  113891. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  113892. private _updateNumberOfRigCameras;
  113893. /** @hidden */
  113894. _updateForDualEyeDebugging(): void;
  113895. private _updateReferenceSpace;
  113896. private _updateReferenceSpaceOffset;
  113897. private _updateFromXRSession;
  113898. }
  113899. }
  113900. declare module BABYLON {
  113901. /**
  113902. * Defining the interface required for a (webxr) feature
  113903. */
  113904. export interface IWebXRFeature extends IDisposable {
  113905. /**
  113906. * Attach the feature to the session
  113907. * Will usually be called by the features manager
  113908. *
  113909. * @returns true if successful.
  113910. */
  113911. attach(): boolean;
  113912. /**
  113913. * Detach the feature from the session
  113914. * Will usually be called by the features manager
  113915. *
  113916. * @returns true if successful.
  113917. */
  113918. detach(): boolean;
  113919. }
  113920. /**
  113921. * Defining the constructor of a feature. Used to register the modules.
  113922. */
  113923. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  113924. /**
  113925. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  113926. * It is mainly used in AR sessions.
  113927. *
  113928. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  113929. */
  113930. export class WebXRFeaturesManager implements IDisposable {
  113931. private _xrSessionManager;
  113932. private static readonly _AvailableFeatures;
  113933. /**
  113934. * Used to register a module. After calling this function a developer can use this feature in the scene.
  113935. * Mainly used internally.
  113936. *
  113937. * @param featureName the name of the feature to register
  113938. * @param constructorFunction the function used to construct the module
  113939. * @param version the (babylon) version of the module
  113940. * @param stable is that a stable version of this module
  113941. */
  113942. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  113943. /**
  113944. * Returns a constructor of a specific feature.
  113945. *
  113946. * @param featureName the name of the feature to construct
  113947. * @param version the version of the feature to load
  113948. * @param xrSessionManager the xrSessionManager. Used to construct the module
  113949. * @param options optional options provided to the module.
  113950. * @returns a function that, when called, will return a new instance of this feature
  113951. */
  113952. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  113953. /**
  113954. * Return the latest unstable version of this feature
  113955. * @param featureName the name of the feature to search
  113956. * @returns the version number. if not found will return -1
  113957. */
  113958. static GetLatestVersionOfFeature(featureName: string): number;
  113959. /**
  113960. * Return the latest stable version of this feature
  113961. * @param featureName the name of the feature to search
  113962. * @returns the version number. if not found will return -1
  113963. */
  113964. static GetStableVersionOfFeature(featureName: string): number;
  113965. /**
  113966. * Can be used to return the list of features currently registered
  113967. *
  113968. * @returns an Array of available features
  113969. */
  113970. static GetAvailableFeatures(): string[];
  113971. /**
  113972. * Gets the versions available for a specific feature
  113973. * @param featureName the name of the feature
  113974. * @returns an array with the available versions
  113975. */
  113976. static GetAvailableVersions(featureName: string): string[];
  113977. private _features;
  113978. /**
  113979. * constructs a new features manages.
  113980. *
  113981. * @param _xrSessionManager an instance of WebXRSessionManager
  113982. */
  113983. constructor(_xrSessionManager: WebXRSessionManager);
  113984. /**
  113985. * 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.
  113986. *
  113987. * @param featureName the name of the feature to load or the class of the feature
  113988. * @param version optional version to load. if not provided the latest version will be enabled
  113989. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  113990. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  113991. * @returns a new constructed feature or throws an error if feature not found.
  113992. */
  113993. enableFeature(featureName: string | {
  113994. Name: string;
  113995. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  113996. /**
  113997. * Used to disable an already-enabled feature
  113998. * @param featureName the feature to disable
  113999. * @returns true if disable was successful
  114000. */
  114001. disableFeature(featureName: string | {
  114002. Name: string;
  114003. }): boolean;
  114004. /**
  114005. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  114006. * Can be used during a session to start a feature
  114007. * @param featureName the name of feature to attach
  114008. */
  114009. attachFeature(featureName: string): void;
  114010. /**
  114011. * Can be used inside a session or when the session ends to detach a specific feature
  114012. * @param featureName the name of the feature to detach
  114013. */
  114014. detachFeature(featureName: string): void;
  114015. /**
  114016. * Get the list of enabled features
  114017. * @returns an array of enabled features
  114018. */
  114019. getEnabledFeatures(): string[];
  114020. /**
  114021. * get the implementation of an enabled feature.
  114022. * @param featureName the name of the feature to load
  114023. * @returns the feature class, if found
  114024. */
  114025. getEnabledFeature(featureName: string): IWebXRFeature;
  114026. /**
  114027. * dispose this features manager
  114028. */
  114029. dispose(): void;
  114030. }
  114031. }
  114032. declare module BABYLON {
  114033. /**
  114034. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  114035. * @see https://doc.babylonjs.com/how_to/webxr
  114036. */
  114037. export class WebXRExperienceHelper implements IDisposable {
  114038. private scene;
  114039. /**
  114040. * Camera used to render xr content
  114041. */
  114042. camera: WebXRCamera;
  114043. /**
  114044. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  114045. */
  114046. state: WebXRState;
  114047. private _setState;
  114048. /**
  114049. * Fires when the state of the experience helper has changed
  114050. */
  114051. onStateChangedObservable: Observable<WebXRState>;
  114052. /**
  114053. * Observers registered here will be triggered after the camera's initial transformation is set
  114054. * This can be used to set a different ground level or an extra rotation.
  114055. *
  114056. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  114057. * to the position set after this observable is done executing.
  114058. */
  114059. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  114060. /** Session manager used to keep track of xr session */
  114061. sessionManager: WebXRSessionManager;
  114062. /** A features manager for this xr session */
  114063. featuresManager: WebXRFeaturesManager;
  114064. private _nonVRCamera;
  114065. private _originalSceneAutoClear;
  114066. private _supported;
  114067. /**
  114068. * Creates the experience helper
  114069. * @param scene the scene to attach the experience helper to
  114070. * @returns a promise for the experience helper
  114071. */
  114072. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  114073. /**
  114074. * Creates a WebXRExperienceHelper
  114075. * @param scene The scene the helper should be created in
  114076. */
  114077. private constructor();
  114078. /**
  114079. * Exits XR mode and returns the scene to its original state
  114080. * @returns promise that resolves after xr mode has exited
  114081. */
  114082. exitXRAsync(): Promise<void>;
  114083. /**
  114084. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  114085. * @param sessionMode options for the XR session
  114086. * @param referenceSpaceType frame of reference of the XR session
  114087. * @param renderTarget the output canvas that will be used to enter XR mode
  114088. * @returns promise that resolves after xr mode has entered
  114089. */
  114090. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  114091. /**
  114092. * Disposes of the experience helper
  114093. */
  114094. dispose(): void;
  114095. private _nonXRToXRCamera;
  114096. }
  114097. }
  114098. declare module BABYLON {
  114099. /**
  114100. * X-Y values for axes in WebXR
  114101. */
  114102. export interface IWebXRMotionControllerAxesValue {
  114103. /**
  114104. * The value of the x axis
  114105. */
  114106. x: number;
  114107. /**
  114108. * The value of the y-axis
  114109. */
  114110. y: number;
  114111. }
  114112. /**
  114113. * changed / previous values for the values of this component
  114114. */
  114115. export interface IWebXRMotionControllerComponentChangesValues<T> {
  114116. /**
  114117. * current (this frame) value
  114118. */
  114119. current: T;
  114120. /**
  114121. * previous (last change) value
  114122. */
  114123. previous: T;
  114124. }
  114125. /**
  114126. * Represents changes in the component between current frame and last values recorded
  114127. */
  114128. export interface IWebXRMotionControllerComponentChanges {
  114129. /**
  114130. * will be populated with previous and current values if touched changed
  114131. */
  114132. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  114133. /**
  114134. * will be populated with previous and current values if pressed changed
  114135. */
  114136. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  114137. /**
  114138. * will be populated with previous and current values if value changed
  114139. */
  114140. value?: IWebXRMotionControllerComponentChangesValues<number>;
  114141. /**
  114142. * will be populated with previous and current values if axes changed
  114143. */
  114144. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  114145. }
  114146. /**
  114147. * This class represents a single component (for example button or thumbstick) of a motion controller
  114148. */
  114149. export class WebXRControllerComponent implements IDisposable {
  114150. /**
  114151. * the id of this component
  114152. */
  114153. id: string;
  114154. /**
  114155. * the type of the component
  114156. */
  114157. type: MotionControllerComponentType;
  114158. private _buttonIndex;
  114159. private _axesIndices;
  114160. /**
  114161. * Observers registered here will be triggered when the state of a button changes
  114162. * State change is either pressed / touched / value
  114163. */
  114164. onButtonStateChanged: Observable<WebXRControllerComponent>;
  114165. /**
  114166. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  114167. * the axes data changes
  114168. */
  114169. onAxisValueChanged: Observable<{
  114170. x: number;
  114171. y: number;
  114172. }>;
  114173. private _currentValue;
  114174. private _touched;
  114175. private _pressed;
  114176. private _axes;
  114177. private _changes;
  114178. /**
  114179. * Creates a new component for a motion controller.
  114180. * It is created by the motion controller itself
  114181. *
  114182. * @param id the id of this component
  114183. * @param type the type of the component
  114184. * @param _buttonIndex index in the buttons array of the gamepad
  114185. * @param _axesIndices indices of the values in the axes array of the gamepad
  114186. */
  114187. constructor(
  114188. /**
  114189. * the id of this component
  114190. */
  114191. id: string,
  114192. /**
  114193. * the type of the component
  114194. */
  114195. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  114196. /**
  114197. * Get the current value of this component
  114198. */
  114199. get value(): number;
  114200. /**
  114201. * is the button currently pressed
  114202. */
  114203. get pressed(): boolean;
  114204. /**
  114205. * is the button currently touched
  114206. */
  114207. get touched(): boolean;
  114208. /**
  114209. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  114210. */
  114211. get axes(): IWebXRMotionControllerAxesValue;
  114212. /**
  114213. * Get the changes. Elements will be populated only if they changed with their previous and current value
  114214. */
  114215. get changes(): IWebXRMotionControllerComponentChanges;
  114216. /**
  114217. * Is this component a button (hence - pressable)
  114218. * @returns true if can be pressed
  114219. */
  114220. isButton(): boolean;
  114221. /**
  114222. * Are there axes correlating to this component
  114223. * @return true is axes data is available
  114224. */
  114225. isAxes(): boolean;
  114226. /**
  114227. * update this component using the gamepad object it is in. Called on every frame
  114228. * @param nativeController the native gamepad controller object
  114229. */
  114230. update(nativeController: IMinimalMotionControllerObject): void;
  114231. /**
  114232. * Dispose this component
  114233. */
  114234. dispose(): void;
  114235. }
  114236. }
  114237. declare module BABYLON {
  114238. /**
  114239. * Class used to represent data loading progression
  114240. */
  114241. export class SceneLoaderProgressEvent {
  114242. /** defines if data length to load can be evaluated */
  114243. readonly lengthComputable: boolean;
  114244. /** defines the loaded data length */
  114245. readonly loaded: number;
  114246. /** defines the data length to load */
  114247. readonly total: number;
  114248. /**
  114249. * Create a new progress event
  114250. * @param lengthComputable defines if data length to load can be evaluated
  114251. * @param loaded defines the loaded data length
  114252. * @param total defines the data length to load
  114253. */
  114254. constructor(
  114255. /** defines if data length to load can be evaluated */
  114256. lengthComputable: boolean,
  114257. /** defines the loaded data length */
  114258. loaded: number,
  114259. /** defines the data length to load */
  114260. total: number);
  114261. /**
  114262. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  114263. * @param event defines the source event
  114264. * @returns a new SceneLoaderProgressEvent
  114265. */
  114266. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  114267. }
  114268. /**
  114269. * Interface used by SceneLoader plugins to define supported file extensions
  114270. */
  114271. export interface ISceneLoaderPluginExtensions {
  114272. /**
  114273. * Defines the list of supported extensions
  114274. */
  114275. [extension: string]: {
  114276. isBinary: boolean;
  114277. };
  114278. }
  114279. /**
  114280. * Interface used by SceneLoader plugin factory
  114281. */
  114282. export interface ISceneLoaderPluginFactory {
  114283. /**
  114284. * Defines the name of the factory
  114285. */
  114286. name: string;
  114287. /**
  114288. * Function called to create a new plugin
  114289. * @return the new plugin
  114290. */
  114291. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  114292. /**
  114293. * The callback that returns true if the data can be directly loaded.
  114294. * @param data string containing the file data
  114295. * @returns if the data can be loaded directly
  114296. */
  114297. canDirectLoad?(data: string): boolean;
  114298. }
  114299. /**
  114300. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  114301. */
  114302. export interface ISceneLoaderPluginBase {
  114303. /**
  114304. * The friendly name of this plugin.
  114305. */
  114306. name: string;
  114307. /**
  114308. * The file extensions supported by this plugin.
  114309. */
  114310. extensions: string | ISceneLoaderPluginExtensions;
  114311. /**
  114312. * The callback called when loading from a url.
  114313. * @param scene scene loading this url
  114314. * @param url url to load
  114315. * @param onSuccess callback called when the file successfully loads
  114316. * @param onProgress callback called while file is loading (if the server supports this mode)
  114317. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  114318. * @param onError callback called when the file fails to load
  114319. * @returns a file request object
  114320. */
  114321. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  114322. /**
  114323. * The callback called when loading from a file object.
  114324. * @param scene scene loading this file
  114325. * @param file defines the file to load
  114326. * @param onSuccess defines the callback to call when data is loaded
  114327. * @param onProgress defines the callback to call during loading process
  114328. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  114329. * @param onError defines the callback to call when an error occurs
  114330. * @returns a file request object
  114331. */
  114332. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  114333. /**
  114334. * The callback that returns true if the data can be directly loaded.
  114335. * @param data string containing the file data
  114336. * @returns if the data can be loaded directly
  114337. */
  114338. canDirectLoad?(data: string): boolean;
  114339. /**
  114340. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  114341. * @param scene scene loading this data
  114342. * @param data string containing the data
  114343. * @returns data to pass to the plugin
  114344. */
  114345. directLoad?(scene: Scene, data: string): any;
  114346. /**
  114347. * The callback that allows custom handling of the root url based on the response url.
  114348. * @param rootUrl the original root url
  114349. * @param responseURL the response url if available
  114350. * @returns the new root url
  114351. */
  114352. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  114353. }
  114354. /**
  114355. * Interface used to define a SceneLoader plugin
  114356. */
  114357. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  114358. /**
  114359. * Import meshes into a scene.
  114360. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  114361. * @param scene The scene to import into
  114362. * @param data The data to import
  114363. * @param rootUrl The root url for scene and resources
  114364. * @param meshes The meshes array to import into
  114365. * @param particleSystems The particle systems array to import into
  114366. * @param skeletons The skeletons array to import into
  114367. * @param onError The callback when import fails
  114368. * @returns True if successful or false otherwise
  114369. */
  114370. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  114371. /**
  114372. * Load into a scene.
  114373. * @param scene The scene to load into
  114374. * @param data The data to import
  114375. * @param rootUrl The root url for scene and resources
  114376. * @param onError The callback when import fails
  114377. * @returns True if successful or false otherwise
  114378. */
  114379. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  114380. /**
  114381. * Load into an asset container.
  114382. * @param scene The scene to load into
  114383. * @param data The data to import
  114384. * @param rootUrl The root url for scene and resources
  114385. * @param onError The callback when import fails
  114386. * @returns The loaded asset container
  114387. */
  114388. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  114389. }
  114390. /**
  114391. * Interface used to define an async SceneLoader plugin
  114392. */
  114393. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  114394. /**
  114395. * Import meshes into a scene.
  114396. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  114397. * @param scene The scene to import into
  114398. * @param data The data to import
  114399. * @param rootUrl The root url for scene and resources
  114400. * @param onProgress The callback when the load progresses
  114401. * @param fileName Defines the name of the file to load
  114402. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  114403. */
  114404. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  114405. meshes: AbstractMesh[];
  114406. particleSystems: IParticleSystem[];
  114407. skeletons: Skeleton[];
  114408. animationGroups: AnimationGroup[];
  114409. }>;
  114410. /**
  114411. * Load into a scene.
  114412. * @param scene The scene to load into
  114413. * @param data The data to import
  114414. * @param rootUrl The root url for scene and resources
  114415. * @param onProgress The callback when the load progresses
  114416. * @param fileName Defines the name of the file to load
  114417. * @returns Nothing
  114418. */
  114419. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  114420. /**
  114421. * Load into an asset container.
  114422. * @param scene The scene to load into
  114423. * @param data The data to import
  114424. * @param rootUrl The root url for scene and resources
  114425. * @param onProgress The callback when the load progresses
  114426. * @param fileName Defines the name of the file to load
  114427. * @returns The loaded asset container
  114428. */
  114429. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  114430. }
  114431. /**
  114432. * Mode that determines how to handle old animation groups before loading new ones.
  114433. */
  114434. export enum SceneLoaderAnimationGroupLoadingMode {
  114435. /**
  114436. * Reset all old animations to initial state then dispose them.
  114437. */
  114438. Clean = 0,
  114439. /**
  114440. * Stop all old animations.
  114441. */
  114442. Stop = 1,
  114443. /**
  114444. * Restart old animations from first frame.
  114445. */
  114446. Sync = 2,
  114447. /**
  114448. * Old animations remains untouched.
  114449. */
  114450. NoSync = 3
  114451. }
  114452. /**
  114453. * Class used to load scene from various file formats using registered plugins
  114454. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  114455. */
  114456. export class SceneLoader {
  114457. /**
  114458. * No logging while loading
  114459. */
  114460. static readonly NO_LOGGING: number;
  114461. /**
  114462. * Minimal logging while loading
  114463. */
  114464. static readonly MINIMAL_LOGGING: number;
  114465. /**
  114466. * Summary logging while loading
  114467. */
  114468. static readonly SUMMARY_LOGGING: number;
  114469. /**
  114470. * Detailled logging while loading
  114471. */
  114472. static readonly DETAILED_LOGGING: number;
  114473. /**
  114474. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  114475. */
  114476. static get ForceFullSceneLoadingForIncremental(): boolean;
  114477. static set ForceFullSceneLoadingForIncremental(value: boolean);
  114478. /**
  114479. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  114480. */
  114481. static get ShowLoadingScreen(): boolean;
  114482. static set ShowLoadingScreen(value: boolean);
  114483. /**
  114484. * Defines the current logging level (while loading the scene)
  114485. * @ignorenaming
  114486. */
  114487. static get loggingLevel(): number;
  114488. static set loggingLevel(value: number);
  114489. /**
  114490. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  114491. */
  114492. static get CleanBoneMatrixWeights(): boolean;
  114493. static set CleanBoneMatrixWeights(value: boolean);
  114494. /**
  114495. * Event raised when a plugin is used to load a scene
  114496. */
  114497. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  114498. private static _registeredPlugins;
  114499. private static _getDefaultPlugin;
  114500. private static _getPluginForExtension;
  114501. private static _getPluginForDirectLoad;
  114502. private static _getPluginForFilename;
  114503. private static _getDirectLoad;
  114504. private static _loadData;
  114505. private static _getFileInfo;
  114506. /**
  114507. * Gets a plugin that can load the given extension
  114508. * @param extension defines the extension to load
  114509. * @returns a plugin or null if none works
  114510. */
  114511. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  114512. /**
  114513. * Gets a boolean indicating that the given extension can be loaded
  114514. * @param extension defines the extension to load
  114515. * @returns true if the extension is supported
  114516. */
  114517. static IsPluginForExtensionAvailable(extension: string): boolean;
  114518. /**
  114519. * Adds a new plugin to the list of registered plugins
  114520. * @param plugin defines the plugin to add
  114521. */
  114522. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  114523. /**
  114524. * Import meshes into a scene
  114525. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  114526. * @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)
  114527. * @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)
  114528. * @param scene the instance of BABYLON.Scene to append to
  114529. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  114530. * @param onProgress a callback with a progress event for each file being loaded
  114531. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114532. * @param pluginExtension the extension used to determine the plugin
  114533. * @returns The loaded plugin
  114534. */
  114535. 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>;
  114536. /**
  114537. * Import meshes into a scene
  114538. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  114539. * @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)
  114540. * @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)
  114541. * @param scene the instance of BABYLON.Scene to append to
  114542. * @param onProgress a callback with a progress event for each file being loaded
  114543. * @param pluginExtension the extension used to determine the plugin
  114544. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  114545. */
  114546. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  114547. meshes: AbstractMesh[];
  114548. particleSystems: IParticleSystem[];
  114549. skeletons: Skeleton[];
  114550. animationGroups: AnimationGroup[];
  114551. }>;
  114552. /**
  114553. * Load a scene
  114554. * @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)
  114555. * @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)
  114556. * @param engine is the instance of BABYLON.Engine to use to create the scene
  114557. * @param onSuccess a callback with the scene when import succeeds
  114558. * @param onProgress a callback with a progress event for each file being loaded
  114559. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114560. * @param pluginExtension the extension used to determine the plugin
  114561. * @returns The loaded plugin
  114562. */
  114563. 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>;
  114564. /**
  114565. * Load a scene
  114566. * @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)
  114567. * @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)
  114568. * @param engine is the instance of BABYLON.Engine to use to create the scene
  114569. * @param onProgress a callback with a progress event for each file being loaded
  114570. * @param pluginExtension the extension used to determine the plugin
  114571. * @returns The loaded scene
  114572. */
  114573. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  114574. /**
  114575. * Append a scene
  114576. * @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)
  114577. * @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)
  114578. * @param scene is the instance of BABYLON.Scene to append to
  114579. * @param onSuccess a callback with the scene when import succeeds
  114580. * @param onProgress a callback with a progress event for each file being loaded
  114581. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114582. * @param pluginExtension the extension used to determine the plugin
  114583. * @returns The loaded plugin
  114584. */
  114585. 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>;
  114586. /**
  114587. * Append a scene
  114588. * @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)
  114589. * @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)
  114590. * @param scene is the instance of BABYLON.Scene to append to
  114591. * @param onProgress a callback with a progress event for each file being loaded
  114592. * @param pluginExtension the extension used to determine the plugin
  114593. * @returns The given scene
  114594. */
  114595. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  114596. /**
  114597. * Load a scene into an asset container
  114598. * @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)
  114599. * @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)
  114600. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  114601. * @param onSuccess a callback with the scene when import succeeds
  114602. * @param onProgress a callback with a progress event for each file being loaded
  114603. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114604. * @param pluginExtension the extension used to determine the plugin
  114605. * @returns The loaded plugin
  114606. */
  114607. 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>;
  114608. /**
  114609. * Load a scene into an asset container
  114610. * @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)
  114611. * @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)
  114612. * @param scene is the instance of Scene to append to
  114613. * @param onProgress a callback with a progress event for each file being loaded
  114614. * @param pluginExtension the extension used to determine the plugin
  114615. * @returns The loaded asset container
  114616. */
  114617. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  114618. /**
  114619. * Import animations from a file into a scene
  114620. * @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)
  114621. * @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)
  114622. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  114623. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  114624. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  114625. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  114626. * @param onSuccess a callback with the scene when import succeeds
  114627. * @param onProgress a callback with a progress event for each file being loaded
  114628. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114629. */
  114630. 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;
  114631. /**
  114632. * Import animations from a file into a scene
  114633. * @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)
  114634. * @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)
  114635. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  114636. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  114637. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  114638. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  114639. * @param onSuccess a callback with the scene when import succeeds
  114640. * @param onProgress a callback with a progress event for each file being loaded
  114641. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  114642. * @returns the updated scene with imported animations
  114643. */
  114644. 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>;
  114645. }
  114646. }
  114647. declare module BABYLON {
  114648. /**
  114649. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  114650. */
  114651. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  114652. /**
  114653. * The type of components available in motion controllers.
  114654. * This is not the name of the component.
  114655. */
  114656. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  114657. /**
  114658. * The schema of motion controller layout.
  114659. * No object will be initialized using this interface
  114660. * This is used just to define the profile.
  114661. */
  114662. export interface IMotionControllerLayout {
  114663. /**
  114664. * Defines the main button component id
  114665. */
  114666. selectComponentId: string;
  114667. /**
  114668. * Available components (unsorted)
  114669. */
  114670. components: {
  114671. /**
  114672. * A map of component Ids
  114673. */
  114674. [componentId: string]: {
  114675. /**
  114676. * The type of input the component outputs
  114677. */
  114678. type: MotionControllerComponentType;
  114679. };
  114680. };
  114681. /**
  114682. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  114683. */
  114684. gamepad?: {
  114685. /**
  114686. * Is the mapping based on the xr-standard defined here:
  114687. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  114688. */
  114689. mapping: "" | "xr-standard";
  114690. /**
  114691. * The buttons available in this input in the right order
  114692. * index of this button will be the index in the gamepadObject.buttons array
  114693. * correlates to the componentId in components
  114694. */
  114695. buttons: Array<string | null>;
  114696. /**
  114697. * Definition of the axes of the gamepad input, sorted
  114698. * Correlates to componentIds in the components map
  114699. */
  114700. axes: Array<{
  114701. /**
  114702. * The component id that the axis correlates to
  114703. */
  114704. componentId: string;
  114705. /**
  114706. * X or Y Axis
  114707. */
  114708. axis: "x-axis" | "y-axis";
  114709. } | null>;
  114710. };
  114711. }
  114712. /**
  114713. * A definition for the layout map in the input profile
  114714. */
  114715. export interface IMotionControllerLayoutMap {
  114716. /**
  114717. * Layouts with handness type as a key
  114718. */
  114719. [handness: string]: IMotionControllerLayout;
  114720. }
  114721. /**
  114722. * The XR Input profile schema
  114723. * Profiles can be found here:
  114724. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  114725. */
  114726. export interface IMotionControllerProfile {
  114727. /**
  114728. * The id of this profile
  114729. * correlates to the profile(s) in the xrInput.profiles array
  114730. */
  114731. profileId: string;
  114732. /**
  114733. * fallback profiles for this profileId
  114734. */
  114735. fallbackProfileIds: string[];
  114736. /**
  114737. * The layout map, with handness as key
  114738. */
  114739. layouts: IMotionControllerLayoutMap;
  114740. }
  114741. /**
  114742. * A helper-interface for the 3 meshes needed for controller button animation
  114743. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  114744. */
  114745. export interface IMotionControllerButtonMeshMap {
  114746. /**
  114747. * The mesh that will be changed when value changes
  114748. */
  114749. valueMesh: AbstractMesh;
  114750. /**
  114751. * the mesh that defines the pressed value mesh position.
  114752. * This is used to find the max-position of this button
  114753. */
  114754. pressedMesh: AbstractMesh;
  114755. /**
  114756. * the mesh that defines the unpressed value mesh position.
  114757. * This is used to find the min (or initial) position of this button
  114758. */
  114759. unpressedMesh: AbstractMesh;
  114760. }
  114761. /**
  114762. * A helper-interface for the 3 meshes needed for controller axis animation.
  114763. * This will be expanded when touchpad animations are fully supported
  114764. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  114765. */
  114766. export interface IMotionControllerAxisMeshMap {
  114767. /**
  114768. * The mesh that will be changed when axis value changes
  114769. */
  114770. valueMesh: AbstractMesh;
  114771. /**
  114772. * the mesh that defines the minimum value mesh position.
  114773. */
  114774. minMesh: AbstractMesh;
  114775. /**
  114776. * the mesh that defines the maximum value mesh position.
  114777. */
  114778. maxMesh: AbstractMesh;
  114779. }
  114780. /**
  114781. * The elements needed for change-detection of the gamepad objects in motion controllers
  114782. */
  114783. export interface IMinimalMotionControllerObject {
  114784. /**
  114785. * An array of available buttons
  114786. */
  114787. buttons: Array<{
  114788. /**
  114789. * Value of the button/trigger
  114790. */
  114791. value: number;
  114792. /**
  114793. * If the button/trigger is currently touched
  114794. */
  114795. touched: boolean;
  114796. /**
  114797. * If the button/trigger is currently pressed
  114798. */
  114799. pressed: boolean;
  114800. }>;
  114801. /**
  114802. * Available axes of this controller
  114803. */
  114804. axes: number[];
  114805. }
  114806. /**
  114807. * An Abstract Motion controller
  114808. * This class receives an xrInput and a profile layout and uses those to initialize the components
  114809. * Each component has an observable to check for changes in value and state
  114810. */
  114811. export abstract class WebXRAbstractMotionController implements IDisposable {
  114812. protected scene: Scene;
  114813. protected layout: IMotionControllerLayout;
  114814. /**
  114815. * The gamepad object correlating to this controller
  114816. */
  114817. gamepadObject: IMinimalMotionControllerObject;
  114818. /**
  114819. * handness (left/right/none) of this controller
  114820. */
  114821. handness: MotionControllerHandness;
  114822. /**
  114823. * Component type map
  114824. */
  114825. static ComponentType: {
  114826. TRIGGER: string;
  114827. SQUEEZE: string;
  114828. TOUCHPAD: string;
  114829. THUMBSTICK: string;
  114830. BUTTON: string;
  114831. };
  114832. /**
  114833. * The profile id of this motion controller
  114834. */
  114835. abstract profileId: string;
  114836. /**
  114837. * A map of components (WebXRControllerComponent) in this motion controller
  114838. * Components have a ComponentType and can also have both button and axis definitions
  114839. */
  114840. readonly components: {
  114841. [id: string]: WebXRControllerComponent;
  114842. };
  114843. /**
  114844. * Observers registered here will be triggered when the model of this controller is done loading
  114845. */
  114846. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  114847. /**
  114848. * The root mesh of the model. It is null if the model was not yet initialized
  114849. */
  114850. rootMesh: Nullable<AbstractMesh>;
  114851. private _modelReady;
  114852. /**
  114853. * constructs a new abstract motion controller
  114854. * @param scene the scene to which the model of the controller will be added
  114855. * @param layout The profile layout to load
  114856. * @param gamepadObject The gamepad object correlating to this controller
  114857. * @param handness handness (left/right/none) of this controller
  114858. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  114859. */
  114860. constructor(scene: Scene, layout: IMotionControllerLayout,
  114861. /**
  114862. * The gamepad object correlating to this controller
  114863. */
  114864. gamepadObject: IMinimalMotionControllerObject,
  114865. /**
  114866. * handness (left/right/none) of this controller
  114867. */
  114868. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  114869. private _initComponent;
  114870. /**
  114871. * Update this model using the current XRFrame
  114872. * @param xrFrame the current xr frame to use and update the model
  114873. */
  114874. updateFromXRFrame(xrFrame: XRFrame): void;
  114875. /**
  114876. * Get the list of components available in this motion controller
  114877. * @returns an array of strings correlating to available components
  114878. */
  114879. getComponentTypes(): string[];
  114880. /**
  114881. * Get the main (Select) component of this controller as defined in the layout
  114882. * @returns the main component of this controller
  114883. */
  114884. getMainComponent(): WebXRControllerComponent;
  114885. /**
  114886. * get a component based an its component id as defined in layout.components
  114887. * @param id the id of the component
  114888. * @returns the component correlates to the id or undefined if not found
  114889. */
  114890. getComponent(id: string): WebXRControllerComponent;
  114891. /**
  114892. * Loads the model correlating to this controller
  114893. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  114894. * @returns A promise fulfilled with the result of the model loading
  114895. */
  114896. loadModel(): Promise<boolean>;
  114897. /**
  114898. * Update the model itself with the current frame data
  114899. * @param xrFrame the frame to use for updating the model mesh
  114900. */
  114901. protected updateModel(xrFrame: XRFrame): void;
  114902. /**
  114903. * Moves the axis on the controller mesh based on its current state
  114904. * @param axis the index of the axis
  114905. * @param axisValue the value of the axis which determines the meshes new position
  114906. * @hidden
  114907. */
  114908. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  114909. /**
  114910. * Moves the buttons on the controller mesh based on their current state
  114911. * @param buttonName the name of the button to move
  114912. * @param buttonValue the value of the button which determines the buttons new position
  114913. */
  114914. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  114915. private _getGenericFilenameAndPath;
  114916. private _getGenericParentMesh;
  114917. /**
  114918. * Get the filename and path for this controller's model
  114919. * @returns a map of filename and path
  114920. */
  114921. protected abstract _getFilenameAndPath(): {
  114922. filename: string;
  114923. path: string;
  114924. };
  114925. /**
  114926. * This function will be called after the model was successfully loaded and can be used
  114927. * for mesh transformations before it is available for the user
  114928. * @param meshes the loaded meshes
  114929. */
  114930. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  114931. /**
  114932. * Set the root mesh for this controller. Important for the WebXR controller class
  114933. * @param meshes the loaded meshes
  114934. */
  114935. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  114936. /**
  114937. * A function executed each frame that updates the mesh (if needed)
  114938. * @param xrFrame the current xrFrame
  114939. */
  114940. protected abstract _updateModel(xrFrame: XRFrame): void;
  114941. /**
  114942. * This function is called before the mesh is loaded. It checks for loading constraints.
  114943. * For example, this function can check if the GLB loader is available
  114944. * If this function returns false, the generic controller will be loaded instead
  114945. * @returns Is the client ready to load the mesh
  114946. */
  114947. protected abstract _getModelLoadingConstraints(): boolean;
  114948. /**
  114949. * Dispose this controller, the model mesh and all its components
  114950. */
  114951. dispose(): void;
  114952. }
  114953. }
  114954. declare module BABYLON {
  114955. /**
  114956. * A generic trigger-only motion controller for WebXR
  114957. */
  114958. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  114959. /**
  114960. * Static version of the profile id of this controller
  114961. */
  114962. static ProfileId: string;
  114963. profileId: string;
  114964. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  114965. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  114966. protected _updateModel(): void;
  114967. protected _getFilenameAndPath(): {
  114968. filename: string;
  114969. path: string;
  114970. };
  114971. protected _setRootMesh(meshes: AbstractMesh[]): void;
  114972. protected _getModelLoadingConstraints(): boolean;
  114973. }
  114974. }
  114975. declare module BABYLON {
  114976. /**
  114977. * A construction function type to create a new controller based on an xrInput object
  114978. */
  114979. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  114980. /**
  114981. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  114982. *
  114983. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  114984. * it should be replaced with auto-loaded controllers.
  114985. *
  114986. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  114987. */
  114988. export class WebXRMotionControllerManager {
  114989. private static _AvailableControllers;
  114990. private static _Fallbacks;
  114991. /**
  114992. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  114993. *
  114994. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  114995. *
  114996. * @param type the profile type to register
  114997. * @param constructFunction the function to be called when loading this profile
  114998. */
  114999. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  115000. /**
  115001. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  115002. * The order of search:
  115003. *
  115004. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  115005. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  115006. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  115007. * 4) return the generic trigger controller if none were found
  115008. *
  115009. * @param xrInput the xrInput to which a new controller is initialized
  115010. * @param scene the scene to which the model will be added
  115011. * @return the motion controller class for this profile id or the generic standard class if none was found
  115012. */
  115013. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene): WebXRAbstractMotionController;
  115014. /**
  115015. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  115016. * @param profileId the profile to which a fallback needs to be found
  115017. * @return an array with corresponding fallback profiles
  115018. */
  115019. static FindFallbackWithProfileId(profileId: string): string[];
  115020. /**
  115021. * Register a fallback to a specific profile.
  115022. * @param profileId the profileId that will receive the fallbacks
  115023. * @param fallbacks A list of fallback profiles
  115024. */
  115025. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  115026. /**
  115027. * Register the default fallbacks.
  115028. * This function is called automatically when this file is imported.
  115029. */
  115030. static DefaultFallbacks(): void;
  115031. }
  115032. }
  115033. declare module BABYLON {
  115034. /**
  115035. * Represents an XR input
  115036. */
  115037. export class WebXRController {
  115038. private scene;
  115039. /** The underlying input source for the controller */
  115040. inputSource: XRInputSource;
  115041. /**
  115042. * 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
  115043. */
  115044. grip?: AbstractMesh;
  115045. /**
  115046. * Pointer which can be used to select objects or attach a visible laser to
  115047. */
  115048. pointer: AbstractMesh;
  115049. private _gamepadMode;
  115050. /**
  115051. * If available, this is the gamepad object related to this controller.
  115052. * Using this object it is possible to get click events and trackpad changes of the
  115053. * webxr controller that is currently being used.
  115054. */
  115055. gamepadController?: WebXRAbstractMotionController;
  115056. /**
  115057. * Event that fires when the controller is removed/disposed
  115058. */
  115059. onDisposeObservable: Observable<{}>;
  115060. private _tmpQuaternion;
  115061. private _tmpVector;
  115062. /**
  115063. * Creates the controller
  115064. * @see https://doc.babylonjs.com/how_to/webxr
  115065. * @param scene the scene which the controller should be associated to
  115066. * @param inputSource the underlying input source for the controller
  115067. * @param parentContainer parent that the controller meshes should be children of
  115068. */
  115069. constructor(scene: Scene,
  115070. /** The underlying input source for the controller */
  115071. inputSource: XRInputSource);
  115072. /**
  115073. * Updates the controller pose based on the given XRFrame
  115074. * @param xrFrame xr frame to update the pose with
  115075. * @param referenceSpace reference space to use
  115076. */
  115077. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  115078. /**
  115079. * Gets a world space ray coming from the controller
  115080. * @param result the resulting ray
  115081. */
  115082. getWorldPointerRayToRef(result: Ray): void;
  115083. /**
  115084. * Get the scene associated with this controller
  115085. * @returns the scene object
  115086. */
  115087. getScene(): Scene;
  115088. /**
  115089. * Disposes of the object
  115090. */
  115091. dispose(): void;
  115092. }
  115093. }
  115094. declare module BABYLON {
  115095. /**
  115096. * The schema for initialization options of the XR Input class
  115097. */
  115098. export interface IWebXRInputOptions {
  115099. /**
  115100. * If set to true no model will be automatically loaded
  115101. */
  115102. doNotLoadControllerMeshes?: boolean;
  115103. }
  115104. /**
  115105. * XR input used to track XR inputs such as controllers/rays
  115106. */
  115107. export class WebXRInput implements IDisposable {
  115108. /**
  115109. * the xr session manager for this session
  115110. */
  115111. xrSessionManager: WebXRSessionManager;
  115112. /**
  115113. * the WebXR camera for this session. Mainly used for teleportation
  115114. */
  115115. xrCamera: WebXRCamera;
  115116. private readonly options;
  115117. /**
  115118. * XR controllers being tracked
  115119. */
  115120. controllers: Array<WebXRController>;
  115121. private _frameObserver;
  115122. private _sessionEndedObserver;
  115123. private _sessionInitObserver;
  115124. /**
  115125. * Event when a controller has been connected/added
  115126. */
  115127. onControllerAddedObservable: Observable<WebXRController>;
  115128. /**
  115129. * Event when a controller has been removed/disconnected
  115130. */
  115131. onControllerRemovedObservable: Observable<WebXRController>;
  115132. /**
  115133. * Initializes the WebXRInput
  115134. * @param xrSessionManager the xr session manager for this session
  115135. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  115136. * @param options = initialization options for this xr input
  115137. */
  115138. constructor(
  115139. /**
  115140. * the xr session manager for this session
  115141. */
  115142. xrSessionManager: WebXRSessionManager,
  115143. /**
  115144. * the WebXR camera for this session. Mainly used for teleportation
  115145. */
  115146. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  115147. private _onInputSourcesChange;
  115148. private _addAndRemoveControllers;
  115149. /**
  115150. * Disposes of the object
  115151. */
  115152. dispose(): void;
  115153. }
  115154. }
  115155. declare module BABYLON {
  115156. /**
  115157. * Handles pointer input automatically for the pointer of XR controllers
  115158. */
  115159. export class WebXRControllerPointerSelection {
  115160. private static _idCounter;
  115161. private _tmpRay;
  115162. /**
  115163. * Creates a WebXRControllerPointerSelection
  115164. * @param input input manager to setup pointer selection
  115165. */
  115166. constructor(input: WebXRInput);
  115167. private _convertNormalToDirectionOfRay;
  115168. private _updatePointerDistance;
  115169. }
  115170. }
  115171. declare module BABYLON {
  115172. /**
  115173. * Enables teleportation
  115174. */
  115175. export class WebXRControllerTeleportation {
  115176. private _teleportationFillColor;
  115177. private _teleportationBorderColor;
  115178. private _tmpRay;
  115179. private _tmpVector;
  115180. /**
  115181. * when set to true (default) teleportation will wait for thumbstick changes.
  115182. * When set to false teleportation will be disabled.
  115183. *
  115184. * If set to false while teleporting results can be unexpected.
  115185. */
  115186. enabled: boolean;
  115187. /**
  115188. * Creates a WebXRControllerTeleportation
  115189. * @param input input manager to add teleportation to
  115190. * @param floorMeshes floormeshes which can be teleported to
  115191. */
  115192. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  115193. }
  115194. }
  115195. declare module BABYLON {
  115196. /**
  115197. * Button which can be used to enter a different mode of XR
  115198. */
  115199. export class WebXREnterExitUIButton {
  115200. /** button element */
  115201. element: HTMLElement;
  115202. /** XR initialization options for the button */
  115203. sessionMode: XRSessionMode;
  115204. /** Reference space type */
  115205. referenceSpaceType: XRReferenceSpaceType;
  115206. /**
  115207. * Creates a WebXREnterExitUIButton
  115208. * @param element button element
  115209. * @param sessionMode XR initialization session mode
  115210. * @param referenceSpaceType the type of reference space to be used
  115211. */
  115212. constructor(
  115213. /** button element */
  115214. element: HTMLElement,
  115215. /** XR initialization options for the button */
  115216. sessionMode: XRSessionMode,
  115217. /** Reference space type */
  115218. referenceSpaceType: XRReferenceSpaceType);
  115219. /**
  115220. * Overwritable function which can be used to update the button's visuals when the state changes
  115221. * @param activeButton the current active button in the UI
  115222. */
  115223. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  115224. }
  115225. /**
  115226. * Options to create the webXR UI
  115227. */
  115228. export class WebXREnterExitUIOptions {
  115229. /**
  115230. * Context to enter xr with
  115231. */
  115232. renderTarget?: Nullable<WebXRRenderTarget>;
  115233. /**
  115234. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  115235. */
  115236. customButtons?: Array<WebXREnterExitUIButton>;
  115237. /**
  115238. * A session mode to use when creating the default button.
  115239. * Default is immersive-vr
  115240. */
  115241. sessionMode?: XRSessionMode;
  115242. /**
  115243. * A reference space type to use when creating the default button.
  115244. * Default is local-floor
  115245. */
  115246. referenceSpaceType?: XRReferenceSpaceType;
  115247. }
  115248. /**
  115249. * UI to allow the user to enter/exit XR mode
  115250. */
  115251. export class WebXREnterExitUI implements IDisposable {
  115252. private scene;
  115253. /** version of the options passed to this UI */
  115254. options: WebXREnterExitUIOptions;
  115255. private _overlay;
  115256. private _buttons;
  115257. private _activeButton;
  115258. /**
  115259. * Fired every time the active button is changed.
  115260. *
  115261. * When xr is entered via a button that launches xr that button will be the callback parameter
  115262. *
  115263. * When exiting xr the callback parameter will be null)
  115264. */
  115265. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  115266. /**
  115267. * Creates UI to allow the user to enter/exit XR mode
  115268. * @param scene the scene to add the ui to
  115269. * @param helper the xr experience helper to enter/exit xr with
  115270. * @param options options to configure the UI
  115271. * @returns the created ui
  115272. */
  115273. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  115274. /**
  115275. *
  115276. * @param scene babylon scene object to use
  115277. * @param options (read-only) version of the options passed to this UI
  115278. */
  115279. private constructor();
  115280. private _updateButtons;
  115281. /**
  115282. * Disposes of the object
  115283. */
  115284. dispose(): void;
  115285. }
  115286. }
  115287. declare module BABYLON {
  115288. /**
  115289. * Options for the default xr helper
  115290. */
  115291. export class WebXRDefaultExperienceOptions {
  115292. /**
  115293. * Floor meshes that should be used for teleporting
  115294. */
  115295. floorMeshes?: Array<AbstractMesh>;
  115296. /**
  115297. * Enable or disable default UI to enter XR
  115298. */
  115299. disableDefaultUI?: boolean;
  115300. /**
  115301. * optional configuration for the output canvas
  115302. */
  115303. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  115304. /**
  115305. * optional UI options. This can be used among other to change session mode and reference space type
  115306. */
  115307. uiOptions?: WebXREnterExitUIOptions;
  115308. /**
  115309. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  115310. */
  115311. inputOptions?: IWebXRInputOptions;
  115312. }
  115313. /**
  115314. * Default experience which provides a similar setup to the previous webVRExperience
  115315. */
  115316. export class WebXRDefaultExperience {
  115317. /**
  115318. * Base experience
  115319. */
  115320. baseExperience: WebXRExperienceHelper;
  115321. /**
  115322. * Input experience extension
  115323. */
  115324. input: WebXRInput;
  115325. /**
  115326. * Enables laser pointer and selection
  115327. */
  115328. pointerSelection: WebXRControllerPointerSelection;
  115329. /**
  115330. * Enables teleportation
  115331. */
  115332. teleportation: WebXRControllerTeleportation;
  115333. /**
  115334. * Enables ui for entering/exiting xr
  115335. */
  115336. enterExitUI: WebXREnterExitUI;
  115337. /**
  115338. * Default target xr should render to
  115339. */
  115340. renderTarget: WebXRRenderTarget;
  115341. /**
  115342. * Creates the default xr experience
  115343. * @param scene scene
  115344. * @param options options for basic configuration
  115345. * @returns resulting WebXRDefaultExperience
  115346. */
  115347. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115348. private constructor();
  115349. /**
  115350. * DIsposes of the experience helper
  115351. */
  115352. dispose(): void;
  115353. }
  115354. }
  115355. declare module BABYLON {
  115356. /**
  115357. * Options to modify the vr teleportation behavior.
  115358. */
  115359. export interface VRTeleportationOptions {
  115360. /**
  115361. * The name of the mesh which should be used as the teleportation floor. (default: null)
  115362. */
  115363. floorMeshName?: string;
  115364. /**
  115365. * A list of meshes to be used as the teleportation floor. (default: empty)
  115366. */
  115367. floorMeshes?: Mesh[];
  115368. /**
  115369. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  115370. */
  115371. teleportationMode?: number;
  115372. /**
  115373. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  115374. */
  115375. teleportationTime?: number;
  115376. /**
  115377. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  115378. */
  115379. teleportationSpeed?: number;
  115380. /**
  115381. * The easing function used in the animation or null for Linear. (default CircleEase)
  115382. */
  115383. easingFunction?: EasingFunction;
  115384. }
  115385. /**
  115386. * Options to modify the vr experience helper's behavior.
  115387. */
  115388. export interface VRExperienceHelperOptions extends WebVROptions {
  115389. /**
  115390. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  115391. */
  115392. createDeviceOrientationCamera?: boolean;
  115393. /**
  115394. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  115395. */
  115396. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  115397. /**
  115398. * Uses the main button on the controller to toggle the laser casted. (default: true)
  115399. */
  115400. laserToggle?: boolean;
  115401. /**
  115402. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  115403. */
  115404. floorMeshes?: Mesh[];
  115405. /**
  115406. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  115407. */
  115408. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  115409. /**
  115410. * Defines if WebXR should be used instead of WebVR (if available)
  115411. */
  115412. useXR?: boolean;
  115413. }
  115414. /**
  115415. * Event containing information after VR has been entered
  115416. */
  115417. export class OnAfterEnteringVRObservableEvent {
  115418. /**
  115419. * If entering vr was successful
  115420. */
  115421. success: boolean;
  115422. }
  115423. /**
  115424. * Helps to quickly add VR support to an existing scene.
  115425. * See http://doc.babylonjs.com/how_to/webvr_helper
  115426. */
  115427. export class VRExperienceHelper {
  115428. /** Options to modify the vr experience helper's behavior. */
  115429. webVROptions: VRExperienceHelperOptions;
  115430. private _scene;
  115431. private _position;
  115432. private _btnVR;
  115433. private _btnVRDisplayed;
  115434. private _webVRsupported;
  115435. private _webVRready;
  115436. private _webVRrequesting;
  115437. private _webVRpresenting;
  115438. private _hasEnteredVR;
  115439. private _fullscreenVRpresenting;
  115440. private _inputElement;
  115441. private _webVRCamera;
  115442. private _vrDeviceOrientationCamera;
  115443. private _deviceOrientationCamera;
  115444. private _existingCamera;
  115445. private _onKeyDown;
  115446. private _onVrDisplayPresentChange;
  115447. private _onVRDisplayChanged;
  115448. private _onVRRequestPresentStart;
  115449. private _onVRRequestPresentComplete;
  115450. /**
  115451. * 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)
  115452. */
  115453. enableGazeEvenWhenNoPointerLock: boolean;
  115454. /**
  115455. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  115456. */
  115457. exitVROnDoubleTap: boolean;
  115458. /**
  115459. * Observable raised right before entering VR.
  115460. */
  115461. onEnteringVRObservable: Observable<VRExperienceHelper>;
  115462. /**
  115463. * Observable raised when entering VR has completed.
  115464. */
  115465. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  115466. /**
  115467. * Observable raised when exiting VR.
  115468. */
  115469. onExitingVRObservable: Observable<VRExperienceHelper>;
  115470. /**
  115471. * Observable raised when controller mesh is loaded.
  115472. */
  115473. onControllerMeshLoadedObservable: Observable<WebVRController>;
  115474. /** Return this.onEnteringVRObservable
  115475. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  115476. */
  115477. get onEnteringVR(): Observable<VRExperienceHelper>;
  115478. /** Return this.onExitingVRObservable
  115479. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  115480. */
  115481. get onExitingVR(): Observable<VRExperienceHelper>;
  115482. /** Return this.onControllerMeshLoadedObservable
  115483. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  115484. */
  115485. get onControllerMeshLoaded(): Observable<WebVRController>;
  115486. private _rayLength;
  115487. private _useCustomVRButton;
  115488. private _teleportationRequested;
  115489. private _teleportActive;
  115490. private _floorMeshName;
  115491. private _floorMeshesCollection;
  115492. private _teleportationMode;
  115493. private _teleportationTime;
  115494. private _teleportationSpeed;
  115495. private _teleportationEasing;
  115496. private _rotationAllowed;
  115497. private _teleportBackwardsVector;
  115498. private _teleportationTarget;
  115499. private _isDefaultTeleportationTarget;
  115500. private _postProcessMove;
  115501. private _teleportationFillColor;
  115502. private _teleportationBorderColor;
  115503. private _rotationAngle;
  115504. private _haloCenter;
  115505. private _cameraGazer;
  115506. private _padSensibilityUp;
  115507. private _padSensibilityDown;
  115508. private _leftController;
  115509. private _rightController;
  115510. private _gazeColor;
  115511. private _laserColor;
  115512. private _pickedLaserColor;
  115513. private _pickedGazeColor;
  115514. /**
  115515. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  115516. */
  115517. onNewMeshSelected: Observable<AbstractMesh>;
  115518. /**
  115519. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  115520. * This observable will provide the mesh and the controller used to select the mesh
  115521. */
  115522. onMeshSelectedWithController: Observable<{
  115523. mesh: AbstractMesh;
  115524. controller: WebVRController;
  115525. }>;
  115526. /**
  115527. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  115528. */
  115529. onNewMeshPicked: Observable<PickingInfo>;
  115530. private _circleEase;
  115531. /**
  115532. * Observable raised before camera teleportation
  115533. */
  115534. onBeforeCameraTeleport: Observable<Vector3>;
  115535. /**
  115536. * Observable raised after camera teleportation
  115537. */
  115538. onAfterCameraTeleport: Observable<Vector3>;
  115539. /**
  115540. * Observable raised when current selected mesh gets unselected
  115541. */
  115542. onSelectedMeshUnselected: Observable<AbstractMesh>;
  115543. private _raySelectionPredicate;
  115544. /**
  115545. * To be optionaly changed by user to define custom ray selection
  115546. */
  115547. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  115548. /**
  115549. * To be optionaly changed by user to define custom selection logic (after ray selection)
  115550. */
  115551. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  115552. /**
  115553. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  115554. */
  115555. teleportationEnabled: boolean;
  115556. private _defaultHeight;
  115557. private _teleportationInitialized;
  115558. private _interactionsEnabled;
  115559. private _interactionsRequested;
  115560. private _displayGaze;
  115561. private _displayLaserPointer;
  115562. /**
  115563. * The mesh used to display where the user is going to teleport.
  115564. */
  115565. get teleportationTarget(): Mesh;
  115566. /**
  115567. * Sets the mesh to be used to display where the user is going to teleport.
  115568. */
  115569. set teleportationTarget(value: Mesh);
  115570. /**
  115571. * 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
  115572. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  115573. * See http://doc.babylonjs.com/resources/baking_transformations
  115574. */
  115575. get gazeTrackerMesh(): Mesh;
  115576. set gazeTrackerMesh(value: Mesh);
  115577. /**
  115578. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  115579. */
  115580. updateGazeTrackerScale: boolean;
  115581. /**
  115582. * If the gaze trackers color should be updated when selecting meshes
  115583. */
  115584. updateGazeTrackerColor: boolean;
  115585. /**
  115586. * If the controller laser color should be updated when selecting meshes
  115587. */
  115588. updateControllerLaserColor: boolean;
  115589. /**
  115590. * The gaze tracking mesh corresponding to the left controller
  115591. */
  115592. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  115593. /**
  115594. * The gaze tracking mesh corresponding to the right controller
  115595. */
  115596. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  115597. /**
  115598. * If the ray of the gaze should be displayed.
  115599. */
  115600. get displayGaze(): boolean;
  115601. /**
  115602. * Sets if the ray of the gaze should be displayed.
  115603. */
  115604. set displayGaze(value: boolean);
  115605. /**
  115606. * If the ray of the LaserPointer should be displayed.
  115607. */
  115608. get displayLaserPointer(): boolean;
  115609. /**
  115610. * Sets if the ray of the LaserPointer should be displayed.
  115611. */
  115612. set displayLaserPointer(value: boolean);
  115613. /**
  115614. * The deviceOrientationCamera used as the camera when not in VR.
  115615. */
  115616. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  115617. /**
  115618. * Based on the current WebVR support, returns the current VR camera used.
  115619. */
  115620. get currentVRCamera(): Nullable<Camera>;
  115621. /**
  115622. * The webVRCamera which is used when in VR.
  115623. */
  115624. get webVRCamera(): WebVRFreeCamera;
  115625. /**
  115626. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  115627. */
  115628. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  115629. /**
  115630. * The html button that is used to trigger entering into VR.
  115631. */
  115632. get vrButton(): Nullable<HTMLButtonElement>;
  115633. private get _teleportationRequestInitiated();
  115634. /**
  115635. * Defines wether or not Pointer lock should be requested when switching to
  115636. * full screen.
  115637. */
  115638. requestPointerLockOnFullScreen: boolean;
  115639. /**
  115640. * If asking to force XR, this will be populated with the default xr experience
  115641. */
  115642. xr: WebXRDefaultExperience;
  115643. /**
  115644. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  115645. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  115646. */
  115647. xrTestDone: boolean;
  115648. /**
  115649. * Instantiates a VRExperienceHelper.
  115650. * Helps to quickly add VR support to an existing scene.
  115651. * @param scene The scene the VRExperienceHelper belongs to.
  115652. * @param webVROptions Options to modify the vr experience helper's behavior.
  115653. */
  115654. constructor(scene: Scene,
  115655. /** Options to modify the vr experience helper's behavior. */
  115656. webVROptions?: VRExperienceHelperOptions);
  115657. private completeVRInit;
  115658. private _onDefaultMeshLoaded;
  115659. private _onResize;
  115660. private _onFullscreenChange;
  115661. /**
  115662. * Gets a value indicating if we are currently in VR mode.
  115663. */
  115664. get isInVRMode(): boolean;
  115665. private onVrDisplayPresentChange;
  115666. private onVRDisplayChanged;
  115667. private moveButtonToBottomRight;
  115668. private displayVRButton;
  115669. private updateButtonVisibility;
  115670. private _cachedAngularSensibility;
  115671. /**
  115672. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  115673. * Otherwise, will use the fullscreen API.
  115674. */
  115675. enterVR(): void;
  115676. /**
  115677. * Attempt to exit VR, or fullscreen.
  115678. */
  115679. exitVR(): void;
  115680. /**
  115681. * The position of the vr experience helper.
  115682. */
  115683. get position(): Vector3;
  115684. /**
  115685. * Sets the position of the vr experience helper.
  115686. */
  115687. set position(value: Vector3);
  115688. /**
  115689. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  115690. */
  115691. enableInteractions(): void;
  115692. private get _noControllerIsActive();
  115693. private beforeRender;
  115694. private _isTeleportationFloor;
  115695. /**
  115696. * Adds a floor mesh to be used for teleportation.
  115697. * @param floorMesh the mesh to be used for teleportation.
  115698. */
  115699. addFloorMesh(floorMesh: Mesh): void;
  115700. /**
  115701. * Removes a floor mesh from being used for teleportation.
  115702. * @param floorMesh the mesh to be removed.
  115703. */
  115704. removeFloorMesh(floorMesh: Mesh): void;
  115705. /**
  115706. * Enables interactions and teleportation using the VR controllers and gaze.
  115707. * @param vrTeleportationOptions options to modify teleportation behavior.
  115708. */
  115709. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  115710. private _onNewGamepadConnected;
  115711. private _tryEnableInteractionOnController;
  115712. private _onNewGamepadDisconnected;
  115713. private _enableInteractionOnController;
  115714. private _checkTeleportWithRay;
  115715. private _checkRotate;
  115716. private _checkTeleportBackwards;
  115717. private _enableTeleportationOnController;
  115718. private _createTeleportationCircles;
  115719. private _displayTeleportationTarget;
  115720. private _hideTeleportationTarget;
  115721. private _rotateCamera;
  115722. private _moveTeleportationSelectorTo;
  115723. private _workingVector;
  115724. private _workingQuaternion;
  115725. private _workingMatrix;
  115726. /**
  115727. * Time Constant Teleportation Mode
  115728. */
  115729. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  115730. /**
  115731. * Speed Constant Teleportation Mode
  115732. */
  115733. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  115734. /**
  115735. * Teleports the users feet to the desired location
  115736. * @param location The location where the user's feet should be placed
  115737. */
  115738. teleportCamera(location: Vector3): void;
  115739. private _convertNormalToDirectionOfRay;
  115740. private _castRayAndSelectObject;
  115741. private _notifySelectedMeshUnselected;
  115742. /**
  115743. * Permanently set new colors for the laser pointer
  115744. * @param color the new laser color
  115745. * @param pickedColor the new laser color when picked mesh detected
  115746. */
  115747. setLaserColor(color: Color3, pickedColor?: Color3): void;
  115748. /**
  115749. * Permanently set new colors for the gaze pointer
  115750. * @param color the new gaze color
  115751. * @param pickedColor the new gaze color when picked mesh detected
  115752. */
  115753. setGazeColor(color: Color3, pickedColor?: Color3): void;
  115754. /**
  115755. * Sets the color of the laser ray from the vr controllers.
  115756. * @param color new color for the ray.
  115757. */
  115758. changeLaserColor(color: Color3): void;
  115759. /**
  115760. * Sets the color of the ray from the vr headsets gaze.
  115761. * @param color new color for the ray.
  115762. */
  115763. changeGazeColor(color: Color3): void;
  115764. /**
  115765. * Exits VR and disposes of the vr experience helper
  115766. */
  115767. dispose(): void;
  115768. /**
  115769. * Gets the name of the VRExperienceHelper class
  115770. * @returns "VRExperienceHelper"
  115771. */
  115772. getClassName(): string;
  115773. }
  115774. }
  115775. declare module BABYLON {
  115776. /**
  115777. * Options used for hit testing
  115778. */
  115779. export interface IWebXRHitTestOptions {
  115780. /**
  115781. * Only test when user interacted with the scene. Default - hit test every frame
  115782. */
  115783. testOnPointerDownOnly?: boolean;
  115784. /**
  115785. * The node to use to transform the local results to world coordinates
  115786. */
  115787. worldParentNode?: TransformNode;
  115788. }
  115789. /**
  115790. * Interface defining the babylon result of raycasting/hit-test
  115791. */
  115792. export interface IWebXRHitResult {
  115793. /**
  115794. * The native hit test result
  115795. */
  115796. xrHitResult: XRHitResult;
  115797. /**
  115798. * Transformation matrix that can be applied to a node that will put it in the hit point location
  115799. */
  115800. transformationMatrix: Matrix;
  115801. }
  115802. /**
  115803. * The currently-working hit-test module.
  115804. * Hit test (or raycasting) is used to interact with the real world.
  115805. * For further information read here - https://github.com/immersive-web/hit-test
  115806. */
  115807. export class WebXRHitTestLegacy implements IWebXRFeature {
  115808. private _xrSessionManager;
  115809. /**
  115810. * options to use when constructing this feature
  115811. */
  115812. readonly options: IWebXRHitTestOptions;
  115813. /**
  115814. * The module's name
  115815. */
  115816. static readonly Name: string;
  115817. /**
  115818. * The (Babylon) version of this module.
  115819. * This is an integer representing the implementation version.
  115820. * This number does not correspond to the webxr specs version
  115821. */
  115822. static readonly Version: number;
  115823. /**
  115824. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  115825. * @param event the (select) event to use to select with
  115826. * @param referenceSpace the reference space to use for this hit test
  115827. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  115828. */
  115829. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  115830. /**
  115831. * execute a hit test with an XR Ray
  115832. *
  115833. * @param xrSession a native xrSession that will execute this hit test
  115834. * @param xrRay the ray (position and direction) to use for raycasting
  115835. * @param referenceSpace native XR reference space to use for the hit-test
  115836. * @param filter filter function that will filter the results
  115837. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  115838. */
  115839. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  115840. /**
  115841. * Triggered when new babylon (transformed) hit test results are available
  115842. */
  115843. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  115844. /**
  115845. * Creates a new instance of the (legacy version) hit test feature
  115846. * @param _xrSessionManager an instance of WebXRSessionManager
  115847. * @param options options to use when constructing this feature
  115848. */
  115849. constructor(_xrSessionManager: WebXRSessionManager,
  115850. /**
  115851. * options to use when constructing this feature
  115852. */
  115853. options?: IWebXRHitTestOptions);
  115854. private _onSelectEnabled;
  115855. private _xrFrameObserver;
  115856. private _attached;
  115857. /**
  115858. * Populated with the last native XR Hit Results
  115859. */
  115860. lastNativeXRHitResults: XRHitResult[];
  115861. /**
  115862. * attach this feature
  115863. * Will usually be called by the features manager
  115864. *
  115865. * @returns true if successful.
  115866. */
  115867. attach(): boolean;
  115868. /**
  115869. * detach this feature.
  115870. * Will usually be called by the features manager
  115871. *
  115872. * @returns true if successful.
  115873. */
  115874. detach(): boolean;
  115875. private _onHitTestResults;
  115876. private _onSelect;
  115877. /**
  115878. * Dispose this feature and all of the resources attached
  115879. */
  115880. dispose(): void;
  115881. }
  115882. }
  115883. declare module BABYLON {
  115884. /**
  115885. * Options used in the plane detector module
  115886. */
  115887. export interface IWebXRPlaneDetectorOptions {
  115888. /**
  115889. * The node to use to transform the local results to world coordinates
  115890. */
  115891. worldParentNode?: TransformNode;
  115892. }
  115893. /**
  115894. * A babylon interface for a webxr plane.
  115895. * A Plane is actually a polygon, built from N points in space
  115896. */
  115897. export interface IWebXRPlane {
  115898. /**
  115899. * a babylon-assigned ID for this polygon
  115900. */
  115901. id: number;
  115902. /**
  115903. * the native xr-plane object
  115904. */
  115905. xrPlane: XRPlane;
  115906. /**
  115907. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  115908. */
  115909. polygonDefinition: Array<Vector3>;
  115910. /**
  115911. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  115912. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  115913. */
  115914. transformationMatrix: Matrix;
  115915. }
  115916. /**
  115917. * The plane detector is used to detect planes in the real world when in AR
  115918. * For more information see https://github.com/immersive-web/real-world-geometry/
  115919. */
  115920. export class WebXRPlaneDetector implements IWebXRFeature {
  115921. private _xrSessionManager;
  115922. private _options;
  115923. /**
  115924. * The module's name
  115925. */
  115926. static readonly Name: string;
  115927. /**
  115928. * The (Babylon) version of this module.
  115929. * This is an integer representing the implementation version.
  115930. * This number does not correspond to the webxr specs version
  115931. */
  115932. static readonly Version: number;
  115933. /**
  115934. * Observers registered here will be executed when a new plane was added to the session
  115935. */
  115936. onPlaneAddedObservable: Observable<IWebXRPlane>;
  115937. /**
  115938. * Observers registered here will be executed when a plane is no longer detected in the session
  115939. */
  115940. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  115941. /**
  115942. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  115943. * This can execute N times every frame
  115944. */
  115945. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  115946. private _enabled;
  115947. private _attached;
  115948. private _detectedPlanes;
  115949. private _lastFrameDetected;
  115950. private _observerTracked;
  115951. /**
  115952. * construct a new Plane Detector
  115953. * @param _xrSessionManager an instance of xr Session manager
  115954. * @param _options configuration to use when constructing this feature
  115955. */
  115956. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  115957. /**
  115958. * attach this feature
  115959. * Will usually be called by the features manager
  115960. *
  115961. * @returns true if successful.
  115962. */
  115963. attach(): boolean;
  115964. /**
  115965. * detach this feature.
  115966. * Will usually be called by the features manager
  115967. *
  115968. * @returns true if successful.
  115969. */
  115970. detach(): boolean;
  115971. /**
  115972. * Dispose this feature and all of the resources attached
  115973. */
  115974. dispose(): void;
  115975. private _updatePlaneWithXRPlane;
  115976. /**
  115977. * avoiding using Array.find for global support.
  115978. * @param xrPlane the plane to find in the array
  115979. */
  115980. private findIndexInPlaneArray;
  115981. }
  115982. }
  115983. declare module BABYLON {
  115984. /**
  115985. * Configuration options of the anchor system
  115986. */
  115987. export interface IWebXRAnchorSystemOptions {
  115988. /**
  115989. * a node that will be used to convert local to world coordinates
  115990. */
  115991. worldParentNode?: TransformNode;
  115992. /**
  115993. * should the anchor system use plane detection.
  115994. * If set to true, the plane-detection feature should be set using setPlaneDetector
  115995. */
  115996. usePlaneDetection?: boolean;
  115997. /**
  115998. * Should a new anchor be added every time a select event is triggered
  115999. */
  116000. addAnchorOnSelect?: boolean;
  116001. }
  116002. /**
  116003. * A babylon container for an XR Anchor
  116004. */
  116005. export interface IWebXRAnchor {
  116006. /**
  116007. * A babylon-assigned ID for this anchor
  116008. */
  116009. id: number;
  116010. /**
  116011. * The native anchor object
  116012. */
  116013. xrAnchor: XRAnchor;
  116014. /**
  116015. * Transformation matrix to apply to an object attached to this anchor
  116016. */
  116017. transformationMatrix: Matrix;
  116018. }
  116019. /**
  116020. * An implementation of the anchor system of WebXR.
  116021. * Note that the current documented implementation is not available in any browser. Future implementations
  116022. * will use the frame to create an anchor and not the session or a detected plane
  116023. * For further information see https://github.com/immersive-web/anchors/
  116024. */
  116025. export class WebXRAnchorSystem implements IWebXRFeature {
  116026. private _xrSessionManager;
  116027. private _options;
  116028. /**
  116029. * The module's name
  116030. */
  116031. static readonly Name: string;
  116032. /**
  116033. * The (Babylon) version of this module.
  116034. * This is an integer representing the implementation version.
  116035. * This number does not correspond to the webxr specs version
  116036. */
  116037. static readonly Version: number;
  116038. /**
  116039. * Observers registered here will be executed when a new anchor was added to the session
  116040. */
  116041. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  116042. /**
  116043. * Observers registered here will be executed when an existing anchor updates
  116044. * This can execute N times every frame
  116045. */
  116046. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  116047. /**
  116048. * Observers registered here will be executed when an anchor was removed from the session
  116049. */
  116050. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  116051. private _planeDetector;
  116052. private _hitTestModule;
  116053. private _enabled;
  116054. private _attached;
  116055. private _trackedAnchors;
  116056. private _lastFrameDetected;
  116057. private _observerTracked;
  116058. /**
  116059. * constructs a new anchor system
  116060. * @param _xrSessionManager an instance of WebXRSessionManager
  116061. * @param _options configuration object for this feature
  116062. */
  116063. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  116064. /**
  116065. * set the plane detector to use in order to create anchors from frames
  116066. * @param planeDetector the plane-detector module to use
  116067. * @param enable enable plane-anchors. default is true
  116068. */
  116069. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  116070. /**
  116071. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  116072. * @param hitTestModule the hit-test module to use.
  116073. */
  116074. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  116075. /**
  116076. * attach this feature
  116077. * Will usually be called by the features manager
  116078. *
  116079. * @returns true if successful.
  116080. */
  116081. attach(): boolean;
  116082. /**
  116083. * detach this feature.
  116084. * Will usually be called by the features manager
  116085. *
  116086. * @returns true if successful.
  116087. */
  116088. detach(): boolean;
  116089. /**
  116090. * Dispose this feature and all of the resources attached
  116091. */
  116092. dispose(): void;
  116093. private _onSelect;
  116094. /**
  116095. * Add anchor at a specific XR point.
  116096. *
  116097. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  116098. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  116099. * @returns a promise the fulfills when the anchor was created
  116100. */
  116101. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  116102. private _updateAnchorWithXRFrame;
  116103. /**
  116104. * avoiding using Array.find for global support.
  116105. * @param xrAnchor the plane to find in the array
  116106. */
  116107. private _findIndexInAnchorArray;
  116108. }
  116109. }
  116110. declare module BABYLON {
  116111. /**
  116112. * Options interface for the background remover plugin
  116113. */
  116114. export interface IWebXRBackgroundRemoverOptions {
  116115. /**
  116116. * don't disable the environment helper
  116117. */
  116118. ignoreEnvironmentHelper?: boolean;
  116119. /**
  116120. * flags to configure the removal of the environment helper.
  116121. * If not set, the entire background will be removed. If set, flags should be set as well.
  116122. */
  116123. environmentHelperRemovalFlags?: {
  116124. /**
  116125. * Should the skybox be removed (default false)
  116126. */
  116127. skyBox?: boolean;
  116128. /**
  116129. * Should the ground be removed (default false)
  116130. */
  116131. ground?: boolean;
  116132. };
  116133. /**
  116134. * Further background meshes to disable when entering AR
  116135. */
  116136. backgroundMeshes?: AbstractMesh[];
  116137. }
  116138. /**
  116139. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  116140. */
  116141. export class WebXRBackgroundRemover implements IWebXRFeature {
  116142. private _xrSessionManager;
  116143. /**
  116144. * read-only options to be used in this module
  116145. */
  116146. readonly options: IWebXRBackgroundRemoverOptions;
  116147. /**
  116148. * The module's name
  116149. */
  116150. static readonly Name: string;
  116151. /**
  116152. * The (Babylon) version of this module.
  116153. * This is an integer representing the implementation version.
  116154. * This number does not correspond to the webxr specs version
  116155. */
  116156. static readonly Version: number;
  116157. /**
  116158. * registered observers will be triggered when the background state changes
  116159. */
  116160. onBackgroundStateChangedObservable: Observable<boolean>;
  116161. /**
  116162. * constructs a new background remover module
  116163. * @param _xrSessionManager the session manager for this module
  116164. * @param options read-only options to be used in this module
  116165. */
  116166. constructor(_xrSessionManager: WebXRSessionManager,
  116167. /**
  116168. * read-only options to be used in this module
  116169. */
  116170. options?: IWebXRBackgroundRemoverOptions);
  116171. /**
  116172. * attach this feature
  116173. * Will usually be called by the features manager
  116174. *
  116175. * @returns true if successful.
  116176. */
  116177. attach(): boolean;
  116178. /**
  116179. * detach this feature.
  116180. * Will usually be called by the features manager
  116181. *
  116182. * @returns true if successful.
  116183. */
  116184. detach(): boolean;
  116185. private _setBackgroundState;
  116186. /**
  116187. * Dispose this feature and all of the resources attached
  116188. */
  116189. dispose(): void;
  116190. }
  116191. }
  116192. declare module BABYLON {
  116193. /**
  116194. * The motion controller class for all microsoft mixed reality controllers
  116195. */
  116196. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  116197. /**
  116198. * The base url used to load the left and right controller models
  116199. */
  116200. static MODEL_BASE_URL: string;
  116201. /**
  116202. * The name of the left controller model file
  116203. */
  116204. static MODEL_LEFT_FILENAME: string;
  116205. /**
  116206. * The name of the right controller model file
  116207. */
  116208. static MODEL_RIGHT_FILENAME: string;
  116209. profileId: string;
  116210. protected readonly _mapping: {
  116211. defaultButton: {
  116212. "valueNodeName": string;
  116213. "unpressedNodeName": string;
  116214. "pressedNodeName": string;
  116215. };
  116216. defaultAxis: {
  116217. "valueNodeName": string;
  116218. "minNodeName": string;
  116219. "maxNodeName": string;
  116220. };
  116221. buttons: {
  116222. "xr-standard-trigger": {
  116223. "rootNodeName": string;
  116224. "componentProperty": string;
  116225. "states": string[];
  116226. };
  116227. "xr-standard-squeeze": {
  116228. "rootNodeName": string;
  116229. "componentProperty": string;
  116230. "states": string[];
  116231. };
  116232. "xr-standard-touchpad": {
  116233. "rootNodeName": string;
  116234. "labelAnchorNodeName": string;
  116235. "touchPointNodeName": string;
  116236. };
  116237. "xr-standard-thumbstick": {
  116238. "rootNodeName": string;
  116239. "componentProperty": string;
  116240. "states": string[];
  116241. };
  116242. "menu": {
  116243. "rootNodeName": string;
  116244. "componentProperty": string;
  116245. "states": string[];
  116246. };
  116247. };
  116248. axes: {
  116249. "xr-standard-touchpad": {
  116250. "x-axis": {
  116251. "rootNodeName": string;
  116252. };
  116253. "y-axis": {
  116254. "rootNodeName": string;
  116255. };
  116256. };
  116257. "xr-standard-thumbstick": {
  116258. "x-axis": {
  116259. "rootNodeName": string;
  116260. };
  116261. "y-axis": {
  116262. "rootNodeName": string;
  116263. };
  116264. };
  116265. };
  116266. };
  116267. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  116268. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  116269. private _getChildByName;
  116270. private _getImmediateChildByName;
  116271. protected _getFilenameAndPath(): {
  116272. filename: string;
  116273. path: string;
  116274. };
  116275. protected _updateModel(): void;
  116276. protected _getModelLoadingConstraints(): boolean;
  116277. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116278. }
  116279. }
  116280. declare module BABYLON {
  116281. /**
  116282. * The motion controller class for oculus touch (quest, rift).
  116283. * This class supports legacy mapping as well the standard xr mapping
  116284. */
  116285. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  116286. private _forceLegacyControllers;
  116287. /**
  116288. * The base url used to load the left and right controller models
  116289. */
  116290. static MODEL_BASE_URL: string;
  116291. /**
  116292. * The name of the left controller model file
  116293. */
  116294. static MODEL_LEFT_FILENAME: string;
  116295. /**
  116296. * The name of the right controller model file
  116297. */
  116298. static MODEL_RIGHT_FILENAME: string;
  116299. /**
  116300. * Base Url for the Quest controller model.
  116301. */
  116302. static QUEST_MODEL_BASE_URL: string;
  116303. profileId: string;
  116304. private _modelRootNode;
  116305. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  116306. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  116307. protected _getFilenameAndPath(): {
  116308. filename: string;
  116309. path: string;
  116310. };
  116311. /**
  116312. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  116313. * between the touch and touch 2.
  116314. */
  116315. private _isQuest;
  116316. protected _updateModel(): void;
  116317. protected _getModelLoadingConstraints(): boolean;
  116318. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116319. }
  116320. }
  116321. declare module BABYLON {
  116322. /**
  116323. * The motion controller class for the standard HTC-Vive controllers
  116324. */
  116325. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  116326. /**
  116327. * The base url used to load the left and right controller models
  116328. */
  116329. static MODEL_BASE_URL: string;
  116330. /**
  116331. * File name for the controller model.
  116332. */
  116333. static MODEL_FILENAME: string;
  116334. profileId: string;
  116335. private _modelRootNode;
  116336. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  116337. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  116338. protected _getFilenameAndPath(): {
  116339. filename: string;
  116340. path: string;
  116341. };
  116342. protected _updateModel(): void;
  116343. protected _getModelLoadingConstraints(): boolean;
  116344. protected _setRootMesh(meshes: AbstractMesh[]): void;
  116345. }
  116346. }
  116347. declare module BABYLON {
  116348. /**
  116349. * Contains an array of blocks representing the octree
  116350. */
  116351. export interface IOctreeContainer<T> {
  116352. /**
  116353. * Blocks within the octree
  116354. */
  116355. blocks: Array<OctreeBlock<T>>;
  116356. }
  116357. /**
  116358. * Class used to store a cell in an octree
  116359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116360. */
  116361. export class OctreeBlock<T> {
  116362. /**
  116363. * Gets the content of the current block
  116364. */
  116365. entries: T[];
  116366. /**
  116367. * Gets the list of block children
  116368. */
  116369. blocks: Array<OctreeBlock<T>>;
  116370. private _depth;
  116371. private _maxDepth;
  116372. private _capacity;
  116373. private _minPoint;
  116374. private _maxPoint;
  116375. private _boundingVectors;
  116376. private _creationFunc;
  116377. /**
  116378. * Creates a new block
  116379. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  116380. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  116381. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  116382. * @param depth defines the current depth of this block in the octree
  116383. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  116384. * @param creationFunc defines a callback to call when an element is added to the block
  116385. */
  116386. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  116387. /**
  116388. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  116389. */
  116390. get capacity(): number;
  116391. /**
  116392. * Gets the minimum vector (in world space) of the block's bounding box
  116393. */
  116394. get minPoint(): Vector3;
  116395. /**
  116396. * Gets the maximum vector (in world space) of the block's bounding box
  116397. */
  116398. get maxPoint(): Vector3;
  116399. /**
  116400. * Add a new element to this block
  116401. * @param entry defines the element to add
  116402. */
  116403. addEntry(entry: T): void;
  116404. /**
  116405. * Remove an element from this block
  116406. * @param entry defines the element to remove
  116407. */
  116408. removeEntry(entry: T): void;
  116409. /**
  116410. * Add an array of elements to this block
  116411. * @param entries defines the array of elements to add
  116412. */
  116413. addEntries(entries: T[]): void;
  116414. /**
  116415. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  116416. * @param frustumPlanes defines the frustum planes to test
  116417. * @param selection defines the array to store current content if selection is positive
  116418. * @param allowDuplicate defines if the selection array can contains duplicated entries
  116419. */
  116420. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  116421. /**
  116422. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  116423. * @param sphereCenter defines the bounding sphere center
  116424. * @param sphereRadius defines the bounding sphere radius
  116425. * @param selection defines the array to store current content if selection is positive
  116426. * @param allowDuplicate defines if the selection array can contains duplicated entries
  116427. */
  116428. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  116429. /**
  116430. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  116431. * @param ray defines the ray to test with
  116432. * @param selection defines the array to store current content if selection is positive
  116433. */
  116434. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  116435. /**
  116436. * Subdivide the content into child blocks (this block will then be empty)
  116437. */
  116438. createInnerBlocks(): void;
  116439. /**
  116440. * @hidden
  116441. */
  116442. 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;
  116443. }
  116444. }
  116445. declare module BABYLON {
  116446. /**
  116447. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  116448. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116449. */
  116450. export class Octree<T> {
  116451. /** 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.) */
  116452. maxDepth: number;
  116453. /**
  116454. * Blocks within the octree containing objects
  116455. */
  116456. blocks: Array<OctreeBlock<T>>;
  116457. /**
  116458. * Content stored in the octree
  116459. */
  116460. dynamicContent: T[];
  116461. private _maxBlockCapacity;
  116462. private _selectionContent;
  116463. private _creationFunc;
  116464. /**
  116465. * Creates a octree
  116466. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116467. * @param creationFunc function to be used to instatiate the octree
  116468. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  116469. * @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.)
  116470. */
  116471. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  116472. /** 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.) */
  116473. maxDepth?: number);
  116474. /**
  116475. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  116476. * @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);
  116477. * @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);
  116478. * @param entries meshes to be added to the octree blocks
  116479. */
  116480. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  116481. /**
  116482. * Adds a mesh to the octree
  116483. * @param entry Mesh to add to the octree
  116484. */
  116485. addMesh(entry: T): void;
  116486. /**
  116487. * Remove an element from the octree
  116488. * @param entry defines the element to remove
  116489. */
  116490. removeMesh(entry: T): void;
  116491. /**
  116492. * Selects an array of meshes within the frustum
  116493. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  116494. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  116495. * @returns array of meshes within the frustum
  116496. */
  116497. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  116498. /**
  116499. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  116500. * @param sphereCenter defines the bounding sphere center
  116501. * @param sphereRadius defines the bounding sphere radius
  116502. * @param allowDuplicate defines if the selection array can contains duplicated entries
  116503. * @returns an array of objects that intersect the sphere
  116504. */
  116505. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  116506. /**
  116507. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  116508. * @param ray defines the ray to test with
  116509. * @returns array of intersected objects
  116510. */
  116511. intersectsRay(ray: Ray): SmartArray<T>;
  116512. /**
  116513. * Adds a mesh into the octree block if it intersects the block
  116514. */
  116515. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  116516. /**
  116517. * Adds a submesh into the octree block if it intersects the block
  116518. */
  116519. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  116520. }
  116521. }
  116522. declare module BABYLON {
  116523. interface Scene {
  116524. /**
  116525. * @hidden
  116526. * Backing Filed
  116527. */
  116528. _selectionOctree: Octree<AbstractMesh>;
  116529. /**
  116530. * Gets the octree used to boost mesh selection (picking)
  116531. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116532. */
  116533. selectionOctree: Octree<AbstractMesh>;
  116534. /**
  116535. * Creates or updates the octree used to boost selection (picking)
  116536. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116537. * @param maxCapacity defines the maximum capacity per leaf
  116538. * @param maxDepth defines the maximum depth of the octree
  116539. * @returns an octree of AbstractMesh
  116540. */
  116541. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  116542. }
  116543. interface AbstractMesh {
  116544. /**
  116545. * @hidden
  116546. * Backing Field
  116547. */
  116548. _submeshesOctree: Octree<SubMesh>;
  116549. /**
  116550. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  116551. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  116552. * @param maxCapacity defines the maximum size of each block (64 by default)
  116553. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  116554. * @returns the new octree
  116555. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  116556. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  116557. */
  116558. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  116559. }
  116560. /**
  116561. * Defines the octree scene component responsible to manage any octrees
  116562. * in a given scene.
  116563. */
  116564. export class OctreeSceneComponent {
  116565. /**
  116566. * The component name help to identify the component in the list of scene components.
  116567. */
  116568. readonly name: string;
  116569. /**
  116570. * The scene the component belongs to.
  116571. */
  116572. scene: Scene;
  116573. /**
  116574. * Indicates if the meshes have been checked to make sure they are isEnabled()
  116575. */
  116576. readonly checksIsEnabled: boolean;
  116577. /**
  116578. * Creates a new instance of the component for the given scene
  116579. * @param scene Defines the scene to register the component in
  116580. */
  116581. constructor(scene: Scene);
  116582. /**
  116583. * Registers the component in a given scene
  116584. */
  116585. register(): void;
  116586. /**
  116587. * Return the list of active meshes
  116588. * @returns the list of active meshes
  116589. */
  116590. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  116591. /**
  116592. * Return the list of active sub meshes
  116593. * @param mesh The mesh to get the candidates sub meshes from
  116594. * @returns the list of active sub meshes
  116595. */
  116596. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  116597. private _tempRay;
  116598. /**
  116599. * Return the list of sub meshes intersecting with a given local ray
  116600. * @param mesh defines the mesh to find the submesh for
  116601. * @param localRay defines the ray in local space
  116602. * @returns the list of intersecting sub meshes
  116603. */
  116604. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  116605. /**
  116606. * Return the list of sub meshes colliding with a collider
  116607. * @param mesh defines the mesh to find the submesh for
  116608. * @param collider defines the collider to evaluate the collision against
  116609. * @returns the list of colliding sub meshes
  116610. */
  116611. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  116612. /**
  116613. * Rebuilds the elements related to this component in case of
  116614. * context lost for instance.
  116615. */
  116616. rebuild(): void;
  116617. /**
  116618. * Disposes the component and the associated ressources.
  116619. */
  116620. dispose(): void;
  116621. }
  116622. }
  116623. declare module BABYLON {
  116624. /**
  116625. * Renders a layer on top of an existing scene
  116626. */
  116627. export class UtilityLayerRenderer implements IDisposable {
  116628. /** the original scene that will be rendered on top of */
  116629. originalScene: Scene;
  116630. private _pointerCaptures;
  116631. private _lastPointerEvents;
  116632. private static _DefaultUtilityLayer;
  116633. private static _DefaultKeepDepthUtilityLayer;
  116634. private _sharedGizmoLight;
  116635. private _renderCamera;
  116636. /**
  116637. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  116638. * @returns the camera that is used when rendering the utility layer
  116639. */
  116640. getRenderCamera(): Nullable<Camera>;
  116641. /**
  116642. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  116643. * @param cam the camera that should be used when rendering the utility layer
  116644. */
  116645. setRenderCamera(cam: Nullable<Camera>): void;
  116646. /**
  116647. * @hidden
  116648. * Light which used by gizmos to get light shading
  116649. */
  116650. _getSharedGizmoLight(): HemisphericLight;
  116651. /**
  116652. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  116653. */
  116654. pickUtilitySceneFirst: boolean;
  116655. /**
  116656. * 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)
  116657. */
  116658. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  116659. /**
  116660. * 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)
  116661. */
  116662. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  116663. /**
  116664. * The scene that is rendered on top of the original scene
  116665. */
  116666. utilityLayerScene: Scene;
  116667. /**
  116668. * If the utility layer should automatically be rendered on top of existing scene
  116669. */
  116670. shouldRender: boolean;
  116671. /**
  116672. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  116673. */
  116674. onlyCheckPointerDownEvents: boolean;
  116675. /**
  116676. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  116677. */
  116678. processAllEvents: boolean;
  116679. /**
  116680. * Observable raised when the pointer move from the utility layer scene to the main scene
  116681. */
  116682. onPointerOutObservable: Observable<number>;
  116683. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  116684. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  116685. private _afterRenderObserver;
  116686. private _sceneDisposeObserver;
  116687. private _originalPointerObserver;
  116688. /**
  116689. * Instantiates a UtilityLayerRenderer
  116690. * @param originalScene the original scene that will be rendered on top of
  116691. * @param handleEvents boolean indicating if the utility layer should handle events
  116692. */
  116693. constructor(
  116694. /** the original scene that will be rendered on top of */
  116695. originalScene: Scene, handleEvents?: boolean);
  116696. private _notifyObservers;
  116697. /**
  116698. * Renders the utility layers scene on top of the original scene
  116699. */
  116700. render(): void;
  116701. /**
  116702. * Disposes of the renderer
  116703. */
  116704. dispose(): void;
  116705. private _updateCamera;
  116706. }
  116707. }
  116708. declare module BABYLON {
  116709. /**
  116710. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  116711. */
  116712. export class Gizmo implements IDisposable {
  116713. /** The utility layer the gizmo will be added to */
  116714. gizmoLayer: UtilityLayerRenderer;
  116715. /**
  116716. * The root mesh of the gizmo
  116717. */
  116718. _rootMesh: Mesh;
  116719. private _attachedMesh;
  116720. /**
  116721. * Ratio for the scale of the gizmo (Default: 1)
  116722. */
  116723. scaleRatio: number;
  116724. /**
  116725. * If a custom mesh has been set (Default: false)
  116726. */
  116727. protected _customMeshSet: boolean;
  116728. /**
  116729. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  116730. * * When set, interactions will be enabled
  116731. */
  116732. get attachedMesh(): Nullable<AbstractMesh>;
  116733. set attachedMesh(value: Nullable<AbstractMesh>);
  116734. /**
  116735. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  116736. * @param mesh The mesh to replace the default mesh of the gizmo
  116737. */
  116738. setCustomMesh(mesh: Mesh): void;
  116739. /**
  116740. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  116741. */
  116742. updateGizmoRotationToMatchAttachedMesh: boolean;
  116743. /**
  116744. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  116745. */
  116746. updateGizmoPositionToMatchAttachedMesh: boolean;
  116747. /**
  116748. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  116749. */
  116750. updateScale: boolean;
  116751. protected _interactionsEnabled: boolean;
  116752. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  116753. private _beforeRenderObserver;
  116754. private _tempVector;
  116755. /**
  116756. * Creates a gizmo
  116757. * @param gizmoLayer The utility layer the gizmo will be added to
  116758. */
  116759. constructor(
  116760. /** The utility layer the gizmo will be added to */
  116761. gizmoLayer?: UtilityLayerRenderer);
  116762. /**
  116763. * Updates the gizmo to match the attached mesh's position/rotation
  116764. */
  116765. protected _update(): void;
  116766. /**
  116767. * Disposes of the gizmo
  116768. */
  116769. dispose(): void;
  116770. }
  116771. }
  116772. declare module BABYLON {
  116773. /**
  116774. * Single plane drag gizmo
  116775. */
  116776. export class PlaneDragGizmo extends Gizmo {
  116777. /**
  116778. * Drag behavior responsible for the gizmos dragging interactions
  116779. */
  116780. dragBehavior: PointerDragBehavior;
  116781. private _pointerObserver;
  116782. /**
  116783. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  116784. */
  116785. snapDistance: number;
  116786. /**
  116787. * Event that fires each time the gizmo snaps to a new location.
  116788. * * snapDistance is the the change in distance
  116789. */
  116790. onSnapObservable: Observable<{
  116791. snapDistance: number;
  116792. }>;
  116793. private _plane;
  116794. private _coloredMaterial;
  116795. private _hoverMaterial;
  116796. private _isEnabled;
  116797. private _parent;
  116798. /** @hidden */
  116799. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  116800. /** @hidden */
  116801. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  116802. /**
  116803. * Creates a PlaneDragGizmo
  116804. * @param gizmoLayer The utility layer the gizmo will be added to
  116805. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  116806. * @param color The color of the gizmo
  116807. */
  116808. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  116809. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  116810. /**
  116811. * If the gizmo is enabled
  116812. */
  116813. set isEnabled(value: boolean);
  116814. get isEnabled(): boolean;
  116815. /**
  116816. * Disposes of the gizmo
  116817. */
  116818. dispose(): void;
  116819. }
  116820. }
  116821. declare module BABYLON {
  116822. /**
  116823. * Gizmo that enables dragging a mesh along 3 axis
  116824. */
  116825. export class PositionGizmo extends Gizmo {
  116826. /**
  116827. * Internal gizmo used for interactions on the x axis
  116828. */
  116829. xGizmo: AxisDragGizmo;
  116830. /**
  116831. * Internal gizmo used for interactions on the y axis
  116832. */
  116833. yGizmo: AxisDragGizmo;
  116834. /**
  116835. * Internal gizmo used for interactions on the z axis
  116836. */
  116837. zGizmo: AxisDragGizmo;
  116838. /**
  116839. * Internal gizmo used for interactions on the yz plane
  116840. */
  116841. xPlaneGizmo: PlaneDragGizmo;
  116842. /**
  116843. * Internal gizmo used for interactions on the xz plane
  116844. */
  116845. yPlaneGizmo: PlaneDragGizmo;
  116846. /**
  116847. * Internal gizmo used for interactions on the xy plane
  116848. */
  116849. zPlaneGizmo: PlaneDragGizmo;
  116850. /**
  116851. * private variables
  116852. */
  116853. private _meshAttached;
  116854. private _updateGizmoRotationToMatchAttachedMesh;
  116855. private _snapDistance;
  116856. private _scaleRatio;
  116857. /** Fires an event when any of it's sub gizmos are dragged */
  116858. onDragStartObservable: Observable<unknown>;
  116859. /** Fires an event when any of it's sub gizmos are released from dragging */
  116860. onDragEndObservable: Observable<unknown>;
  116861. /**
  116862. * If set to true, planar drag is enabled
  116863. */
  116864. private _planarGizmoEnabled;
  116865. get attachedMesh(): Nullable<AbstractMesh>;
  116866. set attachedMesh(mesh: Nullable<AbstractMesh>);
  116867. /**
  116868. * Creates a PositionGizmo
  116869. * @param gizmoLayer The utility layer the gizmo will be added to
  116870. */
  116871. constructor(gizmoLayer?: UtilityLayerRenderer);
  116872. /**
  116873. * If the planar drag gizmo is enabled
  116874. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  116875. */
  116876. set planarGizmoEnabled(value: boolean);
  116877. get planarGizmoEnabled(): boolean;
  116878. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  116879. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  116880. /**
  116881. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  116882. */
  116883. set snapDistance(value: number);
  116884. get snapDistance(): number;
  116885. /**
  116886. * Ratio for the scale of the gizmo (Default: 1)
  116887. */
  116888. set scaleRatio(value: number);
  116889. get scaleRatio(): number;
  116890. /**
  116891. * Disposes of the gizmo
  116892. */
  116893. dispose(): void;
  116894. /**
  116895. * CustomMeshes are not supported by this gizmo
  116896. * @param mesh The mesh to replace the default mesh of the gizmo
  116897. */
  116898. setCustomMesh(mesh: Mesh): void;
  116899. }
  116900. }
  116901. declare module BABYLON {
  116902. /**
  116903. * Single axis drag gizmo
  116904. */
  116905. export class AxisDragGizmo extends Gizmo {
  116906. /**
  116907. * Drag behavior responsible for the gizmos dragging interactions
  116908. */
  116909. dragBehavior: PointerDragBehavior;
  116910. private _pointerObserver;
  116911. /**
  116912. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  116913. */
  116914. snapDistance: number;
  116915. /**
  116916. * Event that fires each time the gizmo snaps to a new location.
  116917. * * snapDistance is the the change in distance
  116918. */
  116919. onSnapObservable: Observable<{
  116920. snapDistance: number;
  116921. }>;
  116922. private _isEnabled;
  116923. private _parent;
  116924. private _arrow;
  116925. private _coloredMaterial;
  116926. private _hoverMaterial;
  116927. /** @hidden */
  116928. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  116929. /** @hidden */
  116930. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  116931. /**
  116932. * Creates an AxisDragGizmo
  116933. * @param gizmoLayer The utility layer the gizmo will be added to
  116934. * @param dragAxis The axis which the gizmo will be able to drag on
  116935. * @param color The color of the gizmo
  116936. */
  116937. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  116938. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  116939. /**
  116940. * If the gizmo is enabled
  116941. */
  116942. set isEnabled(value: boolean);
  116943. get isEnabled(): boolean;
  116944. /**
  116945. * Disposes of the gizmo
  116946. */
  116947. dispose(): void;
  116948. }
  116949. }
  116950. declare module BABYLON.Debug {
  116951. /**
  116952. * The Axes viewer will show 3 axes in a specific point in space
  116953. */
  116954. export class AxesViewer {
  116955. private _xAxis;
  116956. private _yAxis;
  116957. private _zAxis;
  116958. private _scaleLinesFactor;
  116959. private _instanced;
  116960. /**
  116961. * Gets the hosting scene
  116962. */
  116963. scene: Scene;
  116964. /**
  116965. * Gets or sets a number used to scale line length
  116966. */
  116967. scaleLines: number;
  116968. /** Gets the node hierarchy used to render x-axis */
  116969. get xAxis(): TransformNode;
  116970. /** Gets the node hierarchy used to render y-axis */
  116971. get yAxis(): TransformNode;
  116972. /** Gets the node hierarchy used to render z-axis */
  116973. get zAxis(): TransformNode;
  116974. /**
  116975. * Creates a new AxesViewer
  116976. * @param scene defines the hosting scene
  116977. * @param scaleLines defines a number used to scale line length (1 by default)
  116978. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  116979. * @param xAxis defines the node hierarchy used to render the x-axis
  116980. * @param yAxis defines the node hierarchy used to render the y-axis
  116981. * @param zAxis defines the node hierarchy used to render the z-axis
  116982. */
  116983. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  116984. /**
  116985. * Force the viewer to update
  116986. * @param position defines the position of the viewer
  116987. * @param xaxis defines the x axis of the viewer
  116988. * @param yaxis defines the y axis of the viewer
  116989. * @param zaxis defines the z axis of the viewer
  116990. */
  116991. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  116992. /**
  116993. * Creates an instance of this axes viewer.
  116994. * @returns a new axes viewer with instanced meshes
  116995. */
  116996. createInstance(): AxesViewer;
  116997. /** Releases resources */
  116998. dispose(): void;
  116999. private static _SetRenderingGroupId;
  117000. }
  117001. }
  117002. declare module BABYLON.Debug {
  117003. /**
  117004. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  117005. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  117006. */
  117007. export class BoneAxesViewer extends AxesViewer {
  117008. /**
  117009. * Gets or sets the target mesh where to display the axes viewer
  117010. */
  117011. mesh: Nullable<Mesh>;
  117012. /**
  117013. * Gets or sets the target bone where to display the axes viewer
  117014. */
  117015. bone: Nullable<Bone>;
  117016. /** Gets current position */
  117017. pos: Vector3;
  117018. /** Gets direction of X axis */
  117019. xaxis: Vector3;
  117020. /** Gets direction of Y axis */
  117021. yaxis: Vector3;
  117022. /** Gets direction of Z axis */
  117023. zaxis: Vector3;
  117024. /**
  117025. * Creates a new BoneAxesViewer
  117026. * @param scene defines the hosting scene
  117027. * @param bone defines the target bone
  117028. * @param mesh defines the target mesh
  117029. * @param scaleLines defines a scaling factor for line length (1 by default)
  117030. */
  117031. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  117032. /**
  117033. * Force the viewer to update
  117034. */
  117035. update(): void;
  117036. /** Releases resources */
  117037. dispose(): void;
  117038. }
  117039. }
  117040. declare module BABYLON {
  117041. /**
  117042. * Interface used to define scene explorer extensibility option
  117043. */
  117044. export interface IExplorerExtensibilityOption {
  117045. /**
  117046. * Define the option label
  117047. */
  117048. label: string;
  117049. /**
  117050. * Defines the action to execute on click
  117051. */
  117052. action: (entity: any) => void;
  117053. }
  117054. /**
  117055. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  117056. */
  117057. export interface IExplorerExtensibilityGroup {
  117058. /**
  117059. * Defines a predicate to test if a given type mut be extended
  117060. */
  117061. predicate: (entity: any) => boolean;
  117062. /**
  117063. * Gets the list of options added to a type
  117064. */
  117065. entries: IExplorerExtensibilityOption[];
  117066. }
  117067. /**
  117068. * Interface used to define the options to use to create the Inspector
  117069. */
  117070. export interface IInspectorOptions {
  117071. /**
  117072. * Display in overlay mode (default: false)
  117073. */
  117074. overlay?: boolean;
  117075. /**
  117076. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  117077. */
  117078. globalRoot?: HTMLElement;
  117079. /**
  117080. * Display the Scene explorer
  117081. */
  117082. showExplorer?: boolean;
  117083. /**
  117084. * Display the property inspector
  117085. */
  117086. showInspector?: boolean;
  117087. /**
  117088. * Display in embed mode (both panes on the right)
  117089. */
  117090. embedMode?: boolean;
  117091. /**
  117092. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  117093. */
  117094. handleResize?: boolean;
  117095. /**
  117096. * Allow the panes to popup (default: true)
  117097. */
  117098. enablePopup?: boolean;
  117099. /**
  117100. * Allow the panes to be closed by users (default: true)
  117101. */
  117102. enableClose?: boolean;
  117103. /**
  117104. * Optional list of extensibility entries
  117105. */
  117106. explorerExtensibility?: IExplorerExtensibilityGroup[];
  117107. /**
  117108. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  117109. */
  117110. inspectorURL?: string;
  117111. /**
  117112. * Optional initial tab (default to DebugLayerTab.Properties)
  117113. */
  117114. initialTab?: DebugLayerTab;
  117115. }
  117116. interface Scene {
  117117. /**
  117118. * @hidden
  117119. * Backing field
  117120. */
  117121. _debugLayer: DebugLayer;
  117122. /**
  117123. * Gets the debug layer (aka Inspector) associated with the scene
  117124. * @see http://doc.babylonjs.com/features/playground_debuglayer
  117125. */
  117126. debugLayer: DebugLayer;
  117127. }
  117128. /**
  117129. * Enum of inspector action tab
  117130. */
  117131. export enum DebugLayerTab {
  117132. /**
  117133. * Properties tag (default)
  117134. */
  117135. Properties = 0,
  117136. /**
  117137. * Debug tab
  117138. */
  117139. Debug = 1,
  117140. /**
  117141. * Statistics tab
  117142. */
  117143. Statistics = 2,
  117144. /**
  117145. * Tools tab
  117146. */
  117147. Tools = 3,
  117148. /**
  117149. * Settings tab
  117150. */
  117151. Settings = 4
  117152. }
  117153. /**
  117154. * The debug layer (aka Inspector) is the go to tool in order to better understand
  117155. * what is happening in your scene
  117156. * @see http://doc.babylonjs.com/features/playground_debuglayer
  117157. */
  117158. export class DebugLayer {
  117159. /**
  117160. * Define the url to get the inspector script from.
  117161. * By default it uses the babylonjs CDN.
  117162. * @ignoreNaming
  117163. */
  117164. static InspectorURL: string;
  117165. private _scene;
  117166. private BJSINSPECTOR;
  117167. private _onPropertyChangedObservable?;
  117168. /**
  117169. * Observable triggered when a property is changed through the inspector.
  117170. */
  117171. get onPropertyChangedObservable(): any;
  117172. /**
  117173. * Instantiates a new debug layer.
  117174. * The debug layer (aka Inspector) is the go to tool in order to better understand
  117175. * what is happening in your scene
  117176. * @see http://doc.babylonjs.com/features/playground_debuglayer
  117177. * @param scene Defines the scene to inspect
  117178. */
  117179. constructor(scene: Scene);
  117180. /** Creates the inspector window. */
  117181. private _createInspector;
  117182. /**
  117183. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  117184. * @param entity defines the entity to select
  117185. * @param lineContainerTitle defines the specific block to highlight
  117186. */
  117187. select(entity: any, lineContainerTitle?: string): void;
  117188. /** Get the inspector from bundle or global */
  117189. private _getGlobalInspector;
  117190. /**
  117191. * Get if the inspector is visible or not.
  117192. * @returns true if visible otherwise, false
  117193. */
  117194. isVisible(): boolean;
  117195. /**
  117196. * Hide the inspector and close its window.
  117197. */
  117198. hide(): void;
  117199. /**
  117200. * Launch the debugLayer.
  117201. * @param config Define the configuration of the inspector
  117202. * @return a promise fulfilled when the debug layer is visible
  117203. */
  117204. show(config?: IInspectorOptions): Promise<DebugLayer>;
  117205. }
  117206. }
  117207. declare module BABYLON {
  117208. /**
  117209. * Class containing static functions to help procedurally build meshes
  117210. */
  117211. export class BoxBuilder {
  117212. /**
  117213. * Creates a box mesh
  117214. * * The parameter `size` sets the size (float) of each box side (default 1)
  117215. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  117216. * * 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)
  117217. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117221. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117222. * @param name defines the name of the mesh
  117223. * @param options defines the options used to create the mesh
  117224. * @param scene defines the hosting scene
  117225. * @returns the box mesh
  117226. */
  117227. static CreateBox(name: string, options: {
  117228. size?: number;
  117229. width?: number;
  117230. height?: number;
  117231. depth?: number;
  117232. faceUV?: Vector4[];
  117233. faceColors?: Color4[];
  117234. sideOrientation?: number;
  117235. frontUVs?: Vector4;
  117236. backUVs?: Vector4;
  117237. wrap?: boolean;
  117238. topBaseAt?: number;
  117239. bottomBaseAt?: number;
  117240. updatable?: boolean;
  117241. }, scene?: Nullable<Scene>): Mesh;
  117242. }
  117243. }
  117244. declare module BABYLON {
  117245. /**
  117246. * Class containing static functions to help procedurally build meshes
  117247. */
  117248. export class SphereBuilder {
  117249. /**
  117250. * Creates a sphere mesh
  117251. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117252. * * 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`)
  117253. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117254. * * 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
  117255. * * 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)
  117256. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117257. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117259. * @param name defines the name of the mesh
  117260. * @param options defines the options used to create the mesh
  117261. * @param scene defines the hosting scene
  117262. * @returns the sphere mesh
  117263. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117264. */
  117265. static CreateSphere(name: string, options: {
  117266. segments?: number;
  117267. diameter?: number;
  117268. diameterX?: number;
  117269. diameterY?: number;
  117270. diameterZ?: number;
  117271. arc?: number;
  117272. slice?: number;
  117273. sideOrientation?: number;
  117274. frontUVs?: Vector4;
  117275. backUVs?: Vector4;
  117276. updatable?: boolean;
  117277. }, scene?: Nullable<Scene>): Mesh;
  117278. }
  117279. }
  117280. declare module BABYLON.Debug {
  117281. /**
  117282. * Used to show the physics impostor around the specific mesh
  117283. */
  117284. export class PhysicsViewer {
  117285. /** @hidden */
  117286. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  117287. /** @hidden */
  117288. protected _meshes: Array<Nullable<AbstractMesh>>;
  117289. /** @hidden */
  117290. protected _scene: Nullable<Scene>;
  117291. /** @hidden */
  117292. protected _numMeshes: number;
  117293. /** @hidden */
  117294. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  117295. private _renderFunction;
  117296. private _utilityLayer;
  117297. private _debugBoxMesh;
  117298. private _debugSphereMesh;
  117299. private _debugCylinderMesh;
  117300. private _debugMaterial;
  117301. private _debugMeshMeshes;
  117302. /**
  117303. * Creates a new PhysicsViewer
  117304. * @param scene defines the hosting scene
  117305. */
  117306. constructor(scene: Scene);
  117307. /** @hidden */
  117308. protected _updateDebugMeshes(): void;
  117309. /**
  117310. * Renders a specified physic impostor
  117311. * @param impostor defines the impostor to render
  117312. * @param targetMesh defines the mesh represented by the impostor
  117313. * @returns the new debug mesh used to render the impostor
  117314. */
  117315. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  117316. /**
  117317. * Hides a specified physic impostor
  117318. * @param impostor defines the impostor to hide
  117319. */
  117320. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  117321. private _getDebugMaterial;
  117322. private _getDebugBoxMesh;
  117323. private _getDebugSphereMesh;
  117324. private _getDebugCylinderMesh;
  117325. private _getDebugMeshMesh;
  117326. private _getDebugMesh;
  117327. /** Releases all resources */
  117328. dispose(): void;
  117329. }
  117330. }
  117331. declare module BABYLON {
  117332. /**
  117333. * Class containing static functions to help procedurally build meshes
  117334. */
  117335. export class LinesBuilder {
  117336. /**
  117337. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117338. * * 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
  117339. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117340. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117341. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117342. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117343. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117344. * * 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
  117345. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117347. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117348. * @param name defines the name of the new line system
  117349. * @param options defines the options used to create the line system
  117350. * @param scene defines the hosting scene
  117351. * @returns a new line system mesh
  117352. */
  117353. static CreateLineSystem(name: string, options: {
  117354. lines: Vector3[][];
  117355. updatable?: boolean;
  117356. instance?: Nullable<LinesMesh>;
  117357. colors?: Nullable<Color4[][]>;
  117358. useVertexAlpha?: boolean;
  117359. }, scene: Nullable<Scene>): LinesMesh;
  117360. /**
  117361. * Creates a line mesh
  117362. * 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
  117363. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117364. * * The parameter `points` is an array successive Vector3
  117365. * * 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
  117366. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117367. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117368. * * When updating an instance, remember that only point positions can change, not the number of points
  117369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117371. * @param name defines the name of the new line system
  117372. * @param options defines the options used to create the line system
  117373. * @param scene defines the hosting scene
  117374. * @returns a new line mesh
  117375. */
  117376. static CreateLines(name: string, options: {
  117377. points: Vector3[];
  117378. updatable?: boolean;
  117379. instance?: Nullable<LinesMesh>;
  117380. colors?: Color4[];
  117381. useVertexAlpha?: boolean;
  117382. }, scene?: Nullable<Scene>): LinesMesh;
  117383. /**
  117384. * Creates a dashed line mesh
  117385. * * 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
  117386. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117387. * * The parameter `points` is an array successive Vector3
  117388. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117389. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117390. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117391. * * 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
  117392. * * When updating an instance, remember that only point positions can change, not the number of points
  117393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117394. * @param name defines the name of the mesh
  117395. * @param options defines the options used to create the mesh
  117396. * @param scene defines the hosting scene
  117397. * @returns the dashed line mesh
  117398. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117399. */
  117400. static CreateDashedLines(name: string, options: {
  117401. points: Vector3[];
  117402. dashSize?: number;
  117403. gapSize?: number;
  117404. dashNb?: number;
  117405. updatable?: boolean;
  117406. instance?: LinesMesh;
  117407. }, scene?: Nullable<Scene>): LinesMesh;
  117408. }
  117409. }
  117410. declare module BABYLON {
  117411. /**
  117412. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  117413. * in order to better appreciate the issue one might have.
  117414. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  117415. */
  117416. export class RayHelper {
  117417. /**
  117418. * Defines the ray we are currently tryin to visualize.
  117419. */
  117420. ray: Nullable<Ray>;
  117421. private _renderPoints;
  117422. private _renderLine;
  117423. private _renderFunction;
  117424. private _scene;
  117425. private _updateToMeshFunction;
  117426. private _attachedToMesh;
  117427. private _meshSpaceDirection;
  117428. private _meshSpaceOrigin;
  117429. /**
  117430. * Helper function to create a colored helper in a scene in one line.
  117431. * @param ray Defines the ray we are currently tryin to visualize
  117432. * @param scene Defines the scene the ray is used in
  117433. * @param color Defines the color we want to see the ray in
  117434. * @returns The newly created ray helper.
  117435. */
  117436. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  117437. /**
  117438. * Instantiate a new ray helper.
  117439. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  117440. * in order to better appreciate the issue one might have.
  117441. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  117442. * @param ray Defines the ray we are currently tryin to visualize
  117443. */
  117444. constructor(ray: Ray);
  117445. /**
  117446. * Shows the ray we are willing to debug.
  117447. * @param scene Defines the scene the ray needs to be rendered in
  117448. * @param color Defines the color the ray needs to be rendered in
  117449. */
  117450. show(scene: Scene, color?: Color3): void;
  117451. /**
  117452. * Hides the ray we are debugging.
  117453. */
  117454. hide(): void;
  117455. private _render;
  117456. /**
  117457. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  117458. * @param mesh Defines the mesh we want the helper attached to
  117459. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  117460. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  117461. * @param length Defines the length of the ray
  117462. */
  117463. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  117464. /**
  117465. * Detach the ray helper from the mesh it has previously been attached to.
  117466. */
  117467. detachFromMesh(): void;
  117468. private _updateToMesh;
  117469. /**
  117470. * Dispose the helper and release its associated resources.
  117471. */
  117472. dispose(): void;
  117473. }
  117474. }
  117475. declare module BABYLON.Debug {
  117476. /**
  117477. * Class used to render a debug view of a given skeleton
  117478. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  117479. */
  117480. export class SkeletonViewer {
  117481. /** defines the skeleton to render */
  117482. skeleton: Skeleton;
  117483. /** defines the mesh attached to the skeleton */
  117484. mesh: AbstractMesh;
  117485. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  117486. autoUpdateBonesMatrices: boolean;
  117487. /** defines the rendering group id to use with the viewer */
  117488. renderingGroupId: number;
  117489. /** Gets or sets the color used to render the skeleton */
  117490. color: Color3;
  117491. private _scene;
  117492. private _debugLines;
  117493. private _debugMesh;
  117494. private _isEnabled;
  117495. private _renderFunction;
  117496. private _utilityLayer;
  117497. /**
  117498. * Returns the mesh used to render the bones
  117499. */
  117500. get debugMesh(): Nullable<LinesMesh>;
  117501. /**
  117502. * Creates a new SkeletonViewer
  117503. * @param skeleton defines the skeleton to render
  117504. * @param mesh defines the mesh attached to the skeleton
  117505. * @param scene defines the hosting scene
  117506. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  117507. * @param renderingGroupId defines the rendering group id to use with the viewer
  117508. */
  117509. constructor(
  117510. /** defines the skeleton to render */
  117511. skeleton: Skeleton,
  117512. /** defines the mesh attached to the skeleton */
  117513. mesh: AbstractMesh, scene: Scene,
  117514. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  117515. autoUpdateBonesMatrices?: boolean,
  117516. /** defines the rendering group id to use with the viewer */
  117517. renderingGroupId?: number);
  117518. /** Gets or sets a boolean indicating if the viewer is enabled */
  117519. set isEnabled(value: boolean);
  117520. get isEnabled(): boolean;
  117521. private _getBonePosition;
  117522. private _getLinesForBonesWithLength;
  117523. private _getLinesForBonesNoLength;
  117524. /** Update the viewer to sync with current skeleton state */
  117525. update(): void;
  117526. /** Release associated resources */
  117527. dispose(): void;
  117528. }
  117529. }
  117530. declare module BABYLON {
  117531. /**
  117532. * Options to create the null engine
  117533. */
  117534. export class NullEngineOptions {
  117535. /**
  117536. * Render width (Default: 512)
  117537. */
  117538. renderWidth: number;
  117539. /**
  117540. * Render height (Default: 256)
  117541. */
  117542. renderHeight: number;
  117543. /**
  117544. * Texture size (Default: 512)
  117545. */
  117546. textureSize: number;
  117547. /**
  117548. * If delta time between frames should be constant
  117549. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117550. */
  117551. deterministicLockstep: boolean;
  117552. /**
  117553. * Maximum about of steps between frames (Default: 4)
  117554. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117555. */
  117556. lockstepMaxSteps: number;
  117557. }
  117558. /**
  117559. * The null engine class provides support for headless version of babylon.js.
  117560. * This can be used in server side scenario or for testing purposes
  117561. */
  117562. export class NullEngine extends Engine {
  117563. private _options;
  117564. /**
  117565. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  117566. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117567. * @returns true if engine is in deterministic lock step mode
  117568. */
  117569. isDeterministicLockStep(): boolean;
  117570. /**
  117571. * Gets the max steps when engine is running in deterministic lock step
  117572. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117573. * @returns the max steps
  117574. */
  117575. getLockstepMaxSteps(): number;
  117576. /**
  117577. * Gets the current hardware scaling level.
  117578. * By default the hardware scaling level is computed from the window device ratio.
  117579. * 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.
  117580. * @returns a number indicating the current hardware scaling level
  117581. */
  117582. getHardwareScalingLevel(): number;
  117583. constructor(options?: NullEngineOptions);
  117584. /**
  117585. * Creates a vertex buffer
  117586. * @param vertices the data for the vertex buffer
  117587. * @returns the new WebGL static buffer
  117588. */
  117589. createVertexBuffer(vertices: FloatArray): DataBuffer;
  117590. /**
  117591. * Creates a new index buffer
  117592. * @param indices defines the content of the index buffer
  117593. * @param updatable defines if the index buffer must be updatable
  117594. * @returns a new webGL buffer
  117595. */
  117596. createIndexBuffer(indices: IndicesArray): DataBuffer;
  117597. /**
  117598. * Clear the current render buffer or the current render target (if any is set up)
  117599. * @param color defines the color to use
  117600. * @param backBuffer defines if the back buffer must be cleared
  117601. * @param depth defines if the depth buffer must be cleared
  117602. * @param stencil defines if the stencil buffer must be cleared
  117603. */
  117604. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  117605. /**
  117606. * Gets the current render width
  117607. * @param useScreen defines if screen size must be used (or the current render target if any)
  117608. * @returns a number defining the current render width
  117609. */
  117610. getRenderWidth(useScreen?: boolean): number;
  117611. /**
  117612. * Gets the current render height
  117613. * @param useScreen defines if screen size must be used (or the current render target if any)
  117614. * @returns a number defining the current render height
  117615. */
  117616. getRenderHeight(useScreen?: boolean): number;
  117617. /**
  117618. * Set the WebGL's viewport
  117619. * @param viewport defines the viewport element to be used
  117620. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  117621. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  117622. */
  117623. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  117624. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  117625. /**
  117626. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  117627. * @param pipelineContext defines the pipeline context to use
  117628. * @param uniformsNames defines the list of uniform names
  117629. * @returns an array of webGL uniform locations
  117630. */
  117631. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  117632. /**
  117633. * Gets the lsit of active attributes for a given webGL program
  117634. * @param pipelineContext defines the pipeline context to use
  117635. * @param attributesNames defines the list of attribute names to get
  117636. * @returns an array of indices indicating the offset of each attribute
  117637. */
  117638. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  117639. /**
  117640. * Binds an effect to the webGL context
  117641. * @param effect defines the effect to bind
  117642. */
  117643. bindSamplers(effect: Effect): void;
  117644. /**
  117645. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  117646. * @param effect defines the effect to activate
  117647. */
  117648. enableEffect(effect: Effect): void;
  117649. /**
  117650. * Set various states to the webGL context
  117651. * @param culling defines backface culling state
  117652. * @param zOffset defines the value to apply to zOffset (0 by default)
  117653. * @param force defines if states must be applied even if cache is up to date
  117654. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  117655. */
  117656. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  117657. /**
  117658. * Set the value of an uniform to an array of int32
  117659. * @param uniform defines the webGL uniform location where to store the value
  117660. * @param array defines the array of int32 to store
  117661. */
  117662. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  117663. /**
  117664. * Set the value of an uniform to an array of int32 (stored as vec2)
  117665. * @param uniform defines the webGL uniform location where to store the value
  117666. * @param array defines the array of int32 to store
  117667. */
  117668. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  117669. /**
  117670. * Set the value of an uniform to an array of int32 (stored as vec3)
  117671. * @param uniform defines the webGL uniform location where to store the value
  117672. * @param array defines the array of int32 to store
  117673. */
  117674. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  117675. /**
  117676. * Set the value of an uniform to an array of int32 (stored as vec4)
  117677. * @param uniform defines the webGL uniform location where to store the value
  117678. * @param array defines the array of int32 to store
  117679. */
  117680. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  117681. /**
  117682. * Set the value of an uniform to an array of float32
  117683. * @param uniform defines the webGL uniform location where to store the value
  117684. * @param array defines the array of float32 to store
  117685. */
  117686. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  117687. /**
  117688. * Set the value of an uniform to an array of float32 (stored as vec2)
  117689. * @param uniform defines the webGL uniform location where to store the value
  117690. * @param array defines the array of float32 to store
  117691. */
  117692. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  117693. /**
  117694. * Set the value of an uniform to an array of float32 (stored as vec3)
  117695. * @param uniform defines the webGL uniform location where to store the value
  117696. * @param array defines the array of float32 to store
  117697. */
  117698. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  117699. /**
  117700. * Set the value of an uniform to an array of float32 (stored as vec4)
  117701. * @param uniform defines the webGL uniform location where to store the value
  117702. * @param array defines the array of float32 to store
  117703. */
  117704. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  117705. /**
  117706. * Set the value of an uniform to an array of number
  117707. * @param uniform defines the webGL uniform location where to store the value
  117708. * @param array defines the array of number to store
  117709. */
  117710. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  117711. /**
  117712. * Set the value of an uniform to an array of number (stored as vec2)
  117713. * @param uniform defines the webGL uniform location where to store the value
  117714. * @param array defines the array of number to store
  117715. */
  117716. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  117717. /**
  117718. * Set the value of an uniform to an array of number (stored as vec3)
  117719. * @param uniform defines the webGL uniform location where to store the value
  117720. * @param array defines the array of number to store
  117721. */
  117722. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  117723. /**
  117724. * Set the value of an uniform to an array of number (stored as vec4)
  117725. * @param uniform defines the webGL uniform location where to store the value
  117726. * @param array defines the array of number to store
  117727. */
  117728. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  117729. /**
  117730. * Set the value of an uniform to an array of float32 (stored as matrices)
  117731. * @param uniform defines the webGL uniform location where to store the value
  117732. * @param matrices defines the array of float32 to store
  117733. */
  117734. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  117735. /**
  117736. * Set the value of an uniform to a matrix (3x3)
  117737. * @param uniform defines the webGL uniform location where to store the value
  117738. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  117739. */
  117740. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117741. /**
  117742. * Set the value of an uniform to a matrix (2x2)
  117743. * @param uniform defines the webGL uniform location where to store the value
  117744. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  117745. */
  117746. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  117747. /**
  117748. * Set the value of an uniform to a number (float)
  117749. * @param uniform defines the webGL uniform location where to store the value
  117750. * @param value defines the float number to store
  117751. */
  117752. setFloat(uniform: WebGLUniformLocation, value: number): void;
  117753. /**
  117754. * Set the value of an uniform to a vec2
  117755. * @param uniform defines the webGL uniform location where to store the value
  117756. * @param x defines the 1st component of the value
  117757. * @param y defines the 2nd component of the value
  117758. */
  117759. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  117760. /**
  117761. * Set the value of an uniform to a vec3
  117762. * @param uniform defines the webGL uniform location where to store the value
  117763. * @param x defines the 1st component of the value
  117764. * @param y defines the 2nd component of the value
  117765. * @param z defines the 3rd component of the value
  117766. */
  117767. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  117768. /**
  117769. * Set the value of an uniform to a boolean
  117770. * @param uniform defines the webGL uniform location where to store the value
  117771. * @param bool defines the boolean to store
  117772. */
  117773. setBool(uniform: WebGLUniformLocation, bool: number): void;
  117774. /**
  117775. * Set the value of an uniform to a vec4
  117776. * @param uniform defines the webGL uniform location where to store the value
  117777. * @param x defines the 1st component of the value
  117778. * @param y defines the 2nd component of the value
  117779. * @param z defines the 3rd component of the value
  117780. * @param w defines the 4th component of the value
  117781. */
  117782. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  117783. /**
  117784. * Sets the current alpha mode
  117785. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  117786. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  117787. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  117788. */
  117789. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  117790. /**
  117791. * Bind webGl buffers directly to the webGL context
  117792. * @param vertexBuffers defines the vertex buffer to bind
  117793. * @param indexBuffer defines the index buffer to bind
  117794. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  117795. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  117796. * @param effect defines the effect associated with the vertex buffer
  117797. */
  117798. bindBuffers(vertexBuffers: {
  117799. [key: string]: VertexBuffer;
  117800. }, indexBuffer: DataBuffer, effect: Effect): void;
  117801. /**
  117802. * Force the entire cache to be cleared
  117803. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  117804. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  117805. */
  117806. wipeCaches(bruteForce?: boolean): void;
  117807. /**
  117808. * Send a draw order
  117809. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  117810. * @param indexStart defines the starting index
  117811. * @param indexCount defines the number of index to draw
  117812. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117813. */
  117814. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  117815. /**
  117816. * Draw a list of indexed primitives
  117817. * @param fillMode defines the primitive to use
  117818. * @param indexStart defines the starting index
  117819. * @param indexCount defines the number of index to draw
  117820. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117821. */
  117822. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  117823. /**
  117824. * Draw a list of unindexed primitives
  117825. * @param fillMode defines the primitive to use
  117826. * @param verticesStart defines the index of first vertex to draw
  117827. * @param verticesCount defines the count of vertices to draw
  117828. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  117829. */
  117830. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  117831. /** @hidden */
  117832. _createTexture(): WebGLTexture;
  117833. /** @hidden */
  117834. _releaseTexture(texture: InternalTexture): void;
  117835. /**
  117836. * Usually called from Texture.ts.
  117837. * Passed information to create a WebGLTexture
  117838. * @param urlArg defines a value which contains one of the following:
  117839. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  117840. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  117841. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  117842. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  117843. * @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)
  117844. * @param scene needed for loading to the correct scene
  117845. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  117846. * @param onLoad optional callback to be called upon successful completion
  117847. * @param onError optional callback to be called upon failure
  117848. * @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
  117849. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  117850. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  117851. * @param forcedExtension defines the extension to use to pick the right loader
  117852. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  117853. * @returns a InternalTexture for assignment back into BABYLON.Texture
  117854. */
  117855. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  117856. /**
  117857. * Creates a new render target texture
  117858. * @param size defines the size of the texture
  117859. * @param options defines the options used to create the texture
  117860. * @returns a new render target texture stored in an InternalTexture
  117861. */
  117862. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  117863. /**
  117864. * Update the sampling mode of a given texture
  117865. * @param samplingMode defines the required sampling mode
  117866. * @param texture defines the texture to update
  117867. */
  117868. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  117869. /**
  117870. * Binds the frame buffer to the specified texture.
  117871. * @param texture The texture to render to or null for the default canvas
  117872. * @param faceIndex The face of the texture to render to in case of cube texture
  117873. * @param requiredWidth The width of the target to render to
  117874. * @param requiredHeight The height of the target to render to
  117875. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  117876. * @param depthStencilTexture The depth stencil texture to use to render
  117877. * @param lodLevel defines le lod level to bind to the frame buffer
  117878. */
  117879. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  117880. /**
  117881. * Unbind the current render target texture from the webGL context
  117882. * @param texture defines the render target texture to unbind
  117883. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  117884. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  117885. */
  117886. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  117887. /**
  117888. * Creates a dynamic vertex buffer
  117889. * @param vertices the data for the dynamic vertex buffer
  117890. * @returns the new WebGL dynamic buffer
  117891. */
  117892. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  117893. /**
  117894. * Update the content of a dynamic texture
  117895. * @param texture defines the texture to update
  117896. * @param canvas defines the canvas containing the source
  117897. * @param invertY defines if data must be stored with Y axis inverted
  117898. * @param premulAlpha defines if alpha is stored as premultiplied
  117899. * @param format defines the format of the data
  117900. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  117901. */
  117902. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  117903. /**
  117904. * Gets a boolean indicating if all created effects are ready
  117905. * @returns true if all effects are ready
  117906. */
  117907. areAllEffectsReady(): boolean;
  117908. /**
  117909. * @hidden
  117910. * Get the current error code of the webGL context
  117911. * @returns the error code
  117912. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  117913. */
  117914. getError(): number;
  117915. /** @hidden */
  117916. _getUnpackAlignement(): number;
  117917. /** @hidden */
  117918. _unpackFlipY(value: boolean): void;
  117919. /**
  117920. * Update a dynamic index buffer
  117921. * @param indexBuffer defines the target index buffer
  117922. * @param indices defines the data to update
  117923. * @param offset defines the offset in the target index buffer where update should start
  117924. */
  117925. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  117926. /**
  117927. * Updates a dynamic vertex buffer.
  117928. * @param vertexBuffer the vertex buffer to update
  117929. * @param vertices the data used to update the vertex buffer
  117930. * @param byteOffset the byte offset of the data (optional)
  117931. * @param byteLength the byte length of the data (optional)
  117932. */
  117933. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  117934. /** @hidden */
  117935. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  117936. /** @hidden */
  117937. _bindTexture(channel: number, texture: InternalTexture): void;
  117938. protected _deleteBuffer(buffer: WebGLBuffer): void;
  117939. /**
  117940. * 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
  117941. */
  117942. releaseEffects(): void;
  117943. displayLoadingUI(): void;
  117944. hideLoadingUI(): void;
  117945. /** @hidden */
  117946. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117947. /** @hidden */
  117948. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117949. /** @hidden */
  117950. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  117951. /** @hidden */
  117952. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  117953. }
  117954. }
  117955. declare module BABYLON {
  117956. /** @hidden */
  117957. export class _OcclusionDataStorage {
  117958. /** @hidden */
  117959. occlusionInternalRetryCounter: number;
  117960. /** @hidden */
  117961. isOcclusionQueryInProgress: boolean;
  117962. /** @hidden */
  117963. isOccluded: boolean;
  117964. /** @hidden */
  117965. occlusionRetryCount: number;
  117966. /** @hidden */
  117967. occlusionType: number;
  117968. /** @hidden */
  117969. occlusionQueryAlgorithmType: number;
  117970. }
  117971. interface Engine {
  117972. /**
  117973. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  117974. * @return the new query
  117975. */
  117976. createQuery(): WebGLQuery;
  117977. /**
  117978. * Delete and release a webGL query
  117979. * @param query defines the query to delete
  117980. * @return the current engine
  117981. */
  117982. deleteQuery(query: WebGLQuery): Engine;
  117983. /**
  117984. * Check if a given query has resolved and got its value
  117985. * @param query defines the query to check
  117986. * @returns true if the query got its value
  117987. */
  117988. isQueryResultAvailable(query: WebGLQuery): boolean;
  117989. /**
  117990. * Gets the value of a given query
  117991. * @param query defines the query to check
  117992. * @returns the value of the query
  117993. */
  117994. getQueryResult(query: WebGLQuery): number;
  117995. /**
  117996. * Initiates an occlusion query
  117997. * @param algorithmType defines the algorithm to use
  117998. * @param query defines the query to use
  117999. * @returns the current engine
  118000. * @see http://doc.babylonjs.com/features/occlusionquery
  118001. */
  118002. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  118003. /**
  118004. * Ends an occlusion query
  118005. * @see http://doc.babylonjs.com/features/occlusionquery
  118006. * @param algorithmType defines the algorithm to use
  118007. * @returns the current engine
  118008. */
  118009. endOcclusionQuery(algorithmType: number): Engine;
  118010. /**
  118011. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  118012. * Please note that only one query can be issued at a time
  118013. * @returns a time token used to track the time span
  118014. */
  118015. startTimeQuery(): Nullable<_TimeToken>;
  118016. /**
  118017. * Ends a time query
  118018. * @param token defines the token used to measure the time span
  118019. * @returns the time spent (in ns)
  118020. */
  118021. endTimeQuery(token: _TimeToken): int;
  118022. /** @hidden */
  118023. _currentNonTimestampToken: Nullable<_TimeToken>;
  118024. /** @hidden */
  118025. _createTimeQuery(): WebGLQuery;
  118026. /** @hidden */
  118027. _deleteTimeQuery(query: WebGLQuery): void;
  118028. /** @hidden */
  118029. _getGlAlgorithmType(algorithmType: number): number;
  118030. /** @hidden */
  118031. _getTimeQueryResult(query: WebGLQuery): any;
  118032. /** @hidden */
  118033. _getTimeQueryAvailability(query: WebGLQuery): any;
  118034. }
  118035. interface AbstractMesh {
  118036. /**
  118037. * Backing filed
  118038. * @hidden
  118039. */
  118040. __occlusionDataStorage: _OcclusionDataStorage;
  118041. /**
  118042. * Access property
  118043. * @hidden
  118044. */
  118045. _occlusionDataStorage: _OcclusionDataStorage;
  118046. /**
  118047. * 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.
  118048. * The default value is -1 which means don't break the query and wait till the result
  118049. * @see http://doc.babylonjs.com/features/occlusionquery
  118050. */
  118051. occlusionRetryCount: number;
  118052. /**
  118053. * 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:
  118054. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  118055. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  118056. * * 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.
  118057. * @see http://doc.babylonjs.com/features/occlusionquery
  118058. */
  118059. occlusionType: number;
  118060. /**
  118061. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  118062. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  118063. * * 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.
  118064. * @see http://doc.babylonjs.com/features/occlusionquery
  118065. */
  118066. occlusionQueryAlgorithmType: number;
  118067. /**
  118068. * 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
  118069. * @see http://doc.babylonjs.com/features/occlusionquery
  118070. */
  118071. isOccluded: boolean;
  118072. /**
  118073. * Flag to check the progress status of the query
  118074. * @see http://doc.babylonjs.com/features/occlusionquery
  118075. */
  118076. isOcclusionQueryInProgress: boolean;
  118077. }
  118078. }
  118079. declare module BABYLON {
  118080. /** @hidden */
  118081. export var _forceTransformFeedbackToBundle: boolean;
  118082. interface Engine {
  118083. /**
  118084. * Creates a webGL transform feedback object
  118085. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  118086. * @returns the webGL transform feedback object
  118087. */
  118088. createTransformFeedback(): WebGLTransformFeedback;
  118089. /**
  118090. * Delete a webGL transform feedback object
  118091. * @param value defines the webGL transform feedback object to delete
  118092. */
  118093. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  118094. /**
  118095. * Bind a webGL transform feedback object to the webgl context
  118096. * @param value defines the webGL transform feedback object to bind
  118097. */
  118098. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  118099. /**
  118100. * Begins a transform feedback operation
  118101. * @param usePoints defines if points or triangles must be used
  118102. */
  118103. beginTransformFeedback(usePoints: boolean): void;
  118104. /**
  118105. * Ends a transform feedback operation
  118106. */
  118107. endTransformFeedback(): void;
  118108. /**
  118109. * Specify the varyings to use with transform feedback
  118110. * @param program defines the associated webGL program
  118111. * @param value defines the list of strings representing the varying names
  118112. */
  118113. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  118114. /**
  118115. * Bind a webGL buffer for a transform feedback operation
  118116. * @param value defines the webGL buffer to bind
  118117. */
  118118. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  118119. }
  118120. }
  118121. declare module BABYLON {
  118122. /**
  118123. * Creation options of the multi render target texture.
  118124. */
  118125. export interface IMultiRenderTargetOptions {
  118126. /**
  118127. * Define if the texture needs to create mip maps after render.
  118128. */
  118129. generateMipMaps?: boolean;
  118130. /**
  118131. * Define the types of all the draw buffers we want to create
  118132. */
  118133. types?: number[];
  118134. /**
  118135. * Define the sampling modes of all the draw buffers we want to create
  118136. */
  118137. samplingModes?: number[];
  118138. /**
  118139. * Define if a depth buffer is required
  118140. */
  118141. generateDepthBuffer?: boolean;
  118142. /**
  118143. * Define if a stencil buffer is required
  118144. */
  118145. generateStencilBuffer?: boolean;
  118146. /**
  118147. * Define if a depth texture is required instead of a depth buffer
  118148. */
  118149. generateDepthTexture?: boolean;
  118150. /**
  118151. * Define the number of desired draw buffers
  118152. */
  118153. textureCount?: number;
  118154. /**
  118155. * Define if aspect ratio should be adapted to the texture or stay the scene one
  118156. */
  118157. doNotChangeAspectRatio?: boolean;
  118158. /**
  118159. * Define the default type of the buffers we are creating
  118160. */
  118161. defaultType?: number;
  118162. }
  118163. /**
  118164. * A multi render target, like a render target provides the ability to render to a texture.
  118165. * Unlike the render target, it can render to several draw buffers in one draw.
  118166. * This is specially interesting in deferred rendering or for any effects requiring more than
  118167. * just one color from a single pass.
  118168. */
  118169. export class MultiRenderTarget extends RenderTargetTexture {
  118170. private _internalTextures;
  118171. private _textures;
  118172. private _multiRenderTargetOptions;
  118173. /**
  118174. * Get if draw buffers are currently supported by the used hardware and browser.
  118175. */
  118176. get isSupported(): boolean;
  118177. /**
  118178. * Get the list of textures generated by the multi render target.
  118179. */
  118180. get textures(): Texture[];
  118181. /**
  118182. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  118183. */
  118184. get depthTexture(): Texture;
  118185. /**
  118186. * Set the wrapping mode on U of all the textures we are rendering to.
  118187. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  118188. */
  118189. set wrapU(wrap: number);
  118190. /**
  118191. * Set the wrapping mode on V of all the textures we are rendering to.
  118192. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  118193. */
  118194. set wrapV(wrap: number);
  118195. /**
  118196. * Instantiate a new multi render target texture.
  118197. * A multi render target, like a render target provides the ability to render to a texture.
  118198. * Unlike the render target, it can render to several draw buffers in one draw.
  118199. * This is specially interesting in deferred rendering or for any effects requiring more than
  118200. * just one color from a single pass.
  118201. * @param name Define the name of the texture
  118202. * @param size Define the size of the buffers to render to
  118203. * @param count Define the number of target we are rendering into
  118204. * @param scene Define the scene the texture belongs to
  118205. * @param options Define the options used to create the multi render target
  118206. */
  118207. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  118208. /** @hidden */
  118209. _rebuild(): void;
  118210. private _createInternalTextures;
  118211. private _createTextures;
  118212. /**
  118213. * Define the number of samples used if MSAA is enabled.
  118214. */
  118215. get samples(): number;
  118216. set samples(value: number);
  118217. /**
  118218. * Resize all the textures in the multi render target.
  118219. * Be carrefull as it will recreate all the data in the new texture.
  118220. * @param size Define the new size
  118221. */
  118222. resize(size: any): void;
  118223. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  118224. /**
  118225. * Dispose the render targets and their associated resources
  118226. */
  118227. dispose(): void;
  118228. /**
  118229. * Release all the underlying texture used as draw buffers.
  118230. */
  118231. releaseInternalTextures(): void;
  118232. }
  118233. }
  118234. declare module BABYLON {
  118235. interface ThinEngine {
  118236. /**
  118237. * Unbind a list of render target textures from the webGL context
  118238. * This is used only when drawBuffer extension or webGL2 are active
  118239. * @param textures defines the render target textures to unbind
  118240. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  118241. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  118242. */
  118243. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  118244. /**
  118245. * Create a multi render target texture
  118246. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  118247. * @param size defines the size of the texture
  118248. * @param options defines the creation options
  118249. * @returns the cube texture as an InternalTexture
  118250. */
  118251. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  118252. /**
  118253. * Update the sample count for a given multiple render target texture
  118254. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118255. * @param textures defines the textures to update
  118256. * @param samples defines the sample count to set
  118257. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118258. */
  118259. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  118260. }
  118261. }
  118262. declare module BABYLON {
  118263. /**
  118264. * Class used to define an additional view for the engine
  118265. * @see https://doc.babylonjs.com/how_to/multi_canvases
  118266. */
  118267. export class EngineView {
  118268. /** Defines the canvas where to render the view */
  118269. target: HTMLCanvasElement;
  118270. /** Defines an optional camera used to render the view (will use active camera else) */
  118271. camera?: Camera;
  118272. }
  118273. interface Engine {
  118274. /**
  118275. * Gets or sets the HTML element to use for attaching events
  118276. */
  118277. inputElement: Nullable<HTMLElement>;
  118278. /**
  118279. * Gets the current engine view
  118280. * @see https://doc.babylonjs.com/how_to/multi_canvases
  118281. */
  118282. activeView: Nullable<EngineView>;
  118283. /** Gets or sets the list of views */
  118284. views: EngineView[];
  118285. /**
  118286. * Register a new child canvas
  118287. * @param canvas defines the canvas to register
  118288. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  118289. * @returns the associated view
  118290. */
  118291. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  118292. /**
  118293. * Remove a registered child canvas
  118294. * @param canvas defines the canvas to remove
  118295. * @returns the current engine
  118296. */
  118297. unRegisterView(canvas: HTMLCanvasElement): Engine;
  118298. }
  118299. }
  118300. declare module BABYLON {
  118301. /**
  118302. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  118303. */
  118304. export interface CubeMapInfo {
  118305. /**
  118306. * The pixel array for the front face.
  118307. * This is stored in format, left to right, up to down format.
  118308. */
  118309. front: Nullable<ArrayBufferView>;
  118310. /**
  118311. * The pixel array for the back face.
  118312. * This is stored in format, left to right, up to down format.
  118313. */
  118314. back: Nullable<ArrayBufferView>;
  118315. /**
  118316. * The pixel array for the left face.
  118317. * This is stored in format, left to right, up to down format.
  118318. */
  118319. left: Nullable<ArrayBufferView>;
  118320. /**
  118321. * The pixel array for the right face.
  118322. * This is stored in format, left to right, up to down format.
  118323. */
  118324. right: Nullable<ArrayBufferView>;
  118325. /**
  118326. * The pixel array for the up face.
  118327. * This is stored in format, left to right, up to down format.
  118328. */
  118329. up: Nullable<ArrayBufferView>;
  118330. /**
  118331. * The pixel array for the down face.
  118332. * This is stored in format, left to right, up to down format.
  118333. */
  118334. down: Nullable<ArrayBufferView>;
  118335. /**
  118336. * The size of the cubemap stored.
  118337. *
  118338. * Each faces will be size * size pixels.
  118339. */
  118340. size: number;
  118341. /**
  118342. * The format of the texture.
  118343. *
  118344. * RGBA, RGB.
  118345. */
  118346. format: number;
  118347. /**
  118348. * The type of the texture data.
  118349. *
  118350. * UNSIGNED_INT, FLOAT.
  118351. */
  118352. type: number;
  118353. /**
  118354. * Specifies whether the texture is in gamma space.
  118355. */
  118356. gammaSpace: boolean;
  118357. }
  118358. /**
  118359. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  118360. */
  118361. export class PanoramaToCubeMapTools {
  118362. private static FACE_FRONT;
  118363. private static FACE_BACK;
  118364. private static FACE_RIGHT;
  118365. private static FACE_LEFT;
  118366. private static FACE_DOWN;
  118367. private static FACE_UP;
  118368. /**
  118369. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  118370. *
  118371. * @param float32Array The source data.
  118372. * @param inputWidth The width of the input panorama.
  118373. * @param inputHeight The height of the input panorama.
  118374. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  118375. * @return The cubemap data
  118376. */
  118377. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  118378. private static CreateCubemapTexture;
  118379. private static CalcProjectionSpherical;
  118380. }
  118381. }
  118382. declare module BABYLON {
  118383. /**
  118384. * Helper class dealing with the extraction of spherical polynomial dataArray
  118385. * from a cube map.
  118386. */
  118387. export class CubeMapToSphericalPolynomialTools {
  118388. private static FileFaces;
  118389. /**
  118390. * Converts a texture to the according Spherical Polynomial data.
  118391. * This extracts the first 3 orders only as they are the only one used in the lighting.
  118392. *
  118393. * @param texture The texture to extract the information from.
  118394. * @return The Spherical Polynomial data.
  118395. */
  118396. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  118397. /**
  118398. * Converts a cubemap to the according Spherical Polynomial data.
  118399. * This extracts the first 3 orders only as they are the only one used in the lighting.
  118400. *
  118401. * @param cubeInfo The Cube map to extract the information from.
  118402. * @return The Spherical Polynomial data.
  118403. */
  118404. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  118405. }
  118406. }
  118407. declare module BABYLON {
  118408. interface BaseTexture {
  118409. /**
  118410. * Get the polynomial representation of the texture data.
  118411. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  118412. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  118413. */
  118414. sphericalPolynomial: Nullable<SphericalPolynomial>;
  118415. }
  118416. }
  118417. declare module BABYLON {
  118418. /** @hidden */
  118419. export var rgbdEncodePixelShader: {
  118420. name: string;
  118421. shader: string;
  118422. };
  118423. }
  118424. declare module BABYLON {
  118425. /** @hidden */
  118426. export var rgbdDecodePixelShader: {
  118427. name: string;
  118428. shader: string;
  118429. };
  118430. }
  118431. declare module BABYLON {
  118432. /**
  118433. * Raw texture data and descriptor sufficient for WebGL texture upload
  118434. */
  118435. export interface EnvironmentTextureInfo {
  118436. /**
  118437. * Version of the environment map
  118438. */
  118439. version: number;
  118440. /**
  118441. * Width of image
  118442. */
  118443. width: number;
  118444. /**
  118445. * Irradiance information stored in the file.
  118446. */
  118447. irradiance: any;
  118448. /**
  118449. * Specular information stored in the file.
  118450. */
  118451. specular: any;
  118452. }
  118453. /**
  118454. * Defines One Image in the file. It requires only the position in the file
  118455. * as well as the length.
  118456. */
  118457. interface BufferImageData {
  118458. /**
  118459. * Length of the image data.
  118460. */
  118461. length: number;
  118462. /**
  118463. * Position of the data from the null terminator delimiting the end of the JSON.
  118464. */
  118465. position: number;
  118466. }
  118467. /**
  118468. * Defines the specular data enclosed in the file.
  118469. * This corresponds to the version 1 of the data.
  118470. */
  118471. export interface EnvironmentTextureSpecularInfoV1 {
  118472. /**
  118473. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  118474. */
  118475. specularDataPosition?: number;
  118476. /**
  118477. * This contains all the images data needed to reconstruct the cubemap.
  118478. */
  118479. mipmaps: Array<BufferImageData>;
  118480. /**
  118481. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  118482. */
  118483. lodGenerationScale: number;
  118484. }
  118485. /**
  118486. * Sets of helpers addressing the serialization and deserialization of environment texture
  118487. * stored in a BabylonJS env file.
  118488. * Those files are usually stored as .env files.
  118489. */
  118490. export class EnvironmentTextureTools {
  118491. /**
  118492. * Magic number identifying the env file.
  118493. */
  118494. private static _MagicBytes;
  118495. /**
  118496. * Gets the environment info from an env file.
  118497. * @param data The array buffer containing the .env bytes.
  118498. * @returns the environment file info (the json header) if successfully parsed.
  118499. */
  118500. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  118501. /**
  118502. * Creates an environment texture from a loaded cube texture.
  118503. * @param texture defines the cube texture to convert in env file
  118504. * @return a promise containing the environment data if succesfull.
  118505. */
  118506. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  118507. /**
  118508. * Creates a JSON representation of the spherical data.
  118509. * @param texture defines the texture containing the polynomials
  118510. * @return the JSON representation of the spherical info
  118511. */
  118512. private static _CreateEnvTextureIrradiance;
  118513. /**
  118514. * Creates the ArrayBufferViews used for initializing environment texture image data.
  118515. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  118516. * @param info parameters that determine what views will be created for accessing the underlying buffer
  118517. * @return the views described by info providing access to the underlying buffer
  118518. */
  118519. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  118520. /**
  118521. * Uploads the texture info contained in the env file to the GPU.
  118522. * @param texture defines the internal texture to upload to
  118523. * @param arrayBuffer defines the buffer cotaining the data to load
  118524. * @param info defines the texture info retrieved through the GetEnvInfo method
  118525. * @returns a promise
  118526. */
  118527. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  118528. private static _OnImageReadyAsync;
  118529. /**
  118530. * Uploads the levels of image data to the GPU.
  118531. * @param texture defines the internal texture to upload to
  118532. * @param imageData defines the array buffer views of image data [mipmap][face]
  118533. * @returns a promise
  118534. */
  118535. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  118536. /**
  118537. * Uploads spherical polynomials information to the texture.
  118538. * @param texture defines the texture we are trying to upload the information to
  118539. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  118540. */
  118541. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  118542. /** @hidden */
  118543. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  118544. }
  118545. }
  118546. declare module BABYLON {
  118547. /**
  118548. * Contains position and normal vectors for a vertex
  118549. */
  118550. export class PositionNormalVertex {
  118551. /** the position of the vertex (defaut: 0,0,0) */
  118552. position: Vector3;
  118553. /** the normal of the vertex (defaut: 0,1,0) */
  118554. normal: Vector3;
  118555. /**
  118556. * Creates a PositionNormalVertex
  118557. * @param position the position of the vertex (defaut: 0,0,0)
  118558. * @param normal the normal of the vertex (defaut: 0,1,0)
  118559. */
  118560. constructor(
  118561. /** the position of the vertex (defaut: 0,0,0) */
  118562. position?: Vector3,
  118563. /** the normal of the vertex (defaut: 0,1,0) */
  118564. normal?: Vector3);
  118565. /**
  118566. * Clones the PositionNormalVertex
  118567. * @returns the cloned PositionNormalVertex
  118568. */
  118569. clone(): PositionNormalVertex;
  118570. }
  118571. /**
  118572. * Contains position, normal and uv vectors for a vertex
  118573. */
  118574. export class PositionNormalTextureVertex {
  118575. /** the position of the vertex (defaut: 0,0,0) */
  118576. position: Vector3;
  118577. /** the normal of the vertex (defaut: 0,1,0) */
  118578. normal: Vector3;
  118579. /** the uv of the vertex (default: 0,0) */
  118580. uv: Vector2;
  118581. /**
  118582. * Creates a PositionNormalTextureVertex
  118583. * @param position the position of the vertex (defaut: 0,0,0)
  118584. * @param normal the normal of the vertex (defaut: 0,1,0)
  118585. * @param uv the uv of the vertex (default: 0,0)
  118586. */
  118587. constructor(
  118588. /** the position of the vertex (defaut: 0,0,0) */
  118589. position?: Vector3,
  118590. /** the normal of the vertex (defaut: 0,1,0) */
  118591. normal?: Vector3,
  118592. /** the uv of the vertex (default: 0,0) */
  118593. uv?: Vector2);
  118594. /**
  118595. * Clones the PositionNormalTextureVertex
  118596. * @returns the cloned PositionNormalTextureVertex
  118597. */
  118598. clone(): PositionNormalTextureVertex;
  118599. }
  118600. }
  118601. declare module BABYLON {
  118602. /** @hidden */
  118603. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  118604. private _genericAttributeLocation;
  118605. private _varyingLocationCount;
  118606. private _varyingLocationMap;
  118607. private _replacements;
  118608. private _textureCount;
  118609. private _uniforms;
  118610. lineProcessor(line: string): string;
  118611. attributeProcessor(attribute: string): string;
  118612. varyingProcessor(varying: string, isFragment: boolean): string;
  118613. uniformProcessor(uniform: string): string;
  118614. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  118615. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  118616. }
  118617. }
  118618. declare module BABYLON {
  118619. /**
  118620. * Container for accessors for natively-stored mesh data buffers.
  118621. */
  118622. class NativeDataBuffer extends DataBuffer {
  118623. /**
  118624. * Accessor value used to identify/retrieve a natively-stored index buffer.
  118625. */
  118626. nativeIndexBuffer?: any;
  118627. /**
  118628. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  118629. */
  118630. nativeVertexBuffer?: any;
  118631. }
  118632. /** @hidden */
  118633. class NativeTexture extends InternalTexture {
  118634. getInternalTexture(): InternalTexture;
  118635. getViewCount(): number;
  118636. }
  118637. /** @hidden */
  118638. export class NativeEngine extends Engine {
  118639. private readonly _native;
  118640. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  118641. private readonly INVALID_HANDLE;
  118642. getHardwareScalingLevel(): number;
  118643. constructor();
  118644. /**
  118645. * Can be used to override the current requestAnimationFrame requester.
  118646. * @hidden
  118647. */
  118648. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  118649. /**
  118650. * Override default engine behavior.
  118651. * @param color
  118652. * @param backBuffer
  118653. * @param depth
  118654. * @param stencil
  118655. */
  118656. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  118657. /**
  118658. * Gets host document
  118659. * @returns the host document object
  118660. */
  118661. getHostDocument(): Nullable<Document>;
  118662. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  118663. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  118664. createVertexBuffer(data: DataArray): NativeDataBuffer;
  118665. recordVertexArrayObject(vertexBuffers: {
  118666. [key: string]: VertexBuffer;
  118667. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  118668. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  118669. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  118670. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  118671. /**
  118672. * Draw a list of indexed primitives
  118673. * @param fillMode defines the primitive to use
  118674. * @param indexStart defines the starting index
  118675. * @param indexCount defines the number of index to draw
  118676. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  118677. */
  118678. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  118679. /**
  118680. * Draw a list of unindexed primitives
  118681. * @param fillMode defines the primitive to use
  118682. * @param verticesStart defines the index of first vertex to draw
  118683. * @param verticesCount defines the count of vertices to draw
  118684. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  118685. */
  118686. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  118687. createPipelineContext(): IPipelineContext;
  118688. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  118689. /** @hidden */
  118690. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  118691. /** @hidden */
  118692. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  118693. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  118694. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  118695. protected _setProgram(program: WebGLProgram): void;
  118696. _releaseEffect(effect: Effect): void;
  118697. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118698. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  118699. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  118700. bindSamplers(effect: Effect): void;
  118701. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  118702. getRenderWidth(useScreen?: boolean): number;
  118703. getRenderHeight(useScreen?: boolean): number;
  118704. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  118705. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  118706. /**
  118707. * Set the z offset to apply to current rendering
  118708. * @param value defines the offset to apply
  118709. */
  118710. setZOffset(value: number): void;
  118711. /**
  118712. * Gets the current value of the zOffset
  118713. * @returns the current zOffset state
  118714. */
  118715. getZOffset(): number;
  118716. /**
  118717. * Enable or disable depth buffering
  118718. * @param enable defines the state to set
  118719. */
  118720. setDepthBuffer(enable: boolean): void;
  118721. /**
  118722. * Gets a boolean indicating if depth writing is enabled
  118723. * @returns the current depth writing state
  118724. */
  118725. getDepthWrite(): boolean;
  118726. /**
  118727. * Enable or disable depth writing
  118728. * @param enable defines the state to set
  118729. */
  118730. setDepthWrite(enable: boolean): void;
  118731. /**
  118732. * Enable or disable color writing
  118733. * @param enable defines the state to set
  118734. */
  118735. setColorWrite(enable: boolean): void;
  118736. /**
  118737. * Gets a boolean indicating if color writing is enabled
  118738. * @returns the current color writing state
  118739. */
  118740. getColorWrite(): boolean;
  118741. /**
  118742. * Sets alpha constants used by some alpha blending modes
  118743. * @param r defines the red component
  118744. * @param g defines the green component
  118745. * @param b defines the blue component
  118746. * @param a defines the alpha component
  118747. */
  118748. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  118749. /**
  118750. * Sets the current alpha mode
  118751. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  118752. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  118753. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  118754. */
  118755. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  118756. /**
  118757. * Gets the current alpha mode
  118758. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  118759. * @returns the current alpha mode
  118760. */
  118761. getAlphaMode(): number;
  118762. setInt(uniform: WebGLUniformLocation, int: number): void;
  118763. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  118764. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  118765. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  118766. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  118767. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  118768. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  118769. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  118770. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  118771. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  118772. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  118773. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  118774. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  118775. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  118776. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  118777. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  118778. setFloat(uniform: WebGLUniformLocation, value: number): void;
  118779. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  118780. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  118781. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  118782. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  118783. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  118784. wipeCaches(bruteForce?: boolean): void;
  118785. _createTexture(): WebGLTexture;
  118786. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  118787. /**
  118788. * Usually called from BABYLON.Texture.ts.
  118789. * Passed information to create a WebGLTexture
  118790. * @param urlArg defines a value which contains one of the following:
  118791. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  118792. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  118793. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  118794. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  118795. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  118796. * @param scene needed for loading to the correct scene
  118797. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  118798. * @param onLoad optional callback to be called upon successful completion
  118799. * @param onError optional callback to be called upon failure
  118800. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  118801. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  118802. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  118803. * @param forcedExtension defines the extension to use to pick the right loader
  118804. * @returns a InternalTexture for assignment back into BABYLON.Texture
  118805. */
  118806. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  118807. /**
  118808. * Creates a cube texture
  118809. * @param rootUrl defines the url where the files to load is located
  118810. * @param scene defines the current scene
  118811. * @param files defines the list of files to load (1 per face)
  118812. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  118813. * @param onLoad defines an optional callback raised when the texture is loaded
  118814. * @param onError defines an optional callback raised if there is an issue to load the texture
  118815. * @param format defines the format of the data
  118816. * @param forcedExtension defines the extension to use to pick the right loader
  118817. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  118818. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  118819. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  118820. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  118821. * @returns the cube texture as an InternalTexture
  118822. */
  118823. 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;
  118824. private _getSamplingFilter;
  118825. private static _GetNativeTextureFormat;
  118826. createRenderTargetTexture(size: number | {
  118827. width: number;
  118828. height: number;
  118829. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  118830. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  118831. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  118832. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  118833. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  118834. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  118835. /**
  118836. * Updates a dynamic vertex buffer.
  118837. * @param vertexBuffer the vertex buffer to update
  118838. * @param data the data used to update the vertex buffer
  118839. * @param byteOffset the byte offset of the data (optional)
  118840. * @param byteLength the byte length of the data (optional)
  118841. */
  118842. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  118843. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  118844. private _updateAnisotropicLevel;
  118845. private _getAddressMode;
  118846. /** @hidden */
  118847. _bindTexture(channel: number, texture: InternalTexture): void;
  118848. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  118849. releaseEffects(): void;
  118850. /** @hidden */
  118851. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  118852. /** @hidden */
  118853. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  118854. /** @hidden */
  118855. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  118856. /** @hidden */
  118857. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  118858. }
  118859. }
  118860. declare module BABYLON {
  118861. /**
  118862. * Gather the list of clipboard event types as constants.
  118863. */
  118864. export class ClipboardEventTypes {
  118865. /**
  118866. * The clipboard event is fired when a copy command is active (pressed).
  118867. */
  118868. static readonly COPY: number;
  118869. /**
  118870. * The clipboard event is fired when a cut command is active (pressed).
  118871. */
  118872. static readonly CUT: number;
  118873. /**
  118874. * The clipboard event is fired when a paste command is active (pressed).
  118875. */
  118876. static readonly PASTE: number;
  118877. }
  118878. /**
  118879. * This class is used to store clipboard related info for the onClipboardObservable event.
  118880. */
  118881. export class ClipboardInfo {
  118882. /**
  118883. * Defines the type of event (BABYLON.ClipboardEventTypes)
  118884. */
  118885. type: number;
  118886. /**
  118887. * Defines the related dom event
  118888. */
  118889. event: ClipboardEvent;
  118890. /**
  118891. *Creates an instance of ClipboardInfo.
  118892. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  118893. * @param event Defines the related dom event
  118894. */
  118895. constructor(
  118896. /**
  118897. * Defines the type of event (BABYLON.ClipboardEventTypes)
  118898. */
  118899. type: number,
  118900. /**
  118901. * Defines the related dom event
  118902. */
  118903. event: ClipboardEvent);
  118904. /**
  118905. * Get the clipboard event's type from the keycode.
  118906. * @param keyCode Defines the keyCode for the current keyboard event.
  118907. * @return {number}
  118908. */
  118909. static GetTypeFromCharacter(keyCode: number): number;
  118910. }
  118911. }
  118912. declare module BABYLON {
  118913. /**
  118914. * Google Daydream controller
  118915. */
  118916. export class DaydreamController extends WebVRController {
  118917. /**
  118918. * Base Url for the controller model.
  118919. */
  118920. static MODEL_BASE_URL: string;
  118921. /**
  118922. * File name for the controller model.
  118923. */
  118924. static MODEL_FILENAME: string;
  118925. /**
  118926. * Gamepad Id prefix used to identify Daydream Controller.
  118927. */
  118928. static readonly GAMEPAD_ID_PREFIX: string;
  118929. /**
  118930. * Creates a new DaydreamController from a gamepad
  118931. * @param vrGamepad the gamepad that the controller should be created from
  118932. */
  118933. constructor(vrGamepad: any);
  118934. /**
  118935. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  118936. * @param scene scene in which to add meshes
  118937. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  118938. */
  118939. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  118940. /**
  118941. * Called once for each button that changed state since the last frame
  118942. * @param buttonIdx Which button index changed
  118943. * @param state New state of the button
  118944. * @param changes Which properties on the state changed since last frame
  118945. */
  118946. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  118947. }
  118948. }
  118949. declare module BABYLON {
  118950. /**
  118951. * Gear VR Controller
  118952. */
  118953. export class GearVRController extends WebVRController {
  118954. /**
  118955. * Base Url for the controller model.
  118956. */
  118957. static MODEL_BASE_URL: string;
  118958. /**
  118959. * File name for the controller model.
  118960. */
  118961. static MODEL_FILENAME: string;
  118962. /**
  118963. * Gamepad Id prefix used to identify this controller.
  118964. */
  118965. static readonly GAMEPAD_ID_PREFIX: string;
  118966. private readonly _buttonIndexToObservableNameMap;
  118967. /**
  118968. * Creates a new GearVRController from a gamepad
  118969. * @param vrGamepad the gamepad that the controller should be created from
  118970. */
  118971. constructor(vrGamepad: any);
  118972. /**
  118973. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  118974. * @param scene scene in which to add meshes
  118975. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  118976. */
  118977. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  118978. /**
  118979. * Called once for each button that changed state since the last frame
  118980. * @param buttonIdx Which button index changed
  118981. * @param state New state of the button
  118982. * @param changes Which properties on the state changed since last frame
  118983. */
  118984. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  118985. }
  118986. }
  118987. declare module BABYLON {
  118988. /**
  118989. * Generic Controller
  118990. */
  118991. export class GenericController extends WebVRController {
  118992. /**
  118993. * Base Url for the controller model.
  118994. */
  118995. static readonly MODEL_BASE_URL: string;
  118996. /**
  118997. * File name for the controller model.
  118998. */
  118999. static readonly MODEL_FILENAME: string;
  119000. /**
  119001. * Creates a new GenericController from a gamepad
  119002. * @param vrGamepad the gamepad that the controller should be created from
  119003. */
  119004. constructor(vrGamepad: any);
  119005. /**
  119006. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  119007. * @param scene scene in which to add meshes
  119008. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  119009. */
  119010. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  119011. /**
  119012. * Called once for each button that changed state since the last frame
  119013. * @param buttonIdx Which button index changed
  119014. * @param state New state of the button
  119015. * @param changes Which properties on the state changed since last frame
  119016. */
  119017. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  119018. }
  119019. }
  119020. declare module BABYLON {
  119021. /**
  119022. * Oculus Touch Controller
  119023. */
  119024. export class OculusTouchController extends WebVRController {
  119025. /**
  119026. * Base Url for the controller model.
  119027. */
  119028. static MODEL_BASE_URL: string;
  119029. /**
  119030. * File name for the left controller model.
  119031. */
  119032. static MODEL_LEFT_FILENAME: string;
  119033. /**
  119034. * File name for the right controller model.
  119035. */
  119036. static MODEL_RIGHT_FILENAME: string;
  119037. /**
  119038. * Base Url for the Quest controller model.
  119039. */
  119040. static QUEST_MODEL_BASE_URL: string;
  119041. /**
  119042. * @hidden
  119043. * If the controllers are running on a device that needs the updated Quest controller models
  119044. */
  119045. static _IsQuest: boolean;
  119046. /**
  119047. * Fired when the secondary trigger on this controller is modified
  119048. */
  119049. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  119050. /**
  119051. * Fired when the thumb rest on this controller is modified
  119052. */
  119053. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  119054. /**
  119055. * Creates a new OculusTouchController from a gamepad
  119056. * @param vrGamepad the gamepad that the controller should be created from
  119057. */
  119058. constructor(vrGamepad: any);
  119059. /**
  119060. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  119061. * @param scene scene in which to add meshes
  119062. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  119063. */
  119064. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  119065. /**
  119066. * Fired when the A button on this controller is modified
  119067. */
  119068. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119069. /**
  119070. * Fired when the B button on this controller is modified
  119071. */
  119072. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119073. /**
  119074. * Fired when the X button on this controller is modified
  119075. */
  119076. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119077. /**
  119078. * Fired when the Y button on this controller is modified
  119079. */
  119080. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119081. /**
  119082. * Called once for each button that changed state since the last frame
  119083. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  119084. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  119085. * 2) secondary trigger (same)
  119086. * 3) A (right) X (left), touch, pressed = value
  119087. * 4) B / Y
  119088. * 5) thumb rest
  119089. * @param buttonIdx Which button index changed
  119090. * @param state New state of the button
  119091. * @param changes Which properties on the state changed since last frame
  119092. */
  119093. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  119094. }
  119095. }
  119096. declare module BABYLON {
  119097. /**
  119098. * Vive Controller
  119099. */
  119100. export class ViveController extends WebVRController {
  119101. /**
  119102. * Base Url for the controller model.
  119103. */
  119104. static MODEL_BASE_URL: string;
  119105. /**
  119106. * File name for the controller model.
  119107. */
  119108. static MODEL_FILENAME: string;
  119109. /**
  119110. * Creates a new ViveController from a gamepad
  119111. * @param vrGamepad the gamepad that the controller should be created from
  119112. */
  119113. constructor(vrGamepad: any);
  119114. /**
  119115. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  119116. * @param scene scene in which to add meshes
  119117. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  119118. */
  119119. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  119120. /**
  119121. * Fired when the left button on this controller is modified
  119122. */
  119123. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119124. /**
  119125. * Fired when the right button on this controller is modified
  119126. */
  119127. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119128. /**
  119129. * Fired when the menu button on this controller is modified
  119130. */
  119131. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119132. /**
  119133. * Called once for each button that changed state since the last frame
  119134. * Vive mapping:
  119135. * 0: touchpad
  119136. * 1: trigger
  119137. * 2: left AND right buttons
  119138. * 3: menu button
  119139. * @param buttonIdx Which button index changed
  119140. * @param state New state of the button
  119141. * @param changes Which properties on the state changed since last frame
  119142. */
  119143. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  119144. }
  119145. }
  119146. declare module BABYLON {
  119147. /**
  119148. * Defines the WindowsMotionController object that the state of the windows motion controller
  119149. */
  119150. export class WindowsMotionController extends WebVRController {
  119151. /**
  119152. * The base url used to load the left and right controller models
  119153. */
  119154. static MODEL_BASE_URL: string;
  119155. /**
  119156. * The name of the left controller model file
  119157. */
  119158. static MODEL_LEFT_FILENAME: string;
  119159. /**
  119160. * The name of the right controller model file
  119161. */
  119162. static MODEL_RIGHT_FILENAME: string;
  119163. /**
  119164. * The controller name prefix for this controller type
  119165. */
  119166. static readonly GAMEPAD_ID_PREFIX: string;
  119167. /**
  119168. * The controller id pattern for this controller type
  119169. */
  119170. private static readonly GAMEPAD_ID_PATTERN;
  119171. private _loadedMeshInfo;
  119172. protected readonly _mapping: {
  119173. buttons: string[];
  119174. buttonMeshNames: {
  119175. 'trigger': string;
  119176. 'menu': string;
  119177. 'grip': string;
  119178. 'thumbstick': string;
  119179. 'trackpad': string;
  119180. };
  119181. buttonObservableNames: {
  119182. 'trigger': string;
  119183. 'menu': string;
  119184. 'grip': string;
  119185. 'thumbstick': string;
  119186. 'trackpad': string;
  119187. };
  119188. axisMeshNames: string[];
  119189. pointingPoseMeshName: string;
  119190. };
  119191. /**
  119192. * Fired when the trackpad on this controller is clicked
  119193. */
  119194. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  119195. /**
  119196. * Fired when the trackpad on this controller is modified
  119197. */
  119198. onTrackpadValuesChangedObservable: Observable<StickValues>;
  119199. /**
  119200. * The current x and y values of this controller's trackpad
  119201. */
  119202. trackpad: StickValues;
  119203. /**
  119204. * Creates a new WindowsMotionController from a gamepad
  119205. * @param vrGamepad the gamepad that the controller should be created from
  119206. */
  119207. constructor(vrGamepad: any);
  119208. /**
  119209. * Fired when the trigger on this controller is modified
  119210. */
  119211. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119212. /**
  119213. * Fired when the menu button on this controller is modified
  119214. */
  119215. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119216. /**
  119217. * Fired when the grip button on this controller is modified
  119218. */
  119219. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119220. /**
  119221. * Fired when the thumbstick button on this controller is modified
  119222. */
  119223. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119224. /**
  119225. * Fired when the touchpad button on this controller is modified
  119226. */
  119227. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119228. /**
  119229. * Fired when the touchpad values on this controller are modified
  119230. */
  119231. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  119232. protected _updateTrackpad(): void;
  119233. /**
  119234. * Called once per frame by the engine.
  119235. */
  119236. update(): void;
  119237. /**
  119238. * Called once for each button that changed state since the last frame
  119239. * @param buttonIdx Which button index changed
  119240. * @param state New state of the button
  119241. * @param changes Which properties on the state changed since last frame
  119242. */
  119243. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  119244. /**
  119245. * Moves the buttons on the controller mesh based on their current state
  119246. * @param buttonName the name of the button to move
  119247. * @param buttonValue the value of the button which determines the buttons new position
  119248. */
  119249. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  119250. /**
  119251. * Moves the axis on the controller mesh based on its current state
  119252. * @param axis the index of the axis
  119253. * @param axisValue the value of the axis which determines the meshes new position
  119254. * @hidden
  119255. */
  119256. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  119257. /**
  119258. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  119259. * @param scene scene in which to add meshes
  119260. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  119261. */
  119262. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  119263. /**
  119264. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  119265. * can be transformed by button presses and axes values, based on this._mapping.
  119266. *
  119267. * @param scene scene in which the meshes exist
  119268. * @param meshes list of meshes that make up the controller model to process
  119269. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  119270. */
  119271. private processModel;
  119272. private createMeshInfo;
  119273. /**
  119274. * Gets the ray of the controller in the direction the controller is pointing
  119275. * @param length the length the resulting ray should be
  119276. * @returns a ray in the direction the controller is pointing
  119277. */
  119278. getForwardRay(length?: number): Ray;
  119279. /**
  119280. * Disposes of the controller
  119281. */
  119282. dispose(): void;
  119283. }
  119284. /**
  119285. * This class represents a new windows motion controller in XR.
  119286. */
  119287. export class XRWindowsMotionController extends WindowsMotionController {
  119288. /**
  119289. * Changing the original WIndowsMotionController mapping to fir the new mapping
  119290. */
  119291. protected readonly _mapping: {
  119292. buttons: string[];
  119293. buttonMeshNames: {
  119294. 'trigger': string;
  119295. 'menu': string;
  119296. 'grip': string;
  119297. 'thumbstick': string;
  119298. 'trackpad': string;
  119299. };
  119300. buttonObservableNames: {
  119301. 'trigger': string;
  119302. 'menu': string;
  119303. 'grip': string;
  119304. 'thumbstick': string;
  119305. 'trackpad': string;
  119306. };
  119307. axisMeshNames: string[];
  119308. pointingPoseMeshName: string;
  119309. };
  119310. /**
  119311. * Construct a new XR-Based windows motion controller
  119312. *
  119313. * @param gamepadInfo the gamepad object from the browser
  119314. */
  119315. constructor(gamepadInfo: any);
  119316. /**
  119317. * holds the thumbstick values (X,Y)
  119318. */
  119319. thumbstickValues: StickValues;
  119320. /**
  119321. * Fired when the thumbstick on this controller is clicked
  119322. */
  119323. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  119324. /**
  119325. * Fired when the thumbstick on this controller is modified
  119326. */
  119327. onThumbstickValuesChangedObservable: Observable<StickValues>;
  119328. /**
  119329. * Fired when the touchpad button on this controller is modified
  119330. */
  119331. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  119332. /**
  119333. * Fired when the touchpad values on this controller are modified
  119334. */
  119335. onTrackpadValuesChangedObservable: Observable<StickValues>;
  119336. /**
  119337. * Fired when the thumbstick button on this controller is modified
  119338. * here to prevent breaking changes
  119339. */
  119340. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  119341. /**
  119342. * updating the thumbstick(!) and not the trackpad.
  119343. * This is named this way due to the difference between WebVR and XR and to avoid
  119344. * changing the parent class.
  119345. */
  119346. protected _updateTrackpad(): void;
  119347. /**
  119348. * Disposes the class with joy
  119349. */
  119350. dispose(): void;
  119351. }
  119352. }
  119353. declare module BABYLON {
  119354. /**
  119355. * Class containing static functions to help procedurally build meshes
  119356. */
  119357. export class PolyhedronBuilder {
  119358. /**
  119359. * Creates a polyhedron mesh
  119360. * * 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
  119361. * * The parameter `size` (positive float, default 1) sets the polygon size
  119362. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  119363. * * 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`
  119364. * * 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
  119365. * * 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)`)
  119366. * * 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
  119367. * * 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
  119368. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119369. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119371. * @param name defines the name of the mesh
  119372. * @param options defines the options used to create the mesh
  119373. * @param scene defines the hosting scene
  119374. * @returns the polyhedron mesh
  119375. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  119376. */
  119377. static CreatePolyhedron(name: string, options: {
  119378. type?: number;
  119379. size?: number;
  119380. sizeX?: number;
  119381. sizeY?: number;
  119382. sizeZ?: number;
  119383. custom?: any;
  119384. faceUV?: Vector4[];
  119385. faceColors?: Color4[];
  119386. flat?: boolean;
  119387. updatable?: boolean;
  119388. sideOrientation?: number;
  119389. frontUVs?: Vector4;
  119390. backUVs?: Vector4;
  119391. }, scene?: Nullable<Scene>): Mesh;
  119392. }
  119393. }
  119394. declare module BABYLON {
  119395. /**
  119396. * Gizmo that enables scaling a mesh along 3 axis
  119397. */
  119398. export class ScaleGizmo extends Gizmo {
  119399. /**
  119400. * Internal gizmo used for interactions on the x axis
  119401. */
  119402. xGizmo: AxisScaleGizmo;
  119403. /**
  119404. * Internal gizmo used for interactions on the y axis
  119405. */
  119406. yGizmo: AxisScaleGizmo;
  119407. /**
  119408. * Internal gizmo used for interactions on the z axis
  119409. */
  119410. zGizmo: AxisScaleGizmo;
  119411. /**
  119412. * Internal gizmo used to scale all axis equally
  119413. */
  119414. uniformScaleGizmo: AxisScaleGizmo;
  119415. private _meshAttached;
  119416. private _updateGizmoRotationToMatchAttachedMesh;
  119417. private _snapDistance;
  119418. private _scaleRatio;
  119419. private _uniformScalingMesh;
  119420. private _octahedron;
  119421. private _sensitivity;
  119422. /** Fires an event when any of it's sub gizmos are dragged */
  119423. onDragStartObservable: Observable<unknown>;
  119424. /** Fires an event when any of it's sub gizmos are released from dragging */
  119425. onDragEndObservable: Observable<unknown>;
  119426. get attachedMesh(): Nullable<AbstractMesh>;
  119427. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119428. /**
  119429. * Creates a ScaleGizmo
  119430. * @param gizmoLayer The utility layer the gizmo will be added to
  119431. */
  119432. constructor(gizmoLayer?: UtilityLayerRenderer);
  119433. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119434. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119435. /**
  119436. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119437. */
  119438. set snapDistance(value: number);
  119439. get snapDistance(): number;
  119440. /**
  119441. * Ratio for the scale of the gizmo (Default: 1)
  119442. */
  119443. set scaleRatio(value: number);
  119444. get scaleRatio(): number;
  119445. /**
  119446. * Sensitivity factor for dragging (Default: 1)
  119447. */
  119448. set sensitivity(value: number);
  119449. get sensitivity(): number;
  119450. /**
  119451. * Disposes of the gizmo
  119452. */
  119453. dispose(): void;
  119454. }
  119455. }
  119456. declare module BABYLON {
  119457. /**
  119458. * Single axis scale gizmo
  119459. */
  119460. export class AxisScaleGizmo extends Gizmo {
  119461. /**
  119462. * Drag behavior responsible for the gizmos dragging interactions
  119463. */
  119464. dragBehavior: PointerDragBehavior;
  119465. private _pointerObserver;
  119466. /**
  119467. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119468. */
  119469. snapDistance: number;
  119470. /**
  119471. * Event that fires each time the gizmo snaps to a new location.
  119472. * * snapDistance is the the change in distance
  119473. */
  119474. onSnapObservable: Observable<{
  119475. snapDistance: number;
  119476. }>;
  119477. /**
  119478. * If the scaling operation should be done on all axis (default: false)
  119479. */
  119480. uniformScaling: boolean;
  119481. /**
  119482. * Custom sensitivity value for the drag strength
  119483. */
  119484. sensitivity: number;
  119485. private _isEnabled;
  119486. private _parent;
  119487. private _arrow;
  119488. private _coloredMaterial;
  119489. private _hoverMaterial;
  119490. /**
  119491. * Creates an AxisScaleGizmo
  119492. * @param gizmoLayer The utility layer the gizmo will be added to
  119493. * @param dragAxis The axis which the gizmo will be able to scale on
  119494. * @param color The color of the gizmo
  119495. */
  119496. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  119497. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119498. /**
  119499. * If the gizmo is enabled
  119500. */
  119501. set isEnabled(value: boolean);
  119502. get isEnabled(): boolean;
  119503. /**
  119504. * Disposes of the gizmo
  119505. */
  119506. dispose(): void;
  119507. /**
  119508. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119509. * @param mesh The mesh to replace the default mesh of the gizmo
  119510. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  119511. */
  119512. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  119513. }
  119514. }
  119515. declare module BABYLON {
  119516. /**
  119517. * Bounding box gizmo
  119518. */
  119519. export class BoundingBoxGizmo extends Gizmo {
  119520. private _lineBoundingBox;
  119521. private _rotateSpheresParent;
  119522. private _scaleBoxesParent;
  119523. private _boundingDimensions;
  119524. private _renderObserver;
  119525. private _pointerObserver;
  119526. private _scaleDragSpeed;
  119527. private _tmpQuaternion;
  119528. private _tmpVector;
  119529. private _tmpRotationMatrix;
  119530. /**
  119531. * 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)
  119532. */
  119533. ignoreChildren: boolean;
  119534. /**
  119535. * 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)
  119536. */
  119537. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  119538. /**
  119539. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  119540. */
  119541. rotationSphereSize: number;
  119542. /**
  119543. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  119544. */
  119545. scaleBoxSize: number;
  119546. /**
  119547. * 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)
  119548. */
  119549. fixedDragMeshScreenSize: boolean;
  119550. /**
  119551. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  119552. */
  119553. fixedDragMeshScreenSizeDistanceFactor: number;
  119554. /**
  119555. * Fired when a rotation sphere or scale box is dragged
  119556. */
  119557. onDragStartObservable: Observable<{}>;
  119558. /**
  119559. * Fired when a scale box is dragged
  119560. */
  119561. onScaleBoxDragObservable: Observable<{}>;
  119562. /**
  119563. * Fired when a scale box drag is ended
  119564. */
  119565. onScaleBoxDragEndObservable: Observable<{}>;
  119566. /**
  119567. * Fired when a rotation sphere is dragged
  119568. */
  119569. onRotationSphereDragObservable: Observable<{}>;
  119570. /**
  119571. * Fired when a rotation sphere drag is ended
  119572. */
  119573. onRotationSphereDragEndObservable: Observable<{}>;
  119574. /**
  119575. * 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)
  119576. */
  119577. scalePivot: Nullable<Vector3>;
  119578. /**
  119579. * Mesh used as a pivot to rotate the attached mesh
  119580. */
  119581. private _anchorMesh;
  119582. private _existingMeshScale;
  119583. private _dragMesh;
  119584. private pointerDragBehavior;
  119585. private coloredMaterial;
  119586. private hoverColoredMaterial;
  119587. /**
  119588. * Sets the color of the bounding box gizmo
  119589. * @param color the color to set
  119590. */
  119591. setColor(color: Color3): void;
  119592. /**
  119593. * Creates an BoundingBoxGizmo
  119594. * @param gizmoLayer The utility layer the gizmo will be added to
  119595. * @param color The color of the gizmo
  119596. */
  119597. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  119598. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119599. private _selectNode;
  119600. /**
  119601. * Updates the bounding box information for the Gizmo
  119602. */
  119603. updateBoundingBox(): void;
  119604. private _updateRotationSpheres;
  119605. private _updateScaleBoxes;
  119606. /**
  119607. * Enables rotation on the specified axis and disables rotation on the others
  119608. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  119609. */
  119610. setEnabledRotationAxis(axis: string): void;
  119611. /**
  119612. * Enables/disables scaling
  119613. * @param enable if scaling should be enabled
  119614. */
  119615. setEnabledScaling(enable: boolean): void;
  119616. private _updateDummy;
  119617. /**
  119618. * Enables a pointer drag behavior on the bounding box of the gizmo
  119619. */
  119620. enableDragBehavior(): void;
  119621. /**
  119622. * Disposes of the gizmo
  119623. */
  119624. dispose(): void;
  119625. /**
  119626. * 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)
  119627. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  119628. * @returns the bounding box mesh with the passed in mesh as a child
  119629. */
  119630. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  119631. /**
  119632. * CustomMeshes are not supported by this gizmo
  119633. * @param mesh The mesh to replace the default mesh of the gizmo
  119634. */
  119635. setCustomMesh(mesh: Mesh): void;
  119636. }
  119637. }
  119638. declare module BABYLON {
  119639. /**
  119640. * Single plane rotation gizmo
  119641. */
  119642. export class PlaneRotationGizmo extends Gizmo {
  119643. /**
  119644. * Drag behavior responsible for the gizmos dragging interactions
  119645. */
  119646. dragBehavior: PointerDragBehavior;
  119647. private _pointerObserver;
  119648. /**
  119649. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  119650. */
  119651. snapDistance: number;
  119652. /**
  119653. * Event that fires each time the gizmo snaps to a new location.
  119654. * * snapDistance is the the change in distance
  119655. */
  119656. onSnapObservable: Observable<{
  119657. snapDistance: number;
  119658. }>;
  119659. private _isEnabled;
  119660. private _parent;
  119661. /**
  119662. * Creates a PlaneRotationGizmo
  119663. * @param gizmoLayer The utility layer the gizmo will be added to
  119664. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  119665. * @param color The color of the gizmo
  119666. * @param tessellation Amount of tessellation to be used when creating rotation circles
  119667. * @param useEulerRotation Use and update Euler angle instead of quaternion
  119668. */
  119669. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  119670. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119671. /**
  119672. * If the gizmo is enabled
  119673. */
  119674. set isEnabled(value: boolean);
  119675. get isEnabled(): boolean;
  119676. /**
  119677. * Disposes of the gizmo
  119678. */
  119679. dispose(): void;
  119680. }
  119681. }
  119682. declare module BABYLON {
  119683. /**
  119684. * Gizmo that enables rotating a mesh along 3 axis
  119685. */
  119686. export class RotationGizmo extends Gizmo {
  119687. /**
  119688. * Internal gizmo used for interactions on the x axis
  119689. */
  119690. xGizmo: PlaneRotationGizmo;
  119691. /**
  119692. * Internal gizmo used for interactions on the y axis
  119693. */
  119694. yGizmo: PlaneRotationGizmo;
  119695. /**
  119696. * Internal gizmo used for interactions on the z axis
  119697. */
  119698. zGizmo: PlaneRotationGizmo;
  119699. /** Fires an event when any of it's sub gizmos are dragged */
  119700. onDragStartObservable: Observable<unknown>;
  119701. /** Fires an event when any of it's sub gizmos are released from dragging */
  119702. onDragEndObservable: Observable<unknown>;
  119703. private _meshAttached;
  119704. get attachedMesh(): Nullable<AbstractMesh>;
  119705. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119706. /**
  119707. * Creates a RotationGizmo
  119708. * @param gizmoLayer The utility layer the gizmo will be added to
  119709. * @param tessellation Amount of tessellation to be used when creating rotation circles
  119710. * @param useEulerRotation Use and update Euler angle instead of quaternion
  119711. */
  119712. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  119713. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119714. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119715. /**
  119716. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119717. */
  119718. set snapDistance(value: number);
  119719. get snapDistance(): number;
  119720. /**
  119721. * Ratio for the scale of the gizmo (Default: 1)
  119722. */
  119723. set scaleRatio(value: number);
  119724. get scaleRatio(): number;
  119725. /**
  119726. * Disposes of the gizmo
  119727. */
  119728. dispose(): void;
  119729. /**
  119730. * CustomMeshes are not supported by this gizmo
  119731. * @param mesh The mesh to replace the default mesh of the gizmo
  119732. */
  119733. setCustomMesh(mesh: Mesh): void;
  119734. }
  119735. }
  119736. declare module BABYLON {
  119737. /**
  119738. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  119739. */
  119740. export class GizmoManager implements IDisposable {
  119741. private scene;
  119742. /**
  119743. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  119744. */
  119745. gizmos: {
  119746. positionGizmo: Nullable<PositionGizmo>;
  119747. rotationGizmo: Nullable<RotationGizmo>;
  119748. scaleGizmo: Nullable<ScaleGizmo>;
  119749. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  119750. };
  119751. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  119752. clearGizmoOnEmptyPointerEvent: boolean;
  119753. /** Fires an event when the manager is attached to a mesh */
  119754. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  119755. private _gizmosEnabled;
  119756. private _pointerObserver;
  119757. private _attachedMesh;
  119758. private _boundingBoxColor;
  119759. private _defaultUtilityLayer;
  119760. private _defaultKeepDepthUtilityLayer;
  119761. /**
  119762. * When bounding box gizmo is enabled, this can be used to track drag/end events
  119763. */
  119764. boundingBoxDragBehavior: SixDofDragBehavior;
  119765. /**
  119766. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  119767. */
  119768. attachableMeshes: Nullable<Array<AbstractMesh>>;
  119769. /**
  119770. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  119771. */
  119772. usePointerToAttachGizmos: boolean;
  119773. /**
  119774. * Utility layer that the bounding box gizmo belongs to
  119775. */
  119776. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  119777. /**
  119778. * Utility layer that all gizmos besides bounding box belong to
  119779. */
  119780. get utilityLayer(): UtilityLayerRenderer;
  119781. /**
  119782. * Instatiates a gizmo manager
  119783. * @param scene the scene to overlay the gizmos on top of
  119784. */
  119785. constructor(scene: Scene);
  119786. /**
  119787. * Attaches a set of gizmos to the specified mesh
  119788. * @param mesh The mesh the gizmo's should be attached to
  119789. */
  119790. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  119791. /**
  119792. * If the position gizmo is enabled
  119793. */
  119794. set positionGizmoEnabled(value: boolean);
  119795. get positionGizmoEnabled(): boolean;
  119796. /**
  119797. * If the rotation gizmo is enabled
  119798. */
  119799. set rotationGizmoEnabled(value: boolean);
  119800. get rotationGizmoEnabled(): boolean;
  119801. /**
  119802. * If the scale gizmo is enabled
  119803. */
  119804. set scaleGizmoEnabled(value: boolean);
  119805. get scaleGizmoEnabled(): boolean;
  119806. /**
  119807. * If the boundingBox gizmo is enabled
  119808. */
  119809. set boundingBoxGizmoEnabled(value: boolean);
  119810. get boundingBoxGizmoEnabled(): boolean;
  119811. /**
  119812. * Disposes of the gizmo manager
  119813. */
  119814. dispose(): void;
  119815. }
  119816. }
  119817. declare module BABYLON {
  119818. /**
  119819. * A directional light is defined by a direction (what a surprise!).
  119820. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  119821. * 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.
  119822. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119823. */
  119824. export class DirectionalLight extends ShadowLight {
  119825. private _shadowFrustumSize;
  119826. /**
  119827. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  119828. */
  119829. get shadowFrustumSize(): number;
  119830. /**
  119831. * Specifies a fix frustum size for the shadow generation.
  119832. */
  119833. set shadowFrustumSize(value: number);
  119834. private _shadowOrthoScale;
  119835. /**
  119836. * Gets the shadow projection scale against the optimal computed one.
  119837. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  119838. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  119839. */
  119840. get shadowOrthoScale(): number;
  119841. /**
  119842. * Sets the shadow projection scale against the optimal computed one.
  119843. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  119844. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  119845. */
  119846. set shadowOrthoScale(value: number);
  119847. /**
  119848. * Automatically compute the projection matrix to best fit (including all the casters)
  119849. * on each frame.
  119850. */
  119851. autoUpdateExtends: boolean;
  119852. /**
  119853. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  119854. * on each frame. autoUpdateExtends must be set to true for this to work
  119855. */
  119856. autoCalcShadowZBounds: boolean;
  119857. private _orthoLeft;
  119858. private _orthoRight;
  119859. private _orthoTop;
  119860. private _orthoBottom;
  119861. /**
  119862. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  119863. * The directional light is emitted from everywhere in the given direction.
  119864. * It can cast shadows.
  119865. * Documentation : https://doc.babylonjs.com/babylon101/lights
  119866. * @param name The friendly name of the light
  119867. * @param direction The direction of the light
  119868. * @param scene The scene the light belongs to
  119869. */
  119870. constructor(name: string, direction: Vector3, scene: Scene);
  119871. /**
  119872. * Returns the string "DirectionalLight".
  119873. * @return The class name
  119874. */
  119875. getClassName(): string;
  119876. /**
  119877. * Returns the integer 1.
  119878. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  119879. */
  119880. getTypeID(): number;
  119881. /**
  119882. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  119883. * Returns the DirectionalLight Shadow projection matrix.
  119884. */
  119885. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119886. /**
  119887. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  119888. * Returns the DirectionalLight Shadow projection matrix.
  119889. */
  119890. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  119891. /**
  119892. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  119893. * Returns the DirectionalLight Shadow projection matrix.
  119894. */
  119895. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  119896. protected _buildUniformLayout(): void;
  119897. /**
  119898. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  119899. * @param effect The effect to update
  119900. * @param lightIndex The index of the light in the effect to update
  119901. * @returns The directional light
  119902. */
  119903. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  119904. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  119905. /**
  119906. * Gets the minZ used for shadow according to both the scene and the light.
  119907. *
  119908. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  119909. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  119910. * @param activeCamera The camera we are returning the min for
  119911. * @returns the depth min z
  119912. */
  119913. getDepthMinZ(activeCamera: Camera): number;
  119914. /**
  119915. * Gets the maxZ used for shadow according to both the scene and the light.
  119916. *
  119917. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  119918. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  119919. * @param activeCamera The camera we are returning the max for
  119920. * @returns the depth max z
  119921. */
  119922. getDepthMaxZ(activeCamera: Camera): number;
  119923. /**
  119924. * Prepares the list of defines specific to the light type.
  119925. * @param defines the list of defines
  119926. * @param lightIndex defines the index of the light for the effect
  119927. */
  119928. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  119929. }
  119930. }
  119931. declare module BABYLON {
  119932. /**
  119933. * Class containing static functions to help procedurally build meshes
  119934. */
  119935. export class HemisphereBuilder {
  119936. /**
  119937. * Creates a hemisphere mesh
  119938. * @param name defines the name of the mesh
  119939. * @param options defines the options used to create the mesh
  119940. * @param scene defines the hosting scene
  119941. * @returns the hemisphere mesh
  119942. */
  119943. static CreateHemisphere(name: string, options: {
  119944. segments?: number;
  119945. diameter?: number;
  119946. sideOrientation?: number;
  119947. }, scene: any): Mesh;
  119948. }
  119949. }
  119950. declare module BABYLON {
  119951. /**
  119952. * A spot light is defined by a position, a direction, an angle, and an exponent.
  119953. * These values define a cone of light starting from the position, emitting toward the direction.
  119954. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  119955. * and the exponent defines the speed of the decay of the light with distance (reach).
  119956. * Documentation: https://doc.babylonjs.com/babylon101/lights
  119957. */
  119958. export class SpotLight extends ShadowLight {
  119959. private _angle;
  119960. private _innerAngle;
  119961. private _cosHalfAngle;
  119962. private _lightAngleScale;
  119963. private _lightAngleOffset;
  119964. /**
  119965. * Gets the cone angle of the spot light in Radians.
  119966. */
  119967. get angle(): number;
  119968. /**
  119969. * Sets the cone angle of the spot light in Radians.
  119970. */
  119971. set angle(value: number);
  119972. /**
  119973. * Only used in gltf falloff mode, this defines the angle where
  119974. * the directional falloff will start before cutting at angle which could be seen
  119975. * as outer angle.
  119976. */
  119977. get innerAngle(): number;
  119978. /**
  119979. * Only used in gltf falloff mode, this defines the angle where
  119980. * the directional falloff will start before cutting at angle which could be seen
  119981. * as outer angle.
  119982. */
  119983. set innerAngle(value: number);
  119984. private _shadowAngleScale;
  119985. /**
  119986. * Allows scaling the angle of the light for shadow generation only.
  119987. */
  119988. get shadowAngleScale(): number;
  119989. /**
  119990. * Allows scaling the angle of the light for shadow generation only.
  119991. */
  119992. set shadowAngleScale(value: number);
  119993. /**
  119994. * The light decay speed with the distance from the emission spot.
  119995. */
  119996. exponent: number;
  119997. private _projectionTextureMatrix;
  119998. /**
  119999. * Allows reading the projecton texture
  120000. */
  120001. get projectionTextureMatrix(): Matrix;
  120002. protected _projectionTextureLightNear: number;
  120003. /**
  120004. * Gets the near clip of the Spotlight for texture projection.
  120005. */
  120006. get projectionTextureLightNear(): number;
  120007. /**
  120008. * Sets the near clip of the Spotlight for texture projection.
  120009. */
  120010. set projectionTextureLightNear(value: number);
  120011. protected _projectionTextureLightFar: number;
  120012. /**
  120013. * Gets the far clip of the Spotlight for texture projection.
  120014. */
  120015. get projectionTextureLightFar(): number;
  120016. /**
  120017. * Sets the far clip of the Spotlight for texture projection.
  120018. */
  120019. set projectionTextureLightFar(value: number);
  120020. protected _projectionTextureUpDirection: Vector3;
  120021. /**
  120022. * Gets the Up vector of the Spotlight for texture projection.
  120023. */
  120024. get projectionTextureUpDirection(): Vector3;
  120025. /**
  120026. * Sets the Up vector of the Spotlight for texture projection.
  120027. */
  120028. set projectionTextureUpDirection(value: Vector3);
  120029. private _projectionTexture;
  120030. /**
  120031. * Gets the projection texture of the light.
  120032. */
  120033. get projectionTexture(): Nullable<BaseTexture>;
  120034. /**
  120035. * Sets the projection texture of the light.
  120036. */
  120037. set projectionTexture(value: Nullable<BaseTexture>);
  120038. private _projectionTextureViewLightDirty;
  120039. private _projectionTextureProjectionLightDirty;
  120040. private _projectionTextureDirty;
  120041. private _projectionTextureViewTargetVector;
  120042. private _projectionTextureViewLightMatrix;
  120043. private _projectionTextureProjectionLightMatrix;
  120044. private _projectionTextureScalingMatrix;
  120045. /**
  120046. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  120047. * It can cast shadows.
  120048. * Documentation : https://doc.babylonjs.com/babylon101/lights
  120049. * @param name The light friendly name
  120050. * @param position The position of the spot light in the scene
  120051. * @param direction The direction of the light in the scene
  120052. * @param angle The cone angle of the light in Radians
  120053. * @param exponent The light decay speed with the distance from the emission spot
  120054. * @param scene The scene the lights belongs to
  120055. */
  120056. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  120057. /**
  120058. * Returns the string "SpotLight".
  120059. * @returns the class name
  120060. */
  120061. getClassName(): string;
  120062. /**
  120063. * Returns the integer 2.
  120064. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  120065. */
  120066. getTypeID(): number;
  120067. /**
  120068. * Overrides the direction setter to recompute the projection texture view light Matrix.
  120069. */
  120070. protected _setDirection(value: Vector3): void;
  120071. /**
  120072. * Overrides the position setter to recompute the projection texture view light Matrix.
  120073. */
  120074. protected _setPosition(value: Vector3): void;
  120075. /**
  120076. * 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.
  120077. * Returns the SpotLight.
  120078. */
  120079. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  120080. protected _computeProjectionTextureViewLightMatrix(): void;
  120081. protected _computeProjectionTextureProjectionLightMatrix(): void;
  120082. /**
  120083. * Main function for light texture projection matrix computing.
  120084. */
  120085. protected _computeProjectionTextureMatrix(): void;
  120086. protected _buildUniformLayout(): void;
  120087. private _computeAngleValues;
  120088. /**
  120089. * Sets the passed Effect "effect" with the Light textures.
  120090. * @param effect The effect to update
  120091. * @param lightIndex The index of the light in the effect to update
  120092. * @returns The light
  120093. */
  120094. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  120095. /**
  120096. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  120097. * @param effect The effect to update
  120098. * @param lightIndex The index of the light in the effect to update
  120099. * @returns The spot light
  120100. */
  120101. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  120102. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  120103. /**
  120104. * Disposes the light and the associated resources.
  120105. */
  120106. dispose(): void;
  120107. /**
  120108. * Prepares the list of defines specific to the light type.
  120109. * @param defines the list of defines
  120110. * @param lightIndex defines the index of the light for the effect
  120111. */
  120112. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  120113. }
  120114. }
  120115. declare module BABYLON {
  120116. /**
  120117. * Gizmo that enables viewing a light
  120118. */
  120119. export class LightGizmo extends Gizmo {
  120120. private _lightMesh;
  120121. private _material;
  120122. private _cachedPosition;
  120123. private _cachedForward;
  120124. private _attachedMeshParent;
  120125. /**
  120126. * Creates a LightGizmo
  120127. * @param gizmoLayer The utility layer the gizmo will be added to
  120128. */
  120129. constructor(gizmoLayer?: UtilityLayerRenderer);
  120130. private _light;
  120131. /**
  120132. * The light that the gizmo is attached to
  120133. */
  120134. set light(light: Nullable<Light>);
  120135. get light(): Nullable<Light>;
  120136. /**
  120137. * Gets the material used to render the light gizmo
  120138. */
  120139. get material(): StandardMaterial;
  120140. /**
  120141. * @hidden
  120142. * Updates the gizmo to match the attached mesh's position/rotation
  120143. */
  120144. protected _update(): void;
  120145. private static _Scale;
  120146. /**
  120147. * Creates the lines for a light mesh
  120148. */
  120149. private static _CreateLightLines;
  120150. /**
  120151. * Disposes of the light gizmo
  120152. */
  120153. dispose(): void;
  120154. private static _CreateHemisphericLightMesh;
  120155. private static _CreatePointLightMesh;
  120156. private static _CreateSpotLightMesh;
  120157. private static _CreateDirectionalLightMesh;
  120158. }
  120159. }
  120160. declare module BABYLON {
  120161. /** @hidden */
  120162. export var backgroundFragmentDeclaration: {
  120163. name: string;
  120164. shader: string;
  120165. };
  120166. }
  120167. declare module BABYLON {
  120168. /** @hidden */
  120169. export var backgroundUboDeclaration: {
  120170. name: string;
  120171. shader: string;
  120172. };
  120173. }
  120174. declare module BABYLON {
  120175. /** @hidden */
  120176. export var backgroundPixelShader: {
  120177. name: string;
  120178. shader: string;
  120179. };
  120180. }
  120181. declare module BABYLON {
  120182. /** @hidden */
  120183. export var backgroundVertexDeclaration: {
  120184. name: string;
  120185. shader: string;
  120186. };
  120187. }
  120188. declare module BABYLON {
  120189. /** @hidden */
  120190. export var backgroundVertexShader: {
  120191. name: string;
  120192. shader: string;
  120193. };
  120194. }
  120195. declare module BABYLON {
  120196. /**
  120197. * Background material used to create an efficient environement around your scene.
  120198. */
  120199. export class BackgroundMaterial extends PushMaterial {
  120200. /**
  120201. * Standard reflectance value at parallel view angle.
  120202. */
  120203. static StandardReflectance0: number;
  120204. /**
  120205. * Standard reflectance value at grazing angle.
  120206. */
  120207. static StandardReflectance90: number;
  120208. protected _primaryColor: Color3;
  120209. /**
  120210. * Key light Color (multiply against the environement texture)
  120211. */
  120212. primaryColor: Color3;
  120213. protected __perceptualColor: Nullable<Color3>;
  120214. /**
  120215. * Experimental Internal Use Only.
  120216. *
  120217. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  120218. * This acts as a helper to set the primary color to a more "human friendly" value.
  120219. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  120220. * output color as close as possible from the chosen value.
  120221. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  120222. * part of lighting setup.)
  120223. */
  120224. get _perceptualColor(): Nullable<Color3>;
  120225. set _perceptualColor(value: Nullable<Color3>);
  120226. protected _primaryColorShadowLevel: float;
  120227. /**
  120228. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  120229. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  120230. */
  120231. get primaryColorShadowLevel(): float;
  120232. set primaryColorShadowLevel(value: float);
  120233. protected _primaryColorHighlightLevel: float;
  120234. /**
  120235. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  120236. * The primary color is used at the level chosen to define what the white area would look.
  120237. */
  120238. get primaryColorHighlightLevel(): float;
  120239. set primaryColorHighlightLevel(value: float);
  120240. protected _reflectionTexture: Nullable<BaseTexture>;
  120241. /**
  120242. * Reflection Texture used in the material.
  120243. * Should be author in a specific way for the best result (refer to the documentation).
  120244. */
  120245. reflectionTexture: Nullable<BaseTexture>;
  120246. protected _reflectionBlur: float;
  120247. /**
  120248. * Reflection Texture level of blur.
  120249. *
  120250. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  120251. * texture twice.
  120252. */
  120253. reflectionBlur: float;
  120254. protected _diffuseTexture: Nullable<BaseTexture>;
  120255. /**
  120256. * Diffuse Texture used in the material.
  120257. * Should be author in a specific way for the best result (refer to the documentation).
  120258. */
  120259. diffuseTexture: Nullable<BaseTexture>;
  120260. protected _shadowLights: Nullable<IShadowLight[]>;
  120261. /**
  120262. * Specify the list of lights casting shadow on the material.
  120263. * All scene shadow lights will be included if null.
  120264. */
  120265. shadowLights: Nullable<IShadowLight[]>;
  120266. protected _shadowLevel: float;
  120267. /**
  120268. * Helps adjusting the shadow to a softer level if required.
  120269. * 0 means black shadows and 1 means no shadows.
  120270. */
  120271. shadowLevel: float;
  120272. protected _sceneCenter: Vector3;
  120273. /**
  120274. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  120275. * It is usually zero but might be interesting to modify according to your setup.
  120276. */
  120277. sceneCenter: Vector3;
  120278. protected _opacityFresnel: boolean;
  120279. /**
  120280. * This helps specifying that the material is falling off to the sky box at grazing angle.
  120281. * This helps ensuring a nice transition when the camera goes under the ground.
  120282. */
  120283. opacityFresnel: boolean;
  120284. protected _reflectionFresnel: boolean;
  120285. /**
  120286. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  120287. * This helps adding a mirror texture on the ground.
  120288. */
  120289. reflectionFresnel: boolean;
  120290. protected _reflectionFalloffDistance: number;
  120291. /**
  120292. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  120293. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  120294. */
  120295. reflectionFalloffDistance: number;
  120296. protected _reflectionAmount: number;
  120297. /**
  120298. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  120299. */
  120300. reflectionAmount: number;
  120301. protected _reflectionReflectance0: number;
  120302. /**
  120303. * This specifies the weight of the reflection at grazing angle.
  120304. */
  120305. reflectionReflectance0: number;
  120306. protected _reflectionReflectance90: number;
  120307. /**
  120308. * This specifies the weight of the reflection at a perpendicular point of view.
  120309. */
  120310. reflectionReflectance90: number;
  120311. /**
  120312. * Sets the reflection reflectance fresnel values according to the default standard
  120313. * empirically know to work well :-)
  120314. */
  120315. set reflectionStandardFresnelWeight(value: number);
  120316. protected _useRGBColor: boolean;
  120317. /**
  120318. * Helps to directly use the maps channels instead of their level.
  120319. */
  120320. useRGBColor: boolean;
  120321. protected _enableNoise: boolean;
  120322. /**
  120323. * This helps reducing the banding effect that could occur on the background.
  120324. */
  120325. enableNoise: boolean;
  120326. /**
  120327. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  120328. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  120329. * Recommended to be keep at 1.0 except for special cases.
  120330. */
  120331. get fovMultiplier(): number;
  120332. set fovMultiplier(value: number);
  120333. private _fovMultiplier;
  120334. /**
  120335. * Enable the FOV adjustment feature controlled by fovMultiplier.
  120336. */
  120337. useEquirectangularFOV: boolean;
  120338. private _maxSimultaneousLights;
  120339. /**
  120340. * Number of Simultaneous lights allowed on the material.
  120341. */
  120342. maxSimultaneousLights: int;
  120343. /**
  120344. * Default configuration related to image processing available in the Background Material.
  120345. */
  120346. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120347. /**
  120348. * Keep track of the image processing observer to allow dispose and replace.
  120349. */
  120350. private _imageProcessingObserver;
  120351. /**
  120352. * Attaches a new image processing configuration to the PBR Material.
  120353. * @param configuration (if null the scene configuration will be use)
  120354. */
  120355. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  120356. /**
  120357. * Gets the image processing configuration used either in this material.
  120358. */
  120359. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  120360. /**
  120361. * Sets the Default image processing configuration used either in the this material.
  120362. *
  120363. * If sets to null, the scene one is in use.
  120364. */
  120365. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  120366. /**
  120367. * Gets wether the color curves effect is enabled.
  120368. */
  120369. get cameraColorCurvesEnabled(): boolean;
  120370. /**
  120371. * Sets wether the color curves effect is enabled.
  120372. */
  120373. set cameraColorCurvesEnabled(value: boolean);
  120374. /**
  120375. * Gets wether the color grading effect is enabled.
  120376. */
  120377. get cameraColorGradingEnabled(): boolean;
  120378. /**
  120379. * Gets wether the color grading effect is enabled.
  120380. */
  120381. set cameraColorGradingEnabled(value: boolean);
  120382. /**
  120383. * Gets wether tonemapping is enabled or not.
  120384. */
  120385. get cameraToneMappingEnabled(): boolean;
  120386. /**
  120387. * Sets wether tonemapping is enabled or not
  120388. */
  120389. set cameraToneMappingEnabled(value: boolean);
  120390. /**
  120391. * The camera exposure used on this material.
  120392. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  120393. * This corresponds to a photographic exposure.
  120394. */
  120395. get cameraExposure(): float;
  120396. /**
  120397. * The camera exposure used on this material.
  120398. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  120399. * This corresponds to a photographic exposure.
  120400. */
  120401. set cameraExposure(value: float);
  120402. /**
  120403. * Gets The camera contrast used on this material.
  120404. */
  120405. get cameraContrast(): float;
  120406. /**
  120407. * Sets The camera contrast used on this material.
  120408. */
  120409. set cameraContrast(value: float);
  120410. /**
  120411. * Gets the Color Grading 2D Lookup Texture.
  120412. */
  120413. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  120414. /**
  120415. * Sets the Color Grading 2D Lookup Texture.
  120416. */
  120417. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  120418. /**
  120419. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  120420. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  120421. * 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;
  120422. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  120423. */
  120424. get cameraColorCurves(): Nullable<ColorCurves>;
  120425. /**
  120426. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  120427. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  120428. * 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;
  120429. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  120430. */
  120431. set cameraColorCurves(value: Nullable<ColorCurves>);
  120432. /**
  120433. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  120434. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  120435. */
  120436. switchToBGR: boolean;
  120437. private _renderTargets;
  120438. private _reflectionControls;
  120439. private _white;
  120440. private _primaryShadowColor;
  120441. private _primaryHighlightColor;
  120442. /**
  120443. * Instantiates a Background Material in the given scene
  120444. * @param name The friendly name of the material
  120445. * @param scene The scene to add the material to
  120446. */
  120447. constructor(name: string, scene: Scene);
  120448. /**
  120449. * Gets a boolean indicating that current material needs to register RTT
  120450. */
  120451. get hasRenderTargetTextures(): boolean;
  120452. /**
  120453. * The entire material has been created in order to prevent overdraw.
  120454. * @returns false
  120455. */
  120456. needAlphaTesting(): boolean;
  120457. /**
  120458. * The entire material has been created in order to prevent overdraw.
  120459. * @returns true if blending is enable
  120460. */
  120461. needAlphaBlending(): boolean;
  120462. /**
  120463. * Checks wether the material is ready to be rendered for a given mesh.
  120464. * @param mesh The mesh to render
  120465. * @param subMesh The submesh to check against
  120466. * @param useInstances Specify wether or not the material is used with instances
  120467. * @returns true if all the dependencies are ready (Textures, Effects...)
  120468. */
  120469. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  120470. /**
  120471. * Compute the primary color according to the chosen perceptual color.
  120472. */
  120473. private _computePrimaryColorFromPerceptualColor;
  120474. /**
  120475. * Compute the highlights and shadow colors according to their chosen levels.
  120476. */
  120477. private _computePrimaryColors;
  120478. /**
  120479. * Build the uniform buffer used in the material.
  120480. */
  120481. buildUniformLayout(): void;
  120482. /**
  120483. * Unbind the material.
  120484. */
  120485. unbind(): void;
  120486. /**
  120487. * Bind only the world matrix to the material.
  120488. * @param world The world matrix to bind.
  120489. */
  120490. bindOnlyWorldMatrix(world: Matrix): void;
  120491. /**
  120492. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  120493. * @param world The world matrix to bind.
  120494. * @param subMesh The submesh to bind for.
  120495. */
  120496. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  120497. /**
  120498. * Checks to see if a texture is used in the material.
  120499. * @param texture - Base texture to use.
  120500. * @returns - Boolean specifying if a texture is used in the material.
  120501. */
  120502. hasTexture(texture: BaseTexture): boolean;
  120503. /**
  120504. * Dispose the material.
  120505. * @param forceDisposeEffect Force disposal of the associated effect.
  120506. * @param forceDisposeTextures Force disposal of the associated textures.
  120507. */
  120508. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  120509. /**
  120510. * Clones the material.
  120511. * @param name The cloned name.
  120512. * @returns The cloned material.
  120513. */
  120514. clone(name: string): BackgroundMaterial;
  120515. /**
  120516. * Serializes the current material to its JSON representation.
  120517. * @returns The JSON representation.
  120518. */
  120519. serialize(): any;
  120520. /**
  120521. * Gets the class name of the material
  120522. * @returns "BackgroundMaterial"
  120523. */
  120524. getClassName(): string;
  120525. /**
  120526. * Parse a JSON input to create back a background material.
  120527. * @param source The JSON data to parse
  120528. * @param scene The scene to create the parsed material in
  120529. * @param rootUrl The root url of the assets the material depends upon
  120530. * @returns the instantiated BackgroundMaterial.
  120531. */
  120532. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  120533. }
  120534. }
  120535. declare module BABYLON {
  120536. /**
  120537. * Represents the different options available during the creation of
  120538. * a Environment helper.
  120539. *
  120540. * This can control the default ground, skybox and image processing setup of your scene.
  120541. */
  120542. export interface IEnvironmentHelperOptions {
  120543. /**
  120544. * Specifies wether or not to create a ground.
  120545. * True by default.
  120546. */
  120547. createGround: boolean;
  120548. /**
  120549. * Specifies the ground size.
  120550. * 15 by default.
  120551. */
  120552. groundSize: number;
  120553. /**
  120554. * The texture used on the ground for the main color.
  120555. * Comes from the BabylonJS CDN by default.
  120556. *
  120557. * Remarks: Can be either a texture or a url.
  120558. */
  120559. groundTexture: string | BaseTexture;
  120560. /**
  120561. * The color mixed in the ground texture by default.
  120562. * BabylonJS clearColor by default.
  120563. */
  120564. groundColor: Color3;
  120565. /**
  120566. * Specifies the ground opacity.
  120567. * 1 by default.
  120568. */
  120569. groundOpacity: number;
  120570. /**
  120571. * Enables the ground to receive shadows.
  120572. * True by default.
  120573. */
  120574. enableGroundShadow: boolean;
  120575. /**
  120576. * Helps preventing the shadow to be fully black on the ground.
  120577. * 0.5 by default.
  120578. */
  120579. groundShadowLevel: number;
  120580. /**
  120581. * Creates a mirror texture attach to the ground.
  120582. * false by default.
  120583. */
  120584. enableGroundMirror: boolean;
  120585. /**
  120586. * Specifies the ground mirror size ratio.
  120587. * 0.3 by default as the default kernel is 64.
  120588. */
  120589. groundMirrorSizeRatio: number;
  120590. /**
  120591. * Specifies the ground mirror blur kernel size.
  120592. * 64 by default.
  120593. */
  120594. groundMirrorBlurKernel: number;
  120595. /**
  120596. * Specifies the ground mirror visibility amount.
  120597. * 1 by default
  120598. */
  120599. groundMirrorAmount: number;
  120600. /**
  120601. * Specifies the ground mirror reflectance weight.
  120602. * This uses the standard weight of the background material to setup the fresnel effect
  120603. * of the mirror.
  120604. * 1 by default.
  120605. */
  120606. groundMirrorFresnelWeight: number;
  120607. /**
  120608. * Specifies the ground mirror Falloff distance.
  120609. * This can helps reducing the size of the reflection.
  120610. * 0 by Default.
  120611. */
  120612. groundMirrorFallOffDistance: number;
  120613. /**
  120614. * Specifies the ground mirror texture type.
  120615. * Unsigned Int by Default.
  120616. */
  120617. groundMirrorTextureType: number;
  120618. /**
  120619. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  120620. * the shown objects.
  120621. */
  120622. groundYBias: number;
  120623. /**
  120624. * Specifies wether or not to create a skybox.
  120625. * True by default.
  120626. */
  120627. createSkybox: boolean;
  120628. /**
  120629. * Specifies the skybox size.
  120630. * 20 by default.
  120631. */
  120632. skyboxSize: number;
  120633. /**
  120634. * The texture used on the skybox for the main color.
  120635. * Comes from the BabylonJS CDN by default.
  120636. *
  120637. * Remarks: Can be either a texture or a url.
  120638. */
  120639. skyboxTexture: string | BaseTexture;
  120640. /**
  120641. * The color mixed in the skybox texture by default.
  120642. * BabylonJS clearColor by default.
  120643. */
  120644. skyboxColor: Color3;
  120645. /**
  120646. * The background rotation around the Y axis of the scene.
  120647. * This helps aligning the key lights of your scene with the background.
  120648. * 0 by default.
  120649. */
  120650. backgroundYRotation: number;
  120651. /**
  120652. * Compute automatically the size of the elements to best fit with the scene.
  120653. */
  120654. sizeAuto: boolean;
  120655. /**
  120656. * Default position of the rootMesh if autoSize is not true.
  120657. */
  120658. rootPosition: Vector3;
  120659. /**
  120660. * Sets up the image processing in the scene.
  120661. * true by default.
  120662. */
  120663. setupImageProcessing: boolean;
  120664. /**
  120665. * The texture used as your environment texture in the scene.
  120666. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  120667. *
  120668. * Remarks: Can be either a texture or a url.
  120669. */
  120670. environmentTexture: string | BaseTexture;
  120671. /**
  120672. * The value of the exposure to apply to the scene.
  120673. * 0.6 by default if setupImageProcessing is true.
  120674. */
  120675. cameraExposure: number;
  120676. /**
  120677. * The value of the contrast to apply to the scene.
  120678. * 1.6 by default if setupImageProcessing is true.
  120679. */
  120680. cameraContrast: number;
  120681. /**
  120682. * Specifies wether or not tonemapping should be enabled in the scene.
  120683. * true by default if setupImageProcessing is true.
  120684. */
  120685. toneMappingEnabled: boolean;
  120686. }
  120687. /**
  120688. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  120689. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  120690. * It also helps with the default setup of your imageProcessing configuration.
  120691. */
  120692. export class EnvironmentHelper {
  120693. /**
  120694. * Default ground texture URL.
  120695. */
  120696. private static _groundTextureCDNUrl;
  120697. /**
  120698. * Default skybox texture URL.
  120699. */
  120700. private static _skyboxTextureCDNUrl;
  120701. /**
  120702. * Default environment texture URL.
  120703. */
  120704. private static _environmentTextureCDNUrl;
  120705. /**
  120706. * Creates the default options for the helper.
  120707. */
  120708. private static _getDefaultOptions;
  120709. private _rootMesh;
  120710. /**
  120711. * Gets the root mesh created by the helper.
  120712. */
  120713. get rootMesh(): Mesh;
  120714. private _skybox;
  120715. /**
  120716. * Gets the skybox created by the helper.
  120717. */
  120718. get skybox(): Nullable<Mesh>;
  120719. private _skyboxTexture;
  120720. /**
  120721. * Gets the skybox texture created by the helper.
  120722. */
  120723. get skyboxTexture(): Nullable<BaseTexture>;
  120724. private _skyboxMaterial;
  120725. /**
  120726. * Gets the skybox material created by the helper.
  120727. */
  120728. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  120729. private _ground;
  120730. /**
  120731. * Gets the ground mesh created by the helper.
  120732. */
  120733. get ground(): Nullable<Mesh>;
  120734. private _groundTexture;
  120735. /**
  120736. * Gets the ground texture created by the helper.
  120737. */
  120738. get groundTexture(): Nullable<BaseTexture>;
  120739. private _groundMirror;
  120740. /**
  120741. * Gets the ground mirror created by the helper.
  120742. */
  120743. get groundMirror(): Nullable<MirrorTexture>;
  120744. /**
  120745. * Gets the ground mirror render list to helps pushing the meshes
  120746. * you wish in the ground reflection.
  120747. */
  120748. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  120749. private _groundMaterial;
  120750. /**
  120751. * Gets the ground material created by the helper.
  120752. */
  120753. get groundMaterial(): Nullable<BackgroundMaterial>;
  120754. /**
  120755. * Stores the creation options.
  120756. */
  120757. private readonly _scene;
  120758. private _options;
  120759. /**
  120760. * This observable will be notified with any error during the creation of the environment,
  120761. * mainly texture creation errors.
  120762. */
  120763. onErrorObservable: Observable<{
  120764. message?: string;
  120765. exception?: any;
  120766. }>;
  120767. /**
  120768. * constructor
  120769. * @param options Defines the options we want to customize the helper
  120770. * @param scene The scene to add the material to
  120771. */
  120772. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  120773. /**
  120774. * Updates the background according to the new options
  120775. * @param options
  120776. */
  120777. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  120778. /**
  120779. * Sets the primary color of all the available elements.
  120780. * @param color the main color to affect to the ground and the background
  120781. */
  120782. setMainColor(color: Color3): void;
  120783. /**
  120784. * Setup the image processing according to the specified options.
  120785. */
  120786. private _setupImageProcessing;
  120787. /**
  120788. * Setup the environment texture according to the specified options.
  120789. */
  120790. private _setupEnvironmentTexture;
  120791. /**
  120792. * Setup the background according to the specified options.
  120793. */
  120794. private _setupBackground;
  120795. /**
  120796. * Get the scene sizes according to the setup.
  120797. */
  120798. private _getSceneSize;
  120799. /**
  120800. * Setup the ground according to the specified options.
  120801. */
  120802. private _setupGround;
  120803. /**
  120804. * Setup the ground material according to the specified options.
  120805. */
  120806. private _setupGroundMaterial;
  120807. /**
  120808. * Setup the ground diffuse texture according to the specified options.
  120809. */
  120810. private _setupGroundDiffuseTexture;
  120811. /**
  120812. * Setup the ground mirror texture according to the specified options.
  120813. */
  120814. private _setupGroundMirrorTexture;
  120815. /**
  120816. * Setup the ground to receive the mirror texture.
  120817. */
  120818. private _setupMirrorInGroundMaterial;
  120819. /**
  120820. * Setup the skybox according to the specified options.
  120821. */
  120822. private _setupSkybox;
  120823. /**
  120824. * Setup the skybox material according to the specified options.
  120825. */
  120826. private _setupSkyboxMaterial;
  120827. /**
  120828. * Setup the skybox reflection texture according to the specified options.
  120829. */
  120830. private _setupSkyboxReflectionTexture;
  120831. private _errorHandler;
  120832. /**
  120833. * Dispose all the elements created by the Helper.
  120834. */
  120835. dispose(): void;
  120836. }
  120837. }
  120838. declare module BABYLON {
  120839. /**
  120840. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  120841. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  120842. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  120843. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  120844. */
  120845. export class PhotoDome extends TransformNode {
  120846. /**
  120847. * Define the image as a Monoscopic panoramic 360 image.
  120848. */
  120849. static readonly MODE_MONOSCOPIC: number;
  120850. /**
  120851. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  120852. */
  120853. static readonly MODE_TOPBOTTOM: number;
  120854. /**
  120855. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  120856. */
  120857. static readonly MODE_SIDEBYSIDE: number;
  120858. private _useDirectMapping;
  120859. /**
  120860. * The texture being displayed on the sphere
  120861. */
  120862. protected _photoTexture: Texture;
  120863. /**
  120864. * Gets or sets the texture being displayed on the sphere
  120865. */
  120866. get photoTexture(): Texture;
  120867. set photoTexture(value: Texture);
  120868. /**
  120869. * Observable raised when an error occured while loading the 360 image
  120870. */
  120871. onLoadErrorObservable: Observable<string>;
  120872. /**
  120873. * The skybox material
  120874. */
  120875. protected _material: BackgroundMaterial;
  120876. /**
  120877. * The surface used for the skybox
  120878. */
  120879. protected _mesh: Mesh;
  120880. /**
  120881. * Gets the mesh used for the skybox.
  120882. */
  120883. get mesh(): Mesh;
  120884. /**
  120885. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  120886. * Also see the options.resolution property.
  120887. */
  120888. get fovMultiplier(): number;
  120889. set fovMultiplier(value: number);
  120890. private _imageMode;
  120891. /**
  120892. * Gets or set the current video mode for the video. It can be:
  120893. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  120894. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  120895. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  120896. */
  120897. get imageMode(): number;
  120898. set imageMode(value: number);
  120899. /**
  120900. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  120901. * @param name Element's name, child elements will append suffixes for their own names.
  120902. * @param urlsOfPhoto defines the url of the photo to display
  120903. * @param options defines an object containing optional or exposed sub element properties
  120904. * @param onError defines a callback called when an error occured while loading the texture
  120905. */
  120906. constructor(name: string, urlOfPhoto: string, options: {
  120907. resolution?: number;
  120908. size?: number;
  120909. useDirectMapping?: boolean;
  120910. faceForward?: boolean;
  120911. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  120912. private _onBeforeCameraRenderObserver;
  120913. private _changeImageMode;
  120914. /**
  120915. * Releases resources associated with this node.
  120916. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  120917. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  120918. */
  120919. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  120920. }
  120921. }
  120922. declare module BABYLON {
  120923. /**
  120924. * Class used to host RGBD texture specific utilities
  120925. */
  120926. export class RGBDTextureTools {
  120927. /**
  120928. * Expand the RGBD Texture from RGBD to Half Float if possible.
  120929. * @param texture the texture to expand.
  120930. */
  120931. static ExpandRGBDTexture(texture: Texture): void;
  120932. }
  120933. }
  120934. declare module BABYLON {
  120935. /**
  120936. * Class used to host texture specific utilities
  120937. */
  120938. export class BRDFTextureTools {
  120939. /**
  120940. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  120941. * @param scene defines the hosting scene
  120942. * @returns the environment BRDF texture
  120943. */
  120944. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  120945. private static _environmentBRDFBase64Texture;
  120946. }
  120947. }
  120948. declare module BABYLON {
  120949. /**
  120950. * @hidden
  120951. */
  120952. export interface IMaterialClearCoatDefines {
  120953. CLEARCOAT: boolean;
  120954. CLEARCOAT_DEFAULTIOR: boolean;
  120955. CLEARCOAT_TEXTURE: boolean;
  120956. CLEARCOAT_TEXTUREDIRECTUV: number;
  120957. CLEARCOAT_BUMP: boolean;
  120958. CLEARCOAT_BUMPDIRECTUV: number;
  120959. CLEARCOAT_TINT: boolean;
  120960. CLEARCOAT_TINT_TEXTURE: boolean;
  120961. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  120962. /** @hidden */
  120963. _areTexturesDirty: boolean;
  120964. }
  120965. /**
  120966. * Define the code related to the clear coat parameters of the pbr material.
  120967. */
  120968. export class PBRClearCoatConfiguration {
  120969. /**
  120970. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  120971. * The default fits with a polyurethane material.
  120972. */
  120973. private static readonly _DefaultIndexOfRefraction;
  120974. private _isEnabled;
  120975. /**
  120976. * Defines if the clear coat is enabled in the material.
  120977. */
  120978. isEnabled: boolean;
  120979. /**
  120980. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  120981. */
  120982. intensity: number;
  120983. /**
  120984. * Defines the clear coat layer roughness.
  120985. */
  120986. roughness: number;
  120987. private _indexOfRefraction;
  120988. /**
  120989. * Defines the index of refraction of the clear coat.
  120990. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  120991. * The default fits with a polyurethane material.
  120992. * Changing the default value is more performance intensive.
  120993. */
  120994. indexOfRefraction: number;
  120995. private _texture;
  120996. /**
  120997. * Stores the clear coat values in a texture.
  120998. */
  120999. texture: Nullable<BaseTexture>;
  121000. private _bumpTexture;
  121001. /**
  121002. * Define the clear coat specific bump texture.
  121003. */
  121004. bumpTexture: Nullable<BaseTexture>;
  121005. private _isTintEnabled;
  121006. /**
  121007. * Defines if the clear coat tint is enabled in the material.
  121008. */
  121009. isTintEnabled: boolean;
  121010. /**
  121011. * Defines the clear coat tint of the material.
  121012. * This is only use if tint is enabled
  121013. */
  121014. tintColor: Color3;
  121015. /**
  121016. * Defines the distance at which the tint color should be found in the
  121017. * clear coat media.
  121018. * This is only use if tint is enabled
  121019. */
  121020. tintColorAtDistance: number;
  121021. /**
  121022. * Defines the clear coat layer thickness.
  121023. * This is only use if tint is enabled
  121024. */
  121025. tintThickness: number;
  121026. private _tintTexture;
  121027. /**
  121028. * Stores the clear tint values in a texture.
  121029. * rgb is tint
  121030. * a is a thickness factor
  121031. */
  121032. tintTexture: Nullable<BaseTexture>;
  121033. /** @hidden */
  121034. private _internalMarkAllSubMeshesAsTexturesDirty;
  121035. /** @hidden */
  121036. _markAllSubMeshesAsTexturesDirty(): void;
  121037. /**
  121038. * Instantiate a new istance of clear coat configuration.
  121039. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  121040. */
  121041. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  121042. /**
  121043. * Gets wehter the submesh is ready to be used or not.
  121044. * @param defines the list of "defines" to update.
  121045. * @param scene defines the scene the material belongs to.
  121046. * @param engine defines the engine the material belongs to.
  121047. * @param disableBumpMap defines wether the material disables bump or not.
  121048. * @returns - boolean indicating that the submesh is ready or not.
  121049. */
  121050. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  121051. /**
  121052. * Checks to see if a texture is used in the material.
  121053. * @param defines the list of "defines" to update.
  121054. * @param scene defines the scene to the material belongs to.
  121055. */
  121056. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  121057. /**
  121058. * Binds the material data.
  121059. * @param uniformBuffer defines the Uniform buffer to fill in.
  121060. * @param scene defines the scene the material belongs to.
  121061. * @param engine defines the engine the material belongs to.
  121062. * @param disableBumpMap defines wether the material disables bump or not.
  121063. * @param isFrozen defines wether the material is frozen or not.
  121064. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  121065. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  121066. */
  121067. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  121068. /**
  121069. * Checks to see if a texture is used in the material.
  121070. * @param texture - Base texture to use.
  121071. * @returns - Boolean specifying if a texture is used in the material.
  121072. */
  121073. hasTexture(texture: BaseTexture): boolean;
  121074. /**
  121075. * Returns an array of the actively used textures.
  121076. * @param activeTextures Array of BaseTextures
  121077. */
  121078. getActiveTextures(activeTextures: BaseTexture[]): void;
  121079. /**
  121080. * Returns the animatable textures.
  121081. * @param animatables Array of animatable textures.
  121082. */
  121083. getAnimatables(animatables: IAnimatable[]): void;
  121084. /**
  121085. * Disposes the resources of the material.
  121086. * @param forceDisposeTextures - Forces the disposal of all textures.
  121087. */
  121088. dispose(forceDisposeTextures?: boolean): void;
  121089. /**
  121090. * Get the current class name of the texture useful for serialization or dynamic coding.
  121091. * @returns "PBRClearCoatConfiguration"
  121092. */
  121093. getClassName(): string;
  121094. /**
  121095. * Add fallbacks to the effect fallbacks list.
  121096. * @param defines defines the Base texture to use.
  121097. * @param fallbacks defines the current fallback list.
  121098. * @param currentRank defines the current fallback rank.
  121099. * @returns the new fallback rank.
  121100. */
  121101. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  121102. /**
  121103. * Add the required uniforms to the current list.
  121104. * @param uniforms defines the current uniform list.
  121105. */
  121106. static AddUniforms(uniforms: string[]): void;
  121107. /**
  121108. * Add the required samplers to the current list.
  121109. * @param samplers defines the current sampler list.
  121110. */
  121111. static AddSamplers(samplers: string[]): void;
  121112. /**
  121113. * Add the required uniforms to the current buffer.
  121114. * @param uniformBuffer defines the current uniform buffer.
  121115. */
  121116. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  121117. /**
  121118. * Makes a duplicate of the current configuration into another one.
  121119. * @param clearCoatConfiguration define the config where to copy the info
  121120. */
  121121. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  121122. /**
  121123. * Serializes this clear coat configuration.
  121124. * @returns - An object with the serialized config.
  121125. */
  121126. serialize(): any;
  121127. /**
  121128. * Parses a anisotropy Configuration from a serialized object.
  121129. * @param source - Serialized object.
  121130. * @param scene Defines the scene we are parsing for
  121131. * @param rootUrl Defines the rootUrl to load from
  121132. */
  121133. parse(source: any, scene: Scene, rootUrl: string): void;
  121134. }
  121135. }
  121136. declare module BABYLON {
  121137. /**
  121138. * @hidden
  121139. */
  121140. export interface IMaterialAnisotropicDefines {
  121141. ANISOTROPIC: boolean;
  121142. ANISOTROPIC_TEXTURE: boolean;
  121143. ANISOTROPIC_TEXTUREDIRECTUV: number;
  121144. MAINUV1: boolean;
  121145. _areTexturesDirty: boolean;
  121146. _needUVs: boolean;
  121147. }
  121148. /**
  121149. * Define the code related to the anisotropic parameters of the pbr material.
  121150. */
  121151. export class PBRAnisotropicConfiguration {
  121152. private _isEnabled;
  121153. /**
  121154. * Defines if the anisotropy is enabled in the material.
  121155. */
  121156. isEnabled: boolean;
  121157. /**
  121158. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  121159. */
  121160. intensity: number;
  121161. /**
  121162. * Defines if the effect is along the tangents, bitangents or in between.
  121163. * By default, the effect is "strectching" the highlights along the tangents.
  121164. */
  121165. direction: Vector2;
  121166. private _texture;
  121167. /**
  121168. * Stores the anisotropy values in a texture.
  121169. * rg is direction (like normal from -1 to 1)
  121170. * b is a intensity
  121171. */
  121172. texture: Nullable<BaseTexture>;
  121173. /** @hidden */
  121174. private _internalMarkAllSubMeshesAsTexturesDirty;
  121175. /** @hidden */
  121176. _markAllSubMeshesAsTexturesDirty(): void;
  121177. /**
  121178. * Instantiate a new istance of anisotropy configuration.
  121179. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  121180. */
  121181. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  121182. /**
  121183. * Specifies that the submesh is ready to be used.
  121184. * @param defines the list of "defines" to update.
  121185. * @param scene defines the scene the material belongs to.
  121186. * @returns - boolean indicating that the submesh is ready or not.
  121187. */
  121188. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  121189. /**
  121190. * Checks to see if a texture is used in the material.
  121191. * @param defines the list of "defines" to update.
  121192. * @param mesh the mesh we are preparing the defines for.
  121193. * @param scene defines the scene the material belongs to.
  121194. */
  121195. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  121196. /**
  121197. * Binds the material data.
  121198. * @param uniformBuffer defines the Uniform buffer to fill in.
  121199. * @param scene defines the scene the material belongs to.
  121200. * @param isFrozen defines wether the material is frozen or not.
  121201. */
  121202. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  121203. /**
  121204. * Checks to see if a texture is used in the material.
  121205. * @param texture - Base texture to use.
  121206. * @returns - Boolean specifying if a texture is used in the material.
  121207. */
  121208. hasTexture(texture: BaseTexture): boolean;
  121209. /**
  121210. * Returns an array of the actively used textures.
  121211. * @param activeTextures Array of BaseTextures
  121212. */
  121213. getActiveTextures(activeTextures: BaseTexture[]): void;
  121214. /**
  121215. * Returns the animatable textures.
  121216. * @param animatables Array of animatable textures.
  121217. */
  121218. getAnimatables(animatables: IAnimatable[]): void;
  121219. /**
  121220. * Disposes the resources of the material.
  121221. * @param forceDisposeTextures - Forces the disposal of all textures.
  121222. */
  121223. dispose(forceDisposeTextures?: boolean): void;
  121224. /**
  121225. * Get the current class name of the texture useful for serialization or dynamic coding.
  121226. * @returns "PBRAnisotropicConfiguration"
  121227. */
  121228. getClassName(): string;
  121229. /**
  121230. * Add fallbacks to the effect fallbacks list.
  121231. * @param defines defines the Base texture to use.
  121232. * @param fallbacks defines the current fallback list.
  121233. * @param currentRank defines the current fallback rank.
  121234. * @returns the new fallback rank.
  121235. */
  121236. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  121237. /**
  121238. * Add the required uniforms to the current list.
  121239. * @param uniforms defines the current uniform list.
  121240. */
  121241. static AddUniforms(uniforms: string[]): void;
  121242. /**
  121243. * Add the required uniforms to the current buffer.
  121244. * @param uniformBuffer defines the current uniform buffer.
  121245. */
  121246. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  121247. /**
  121248. * Add the required samplers to the current list.
  121249. * @param samplers defines the current sampler list.
  121250. */
  121251. static AddSamplers(samplers: string[]): void;
  121252. /**
  121253. * Makes a duplicate of the current configuration into another one.
  121254. * @param anisotropicConfiguration define the config where to copy the info
  121255. */
  121256. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  121257. /**
  121258. * Serializes this anisotropy configuration.
  121259. * @returns - An object with the serialized config.
  121260. */
  121261. serialize(): any;
  121262. /**
  121263. * Parses a anisotropy Configuration from a serialized object.
  121264. * @param source - Serialized object.
  121265. * @param scene Defines the scene we are parsing for
  121266. * @param rootUrl Defines the rootUrl to load from
  121267. */
  121268. parse(source: any, scene: Scene, rootUrl: string): void;
  121269. }
  121270. }
  121271. declare module BABYLON {
  121272. /**
  121273. * @hidden
  121274. */
  121275. export interface IMaterialBRDFDefines {
  121276. BRDF_V_HEIGHT_CORRELATED: boolean;
  121277. MS_BRDF_ENERGY_CONSERVATION: boolean;
  121278. SPHERICAL_HARMONICS: boolean;
  121279. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  121280. /** @hidden */
  121281. _areMiscDirty: boolean;
  121282. }
  121283. /**
  121284. * Define the code related to the BRDF parameters of the pbr material.
  121285. */
  121286. export class PBRBRDFConfiguration {
  121287. /**
  121288. * Default value used for the energy conservation.
  121289. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  121290. */
  121291. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  121292. /**
  121293. * Default value used for the Smith Visibility Height Correlated mode.
  121294. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  121295. */
  121296. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  121297. /**
  121298. * Default value used for the IBL diffuse part.
  121299. * This can help switching back to the polynomials mode globally which is a tiny bit
  121300. * less GPU intensive at the drawback of a lower quality.
  121301. */
  121302. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  121303. /**
  121304. * Default value used for activating energy conservation for the specular workflow.
  121305. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  121306. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  121307. */
  121308. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  121309. private _useEnergyConservation;
  121310. /**
  121311. * Defines if the material uses energy conservation.
  121312. */
  121313. useEnergyConservation: boolean;
  121314. private _useSmithVisibilityHeightCorrelated;
  121315. /**
  121316. * LEGACY Mode set to false
  121317. * Defines if the material uses height smith correlated visibility term.
  121318. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  121319. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  121320. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  121321. * Not relying on height correlated will also disable energy conservation.
  121322. */
  121323. useSmithVisibilityHeightCorrelated: boolean;
  121324. private _useSphericalHarmonics;
  121325. /**
  121326. * LEGACY Mode set to false
  121327. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  121328. * diffuse part of the IBL.
  121329. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  121330. * to the ground truth.
  121331. */
  121332. useSphericalHarmonics: boolean;
  121333. private _useSpecularGlossinessInputEnergyConservation;
  121334. /**
  121335. * Defines if the material uses energy conservation, when the specular workflow is active.
  121336. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  121337. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  121338. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  121339. */
  121340. useSpecularGlossinessInputEnergyConservation: boolean;
  121341. /** @hidden */
  121342. private _internalMarkAllSubMeshesAsMiscDirty;
  121343. /** @hidden */
  121344. _markAllSubMeshesAsMiscDirty(): void;
  121345. /**
  121346. * Instantiate a new istance of clear coat configuration.
  121347. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  121348. */
  121349. constructor(markAllSubMeshesAsMiscDirty: () => void);
  121350. /**
  121351. * Checks to see if a texture is used in the material.
  121352. * @param defines the list of "defines" to update.
  121353. */
  121354. prepareDefines(defines: IMaterialBRDFDefines): void;
  121355. /**
  121356. * Get the current class name of the texture useful for serialization or dynamic coding.
  121357. * @returns "PBRClearCoatConfiguration"
  121358. */
  121359. getClassName(): string;
  121360. /**
  121361. * Makes a duplicate of the current configuration into another one.
  121362. * @param brdfConfiguration define the config where to copy the info
  121363. */
  121364. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  121365. /**
  121366. * Serializes this BRDF configuration.
  121367. * @returns - An object with the serialized config.
  121368. */
  121369. serialize(): any;
  121370. /**
  121371. * Parses a anisotropy Configuration from a serialized object.
  121372. * @param source - Serialized object.
  121373. * @param scene Defines the scene we are parsing for
  121374. * @param rootUrl Defines the rootUrl to load from
  121375. */
  121376. parse(source: any, scene: Scene, rootUrl: string): void;
  121377. }
  121378. }
  121379. declare module BABYLON {
  121380. /**
  121381. * @hidden
  121382. */
  121383. export interface IMaterialSheenDefines {
  121384. SHEEN: boolean;
  121385. SHEEN_TEXTURE: boolean;
  121386. SHEEN_TEXTUREDIRECTUV: number;
  121387. SHEEN_LINKWITHALBEDO: boolean;
  121388. /** @hidden */
  121389. _areTexturesDirty: boolean;
  121390. }
  121391. /**
  121392. * Define the code related to the Sheen parameters of the pbr material.
  121393. */
  121394. export class PBRSheenConfiguration {
  121395. private _isEnabled;
  121396. /**
  121397. * Defines if the material uses sheen.
  121398. */
  121399. isEnabled: boolean;
  121400. private _linkSheenWithAlbedo;
  121401. /**
  121402. * Defines if the sheen is linked to the sheen color.
  121403. */
  121404. linkSheenWithAlbedo: boolean;
  121405. /**
  121406. * Defines the sheen intensity.
  121407. */
  121408. intensity: number;
  121409. /**
  121410. * Defines the sheen color.
  121411. */
  121412. color: Color3;
  121413. private _texture;
  121414. /**
  121415. * Stores the sheen tint values in a texture.
  121416. * rgb is tint
  121417. * a is a intensity
  121418. */
  121419. texture: Nullable<BaseTexture>;
  121420. /** @hidden */
  121421. private _internalMarkAllSubMeshesAsTexturesDirty;
  121422. /** @hidden */
  121423. _markAllSubMeshesAsTexturesDirty(): void;
  121424. /**
  121425. * Instantiate a new istance of clear coat configuration.
  121426. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  121427. */
  121428. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  121429. /**
  121430. * Specifies that the submesh is ready to be used.
  121431. * @param defines the list of "defines" to update.
  121432. * @param scene defines the scene the material belongs to.
  121433. * @returns - boolean indicating that the submesh is ready or not.
  121434. */
  121435. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  121436. /**
  121437. * Checks to see if a texture is used in the material.
  121438. * @param defines the list of "defines" to update.
  121439. * @param scene defines the scene the material belongs to.
  121440. */
  121441. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  121442. /**
  121443. * Binds the material data.
  121444. * @param uniformBuffer defines the Uniform buffer to fill in.
  121445. * @param scene defines the scene the material belongs to.
  121446. * @param isFrozen defines wether the material is frozen or not.
  121447. */
  121448. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  121449. /**
  121450. * Checks to see if a texture is used in the material.
  121451. * @param texture - Base texture to use.
  121452. * @returns - Boolean specifying if a texture is used in the material.
  121453. */
  121454. hasTexture(texture: BaseTexture): boolean;
  121455. /**
  121456. * Returns an array of the actively used textures.
  121457. * @param activeTextures Array of BaseTextures
  121458. */
  121459. getActiveTextures(activeTextures: BaseTexture[]): void;
  121460. /**
  121461. * Returns the animatable textures.
  121462. * @param animatables Array of animatable textures.
  121463. */
  121464. getAnimatables(animatables: IAnimatable[]): void;
  121465. /**
  121466. * Disposes the resources of the material.
  121467. * @param forceDisposeTextures - Forces the disposal of all textures.
  121468. */
  121469. dispose(forceDisposeTextures?: boolean): void;
  121470. /**
  121471. * Get the current class name of the texture useful for serialization or dynamic coding.
  121472. * @returns "PBRSheenConfiguration"
  121473. */
  121474. getClassName(): string;
  121475. /**
  121476. * Add fallbacks to the effect fallbacks list.
  121477. * @param defines defines the Base texture to use.
  121478. * @param fallbacks defines the current fallback list.
  121479. * @param currentRank defines the current fallback rank.
  121480. * @returns the new fallback rank.
  121481. */
  121482. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  121483. /**
  121484. * Add the required uniforms to the current list.
  121485. * @param uniforms defines the current uniform list.
  121486. */
  121487. static AddUniforms(uniforms: string[]): void;
  121488. /**
  121489. * Add the required uniforms to the current buffer.
  121490. * @param uniformBuffer defines the current uniform buffer.
  121491. */
  121492. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  121493. /**
  121494. * Add the required samplers to the current list.
  121495. * @param samplers defines the current sampler list.
  121496. */
  121497. static AddSamplers(samplers: string[]): void;
  121498. /**
  121499. * Makes a duplicate of the current configuration into another one.
  121500. * @param sheenConfiguration define the config where to copy the info
  121501. */
  121502. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  121503. /**
  121504. * Serializes this BRDF configuration.
  121505. * @returns - An object with the serialized config.
  121506. */
  121507. serialize(): any;
  121508. /**
  121509. * Parses a anisotropy Configuration from a serialized object.
  121510. * @param source - Serialized object.
  121511. * @param scene Defines the scene we are parsing for
  121512. * @param rootUrl Defines the rootUrl to load from
  121513. */
  121514. parse(source: any, scene: Scene, rootUrl: string): void;
  121515. }
  121516. }
  121517. declare module BABYLON {
  121518. /**
  121519. * @hidden
  121520. */
  121521. export interface IMaterialSubSurfaceDefines {
  121522. SUBSURFACE: boolean;
  121523. SS_REFRACTION: boolean;
  121524. SS_TRANSLUCENCY: boolean;
  121525. SS_SCATERRING: boolean;
  121526. SS_THICKNESSANDMASK_TEXTURE: boolean;
  121527. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  121528. SS_REFRACTIONMAP_3D: boolean;
  121529. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  121530. SS_LODINREFRACTIONALPHA: boolean;
  121531. SS_GAMMAREFRACTION: boolean;
  121532. SS_RGBDREFRACTION: boolean;
  121533. SS_LINEARSPECULARREFRACTION: boolean;
  121534. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  121535. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  121536. /** @hidden */
  121537. _areTexturesDirty: boolean;
  121538. }
  121539. /**
  121540. * Define the code related to the sub surface parameters of the pbr material.
  121541. */
  121542. export class PBRSubSurfaceConfiguration {
  121543. private _isRefractionEnabled;
  121544. /**
  121545. * Defines if the refraction is enabled in the material.
  121546. */
  121547. isRefractionEnabled: boolean;
  121548. private _isTranslucencyEnabled;
  121549. /**
  121550. * Defines if the translucency is enabled in the material.
  121551. */
  121552. isTranslucencyEnabled: boolean;
  121553. private _isScatteringEnabled;
  121554. /**
  121555. * Defines the refraction intensity of the material.
  121556. * The refraction when enabled replaces the Diffuse part of the material.
  121557. * The intensity helps transitionning between diffuse and refraction.
  121558. */
  121559. refractionIntensity: number;
  121560. /**
  121561. * Defines the translucency intensity of the material.
  121562. * When translucency has been enabled, this defines how much of the "translucency"
  121563. * is addded to the diffuse part of the material.
  121564. */
  121565. translucencyIntensity: number;
  121566. /**
  121567. * Defines the scattering intensity of the material.
  121568. * When scattering has been enabled, this defines how much of the "scattered light"
  121569. * is addded to the diffuse part of the material.
  121570. */
  121571. scatteringIntensity: number;
  121572. private _thicknessTexture;
  121573. /**
  121574. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  121575. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  121576. * 0 would mean minimumThickness
  121577. * 1 would mean maximumThickness
  121578. * The other channels might be use as a mask to vary the different effects intensity.
  121579. */
  121580. thicknessTexture: Nullable<BaseTexture>;
  121581. private _refractionTexture;
  121582. /**
  121583. * Defines the texture to use for refraction.
  121584. */
  121585. refractionTexture: Nullable<BaseTexture>;
  121586. private _indexOfRefraction;
  121587. /**
  121588. * Defines the index of refraction used in the material.
  121589. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  121590. */
  121591. indexOfRefraction: number;
  121592. private _invertRefractionY;
  121593. /**
  121594. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  121595. */
  121596. invertRefractionY: boolean;
  121597. private _linkRefractionWithTransparency;
  121598. /**
  121599. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  121600. * Materials half opaque for instance using refraction could benefit from this control.
  121601. */
  121602. linkRefractionWithTransparency: boolean;
  121603. /**
  121604. * Defines the minimum thickness stored in the thickness map.
  121605. * If no thickness map is defined, this value will be used to simulate thickness.
  121606. */
  121607. minimumThickness: number;
  121608. /**
  121609. * Defines the maximum thickness stored in the thickness map.
  121610. */
  121611. maximumThickness: number;
  121612. /**
  121613. * Defines the volume tint of the material.
  121614. * This is used for both translucency and scattering.
  121615. */
  121616. tintColor: Color3;
  121617. /**
  121618. * Defines the distance at which the tint color should be found in the media.
  121619. * This is used for refraction only.
  121620. */
  121621. tintColorAtDistance: number;
  121622. /**
  121623. * Defines how far each channel transmit through the media.
  121624. * It is defined as a color to simplify it selection.
  121625. */
  121626. diffusionDistance: Color3;
  121627. private _useMaskFromThicknessTexture;
  121628. /**
  121629. * Stores the intensity of the different subsurface effects in the thickness texture.
  121630. * * the green channel is the translucency intensity.
  121631. * * the blue channel is the scattering intensity.
  121632. * * the alpha channel is the refraction intensity.
  121633. */
  121634. useMaskFromThicknessTexture: boolean;
  121635. /** @hidden */
  121636. private _internalMarkAllSubMeshesAsTexturesDirty;
  121637. /** @hidden */
  121638. _markAllSubMeshesAsTexturesDirty(): void;
  121639. /**
  121640. * Instantiate a new istance of sub surface configuration.
  121641. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  121642. */
  121643. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  121644. /**
  121645. * Gets wehter the submesh is ready to be used or not.
  121646. * @param defines the list of "defines" to update.
  121647. * @param scene defines the scene the material belongs to.
  121648. * @returns - boolean indicating that the submesh is ready or not.
  121649. */
  121650. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  121651. /**
  121652. * Checks to see if a texture is used in the material.
  121653. * @param defines the list of "defines" to update.
  121654. * @param scene defines the scene to the material belongs to.
  121655. */
  121656. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  121657. /**
  121658. * Binds the material data.
  121659. * @param uniformBuffer defines the Uniform buffer to fill in.
  121660. * @param scene defines the scene the material belongs to.
  121661. * @param engine defines the engine the material belongs to.
  121662. * @param isFrozen defines wether the material is frozen or not.
  121663. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  121664. */
  121665. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  121666. /**
  121667. * Unbinds the material from the mesh.
  121668. * @param activeEffect defines the effect that should be unbound from.
  121669. * @returns true if unbound, otherwise false
  121670. */
  121671. unbind(activeEffect: Effect): boolean;
  121672. /**
  121673. * Returns the texture used for refraction or null if none is used.
  121674. * @param scene defines the scene the material belongs to.
  121675. * @returns - Refraction texture if present. If no refraction texture and refraction
  121676. * is linked with transparency, returns environment texture. Otherwise, returns null.
  121677. */
  121678. private _getRefractionTexture;
  121679. /**
  121680. * Returns true if alpha blending should be disabled.
  121681. */
  121682. get disableAlphaBlending(): boolean;
  121683. /**
  121684. * Fills the list of render target textures.
  121685. * @param renderTargets the list of render targets to update
  121686. */
  121687. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  121688. /**
  121689. * Checks to see if a texture is used in the material.
  121690. * @param texture - Base texture to use.
  121691. * @returns - Boolean specifying if a texture is used in the material.
  121692. */
  121693. hasTexture(texture: BaseTexture): boolean;
  121694. /**
  121695. * Gets a boolean indicating that current material needs to register RTT
  121696. * @returns true if this uses a render target otherwise false.
  121697. */
  121698. hasRenderTargetTextures(): boolean;
  121699. /**
  121700. * Returns an array of the actively used textures.
  121701. * @param activeTextures Array of BaseTextures
  121702. */
  121703. getActiveTextures(activeTextures: BaseTexture[]): void;
  121704. /**
  121705. * Returns the animatable textures.
  121706. * @param animatables Array of animatable textures.
  121707. */
  121708. getAnimatables(animatables: IAnimatable[]): void;
  121709. /**
  121710. * Disposes the resources of the material.
  121711. * @param forceDisposeTextures - Forces the disposal of all textures.
  121712. */
  121713. dispose(forceDisposeTextures?: boolean): void;
  121714. /**
  121715. * Get the current class name of the texture useful for serialization or dynamic coding.
  121716. * @returns "PBRSubSurfaceConfiguration"
  121717. */
  121718. getClassName(): string;
  121719. /**
  121720. * Add fallbacks to the effect fallbacks list.
  121721. * @param defines defines the Base texture to use.
  121722. * @param fallbacks defines the current fallback list.
  121723. * @param currentRank defines the current fallback rank.
  121724. * @returns the new fallback rank.
  121725. */
  121726. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  121727. /**
  121728. * Add the required uniforms to the current list.
  121729. * @param uniforms defines the current uniform list.
  121730. */
  121731. static AddUniforms(uniforms: string[]): void;
  121732. /**
  121733. * Add the required samplers to the current list.
  121734. * @param samplers defines the current sampler list.
  121735. */
  121736. static AddSamplers(samplers: string[]): void;
  121737. /**
  121738. * Add the required uniforms to the current buffer.
  121739. * @param uniformBuffer defines the current uniform buffer.
  121740. */
  121741. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  121742. /**
  121743. * Makes a duplicate of the current configuration into another one.
  121744. * @param configuration define the config where to copy the info
  121745. */
  121746. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  121747. /**
  121748. * Serializes this Sub Surface configuration.
  121749. * @returns - An object with the serialized config.
  121750. */
  121751. serialize(): any;
  121752. /**
  121753. * Parses a anisotropy Configuration from a serialized object.
  121754. * @param source - Serialized object.
  121755. * @param scene Defines the scene we are parsing for
  121756. * @param rootUrl Defines the rootUrl to load from
  121757. */
  121758. parse(source: any, scene: Scene, rootUrl: string): void;
  121759. }
  121760. }
  121761. declare module BABYLON {
  121762. /** @hidden */
  121763. export var pbrFragmentDeclaration: {
  121764. name: string;
  121765. shader: string;
  121766. };
  121767. }
  121768. declare module BABYLON {
  121769. /** @hidden */
  121770. export var pbrUboDeclaration: {
  121771. name: string;
  121772. shader: string;
  121773. };
  121774. }
  121775. declare module BABYLON {
  121776. /** @hidden */
  121777. export var pbrFragmentExtraDeclaration: {
  121778. name: string;
  121779. shader: string;
  121780. };
  121781. }
  121782. declare module BABYLON {
  121783. /** @hidden */
  121784. export var pbrFragmentSamplersDeclaration: {
  121785. name: string;
  121786. shader: string;
  121787. };
  121788. }
  121789. declare module BABYLON {
  121790. /** @hidden */
  121791. export var pbrHelperFunctions: {
  121792. name: string;
  121793. shader: string;
  121794. };
  121795. }
  121796. declare module BABYLON {
  121797. /** @hidden */
  121798. export var harmonicsFunctions: {
  121799. name: string;
  121800. shader: string;
  121801. };
  121802. }
  121803. declare module BABYLON {
  121804. /** @hidden */
  121805. export var pbrDirectLightingSetupFunctions: {
  121806. name: string;
  121807. shader: string;
  121808. };
  121809. }
  121810. declare module BABYLON {
  121811. /** @hidden */
  121812. export var pbrDirectLightingFalloffFunctions: {
  121813. name: string;
  121814. shader: string;
  121815. };
  121816. }
  121817. declare module BABYLON {
  121818. /** @hidden */
  121819. export var pbrBRDFFunctions: {
  121820. name: string;
  121821. shader: string;
  121822. };
  121823. }
  121824. declare module BABYLON {
  121825. /** @hidden */
  121826. export var pbrDirectLightingFunctions: {
  121827. name: string;
  121828. shader: string;
  121829. };
  121830. }
  121831. declare module BABYLON {
  121832. /** @hidden */
  121833. export var pbrIBLFunctions: {
  121834. name: string;
  121835. shader: string;
  121836. };
  121837. }
  121838. declare module BABYLON {
  121839. /** @hidden */
  121840. export var pbrDebug: {
  121841. name: string;
  121842. shader: string;
  121843. };
  121844. }
  121845. declare module BABYLON {
  121846. /** @hidden */
  121847. export var pbrPixelShader: {
  121848. name: string;
  121849. shader: string;
  121850. };
  121851. }
  121852. declare module BABYLON {
  121853. /** @hidden */
  121854. export var pbrVertexDeclaration: {
  121855. name: string;
  121856. shader: string;
  121857. };
  121858. }
  121859. declare module BABYLON {
  121860. /** @hidden */
  121861. export var pbrVertexShader: {
  121862. name: string;
  121863. shader: string;
  121864. };
  121865. }
  121866. declare module BABYLON {
  121867. /**
  121868. * Manages the defines for the PBR Material.
  121869. * @hidden
  121870. */
  121871. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  121872. PBR: boolean;
  121873. MAINUV1: boolean;
  121874. MAINUV2: boolean;
  121875. UV1: boolean;
  121876. UV2: boolean;
  121877. ALBEDO: boolean;
  121878. ALBEDODIRECTUV: number;
  121879. VERTEXCOLOR: boolean;
  121880. AMBIENT: boolean;
  121881. AMBIENTDIRECTUV: number;
  121882. AMBIENTINGRAYSCALE: boolean;
  121883. OPACITY: boolean;
  121884. VERTEXALPHA: boolean;
  121885. OPACITYDIRECTUV: number;
  121886. OPACITYRGB: boolean;
  121887. ALPHATEST: boolean;
  121888. DEPTHPREPASS: boolean;
  121889. ALPHABLEND: boolean;
  121890. ALPHAFROMALBEDO: boolean;
  121891. ALPHATESTVALUE: string;
  121892. SPECULAROVERALPHA: boolean;
  121893. RADIANCEOVERALPHA: boolean;
  121894. ALPHAFRESNEL: boolean;
  121895. LINEARALPHAFRESNEL: boolean;
  121896. PREMULTIPLYALPHA: boolean;
  121897. EMISSIVE: boolean;
  121898. EMISSIVEDIRECTUV: number;
  121899. REFLECTIVITY: boolean;
  121900. REFLECTIVITYDIRECTUV: number;
  121901. SPECULARTERM: boolean;
  121902. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  121903. MICROSURFACEAUTOMATIC: boolean;
  121904. LODBASEDMICROSFURACE: boolean;
  121905. MICROSURFACEMAP: boolean;
  121906. MICROSURFACEMAPDIRECTUV: number;
  121907. METALLICWORKFLOW: boolean;
  121908. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  121909. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  121910. METALLNESSSTOREINMETALMAPBLUE: boolean;
  121911. AOSTOREINMETALMAPRED: boolean;
  121912. METALLICF0FACTORFROMMETALLICMAP: boolean;
  121913. ENVIRONMENTBRDF: boolean;
  121914. ENVIRONMENTBRDF_RGBD: boolean;
  121915. NORMAL: boolean;
  121916. TANGENT: boolean;
  121917. BUMP: boolean;
  121918. BUMPDIRECTUV: number;
  121919. OBJECTSPACE_NORMALMAP: boolean;
  121920. PARALLAX: boolean;
  121921. PARALLAXOCCLUSION: boolean;
  121922. NORMALXYSCALE: boolean;
  121923. LIGHTMAP: boolean;
  121924. LIGHTMAPDIRECTUV: number;
  121925. USELIGHTMAPASSHADOWMAP: boolean;
  121926. GAMMALIGHTMAP: boolean;
  121927. RGBDLIGHTMAP: boolean;
  121928. REFLECTION: boolean;
  121929. REFLECTIONMAP_3D: boolean;
  121930. REFLECTIONMAP_SPHERICAL: boolean;
  121931. REFLECTIONMAP_PLANAR: boolean;
  121932. REFLECTIONMAP_CUBIC: boolean;
  121933. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  121934. REFLECTIONMAP_PROJECTION: boolean;
  121935. REFLECTIONMAP_SKYBOX: boolean;
  121936. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  121937. REFLECTIONMAP_EXPLICIT: boolean;
  121938. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  121939. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  121940. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  121941. INVERTCUBICMAP: boolean;
  121942. USESPHERICALFROMREFLECTIONMAP: boolean;
  121943. USEIRRADIANCEMAP: boolean;
  121944. SPHERICAL_HARMONICS: boolean;
  121945. USESPHERICALINVERTEX: boolean;
  121946. REFLECTIONMAP_OPPOSITEZ: boolean;
  121947. LODINREFLECTIONALPHA: boolean;
  121948. GAMMAREFLECTION: boolean;
  121949. RGBDREFLECTION: boolean;
  121950. LINEARSPECULARREFLECTION: boolean;
  121951. RADIANCEOCCLUSION: boolean;
  121952. HORIZONOCCLUSION: boolean;
  121953. INSTANCES: boolean;
  121954. NUM_BONE_INFLUENCERS: number;
  121955. BonesPerMesh: number;
  121956. BONETEXTURE: boolean;
  121957. NONUNIFORMSCALING: boolean;
  121958. MORPHTARGETS: boolean;
  121959. MORPHTARGETS_NORMAL: boolean;
  121960. MORPHTARGETS_TANGENT: boolean;
  121961. MORPHTARGETS_UV: boolean;
  121962. NUM_MORPH_INFLUENCERS: number;
  121963. IMAGEPROCESSING: boolean;
  121964. VIGNETTE: boolean;
  121965. VIGNETTEBLENDMODEMULTIPLY: boolean;
  121966. VIGNETTEBLENDMODEOPAQUE: boolean;
  121967. TONEMAPPING: boolean;
  121968. TONEMAPPING_ACES: boolean;
  121969. CONTRAST: boolean;
  121970. COLORCURVES: boolean;
  121971. COLORGRADING: boolean;
  121972. COLORGRADING3D: boolean;
  121973. SAMPLER3DGREENDEPTH: boolean;
  121974. SAMPLER3DBGRMAP: boolean;
  121975. IMAGEPROCESSINGPOSTPROCESS: boolean;
  121976. EXPOSURE: boolean;
  121977. MULTIVIEW: boolean;
  121978. USEPHYSICALLIGHTFALLOFF: boolean;
  121979. USEGLTFLIGHTFALLOFF: boolean;
  121980. TWOSIDEDLIGHTING: boolean;
  121981. SHADOWFLOAT: boolean;
  121982. CLIPPLANE: boolean;
  121983. CLIPPLANE2: boolean;
  121984. CLIPPLANE3: boolean;
  121985. CLIPPLANE4: boolean;
  121986. CLIPPLANE5: boolean;
  121987. CLIPPLANE6: boolean;
  121988. POINTSIZE: boolean;
  121989. FOG: boolean;
  121990. LOGARITHMICDEPTH: boolean;
  121991. FORCENORMALFORWARD: boolean;
  121992. SPECULARAA: boolean;
  121993. CLEARCOAT: boolean;
  121994. CLEARCOAT_DEFAULTIOR: boolean;
  121995. CLEARCOAT_TEXTURE: boolean;
  121996. CLEARCOAT_TEXTUREDIRECTUV: number;
  121997. CLEARCOAT_BUMP: boolean;
  121998. CLEARCOAT_BUMPDIRECTUV: number;
  121999. CLEARCOAT_TINT: boolean;
  122000. CLEARCOAT_TINT_TEXTURE: boolean;
  122001. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  122002. ANISOTROPIC: boolean;
  122003. ANISOTROPIC_TEXTURE: boolean;
  122004. ANISOTROPIC_TEXTUREDIRECTUV: number;
  122005. BRDF_V_HEIGHT_CORRELATED: boolean;
  122006. MS_BRDF_ENERGY_CONSERVATION: boolean;
  122007. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  122008. SHEEN: boolean;
  122009. SHEEN_TEXTURE: boolean;
  122010. SHEEN_TEXTUREDIRECTUV: number;
  122011. SHEEN_LINKWITHALBEDO: boolean;
  122012. SUBSURFACE: boolean;
  122013. SS_REFRACTION: boolean;
  122014. SS_TRANSLUCENCY: boolean;
  122015. SS_SCATERRING: boolean;
  122016. SS_THICKNESSANDMASK_TEXTURE: boolean;
  122017. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  122018. SS_REFRACTIONMAP_3D: boolean;
  122019. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  122020. SS_LODINREFRACTIONALPHA: boolean;
  122021. SS_GAMMAREFRACTION: boolean;
  122022. SS_RGBDREFRACTION: boolean;
  122023. SS_LINEARSPECULARREFRACTION: boolean;
  122024. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  122025. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  122026. UNLIT: boolean;
  122027. DEBUGMODE: number;
  122028. /**
  122029. * Initializes the PBR Material defines.
  122030. */
  122031. constructor();
  122032. /**
  122033. * Resets the PBR Material defines.
  122034. */
  122035. reset(): void;
  122036. }
  122037. /**
  122038. * The Physically based material base class of BJS.
  122039. *
  122040. * This offers the main features of a standard PBR material.
  122041. * For more information, please refer to the documentation :
  122042. * https://doc.babylonjs.com/how_to/physically_based_rendering
  122043. */
  122044. export abstract class PBRBaseMaterial extends PushMaterial {
  122045. /**
  122046. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  122047. */
  122048. static readonly PBRMATERIAL_OPAQUE: number;
  122049. /**
  122050. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  122051. */
  122052. static readonly PBRMATERIAL_ALPHATEST: number;
  122053. /**
  122054. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  122055. */
  122056. static readonly PBRMATERIAL_ALPHABLEND: number;
  122057. /**
  122058. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  122059. * They are also discarded below the alpha cutoff threshold to improve performances.
  122060. */
  122061. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  122062. /**
  122063. * Defines the default value of how much AO map is occluding the analytical lights
  122064. * (point spot...).
  122065. */
  122066. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  122067. /**
  122068. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  122069. */
  122070. static readonly LIGHTFALLOFF_PHYSICAL: number;
  122071. /**
  122072. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  122073. * to enhance interoperability with other engines.
  122074. */
  122075. static readonly LIGHTFALLOFF_GLTF: number;
  122076. /**
  122077. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  122078. * to enhance interoperability with other materials.
  122079. */
  122080. static readonly LIGHTFALLOFF_STANDARD: number;
  122081. /**
  122082. * Intensity of the direct lights e.g. the four lights available in your scene.
  122083. * This impacts both the direct diffuse and specular highlights.
  122084. */
  122085. protected _directIntensity: number;
  122086. /**
  122087. * Intensity of the emissive part of the material.
  122088. * This helps controlling the emissive effect without modifying the emissive color.
  122089. */
  122090. protected _emissiveIntensity: number;
  122091. /**
  122092. * Intensity of the environment e.g. how much the environment will light the object
  122093. * either through harmonics for rough material or through the refelction for shiny ones.
  122094. */
  122095. protected _environmentIntensity: number;
  122096. /**
  122097. * This is a special control allowing the reduction of the specular highlights coming from the
  122098. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  122099. */
  122100. protected _specularIntensity: number;
  122101. /**
  122102. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  122103. */
  122104. private _lightingInfos;
  122105. /**
  122106. * Debug Control allowing disabling the bump map on this material.
  122107. */
  122108. protected _disableBumpMap: boolean;
  122109. /**
  122110. * AKA Diffuse Texture in standard nomenclature.
  122111. */
  122112. protected _albedoTexture: Nullable<BaseTexture>;
  122113. /**
  122114. * AKA Occlusion Texture in other nomenclature.
  122115. */
  122116. protected _ambientTexture: Nullable<BaseTexture>;
  122117. /**
  122118. * AKA Occlusion Texture Intensity in other nomenclature.
  122119. */
  122120. protected _ambientTextureStrength: number;
  122121. /**
  122122. * Defines how much the AO map is occluding the analytical lights (point spot...).
  122123. * 1 means it completely occludes it
  122124. * 0 mean it has no impact
  122125. */
  122126. protected _ambientTextureImpactOnAnalyticalLights: number;
  122127. /**
  122128. * Stores the alpha values in a texture.
  122129. */
  122130. protected _opacityTexture: Nullable<BaseTexture>;
  122131. /**
  122132. * Stores the reflection values in a texture.
  122133. */
  122134. protected _reflectionTexture: Nullable<BaseTexture>;
  122135. /**
  122136. * Stores the emissive values in a texture.
  122137. */
  122138. protected _emissiveTexture: Nullable<BaseTexture>;
  122139. /**
  122140. * AKA Specular texture in other nomenclature.
  122141. */
  122142. protected _reflectivityTexture: Nullable<BaseTexture>;
  122143. /**
  122144. * Used to switch from specular/glossiness to metallic/roughness workflow.
  122145. */
  122146. protected _metallicTexture: Nullable<BaseTexture>;
  122147. /**
  122148. * Specifies the metallic scalar of the metallic/roughness workflow.
  122149. * Can also be used to scale the metalness values of the metallic texture.
  122150. */
  122151. protected _metallic: Nullable<number>;
  122152. /**
  122153. * Specifies the roughness scalar of the metallic/roughness workflow.
  122154. * Can also be used to scale the roughness values of the metallic texture.
  122155. */
  122156. protected _roughness: Nullable<number>;
  122157. /**
  122158. * Specifies the an F0 factor to help configuring the material F0.
  122159. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  122160. * to 0.5 the previously hard coded value stays the same.
  122161. * Can also be used to scale the F0 values of the metallic texture.
  122162. */
  122163. protected _metallicF0Factor: number;
  122164. /**
  122165. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  122166. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  122167. * your expectation as it multiplies with the texture data.
  122168. */
  122169. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  122170. /**
  122171. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  122172. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  122173. */
  122174. protected _microSurfaceTexture: Nullable<BaseTexture>;
  122175. /**
  122176. * Stores surface normal data used to displace a mesh in a texture.
  122177. */
  122178. protected _bumpTexture: Nullable<BaseTexture>;
  122179. /**
  122180. * Stores the pre-calculated light information of a mesh in a texture.
  122181. */
  122182. protected _lightmapTexture: Nullable<BaseTexture>;
  122183. /**
  122184. * The color of a material in ambient lighting.
  122185. */
  122186. protected _ambientColor: Color3;
  122187. /**
  122188. * AKA Diffuse Color in other nomenclature.
  122189. */
  122190. protected _albedoColor: Color3;
  122191. /**
  122192. * AKA Specular Color in other nomenclature.
  122193. */
  122194. protected _reflectivityColor: Color3;
  122195. /**
  122196. * The color applied when light is reflected from a material.
  122197. */
  122198. protected _reflectionColor: Color3;
  122199. /**
  122200. * The color applied when light is emitted from a material.
  122201. */
  122202. protected _emissiveColor: Color3;
  122203. /**
  122204. * AKA Glossiness in other nomenclature.
  122205. */
  122206. protected _microSurface: number;
  122207. /**
  122208. * Specifies that the material will use the light map as a show map.
  122209. */
  122210. protected _useLightmapAsShadowmap: boolean;
  122211. /**
  122212. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  122213. * makes the reflect vector face the model (under horizon).
  122214. */
  122215. protected _useHorizonOcclusion: boolean;
  122216. /**
  122217. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  122218. * too much the area relying on ambient texture to define their ambient occlusion.
  122219. */
  122220. protected _useRadianceOcclusion: boolean;
  122221. /**
  122222. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  122223. */
  122224. protected _useAlphaFromAlbedoTexture: boolean;
  122225. /**
  122226. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  122227. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  122228. */
  122229. protected _useSpecularOverAlpha: boolean;
  122230. /**
  122231. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  122232. */
  122233. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  122234. /**
  122235. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  122236. */
  122237. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  122238. /**
  122239. * Specifies if the metallic texture contains the roughness information in its green channel.
  122240. */
  122241. protected _useRoughnessFromMetallicTextureGreen: boolean;
  122242. /**
  122243. * Specifies if the metallic texture contains the metallness information in its blue channel.
  122244. */
  122245. protected _useMetallnessFromMetallicTextureBlue: boolean;
  122246. /**
  122247. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  122248. */
  122249. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  122250. /**
  122251. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  122252. */
  122253. protected _useAmbientInGrayScale: boolean;
  122254. /**
  122255. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  122256. * The material will try to infer what glossiness each pixel should be.
  122257. */
  122258. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  122259. /**
  122260. * Defines the falloff type used in this material.
  122261. * It by default is Physical.
  122262. */
  122263. protected _lightFalloff: number;
  122264. /**
  122265. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  122266. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  122267. */
  122268. protected _useRadianceOverAlpha: boolean;
  122269. /**
  122270. * Allows using an object space normal map (instead of tangent space).
  122271. */
  122272. protected _useObjectSpaceNormalMap: boolean;
  122273. /**
  122274. * Allows using the bump map in parallax mode.
  122275. */
  122276. protected _useParallax: boolean;
  122277. /**
  122278. * Allows using the bump map in parallax occlusion mode.
  122279. */
  122280. protected _useParallaxOcclusion: boolean;
  122281. /**
  122282. * Controls the scale bias of the parallax mode.
  122283. */
  122284. protected _parallaxScaleBias: number;
  122285. /**
  122286. * If sets to true, disables all the lights affecting the material.
  122287. */
  122288. protected _disableLighting: boolean;
  122289. /**
  122290. * Number of Simultaneous lights allowed on the material.
  122291. */
  122292. protected _maxSimultaneousLights: number;
  122293. /**
  122294. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  122295. */
  122296. protected _invertNormalMapX: boolean;
  122297. /**
  122298. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  122299. */
  122300. protected _invertNormalMapY: boolean;
  122301. /**
  122302. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  122303. */
  122304. protected _twoSidedLighting: boolean;
  122305. /**
  122306. * Defines the alpha limits in alpha test mode.
  122307. */
  122308. protected _alphaCutOff: number;
  122309. /**
  122310. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  122311. */
  122312. protected _forceAlphaTest: boolean;
  122313. /**
  122314. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  122315. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  122316. */
  122317. protected _useAlphaFresnel: boolean;
  122318. /**
  122319. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  122320. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  122321. */
  122322. protected _useLinearAlphaFresnel: boolean;
  122323. /**
  122324. * The transparency mode of the material.
  122325. */
  122326. protected _transparencyMode: Nullable<number>;
  122327. /**
  122328. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  122329. * from cos thetav and roughness:
  122330. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  122331. */
  122332. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  122333. /**
  122334. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  122335. */
  122336. protected _forceIrradianceInFragment: boolean;
  122337. /**
  122338. * Force normal to face away from face.
  122339. */
  122340. protected _forceNormalForward: boolean;
  122341. /**
  122342. * Enables specular anti aliasing in the PBR shader.
  122343. * It will both interacts on the Geometry for analytical and IBL lighting.
  122344. * It also prefilter the roughness map based on the bump values.
  122345. */
  122346. protected _enableSpecularAntiAliasing: boolean;
  122347. /**
  122348. * Default configuration related to image processing available in the PBR Material.
  122349. */
  122350. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122351. /**
  122352. * Keep track of the image processing observer to allow dispose and replace.
  122353. */
  122354. private _imageProcessingObserver;
  122355. /**
  122356. * Attaches a new image processing configuration to the PBR Material.
  122357. * @param configuration
  122358. */
  122359. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122360. /**
  122361. * Stores the available render targets.
  122362. */
  122363. private _renderTargets;
  122364. /**
  122365. * Sets the global ambient color for the material used in lighting calculations.
  122366. */
  122367. private _globalAmbientColor;
  122368. /**
  122369. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  122370. */
  122371. private _useLogarithmicDepth;
  122372. /**
  122373. * If set to true, no lighting calculations will be applied.
  122374. */
  122375. private _unlit;
  122376. private _debugMode;
  122377. /**
  122378. * @hidden
  122379. * This is reserved for the inspector.
  122380. * Defines the material debug mode.
  122381. * It helps seeing only some components of the material while troubleshooting.
  122382. */
  122383. debugMode: number;
  122384. /**
  122385. * @hidden
  122386. * This is reserved for the inspector.
  122387. * Specify from where on screen the debug mode should start.
  122388. * The value goes from -1 (full screen) to 1 (not visible)
  122389. * It helps with side by side comparison against the final render
  122390. * This defaults to -1
  122391. */
  122392. private debugLimit;
  122393. /**
  122394. * @hidden
  122395. * This is reserved for the inspector.
  122396. * As the default viewing range might not be enough (if the ambient is really small for instance)
  122397. * You can use the factor to better multiply the final value.
  122398. */
  122399. private debugFactor;
  122400. /**
  122401. * Defines the clear coat layer parameters for the material.
  122402. */
  122403. readonly clearCoat: PBRClearCoatConfiguration;
  122404. /**
  122405. * Defines the anisotropic parameters for the material.
  122406. */
  122407. readonly anisotropy: PBRAnisotropicConfiguration;
  122408. /**
  122409. * Defines the BRDF parameters for the material.
  122410. */
  122411. readonly brdf: PBRBRDFConfiguration;
  122412. /**
  122413. * Defines the Sheen parameters for the material.
  122414. */
  122415. readonly sheen: PBRSheenConfiguration;
  122416. /**
  122417. * Defines the SubSurface parameters for the material.
  122418. */
  122419. readonly subSurface: PBRSubSurfaceConfiguration;
  122420. /**
  122421. * Custom callback helping to override the default shader used in the material.
  122422. */
  122423. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  122424. protected _rebuildInParallel: boolean;
  122425. /**
  122426. * Instantiates a new PBRMaterial instance.
  122427. *
  122428. * @param name The material name
  122429. * @param scene The scene the material will be use in.
  122430. */
  122431. constructor(name: string, scene: Scene);
  122432. /**
  122433. * Gets a boolean indicating that current material needs to register RTT
  122434. */
  122435. get hasRenderTargetTextures(): boolean;
  122436. /**
  122437. * Gets the name of the material class.
  122438. */
  122439. getClassName(): string;
  122440. /**
  122441. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  122442. */
  122443. get useLogarithmicDepth(): boolean;
  122444. /**
  122445. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  122446. */
  122447. set useLogarithmicDepth(value: boolean);
  122448. /**
  122449. * Gets the current transparency mode.
  122450. */
  122451. get transparencyMode(): Nullable<number>;
  122452. /**
  122453. * Sets the transparency mode of the material.
  122454. *
  122455. * | Value | Type | Description |
  122456. * | ----- | ----------------------------------- | ----------- |
  122457. * | 0 | OPAQUE | |
  122458. * | 1 | ALPHATEST | |
  122459. * | 2 | ALPHABLEND | |
  122460. * | 3 | ALPHATESTANDBLEND | |
  122461. *
  122462. */
  122463. set transparencyMode(value: Nullable<number>);
  122464. /**
  122465. * Returns true if alpha blending should be disabled.
  122466. */
  122467. private get _disableAlphaBlending();
  122468. /**
  122469. * Specifies whether or not this material should be rendered in alpha blend mode.
  122470. */
  122471. needAlphaBlending(): boolean;
  122472. /**
  122473. * Specifies if the mesh will require alpha blending.
  122474. * @param mesh - BJS mesh.
  122475. */
  122476. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  122477. /**
  122478. * Specifies whether or not this material should be rendered in alpha test mode.
  122479. */
  122480. needAlphaTesting(): boolean;
  122481. /**
  122482. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  122483. */
  122484. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  122485. /**
  122486. * Gets the texture used for the alpha test.
  122487. */
  122488. getAlphaTestTexture(): Nullable<BaseTexture>;
  122489. /**
  122490. * Specifies that the submesh is ready to be used.
  122491. * @param mesh - BJS mesh.
  122492. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  122493. * @param useInstances - Specifies that instances should be used.
  122494. * @returns - boolean indicating that the submesh is ready or not.
  122495. */
  122496. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122497. /**
  122498. * Specifies if the material uses metallic roughness workflow.
  122499. * @returns boolean specifiying if the material uses metallic roughness workflow.
  122500. */
  122501. isMetallicWorkflow(): boolean;
  122502. private _prepareEffect;
  122503. private _prepareDefines;
  122504. /**
  122505. * Force shader compilation
  122506. */
  122507. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  122508. /**
  122509. * Initializes the uniform buffer layout for the shader.
  122510. */
  122511. buildUniformLayout(): void;
  122512. /**
  122513. * Unbinds the material from the mesh
  122514. */
  122515. unbind(): void;
  122516. /**
  122517. * Binds the submesh data.
  122518. * @param world - The world matrix.
  122519. * @param mesh - The BJS mesh.
  122520. * @param subMesh - A submesh of the BJS mesh.
  122521. */
  122522. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122523. /**
  122524. * Returns the animatable textures.
  122525. * @returns - Array of animatable textures.
  122526. */
  122527. getAnimatables(): IAnimatable[];
  122528. /**
  122529. * Returns the texture used for reflections.
  122530. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  122531. */
  122532. private _getReflectionTexture;
  122533. /**
  122534. * Returns an array of the actively used textures.
  122535. * @returns - Array of BaseTextures
  122536. */
  122537. getActiveTextures(): BaseTexture[];
  122538. /**
  122539. * Checks to see if a texture is used in the material.
  122540. * @param texture - Base texture to use.
  122541. * @returns - Boolean specifying if a texture is used in the material.
  122542. */
  122543. hasTexture(texture: BaseTexture): boolean;
  122544. /**
  122545. * Disposes the resources of the material.
  122546. * @param forceDisposeEffect - Forces the disposal of effects.
  122547. * @param forceDisposeTextures - Forces the disposal of all textures.
  122548. */
  122549. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122550. }
  122551. }
  122552. declare module BABYLON {
  122553. /**
  122554. * The Physically based material of BJS.
  122555. *
  122556. * This offers the main features of a standard PBR material.
  122557. * For more information, please refer to the documentation :
  122558. * https://doc.babylonjs.com/how_to/physically_based_rendering
  122559. */
  122560. export class PBRMaterial extends PBRBaseMaterial {
  122561. /**
  122562. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  122563. */
  122564. static readonly PBRMATERIAL_OPAQUE: number;
  122565. /**
  122566. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  122567. */
  122568. static readonly PBRMATERIAL_ALPHATEST: number;
  122569. /**
  122570. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  122571. */
  122572. static readonly PBRMATERIAL_ALPHABLEND: number;
  122573. /**
  122574. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  122575. * They are also discarded below the alpha cutoff threshold to improve performances.
  122576. */
  122577. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  122578. /**
  122579. * Defines the default value of how much AO map is occluding the analytical lights
  122580. * (point spot...).
  122581. */
  122582. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  122583. /**
  122584. * Intensity of the direct lights e.g. the four lights available in your scene.
  122585. * This impacts both the direct diffuse and specular highlights.
  122586. */
  122587. directIntensity: number;
  122588. /**
  122589. * Intensity of the emissive part of the material.
  122590. * This helps controlling the emissive effect without modifying the emissive color.
  122591. */
  122592. emissiveIntensity: number;
  122593. /**
  122594. * Intensity of the environment e.g. how much the environment will light the object
  122595. * either through harmonics for rough material or through the refelction for shiny ones.
  122596. */
  122597. environmentIntensity: number;
  122598. /**
  122599. * This is a special control allowing the reduction of the specular highlights coming from the
  122600. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  122601. */
  122602. specularIntensity: number;
  122603. /**
  122604. * Debug Control allowing disabling the bump map on this material.
  122605. */
  122606. disableBumpMap: boolean;
  122607. /**
  122608. * AKA Diffuse Texture in standard nomenclature.
  122609. */
  122610. albedoTexture: BaseTexture;
  122611. /**
  122612. * AKA Occlusion Texture in other nomenclature.
  122613. */
  122614. ambientTexture: BaseTexture;
  122615. /**
  122616. * AKA Occlusion Texture Intensity in other nomenclature.
  122617. */
  122618. ambientTextureStrength: number;
  122619. /**
  122620. * Defines how much the AO map is occluding the analytical lights (point spot...).
  122621. * 1 means it completely occludes it
  122622. * 0 mean it has no impact
  122623. */
  122624. ambientTextureImpactOnAnalyticalLights: number;
  122625. /**
  122626. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  122627. */
  122628. opacityTexture: BaseTexture;
  122629. /**
  122630. * Stores the reflection values in a texture.
  122631. */
  122632. reflectionTexture: Nullable<BaseTexture>;
  122633. /**
  122634. * Stores the emissive values in a texture.
  122635. */
  122636. emissiveTexture: BaseTexture;
  122637. /**
  122638. * AKA Specular texture in other nomenclature.
  122639. */
  122640. reflectivityTexture: BaseTexture;
  122641. /**
  122642. * Used to switch from specular/glossiness to metallic/roughness workflow.
  122643. */
  122644. metallicTexture: BaseTexture;
  122645. /**
  122646. * Specifies the metallic scalar of the metallic/roughness workflow.
  122647. * Can also be used to scale the metalness values of the metallic texture.
  122648. */
  122649. metallic: Nullable<number>;
  122650. /**
  122651. * Specifies the roughness scalar of the metallic/roughness workflow.
  122652. * Can also be used to scale the roughness values of the metallic texture.
  122653. */
  122654. roughness: Nullable<number>;
  122655. /**
  122656. * Specifies the an F0 factor to help configuring the material F0.
  122657. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  122658. * to 0.5 the previously hard coded value stays the same.
  122659. * Can also be used to scale the F0 values of the metallic texture.
  122660. */
  122661. metallicF0Factor: number;
  122662. /**
  122663. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  122664. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  122665. * your expectation as it multiplies with the texture data.
  122666. */
  122667. useMetallicF0FactorFromMetallicTexture: boolean;
  122668. /**
  122669. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  122670. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  122671. */
  122672. microSurfaceTexture: BaseTexture;
  122673. /**
  122674. * Stores surface normal data used to displace a mesh in a texture.
  122675. */
  122676. bumpTexture: BaseTexture;
  122677. /**
  122678. * Stores the pre-calculated light information of a mesh in a texture.
  122679. */
  122680. lightmapTexture: BaseTexture;
  122681. /**
  122682. * Stores the refracted light information in a texture.
  122683. */
  122684. get refractionTexture(): Nullable<BaseTexture>;
  122685. set refractionTexture(value: Nullable<BaseTexture>);
  122686. /**
  122687. * The color of a material in ambient lighting.
  122688. */
  122689. ambientColor: Color3;
  122690. /**
  122691. * AKA Diffuse Color in other nomenclature.
  122692. */
  122693. albedoColor: Color3;
  122694. /**
  122695. * AKA Specular Color in other nomenclature.
  122696. */
  122697. reflectivityColor: Color3;
  122698. /**
  122699. * The color reflected from the material.
  122700. */
  122701. reflectionColor: Color3;
  122702. /**
  122703. * The color emitted from the material.
  122704. */
  122705. emissiveColor: Color3;
  122706. /**
  122707. * AKA Glossiness in other nomenclature.
  122708. */
  122709. microSurface: number;
  122710. /**
  122711. * source material index of refraction (IOR)' / 'destination material IOR.
  122712. */
  122713. get indexOfRefraction(): number;
  122714. set indexOfRefraction(value: number);
  122715. /**
  122716. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  122717. */
  122718. get invertRefractionY(): boolean;
  122719. set invertRefractionY(value: boolean);
  122720. /**
  122721. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  122722. * Materials half opaque for instance using refraction could benefit from this control.
  122723. */
  122724. get linkRefractionWithTransparency(): boolean;
  122725. set linkRefractionWithTransparency(value: boolean);
  122726. /**
  122727. * If true, the light map contains occlusion information instead of lighting info.
  122728. */
  122729. useLightmapAsShadowmap: boolean;
  122730. /**
  122731. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  122732. */
  122733. useAlphaFromAlbedoTexture: boolean;
  122734. /**
  122735. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  122736. */
  122737. forceAlphaTest: boolean;
  122738. /**
  122739. * Defines the alpha limits in alpha test mode.
  122740. */
  122741. alphaCutOff: number;
  122742. /**
  122743. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  122744. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  122745. */
  122746. useSpecularOverAlpha: boolean;
  122747. /**
  122748. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  122749. */
  122750. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  122751. /**
  122752. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  122753. */
  122754. useRoughnessFromMetallicTextureAlpha: boolean;
  122755. /**
  122756. * Specifies if the metallic texture contains the roughness information in its green channel.
  122757. */
  122758. useRoughnessFromMetallicTextureGreen: boolean;
  122759. /**
  122760. * Specifies if the metallic texture contains the metallness information in its blue channel.
  122761. */
  122762. useMetallnessFromMetallicTextureBlue: boolean;
  122763. /**
  122764. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  122765. */
  122766. useAmbientOcclusionFromMetallicTextureRed: boolean;
  122767. /**
  122768. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  122769. */
  122770. useAmbientInGrayScale: boolean;
  122771. /**
  122772. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  122773. * The material will try to infer what glossiness each pixel should be.
  122774. */
  122775. useAutoMicroSurfaceFromReflectivityMap: boolean;
  122776. /**
  122777. * BJS is using an harcoded light falloff based on a manually sets up range.
  122778. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  122779. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  122780. */
  122781. get usePhysicalLightFalloff(): boolean;
  122782. /**
  122783. * BJS is using an harcoded light falloff based on a manually sets up range.
  122784. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  122785. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  122786. */
  122787. set usePhysicalLightFalloff(value: boolean);
  122788. /**
  122789. * In order to support the falloff compatibility with gltf, a special mode has been added
  122790. * to reproduce the gltf light falloff.
  122791. */
  122792. get useGLTFLightFalloff(): boolean;
  122793. /**
  122794. * In order to support the falloff compatibility with gltf, a special mode has been added
  122795. * to reproduce the gltf light falloff.
  122796. */
  122797. set useGLTFLightFalloff(value: boolean);
  122798. /**
  122799. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  122800. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  122801. */
  122802. useRadianceOverAlpha: boolean;
  122803. /**
  122804. * Allows using an object space normal map (instead of tangent space).
  122805. */
  122806. useObjectSpaceNormalMap: boolean;
  122807. /**
  122808. * Allows using the bump map in parallax mode.
  122809. */
  122810. useParallax: boolean;
  122811. /**
  122812. * Allows using the bump map in parallax occlusion mode.
  122813. */
  122814. useParallaxOcclusion: boolean;
  122815. /**
  122816. * Controls the scale bias of the parallax mode.
  122817. */
  122818. parallaxScaleBias: number;
  122819. /**
  122820. * If sets to true, disables all the lights affecting the material.
  122821. */
  122822. disableLighting: boolean;
  122823. /**
  122824. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  122825. */
  122826. forceIrradianceInFragment: boolean;
  122827. /**
  122828. * Number of Simultaneous lights allowed on the material.
  122829. */
  122830. maxSimultaneousLights: number;
  122831. /**
  122832. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  122833. */
  122834. invertNormalMapX: boolean;
  122835. /**
  122836. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  122837. */
  122838. invertNormalMapY: boolean;
  122839. /**
  122840. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  122841. */
  122842. twoSidedLighting: boolean;
  122843. /**
  122844. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  122845. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  122846. */
  122847. useAlphaFresnel: boolean;
  122848. /**
  122849. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  122850. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  122851. */
  122852. useLinearAlphaFresnel: boolean;
  122853. /**
  122854. * Let user defines the brdf lookup texture used for IBL.
  122855. * A default 8bit version is embedded but you could point at :
  122856. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  122857. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  122858. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  122859. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  122860. */
  122861. environmentBRDFTexture: Nullable<BaseTexture>;
  122862. /**
  122863. * Force normal to face away from face.
  122864. */
  122865. forceNormalForward: boolean;
  122866. /**
  122867. * Enables specular anti aliasing in the PBR shader.
  122868. * It will both interacts on the Geometry for analytical and IBL lighting.
  122869. * It also prefilter the roughness map based on the bump values.
  122870. */
  122871. enableSpecularAntiAliasing: boolean;
  122872. /**
  122873. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  122874. * makes the reflect vector face the model (under horizon).
  122875. */
  122876. useHorizonOcclusion: boolean;
  122877. /**
  122878. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  122879. * too much the area relying on ambient texture to define their ambient occlusion.
  122880. */
  122881. useRadianceOcclusion: boolean;
  122882. /**
  122883. * If set to true, no lighting calculations will be applied.
  122884. */
  122885. unlit: boolean;
  122886. /**
  122887. * Gets the image processing configuration used either in this material.
  122888. */
  122889. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  122890. /**
  122891. * Sets the Default image processing configuration used either in the this material.
  122892. *
  122893. * If sets to null, the scene one is in use.
  122894. */
  122895. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  122896. /**
  122897. * Gets wether the color curves effect is enabled.
  122898. */
  122899. get cameraColorCurvesEnabled(): boolean;
  122900. /**
  122901. * Sets wether the color curves effect is enabled.
  122902. */
  122903. set cameraColorCurvesEnabled(value: boolean);
  122904. /**
  122905. * Gets wether the color grading effect is enabled.
  122906. */
  122907. get cameraColorGradingEnabled(): boolean;
  122908. /**
  122909. * Gets wether the color grading effect is enabled.
  122910. */
  122911. set cameraColorGradingEnabled(value: boolean);
  122912. /**
  122913. * Gets wether tonemapping is enabled or not.
  122914. */
  122915. get cameraToneMappingEnabled(): boolean;
  122916. /**
  122917. * Sets wether tonemapping is enabled or not
  122918. */
  122919. set cameraToneMappingEnabled(value: boolean);
  122920. /**
  122921. * The camera exposure used on this material.
  122922. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122923. * This corresponds to a photographic exposure.
  122924. */
  122925. get cameraExposure(): number;
  122926. /**
  122927. * The camera exposure used on this material.
  122928. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122929. * This corresponds to a photographic exposure.
  122930. */
  122931. set cameraExposure(value: number);
  122932. /**
  122933. * Gets The camera contrast used on this material.
  122934. */
  122935. get cameraContrast(): number;
  122936. /**
  122937. * Sets The camera contrast used on this material.
  122938. */
  122939. set cameraContrast(value: number);
  122940. /**
  122941. * Gets the Color Grading 2D Lookup Texture.
  122942. */
  122943. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122944. /**
  122945. * Sets the Color Grading 2D Lookup Texture.
  122946. */
  122947. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122948. /**
  122949. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122950. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122951. * 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;
  122952. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122953. */
  122954. get cameraColorCurves(): Nullable<ColorCurves>;
  122955. /**
  122956. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122957. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122958. * 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;
  122959. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122960. */
  122961. set cameraColorCurves(value: Nullable<ColorCurves>);
  122962. /**
  122963. * Instantiates a new PBRMaterial instance.
  122964. *
  122965. * @param name The material name
  122966. * @param scene The scene the material will be use in.
  122967. */
  122968. constructor(name: string, scene: Scene);
  122969. /**
  122970. * Returns the name of this material class.
  122971. */
  122972. getClassName(): string;
  122973. /**
  122974. * Makes a duplicate of the current material.
  122975. * @param name - name to use for the new material.
  122976. */
  122977. clone(name: string): PBRMaterial;
  122978. /**
  122979. * Serializes this PBR Material.
  122980. * @returns - An object with the serialized material.
  122981. */
  122982. serialize(): any;
  122983. /**
  122984. * Parses a PBR Material from a serialized object.
  122985. * @param source - Serialized object.
  122986. * @param scene - BJS scene instance.
  122987. * @param rootUrl - url for the scene object
  122988. * @returns - PBRMaterial
  122989. */
  122990. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  122991. }
  122992. }
  122993. declare module BABYLON {
  122994. /**
  122995. * Direct draw surface info
  122996. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  122997. */
  122998. export interface DDSInfo {
  122999. /**
  123000. * Width of the texture
  123001. */
  123002. width: number;
  123003. /**
  123004. * Width of the texture
  123005. */
  123006. height: number;
  123007. /**
  123008. * Number of Mipmaps for the texture
  123009. * @see https://en.wikipedia.org/wiki/Mipmap
  123010. */
  123011. mipmapCount: number;
  123012. /**
  123013. * If the textures format is a known fourCC format
  123014. * @see https://www.fourcc.org/
  123015. */
  123016. isFourCC: boolean;
  123017. /**
  123018. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  123019. */
  123020. isRGB: boolean;
  123021. /**
  123022. * If the texture is a lumincance format
  123023. */
  123024. isLuminance: boolean;
  123025. /**
  123026. * If this is a cube texture
  123027. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  123028. */
  123029. isCube: boolean;
  123030. /**
  123031. * If the texture is a compressed format eg. FOURCC_DXT1
  123032. */
  123033. isCompressed: boolean;
  123034. /**
  123035. * The dxgiFormat of the texture
  123036. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  123037. */
  123038. dxgiFormat: number;
  123039. /**
  123040. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  123041. */
  123042. textureType: number;
  123043. /**
  123044. * Sphericle polynomial created for the dds texture
  123045. */
  123046. sphericalPolynomial?: SphericalPolynomial;
  123047. }
  123048. /**
  123049. * Class used to provide DDS decompression tools
  123050. */
  123051. export class DDSTools {
  123052. /**
  123053. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  123054. */
  123055. static StoreLODInAlphaChannel: boolean;
  123056. /**
  123057. * Gets DDS information from an array buffer
  123058. * @param arrayBuffer defines the array buffer to read data from
  123059. * @returns the DDS information
  123060. */
  123061. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  123062. private static _FloatView;
  123063. private static _Int32View;
  123064. private static _ToHalfFloat;
  123065. private static _FromHalfFloat;
  123066. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  123067. private static _GetHalfFloatRGBAArrayBuffer;
  123068. private static _GetFloatRGBAArrayBuffer;
  123069. private static _GetFloatAsUIntRGBAArrayBuffer;
  123070. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  123071. private static _GetRGBAArrayBuffer;
  123072. private static _ExtractLongWordOrder;
  123073. private static _GetRGBArrayBuffer;
  123074. private static _GetLuminanceArrayBuffer;
  123075. /**
  123076. * Uploads DDS Levels to a Babylon Texture
  123077. * @hidden
  123078. */
  123079. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  123080. }
  123081. interface ThinEngine {
  123082. /**
  123083. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  123084. * @param rootUrl defines the url where the file to load is located
  123085. * @param scene defines the current scene
  123086. * @param lodScale defines scale to apply to the mip map selection
  123087. * @param lodOffset defines offset to apply to the mip map selection
  123088. * @param onLoad defines an optional callback raised when the texture is loaded
  123089. * @param onError defines an optional callback raised if there is an issue to load the texture
  123090. * @param format defines the format of the data
  123091. * @param forcedExtension defines the extension to use to pick the right loader
  123092. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  123093. * @returns the cube texture as an InternalTexture
  123094. */
  123095. 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;
  123096. }
  123097. }
  123098. declare module BABYLON {
  123099. /**
  123100. * Implementation of the DDS Texture Loader.
  123101. * @hidden
  123102. */
  123103. export class _DDSTextureLoader implements IInternalTextureLoader {
  123104. /**
  123105. * Defines wether the loader supports cascade loading the different faces.
  123106. */
  123107. readonly supportCascades: boolean;
  123108. /**
  123109. * This returns if the loader support the current file information.
  123110. * @param extension defines the file extension of the file being loaded
  123111. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123112. * @param fallback defines the fallback internal texture if any
  123113. * @param isBase64 defines whether the texture is encoded as a base64
  123114. * @param isBuffer defines whether the texture data are stored as a buffer
  123115. * @returns true if the loader can load the specified file
  123116. */
  123117. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  123118. /**
  123119. * Transform the url before loading if required.
  123120. * @param rootUrl the url of the texture
  123121. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123122. * @returns the transformed texture
  123123. */
  123124. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  123125. /**
  123126. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  123127. * @param rootUrl the url of the texture
  123128. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123129. * @returns the fallback texture
  123130. */
  123131. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  123132. /**
  123133. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  123134. * @param data contains the texture data
  123135. * @param texture defines the BabylonJS internal texture
  123136. * @param createPolynomials will be true if polynomials have been requested
  123137. * @param onLoad defines the callback to trigger once the texture is ready
  123138. * @param onError defines the callback to trigger in case of error
  123139. */
  123140. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  123141. /**
  123142. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  123143. * @param data contains the texture data
  123144. * @param texture defines the BabylonJS internal texture
  123145. * @param callback defines the method to call once ready to upload
  123146. */
  123147. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  123148. }
  123149. }
  123150. declare module BABYLON {
  123151. /**
  123152. * Implementation of the ENV Texture Loader.
  123153. * @hidden
  123154. */
  123155. export class _ENVTextureLoader implements IInternalTextureLoader {
  123156. /**
  123157. * Defines wether the loader supports cascade loading the different faces.
  123158. */
  123159. readonly supportCascades: boolean;
  123160. /**
  123161. * This returns if the loader support the current file information.
  123162. * @param extension defines the file extension of the file being loaded
  123163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123164. * @param fallback defines the fallback internal texture if any
  123165. * @param isBase64 defines whether the texture is encoded as a base64
  123166. * @param isBuffer defines whether the texture data are stored as a buffer
  123167. * @returns true if the loader can load the specified file
  123168. */
  123169. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  123170. /**
  123171. * Transform the url before loading if required.
  123172. * @param rootUrl the url of the texture
  123173. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123174. * @returns the transformed texture
  123175. */
  123176. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  123177. /**
  123178. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  123179. * @param rootUrl the url of the texture
  123180. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123181. * @returns the fallback texture
  123182. */
  123183. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  123184. /**
  123185. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  123186. * @param data contains the texture data
  123187. * @param texture defines the BabylonJS internal texture
  123188. * @param createPolynomials will be true if polynomials have been requested
  123189. * @param onLoad defines the callback to trigger once the texture is ready
  123190. * @param onError defines the callback to trigger in case of error
  123191. */
  123192. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  123193. /**
  123194. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  123195. * @param data contains the texture data
  123196. * @param texture defines the BabylonJS internal texture
  123197. * @param callback defines the method to call once ready to upload
  123198. */
  123199. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  123200. }
  123201. }
  123202. declare module BABYLON {
  123203. /**
  123204. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  123205. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  123206. */
  123207. export class KhronosTextureContainer {
  123208. /** contents of the KTX container file */
  123209. arrayBuffer: any;
  123210. private static HEADER_LEN;
  123211. private static COMPRESSED_2D;
  123212. private static COMPRESSED_3D;
  123213. private static TEX_2D;
  123214. private static TEX_3D;
  123215. /**
  123216. * Gets the openGL type
  123217. */
  123218. glType: number;
  123219. /**
  123220. * Gets the openGL type size
  123221. */
  123222. glTypeSize: number;
  123223. /**
  123224. * Gets the openGL format
  123225. */
  123226. glFormat: number;
  123227. /**
  123228. * Gets the openGL internal format
  123229. */
  123230. glInternalFormat: number;
  123231. /**
  123232. * Gets the base internal format
  123233. */
  123234. glBaseInternalFormat: number;
  123235. /**
  123236. * Gets image width in pixel
  123237. */
  123238. pixelWidth: number;
  123239. /**
  123240. * Gets image height in pixel
  123241. */
  123242. pixelHeight: number;
  123243. /**
  123244. * Gets image depth in pixels
  123245. */
  123246. pixelDepth: number;
  123247. /**
  123248. * Gets the number of array elements
  123249. */
  123250. numberOfArrayElements: number;
  123251. /**
  123252. * Gets the number of faces
  123253. */
  123254. numberOfFaces: number;
  123255. /**
  123256. * Gets the number of mipmap levels
  123257. */
  123258. numberOfMipmapLevels: number;
  123259. /**
  123260. * Gets the bytes of key value data
  123261. */
  123262. bytesOfKeyValueData: number;
  123263. /**
  123264. * Gets the load type
  123265. */
  123266. loadType: number;
  123267. /**
  123268. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  123269. */
  123270. isInvalid: boolean;
  123271. /**
  123272. * Creates a new KhronosTextureContainer
  123273. * @param arrayBuffer contents of the KTX container file
  123274. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  123275. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  123276. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  123277. */
  123278. constructor(
  123279. /** contents of the KTX container file */
  123280. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  123281. /**
  123282. * Uploads KTX content to a Babylon Texture.
  123283. * It is assumed that the texture has already been created & is currently bound
  123284. * @hidden
  123285. */
  123286. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  123287. private _upload2DCompressedLevels;
  123288. }
  123289. }
  123290. declare module BABYLON {
  123291. /**
  123292. * Implementation of the KTX Texture Loader.
  123293. * @hidden
  123294. */
  123295. export class _KTXTextureLoader implements IInternalTextureLoader {
  123296. /**
  123297. * Defines wether the loader supports cascade loading the different faces.
  123298. */
  123299. readonly supportCascades: boolean;
  123300. /**
  123301. * This returns if the loader support the current file information.
  123302. * @param extension defines the file extension of the file being loaded
  123303. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123304. * @param fallback defines the fallback internal texture if any
  123305. * @param isBase64 defines whether the texture is encoded as a base64
  123306. * @param isBuffer defines whether the texture data are stored as a buffer
  123307. * @returns true if the loader can load the specified file
  123308. */
  123309. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  123310. /**
  123311. * Transform the url before loading if required.
  123312. * @param rootUrl the url of the texture
  123313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123314. * @returns the transformed texture
  123315. */
  123316. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  123317. /**
  123318. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  123319. * @param rootUrl the url of the texture
  123320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  123321. * @returns the fallback texture
  123322. */
  123323. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  123324. /**
  123325. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  123326. * @param data contains the texture data
  123327. * @param texture defines the BabylonJS internal texture
  123328. * @param createPolynomials will be true if polynomials have been requested
  123329. * @param onLoad defines the callback to trigger once the texture is ready
  123330. * @param onError defines the callback to trigger in case of error
  123331. */
  123332. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  123333. /**
  123334. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  123335. * @param data contains the texture data
  123336. * @param texture defines the BabylonJS internal texture
  123337. * @param callback defines the method to call once ready to upload
  123338. */
  123339. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  123340. }
  123341. }
  123342. declare module BABYLON {
  123343. /** @hidden */
  123344. export var _forceSceneHelpersToBundle: boolean;
  123345. interface Scene {
  123346. /**
  123347. * Creates a default light for the scene.
  123348. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  123349. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  123350. */
  123351. createDefaultLight(replace?: boolean): void;
  123352. /**
  123353. * Creates a default camera for the scene.
  123354. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  123355. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  123356. * @param replace has default false, when true replaces the active camera in the scene
  123357. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  123358. */
  123359. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  123360. /**
  123361. * Creates a default camera and a default light.
  123362. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  123363. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  123364. * @param replace has the default false, when true replaces the active camera/light in the scene
  123365. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  123366. */
  123367. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  123368. /**
  123369. * Creates a new sky box
  123370. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  123371. * @param environmentTexture defines the texture to use as environment texture
  123372. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  123373. * @param scale defines the overall scale of the skybox
  123374. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  123375. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  123376. * @returns a new mesh holding the sky box
  123377. */
  123378. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  123379. /**
  123380. * Creates a new environment
  123381. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  123382. * @param options defines the options you can use to configure the environment
  123383. * @returns the new EnvironmentHelper
  123384. */
  123385. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  123386. /**
  123387. * Creates a new VREXperienceHelper
  123388. * @see http://doc.babylonjs.com/how_to/webvr_helper
  123389. * @param webVROptions defines the options used to create the new VREXperienceHelper
  123390. * @returns a new VREXperienceHelper
  123391. */
  123392. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  123393. /**
  123394. * Creates a new WebXRDefaultExperience
  123395. * @see http://doc.babylonjs.com/how_to/webxr
  123396. * @param options experience options
  123397. * @returns a promise for a new WebXRDefaultExperience
  123398. */
  123399. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  123400. }
  123401. }
  123402. declare module BABYLON {
  123403. /**
  123404. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  123405. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  123406. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  123407. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123408. */
  123409. export class VideoDome extends TransformNode {
  123410. /**
  123411. * Define the video source as a Monoscopic panoramic 360 video.
  123412. */
  123413. static readonly MODE_MONOSCOPIC: number;
  123414. /**
  123415. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  123416. */
  123417. static readonly MODE_TOPBOTTOM: number;
  123418. /**
  123419. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  123420. */
  123421. static readonly MODE_SIDEBYSIDE: number;
  123422. private _halfDome;
  123423. private _useDirectMapping;
  123424. /**
  123425. * The video texture being displayed on the sphere
  123426. */
  123427. protected _videoTexture: VideoTexture;
  123428. /**
  123429. * Gets the video texture being displayed on the sphere
  123430. */
  123431. get videoTexture(): VideoTexture;
  123432. /**
  123433. * The skybox material
  123434. */
  123435. protected _material: BackgroundMaterial;
  123436. /**
  123437. * The surface used for the skybox
  123438. */
  123439. protected _mesh: Mesh;
  123440. /**
  123441. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  123442. */
  123443. private _halfDomeMask;
  123444. /**
  123445. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123446. * Also see the options.resolution property.
  123447. */
  123448. get fovMultiplier(): number;
  123449. set fovMultiplier(value: number);
  123450. private _videoMode;
  123451. /**
  123452. * Gets or set the current video mode for the video. It can be:
  123453. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  123454. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  123455. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  123456. */
  123457. get videoMode(): number;
  123458. set videoMode(value: number);
  123459. /**
  123460. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  123461. *
  123462. */
  123463. get halfDome(): boolean;
  123464. /**
  123465. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  123466. */
  123467. set halfDome(enabled: boolean);
  123468. /**
  123469. * Oberserver used in Stereoscopic VR Mode.
  123470. */
  123471. private _onBeforeCameraRenderObserver;
  123472. /**
  123473. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  123474. * @param name Element's name, child elements will append suffixes for their own names.
  123475. * @param urlsOrVideo defines the url(s) or the video element to use
  123476. * @param options An object containing optional or exposed sub element properties
  123477. */
  123478. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  123479. resolution?: number;
  123480. clickToPlay?: boolean;
  123481. autoPlay?: boolean;
  123482. loop?: boolean;
  123483. size?: number;
  123484. poster?: string;
  123485. faceForward?: boolean;
  123486. useDirectMapping?: boolean;
  123487. halfDomeMode?: boolean;
  123488. }, scene: Scene);
  123489. private _changeVideoMode;
  123490. /**
  123491. * Releases resources associated with this node.
  123492. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123493. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123494. */
  123495. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123496. }
  123497. }
  123498. declare module BABYLON {
  123499. /**
  123500. * This class can be used to get instrumentation data from a Babylon engine
  123501. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  123502. */
  123503. export class EngineInstrumentation implements IDisposable {
  123504. /**
  123505. * Define the instrumented engine.
  123506. */
  123507. engine: Engine;
  123508. private _captureGPUFrameTime;
  123509. private _gpuFrameTimeToken;
  123510. private _gpuFrameTime;
  123511. private _captureShaderCompilationTime;
  123512. private _shaderCompilationTime;
  123513. private _onBeginFrameObserver;
  123514. private _onEndFrameObserver;
  123515. private _onBeforeShaderCompilationObserver;
  123516. private _onAfterShaderCompilationObserver;
  123517. /**
  123518. * Gets the perf counter used for GPU frame time
  123519. */
  123520. get gpuFrameTimeCounter(): PerfCounter;
  123521. /**
  123522. * Gets the GPU frame time capture status
  123523. */
  123524. get captureGPUFrameTime(): boolean;
  123525. /**
  123526. * Enable or disable the GPU frame time capture
  123527. */
  123528. set captureGPUFrameTime(value: boolean);
  123529. /**
  123530. * Gets the perf counter used for shader compilation time
  123531. */
  123532. get shaderCompilationTimeCounter(): PerfCounter;
  123533. /**
  123534. * Gets the shader compilation time capture status
  123535. */
  123536. get captureShaderCompilationTime(): boolean;
  123537. /**
  123538. * Enable or disable the shader compilation time capture
  123539. */
  123540. set captureShaderCompilationTime(value: boolean);
  123541. /**
  123542. * Instantiates a new engine instrumentation.
  123543. * This class can be used to get instrumentation data from a Babylon engine
  123544. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  123545. * @param engine Defines the engine to instrument
  123546. */
  123547. constructor(
  123548. /**
  123549. * Define the instrumented engine.
  123550. */
  123551. engine: Engine);
  123552. /**
  123553. * Dispose and release associated resources.
  123554. */
  123555. dispose(): void;
  123556. }
  123557. }
  123558. declare module BABYLON {
  123559. /**
  123560. * This class can be used to get instrumentation data from a Babylon engine
  123561. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  123562. */
  123563. export class SceneInstrumentation implements IDisposable {
  123564. /**
  123565. * Defines the scene to instrument
  123566. */
  123567. scene: Scene;
  123568. private _captureActiveMeshesEvaluationTime;
  123569. private _activeMeshesEvaluationTime;
  123570. private _captureRenderTargetsRenderTime;
  123571. private _renderTargetsRenderTime;
  123572. private _captureFrameTime;
  123573. private _frameTime;
  123574. private _captureRenderTime;
  123575. private _renderTime;
  123576. private _captureInterFrameTime;
  123577. private _interFrameTime;
  123578. private _captureParticlesRenderTime;
  123579. private _particlesRenderTime;
  123580. private _captureSpritesRenderTime;
  123581. private _spritesRenderTime;
  123582. private _capturePhysicsTime;
  123583. private _physicsTime;
  123584. private _captureAnimationsTime;
  123585. private _animationsTime;
  123586. private _captureCameraRenderTime;
  123587. private _cameraRenderTime;
  123588. private _onBeforeActiveMeshesEvaluationObserver;
  123589. private _onAfterActiveMeshesEvaluationObserver;
  123590. private _onBeforeRenderTargetsRenderObserver;
  123591. private _onAfterRenderTargetsRenderObserver;
  123592. private _onAfterRenderObserver;
  123593. private _onBeforeDrawPhaseObserver;
  123594. private _onAfterDrawPhaseObserver;
  123595. private _onBeforeAnimationsObserver;
  123596. private _onBeforeParticlesRenderingObserver;
  123597. private _onAfterParticlesRenderingObserver;
  123598. private _onBeforeSpritesRenderingObserver;
  123599. private _onAfterSpritesRenderingObserver;
  123600. private _onBeforePhysicsObserver;
  123601. private _onAfterPhysicsObserver;
  123602. private _onAfterAnimationsObserver;
  123603. private _onBeforeCameraRenderObserver;
  123604. private _onAfterCameraRenderObserver;
  123605. /**
  123606. * Gets the perf counter used for active meshes evaluation time
  123607. */
  123608. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  123609. /**
  123610. * Gets the active meshes evaluation time capture status
  123611. */
  123612. get captureActiveMeshesEvaluationTime(): boolean;
  123613. /**
  123614. * Enable or disable the active meshes evaluation time capture
  123615. */
  123616. set captureActiveMeshesEvaluationTime(value: boolean);
  123617. /**
  123618. * Gets the perf counter used for render targets render time
  123619. */
  123620. get renderTargetsRenderTimeCounter(): PerfCounter;
  123621. /**
  123622. * Gets the render targets render time capture status
  123623. */
  123624. get captureRenderTargetsRenderTime(): boolean;
  123625. /**
  123626. * Enable or disable the render targets render time capture
  123627. */
  123628. set captureRenderTargetsRenderTime(value: boolean);
  123629. /**
  123630. * Gets the perf counter used for particles render time
  123631. */
  123632. get particlesRenderTimeCounter(): PerfCounter;
  123633. /**
  123634. * Gets the particles render time capture status
  123635. */
  123636. get captureParticlesRenderTime(): boolean;
  123637. /**
  123638. * Enable or disable the particles render time capture
  123639. */
  123640. set captureParticlesRenderTime(value: boolean);
  123641. /**
  123642. * Gets the perf counter used for sprites render time
  123643. */
  123644. get spritesRenderTimeCounter(): PerfCounter;
  123645. /**
  123646. * Gets the sprites render time capture status
  123647. */
  123648. get captureSpritesRenderTime(): boolean;
  123649. /**
  123650. * Enable or disable the sprites render time capture
  123651. */
  123652. set captureSpritesRenderTime(value: boolean);
  123653. /**
  123654. * Gets the perf counter used for physics time
  123655. */
  123656. get physicsTimeCounter(): PerfCounter;
  123657. /**
  123658. * Gets the physics time capture status
  123659. */
  123660. get capturePhysicsTime(): boolean;
  123661. /**
  123662. * Enable or disable the physics time capture
  123663. */
  123664. set capturePhysicsTime(value: boolean);
  123665. /**
  123666. * Gets the perf counter used for animations time
  123667. */
  123668. get animationsTimeCounter(): PerfCounter;
  123669. /**
  123670. * Gets the animations time capture status
  123671. */
  123672. get captureAnimationsTime(): boolean;
  123673. /**
  123674. * Enable or disable the animations time capture
  123675. */
  123676. set captureAnimationsTime(value: boolean);
  123677. /**
  123678. * Gets the perf counter used for frame time capture
  123679. */
  123680. get frameTimeCounter(): PerfCounter;
  123681. /**
  123682. * Gets the frame time capture status
  123683. */
  123684. get captureFrameTime(): boolean;
  123685. /**
  123686. * Enable or disable the frame time capture
  123687. */
  123688. set captureFrameTime(value: boolean);
  123689. /**
  123690. * Gets the perf counter used for inter-frames time capture
  123691. */
  123692. get interFrameTimeCounter(): PerfCounter;
  123693. /**
  123694. * Gets the inter-frames time capture status
  123695. */
  123696. get captureInterFrameTime(): boolean;
  123697. /**
  123698. * Enable or disable the inter-frames time capture
  123699. */
  123700. set captureInterFrameTime(value: boolean);
  123701. /**
  123702. * Gets the perf counter used for render time capture
  123703. */
  123704. get renderTimeCounter(): PerfCounter;
  123705. /**
  123706. * Gets the render time capture status
  123707. */
  123708. get captureRenderTime(): boolean;
  123709. /**
  123710. * Enable or disable the render time capture
  123711. */
  123712. set captureRenderTime(value: boolean);
  123713. /**
  123714. * Gets the perf counter used for camera render time capture
  123715. */
  123716. get cameraRenderTimeCounter(): PerfCounter;
  123717. /**
  123718. * Gets the camera render time capture status
  123719. */
  123720. get captureCameraRenderTime(): boolean;
  123721. /**
  123722. * Enable or disable the camera render time capture
  123723. */
  123724. set captureCameraRenderTime(value: boolean);
  123725. /**
  123726. * Gets the perf counter used for draw calls
  123727. */
  123728. get drawCallsCounter(): PerfCounter;
  123729. /**
  123730. * Instantiates a new scene instrumentation.
  123731. * This class can be used to get instrumentation data from a Babylon engine
  123732. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  123733. * @param scene Defines the scene to instrument
  123734. */
  123735. constructor(
  123736. /**
  123737. * Defines the scene to instrument
  123738. */
  123739. scene: Scene);
  123740. /**
  123741. * Dispose and release associated resources.
  123742. */
  123743. dispose(): void;
  123744. }
  123745. }
  123746. declare module BABYLON {
  123747. /** @hidden */
  123748. export var glowMapGenerationPixelShader: {
  123749. name: string;
  123750. shader: string;
  123751. };
  123752. }
  123753. declare module BABYLON {
  123754. /** @hidden */
  123755. export var glowMapGenerationVertexShader: {
  123756. name: string;
  123757. shader: string;
  123758. };
  123759. }
  123760. declare module BABYLON {
  123761. /**
  123762. * Effect layer options. This helps customizing the behaviour
  123763. * of the effect layer.
  123764. */
  123765. export interface IEffectLayerOptions {
  123766. /**
  123767. * Multiplication factor apply to the canvas size to compute the render target size
  123768. * used to generated the objects (the smaller the faster).
  123769. */
  123770. mainTextureRatio: number;
  123771. /**
  123772. * Enforces a fixed size texture to ensure effect stability across devices.
  123773. */
  123774. mainTextureFixedSize?: number;
  123775. /**
  123776. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  123777. */
  123778. alphaBlendingMode: number;
  123779. /**
  123780. * The camera attached to the layer.
  123781. */
  123782. camera: Nullable<Camera>;
  123783. /**
  123784. * The rendering group to draw the layer in.
  123785. */
  123786. renderingGroupId: number;
  123787. }
  123788. /**
  123789. * The effect layer Helps adding post process effect blended with the main pass.
  123790. *
  123791. * This can be for instance use to generate glow or higlight effects on the scene.
  123792. *
  123793. * The effect layer class can not be used directly and is intented to inherited from to be
  123794. * customized per effects.
  123795. */
  123796. export abstract class EffectLayer {
  123797. private _vertexBuffers;
  123798. private _indexBuffer;
  123799. private _cachedDefines;
  123800. private _effectLayerMapGenerationEffect;
  123801. private _effectLayerOptions;
  123802. private _mergeEffect;
  123803. protected _scene: Scene;
  123804. protected _engine: Engine;
  123805. protected _maxSize: number;
  123806. protected _mainTextureDesiredSize: ISize;
  123807. protected _mainTexture: RenderTargetTexture;
  123808. protected _shouldRender: boolean;
  123809. protected _postProcesses: PostProcess[];
  123810. protected _textures: BaseTexture[];
  123811. protected _emissiveTextureAndColor: {
  123812. texture: Nullable<BaseTexture>;
  123813. color: Color4;
  123814. };
  123815. /**
  123816. * The name of the layer
  123817. */
  123818. name: string;
  123819. /**
  123820. * The clear color of the texture used to generate the glow map.
  123821. */
  123822. neutralColor: Color4;
  123823. /**
  123824. * Specifies wether the highlight layer is enabled or not.
  123825. */
  123826. isEnabled: boolean;
  123827. /**
  123828. * Gets the camera attached to the layer.
  123829. */
  123830. get camera(): Nullable<Camera>;
  123831. /**
  123832. * Gets the rendering group id the layer should render in.
  123833. */
  123834. get renderingGroupId(): number;
  123835. set renderingGroupId(renderingGroupId: number);
  123836. /**
  123837. * An event triggered when the effect layer has been disposed.
  123838. */
  123839. onDisposeObservable: Observable<EffectLayer>;
  123840. /**
  123841. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  123842. */
  123843. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  123844. /**
  123845. * An event triggered when the generated texture is being merged in the scene.
  123846. */
  123847. onBeforeComposeObservable: Observable<EffectLayer>;
  123848. /**
  123849. * An event triggered when the mesh is rendered into the effect render target.
  123850. */
  123851. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  123852. /**
  123853. * An event triggered after the mesh has been rendered into the effect render target.
  123854. */
  123855. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  123856. /**
  123857. * An event triggered when the generated texture has been merged in the scene.
  123858. */
  123859. onAfterComposeObservable: Observable<EffectLayer>;
  123860. /**
  123861. * An event triggered when the efffect layer changes its size.
  123862. */
  123863. onSizeChangedObservable: Observable<EffectLayer>;
  123864. /** @hidden */
  123865. static _SceneComponentInitialization: (scene: Scene) => void;
  123866. /**
  123867. * Instantiates a new effect Layer and references it in the scene.
  123868. * @param name The name of the layer
  123869. * @param scene The scene to use the layer in
  123870. */
  123871. constructor(
  123872. /** The Friendly of the effect in the scene */
  123873. name: string, scene: Scene);
  123874. /**
  123875. * Get the effect name of the layer.
  123876. * @return The effect name
  123877. */
  123878. abstract getEffectName(): string;
  123879. /**
  123880. * Checks for the readiness of the element composing the layer.
  123881. * @param subMesh the mesh to check for
  123882. * @param useInstances specify wether or not to use instances to render the mesh
  123883. * @return true if ready otherwise, false
  123884. */
  123885. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  123886. /**
  123887. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  123888. * @returns true if the effect requires stencil during the main canvas render pass.
  123889. */
  123890. abstract needStencil(): boolean;
  123891. /**
  123892. * Create the merge effect. This is the shader use to blit the information back
  123893. * to the main canvas at the end of the scene rendering.
  123894. * @returns The effect containing the shader used to merge the effect on the main canvas
  123895. */
  123896. protected abstract _createMergeEffect(): Effect;
  123897. /**
  123898. * Creates the render target textures and post processes used in the effect layer.
  123899. */
  123900. protected abstract _createTextureAndPostProcesses(): void;
  123901. /**
  123902. * Implementation specific of rendering the generating effect on the main canvas.
  123903. * @param effect The effect used to render through
  123904. */
  123905. protected abstract _internalRender(effect: Effect): void;
  123906. /**
  123907. * Sets the required values for both the emissive texture and and the main color.
  123908. */
  123909. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  123910. /**
  123911. * Free any resources and references associated to a mesh.
  123912. * Internal use
  123913. * @param mesh The mesh to free.
  123914. */
  123915. abstract _disposeMesh(mesh: Mesh): void;
  123916. /**
  123917. * Serializes this layer (Glow or Highlight for example)
  123918. * @returns a serialized layer object
  123919. */
  123920. abstract serialize?(): any;
  123921. /**
  123922. * Initializes the effect layer with the required options.
  123923. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  123924. */
  123925. protected _init(options: Partial<IEffectLayerOptions>): void;
  123926. /**
  123927. * Generates the index buffer of the full screen quad blending to the main canvas.
  123928. */
  123929. private _generateIndexBuffer;
  123930. /**
  123931. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  123932. */
  123933. private _generateVertexBuffer;
  123934. /**
  123935. * Sets the main texture desired size which is the closest power of two
  123936. * of the engine canvas size.
  123937. */
  123938. private _setMainTextureSize;
  123939. /**
  123940. * Creates the main texture for the effect layer.
  123941. */
  123942. protected _createMainTexture(): void;
  123943. /**
  123944. * Adds specific effects defines.
  123945. * @param defines The defines to add specifics to.
  123946. */
  123947. protected _addCustomEffectDefines(defines: string[]): void;
  123948. /**
  123949. * Checks for the readiness of the element composing the layer.
  123950. * @param subMesh the mesh to check for
  123951. * @param useInstances specify wether or not to use instances to render the mesh
  123952. * @param emissiveTexture the associated emissive texture used to generate the glow
  123953. * @return true if ready otherwise, false
  123954. */
  123955. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  123956. /**
  123957. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  123958. */
  123959. render(): void;
  123960. /**
  123961. * Determine if a given mesh will be used in the current effect.
  123962. * @param mesh mesh to test
  123963. * @returns true if the mesh will be used
  123964. */
  123965. hasMesh(mesh: AbstractMesh): boolean;
  123966. /**
  123967. * Returns true if the layer contains information to display, otherwise false.
  123968. * @returns true if the glow layer should be rendered
  123969. */
  123970. shouldRender(): boolean;
  123971. /**
  123972. * Returns true if the mesh should render, otherwise false.
  123973. * @param mesh The mesh to render
  123974. * @returns true if it should render otherwise false
  123975. */
  123976. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  123977. /**
  123978. * Returns true if the mesh can be rendered, otherwise false.
  123979. * @param mesh The mesh to render
  123980. * @param material The material used on the mesh
  123981. * @returns true if it can be rendered otherwise false
  123982. */
  123983. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  123984. /**
  123985. * Returns true if the mesh should render, otherwise false.
  123986. * @param mesh The mesh to render
  123987. * @returns true if it should render otherwise false
  123988. */
  123989. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  123990. /**
  123991. * Renders the submesh passed in parameter to the generation map.
  123992. */
  123993. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  123994. /**
  123995. * Defines wether the current material of the mesh should be use to render the effect.
  123996. * @param mesh defines the current mesh to render
  123997. */
  123998. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  123999. /**
  124000. * Rebuild the required buffers.
  124001. * @hidden Internal use only.
  124002. */
  124003. _rebuild(): void;
  124004. /**
  124005. * Dispose only the render target textures and post process.
  124006. */
  124007. private _disposeTextureAndPostProcesses;
  124008. /**
  124009. * Dispose the highlight layer and free resources.
  124010. */
  124011. dispose(): void;
  124012. /**
  124013. * Gets the class name of the effect layer
  124014. * @returns the string with the class name of the effect layer
  124015. */
  124016. getClassName(): string;
  124017. /**
  124018. * Creates an effect layer from parsed effect layer data
  124019. * @param parsedEffectLayer defines effect layer data
  124020. * @param scene defines the current scene
  124021. * @param rootUrl defines the root URL containing the effect layer information
  124022. * @returns a parsed effect Layer
  124023. */
  124024. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  124025. }
  124026. }
  124027. declare module BABYLON {
  124028. interface AbstractScene {
  124029. /**
  124030. * The list of effect layers (highlights/glow) added to the scene
  124031. * @see http://doc.babylonjs.com/how_to/highlight_layer
  124032. * @see http://doc.babylonjs.com/how_to/glow_layer
  124033. */
  124034. effectLayers: Array<EffectLayer>;
  124035. /**
  124036. * Removes the given effect layer from this scene.
  124037. * @param toRemove defines the effect layer to remove
  124038. * @returns the index of the removed effect layer
  124039. */
  124040. removeEffectLayer(toRemove: EffectLayer): number;
  124041. /**
  124042. * Adds the given effect layer to this scene
  124043. * @param newEffectLayer defines the effect layer to add
  124044. */
  124045. addEffectLayer(newEffectLayer: EffectLayer): void;
  124046. }
  124047. /**
  124048. * Defines the layer scene component responsible to manage any effect layers
  124049. * in a given scene.
  124050. */
  124051. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  124052. /**
  124053. * The component name helpfull to identify the component in the list of scene components.
  124054. */
  124055. readonly name: string;
  124056. /**
  124057. * The scene the component belongs to.
  124058. */
  124059. scene: Scene;
  124060. private _engine;
  124061. private _renderEffects;
  124062. private _needStencil;
  124063. private _previousStencilState;
  124064. /**
  124065. * Creates a new instance of the component for the given scene
  124066. * @param scene Defines the scene to register the component in
  124067. */
  124068. constructor(scene: Scene);
  124069. /**
  124070. * Registers the component in a given scene
  124071. */
  124072. register(): void;
  124073. /**
  124074. * Rebuilds the elements related to this component in case of
  124075. * context lost for instance.
  124076. */
  124077. rebuild(): void;
  124078. /**
  124079. * Serializes the component data to the specified json object
  124080. * @param serializationObject The object to serialize to
  124081. */
  124082. serialize(serializationObject: any): void;
  124083. /**
  124084. * Adds all the elements from the container to the scene
  124085. * @param container the container holding the elements
  124086. */
  124087. addFromContainer(container: AbstractScene): void;
  124088. /**
  124089. * Removes all the elements in the container from the scene
  124090. * @param container contains the elements to remove
  124091. * @param dispose if the removed element should be disposed (default: false)
  124092. */
  124093. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  124094. /**
  124095. * Disposes the component and the associated ressources.
  124096. */
  124097. dispose(): void;
  124098. private _isReadyForMesh;
  124099. private _renderMainTexture;
  124100. private _setStencil;
  124101. private _setStencilBack;
  124102. private _draw;
  124103. private _drawCamera;
  124104. private _drawRenderingGroup;
  124105. }
  124106. }
  124107. declare module BABYLON {
  124108. /** @hidden */
  124109. export var glowMapMergePixelShader: {
  124110. name: string;
  124111. shader: string;
  124112. };
  124113. }
  124114. declare module BABYLON {
  124115. /** @hidden */
  124116. export var glowMapMergeVertexShader: {
  124117. name: string;
  124118. shader: string;
  124119. };
  124120. }
  124121. declare module BABYLON {
  124122. interface AbstractScene {
  124123. /**
  124124. * Return a the first highlight layer of the scene with a given name.
  124125. * @param name The name of the highlight layer to look for.
  124126. * @return The highlight layer if found otherwise null.
  124127. */
  124128. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  124129. }
  124130. /**
  124131. * Glow layer options. This helps customizing the behaviour
  124132. * of the glow layer.
  124133. */
  124134. export interface IGlowLayerOptions {
  124135. /**
  124136. * Multiplication factor apply to the canvas size to compute the render target size
  124137. * used to generated the glowing objects (the smaller the faster).
  124138. */
  124139. mainTextureRatio: number;
  124140. /**
  124141. * Enforces a fixed size texture to ensure resize independant blur.
  124142. */
  124143. mainTextureFixedSize?: number;
  124144. /**
  124145. * How big is the kernel of the blur texture.
  124146. */
  124147. blurKernelSize: number;
  124148. /**
  124149. * The camera attached to the layer.
  124150. */
  124151. camera: Nullable<Camera>;
  124152. /**
  124153. * Enable MSAA by chosing the number of samples.
  124154. */
  124155. mainTextureSamples?: number;
  124156. /**
  124157. * The rendering group to draw the layer in.
  124158. */
  124159. renderingGroupId: number;
  124160. }
  124161. /**
  124162. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  124163. *
  124164. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  124165. *
  124166. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  124167. */
  124168. export class GlowLayer extends EffectLayer {
  124169. /**
  124170. * Effect Name of the layer.
  124171. */
  124172. static readonly EffectName: string;
  124173. /**
  124174. * The default blur kernel size used for the glow.
  124175. */
  124176. static DefaultBlurKernelSize: number;
  124177. /**
  124178. * The default texture size ratio used for the glow.
  124179. */
  124180. static DefaultTextureRatio: number;
  124181. /**
  124182. * Sets the kernel size of the blur.
  124183. */
  124184. set blurKernelSize(value: number);
  124185. /**
  124186. * Gets the kernel size of the blur.
  124187. */
  124188. get blurKernelSize(): number;
  124189. /**
  124190. * Sets the glow intensity.
  124191. */
  124192. set intensity(value: number);
  124193. /**
  124194. * Gets the glow intensity.
  124195. */
  124196. get intensity(): number;
  124197. private _options;
  124198. private _intensity;
  124199. private _horizontalBlurPostprocess1;
  124200. private _verticalBlurPostprocess1;
  124201. private _horizontalBlurPostprocess2;
  124202. private _verticalBlurPostprocess2;
  124203. private _blurTexture1;
  124204. private _blurTexture2;
  124205. private _postProcesses1;
  124206. private _postProcesses2;
  124207. private _includedOnlyMeshes;
  124208. private _excludedMeshes;
  124209. private _meshesUsingTheirOwnMaterials;
  124210. /**
  124211. * Callback used to let the user override the color selection on a per mesh basis
  124212. */
  124213. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  124214. /**
  124215. * Callback used to let the user override the texture selection on a per mesh basis
  124216. */
  124217. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  124218. /**
  124219. * Instantiates a new glow Layer and references it to the scene.
  124220. * @param name The name of the layer
  124221. * @param scene The scene to use the layer in
  124222. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  124223. */
  124224. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  124225. /**
  124226. * Get the effect name of the layer.
  124227. * @return The effect name
  124228. */
  124229. getEffectName(): string;
  124230. /**
  124231. * Create the merge effect. This is the shader use to blit the information back
  124232. * to the main canvas at the end of the scene rendering.
  124233. */
  124234. protected _createMergeEffect(): Effect;
  124235. /**
  124236. * Creates the render target textures and post processes used in the glow layer.
  124237. */
  124238. protected _createTextureAndPostProcesses(): void;
  124239. /**
  124240. * Checks for the readiness of the element composing the layer.
  124241. * @param subMesh the mesh to check for
  124242. * @param useInstances specify wether or not to use instances to render the mesh
  124243. * @param emissiveTexture the associated emissive texture used to generate the glow
  124244. * @return true if ready otherwise, false
  124245. */
  124246. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124247. /**
  124248. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  124249. */
  124250. needStencil(): boolean;
  124251. /**
  124252. * Returns true if the mesh can be rendered, otherwise false.
  124253. * @param mesh The mesh to render
  124254. * @param material The material used on the mesh
  124255. * @returns true if it can be rendered otherwise false
  124256. */
  124257. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  124258. /**
  124259. * Implementation specific of rendering the generating effect on the main canvas.
  124260. * @param effect The effect used to render through
  124261. */
  124262. protected _internalRender(effect: Effect): void;
  124263. /**
  124264. * Sets the required values for both the emissive texture and and the main color.
  124265. */
  124266. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  124267. /**
  124268. * Returns true if the mesh should render, otherwise false.
  124269. * @param mesh The mesh to render
  124270. * @returns true if it should render otherwise false
  124271. */
  124272. protected _shouldRenderMesh(mesh: Mesh): boolean;
  124273. /**
  124274. * Adds specific effects defines.
  124275. * @param defines The defines to add specifics to.
  124276. */
  124277. protected _addCustomEffectDefines(defines: string[]): void;
  124278. /**
  124279. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  124280. * @param mesh The mesh to exclude from the glow layer
  124281. */
  124282. addExcludedMesh(mesh: Mesh): void;
  124283. /**
  124284. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  124285. * @param mesh The mesh to remove
  124286. */
  124287. removeExcludedMesh(mesh: Mesh): void;
  124288. /**
  124289. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  124290. * @param mesh The mesh to include in the glow layer
  124291. */
  124292. addIncludedOnlyMesh(mesh: Mesh): void;
  124293. /**
  124294. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  124295. * @param mesh The mesh to remove
  124296. */
  124297. removeIncludedOnlyMesh(mesh: Mesh): void;
  124298. /**
  124299. * Determine if a given mesh will be used in the glow layer
  124300. * @param mesh The mesh to test
  124301. * @returns true if the mesh will be highlighted by the current glow layer
  124302. */
  124303. hasMesh(mesh: AbstractMesh): boolean;
  124304. /**
  124305. * Defines wether the current material of the mesh should be use to render the effect.
  124306. * @param mesh defines the current mesh to render
  124307. */
  124308. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  124309. /**
  124310. * Add a mesh to be rendered through its own material and not with emissive only.
  124311. * @param mesh The mesh for which we need to use its material
  124312. */
  124313. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  124314. /**
  124315. * Remove a mesh from being rendered through its own material and not with emissive only.
  124316. * @param mesh The mesh for which we need to not use its material
  124317. */
  124318. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  124319. /**
  124320. * Free any resources and references associated to a mesh.
  124321. * Internal use
  124322. * @param mesh The mesh to free.
  124323. * @hidden
  124324. */
  124325. _disposeMesh(mesh: Mesh): void;
  124326. /**
  124327. * Gets the class name of the effect layer
  124328. * @returns the string with the class name of the effect layer
  124329. */
  124330. getClassName(): string;
  124331. /**
  124332. * Serializes this glow layer
  124333. * @returns a serialized glow layer object
  124334. */
  124335. serialize(): any;
  124336. /**
  124337. * Creates a Glow Layer from parsed glow layer data
  124338. * @param parsedGlowLayer defines glow layer data
  124339. * @param scene defines the current scene
  124340. * @param rootUrl defines the root URL containing the glow layer information
  124341. * @returns a parsed Glow Layer
  124342. */
  124343. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  124344. }
  124345. }
  124346. declare module BABYLON {
  124347. /** @hidden */
  124348. export var glowBlurPostProcessPixelShader: {
  124349. name: string;
  124350. shader: string;
  124351. };
  124352. }
  124353. declare module BABYLON {
  124354. interface AbstractScene {
  124355. /**
  124356. * Return a the first highlight layer of the scene with a given name.
  124357. * @param name The name of the highlight layer to look for.
  124358. * @return The highlight layer if found otherwise null.
  124359. */
  124360. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  124361. }
  124362. /**
  124363. * Highlight layer options. This helps customizing the behaviour
  124364. * of the highlight layer.
  124365. */
  124366. export interface IHighlightLayerOptions {
  124367. /**
  124368. * Multiplication factor apply to the canvas size to compute the render target size
  124369. * used to generated the glowing objects (the smaller the faster).
  124370. */
  124371. mainTextureRatio: number;
  124372. /**
  124373. * Enforces a fixed size texture to ensure resize independant blur.
  124374. */
  124375. mainTextureFixedSize?: number;
  124376. /**
  124377. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  124378. * of the picture to blur (the smaller the faster).
  124379. */
  124380. blurTextureSizeRatio: number;
  124381. /**
  124382. * How big in texel of the blur texture is the vertical blur.
  124383. */
  124384. blurVerticalSize: number;
  124385. /**
  124386. * How big in texel of the blur texture is the horizontal blur.
  124387. */
  124388. blurHorizontalSize: number;
  124389. /**
  124390. * Alpha blending mode used to apply the blur. Default is combine.
  124391. */
  124392. alphaBlendingMode: number;
  124393. /**
  124394. * The camera attached to the layer.
  124395. */
  124396. camera: Nullable<Camera>;
  124397. /**
  124398. * Should we display highlight as a solid stroke?
  124399. */
  124400. isStroke?: boolean;
  124401. /**
  124402. * The rendering group to draw the layer in.
  124403. */
  124404. renderingGroupId: number;
  124405. }
  124406. /**
  124407. * The highlight layer Helps adding a glow effect around a mesh.
  124408. *
  124409. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  124410. * glowy meshes to your scene.
  124411. *
  124412. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  124413. */
  124414. export class HighlightLayer extends EffectLayer {
  124415. name: string;
  124416. /**
  124417. * Effect Name of the highlight layer.
  124418. */
  124419. static readonly EffectName: string;
  124420. /**
  124421. * The neutral color used during the preparation of the glow effect.
  124422. * This is black by default as the blend operation is a blend operation.
  124423. */
  124424. static NeutralColor: Color4;
  124425. /**
  124426. * Stencil value used for glowing meshes.
  124427. */
  124428. static GlowingMeshStencilReference: number;
  124429. /**
  124430. * Stencil value used for the other meshes in the scene.
  124431. */
  124432. static NormalMeshStencilReference: number;
  124433. /**
  124434. * Specifies whether or not the inner glow is ACTIVE in the layer.
  124435. */
  124436. innerGlow: boolean;
  124437. /**
  124438. * Specifies whether or not the outer glow is ACTIVE in the layer.
  124439. */
  124440. outerGlow: boolean;
  124441. /**
  124442. * Specifies the horizontal size of the blur.
  124443. */
  124444. set blurHorizontalSize(value: number);
  124445. /**
  124446. * Specifies the vertical size of the blur.
  124447. */
  124448. set blurVerticalSize(value: number);
  124449. /**
  124450. * Gets the horizontal size of the blur.
  124451. */
  124452. get blurHorizontalSize(): number;
  124453. /**
  124454. * Gets the vertical size of the blur.
  124455. */
  124456. get blurVerticalSize(): number;
  124457. /**
  124458. * An event triggered when the highlight layer is being blurred.
  124459. */
  124460. onBeforeBlurObservable: Observable<HighlightLayer>;
  124461. /**
  124462. * An event triggered when the highlight layer has been blurred.
  124463. */
  124464. onAfterBlurObservable: Observable<HighlightLayer>;
  124465. private _instanceGlowingMeshStencilReference;
  124466. private _options;
  124467. private _downSamplePostprocess;
  124468. private _horizontalBlurPostprocess;
  124469. private _verticalBlurPostprocess;
  124470. private _blurTexture;
  124471. private _meshes;
  124472. private _excludedMeshes;
  124473. /**
  124474. * Instantiates a new highlight Layer and references it to the scene..
  124475. * @param name The name of the layer
  124476. * @param scene The scene to use the layer in
  124477. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  124478. */
  124479. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  124480. /**
  124481. * Get the effect name of the layer.
  124482. * @return The effect name
  124483. */
  124484. getEffectName(): string;
  124485. /**
  124486. * Create the merge effect. This is the shader use to blit the information back
  124487. * to the main canvas at the end of the scene rendering.
  124488. */
  124489. protected _createMergeEffect(): Effect;
  124490. /**
  124491. * Creates the render target textures and post processes used in the highlight layer.
  124492. */
  124493. protected _createTextureAndPostProcesses(): void;
  124494. /**
  124495. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  124496. */
  124497. needStencil(): boolean;
  124498. /**
  124499. * Checks for the readiness of the element composing the layer.
  124500. * @param subMesh the mesh to check for
  124501. * @param useInstances specify wether or not to use instances to render the mesh
  124502. * @param emissiveTexture the associated emissive texture used to generate the glow
  124503. * @return true if ready otherwise, false
  124504. */
  124505. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  124506. /**
  124507. * Implementation specific of rendering the generating effect on the main canvas.
  124508. * @param effect The effect used to render through
  124509. */
  124510. protected _internalRender(effect: Effect): void;
  124511. /**
  124512. * Returns true if the layer contains information to display, otherwise false.
  124513. */
  124514. shouldRender(): boolean;
  124515. /**
  124516. * Returns true if the mesh should render, otherwise false.
  124517. * @param mesh The mesh to render
  124518. * @returns true if it should render otherwise false
  124519. */
  124520. protected _shouldRenderMesh(mesh: Mesh): boolean;
  124521. /**
  124522. * Sets the required values for both the emissive texture and and the main color.
  124523. */
  124524. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  124525. /**
  124526. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  124527. * @param mesh The mesh to exclude from the highlight layer
  124528. */
  124529. addExcludedMesh(mesh: Mesh): void;
  124530. /**
  124531. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  124532. * @param mesh The mesh to highlight
  124533. */
  124534. removeExcludedMesh(mesh: Mesh): void;
  124535. /**
  124536. * Determine if a given mesh will be highlighted by the current HighlightLayer
  124537. * @param mesh mesh to test
  124538. * @returns true if the mesh will be highlighted by the current HighlightLayer
  124539. */
  124540. hasMesh(mesh: AbstractMesh): boolean;
  124541. /**
  124542. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  124543. * @param mesh The mesh to highlight
  124544. * @param color The color of the highlight
  124545. * @param glowEmissiveOnly Extract the glow from the emissive texture
  124546. */
  124547. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  124548. /**
  124549. * Remove a mesh from the highlight layer in order to make it stop glowing.
  124550. * @param mesh The mesh to highlight
  124551. */
  124552. removeMesh(mesh: Mesh): void;
  124553. /**
  124554. * Force the stencil to the normal expected value for none glowing parts
  124555. */
  124556. private _defaultStencilReference;
  124557. /**
  124558. * Free any resources and references associated to a mesh.
  124559. * Internal use
  124560. * @param mesh The mesh to free.
  124561. * @hidden
  124562. */
  124563. _disposeMesh(mesh: Mesh): void;
  124564. /**
  124565. * Dispose the highlight layer and free resources.
  124566. */
  124567. dispose(): void;
  124568. /**
  124569. * Gets the class name of the effect layer
  124570. * @returns the string with the class name of the effect layer
  124571. */
  124572. getClassName(): string;
  124573. /**
  124574. * Serializes this Highlight layer
  124575. * @returns a serialized Highlight layer object
  124576. */
  124577. serialize(): any;
  124578. /**
  124579. * Creates a Highlight layer from parsed Highlight layer data
  124580. * @param parsedHightlightLayer defines the Highlight layer data
  124581. * @param scene defines the current scene
  124582. * @param rootUrl defines the root URL containing the Highlight layer information
  124583. * @returns a parsed Highlight layer
  124584. */
  124585. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  124586. }
  124587. }
  124588. declare module BABYLON {
  124589. interface AbstractScene {
  124590. /**
  124591. * The list of layers (background and foreground) of the scene
  124592. */
  124593. layers: Array<Layer>;
  124594. }
  124595. /**
  124596. * Defines the layer scene component responsible to manage any layers
  124597. * in a given scene.
  124598. */
  124599. export class LayerSceneComponent implements ISceneComponent {
  124600. /**
  124601. * The component name helpfull to identify the component in the list of scene components.
  124602. */
  124603. readonly name: string;
  124604. /**
  124605. * The scene the component belongs to.
  124606. */
  124607. scene: Scene;
  124608. private _engine;
  124609. /**
  124610. * Creates a new instance of the component for the given scene
  124611. * @param scene Defines the scene to register the component in
  124612. */
  124613. constructor(scene: Scene);
  124614. /**
  124615. * Registers the component in a given scene
  124616. */
  124617. register(): void;
  124618. /**
  124619. * Rebuilds the elements related to this component in case of
  124620. * context lost for instance.
  124621. */
  124622. rebuild(): void;
  124623. /**
  124624. * Disposes the component and the associated ressources.
  124625. */
  124626. dispose(): void;
  124627. private _draw;
  124628. private _drawCameraPredicate;
  124629. private _drawCameraBackground;
  124630. private _drawCameraForeground;
  124631. private _drawRenderTargetPredicate;
  124632. private _drawRenderTargetBackground;
  124633. private _drawRenderTargetForeground;
  124634. /**
  124635. * Adds all the elements from the container to the scene
  124636. * @param container the container holding the elements
  124637. */
  124638. addFromContainer(container: AbstractScene): void;
  124639. /**
  124640. * Removes all the elements in the container from the scene
  124641. * @param container contains the elements to remove
  124642. * @param dispose if the removed element should be disposed (default: false)
  124643. */
  124644. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  124645. }
  124646. }
  124647. declare module BABYLON {
  124648. /** @hidden */
  124649. export var layerPixelShader: {
  124650. name: string;
  124651. shader: string;
  124652. };
  124653. }
  124654. declare module BABYLON {
  124655. /** @hidden */
  124656. export var layerVertexShader: {
  124657. name: string;
  124658. shader: string;
  124659. };
  124660. }
  124661. declare module BABYLON {
  124662. /**
  124663. * This represents a full screen 2d layer.
  124664. * This can be useful to display a picture in the background of your scene for instance.
  124665. * @see https://www.babylonjs-playground.com/#08A2BS#1
  124666. */
  124667. export class Layer {
  124668. /**
  124669. * Define the name of the layer.
  124670. */
  124671. name: string;
  124672. /**
  124673. * Define the texture the layer should display.
  124674. */
  124675. texture: Nullable<Texture>;
  124676. /**
  124677. * Is the layer in background or foreground.
  124678. */
  124679. isBackground: boolean;
  124680. /**
  124681. * Define the color of the layer (instead of texture).
  124682. */
  124683. color: Color4;
  124684. /**
  124685. * Define the scale of the layer in order to zoom in out of the texture.
  124686. */
  124687. scale: Vector2;
  124688. /**
  124689. * Define an offset for the layer in order to shift the texture.
  124690. */
  124691. offset: Vector2;
  124692. /**
  124693. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  124694. */
  124695. alphaBlendingMode: number;
  124696. /**
  124697. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  124698. * Alpha test will not mix with the background color in case of transparency.
  124699. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  124700. */
  124701. alphaTest: boolean;
  124702. /**
  124703. * Define a mask to restrict the layer to only some of the scene cameras.
  124704. */
  124705. layerMask: number;
  124706. /**
  124707. * Define the list of render target the layer is visible into.
  124708. */
  124709. renderTargetTextures: RenderTargetTexture[];
  124710. /**
  124711. * Define if the layer is only used in renderTarget or if it also
  124712. * renders in the main frame buffer of the canvas.
  124713. */
  124714. renderOnlyInRenderTargetTextures: boolean;
  124715. private _scene;
  124716. private _vertexBuffers;
  124717. private _indexBuffer;
  124718. private _effect;
  124719. private _previousDefines;
  124720. /**
  124721. * An event triggered when the layer is disposed.
  124722. */
  124723. onDisposeObservable: Observable<Layer>;
  124724. private _onDisposeObserver;
  124725. /**
  124726. * Back compatibility with callback before the onDisposeObservable existed.
  124727. * The set callback will be triggered when the layer has been disposed.
  124728. */
  124729. set onDispose(callback: () => void);
  124730. /**
  124731. * An event triggered before rendering the scene
  124732. */
  124733. onBeforeRenderObservable: Observable<Layer>;
  124734. private _onBeforeRenderObserver;
  124735. /**
  124736. * Back compatibility with callback before the onBeforeRenderObservable existed.
  124737. * The set callback will be triggered just before rendering the layer.
  124738. */
  124739. set onBeforeRender(callback: () => void);
  124740. /**
  124741. * An event triggered after rendering the scene
  124742. */
  124743. onAfterRenderObservable: Observable<Layer>;
  124744. private _onAfterRenderObserver;
  124745. /**
  124746. * Back compatibility with callback before the onAfterRenderObservable existed.
  124747. * The set callback will be triggered just after rendering the layer.
  124748. */
  124749. set onAfterRender(callback: () => void);
  124750. /**
  124751. * Instantiates a new layer.
  124752. * This represents a full screen 2d layer.
  124753. * This can be useful to display a picture in the background of your scene for instance.
  124754. * @see https://www.babylonjs-playground.com/#08A2BS#1
  124755. * @param name Define the name of the layer in the scene
  124756. * @param imgUrl Define the url of the texture to display in the layer
  124757. * @param scene Define the scene the layer belongs to
  124758. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  124759. * @param color Defines a color for the layer
  124760. */
  124761. constructor(
  124762. /**
  124763. * Define the name of the layer.
  124764. */
  124765. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  124766. private _createIndexBuffer;
  124767. /** @hidden */
  124768. _rebuild(): void;
  124769. /**
  124770. * Renders the layer in the scene.
  124771. */
  124772. render(): void;
  124773. /**
  124774. * Disposes and releases the associated ressources.
  124775. */
  124776. dispose(): void;
  124777. }
  124778. }
  124779. declare module BABYLON {
  124780. /** @hidden */
  124781. export var lensFlarePixelShader: {
  124782. name: string;
  124783. shader: string;
  124784. };
  124785. }
  124786. declare module BABYLON {
  124787. /** @hidden */
  124788. export var lensFlareVertexShader: {
  124789. name: string;
  124790. shader: string;
  124791. };
  124792. }
  124793. declare module BABYLON {
  124794. /**
  124795. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  124796. * It is usually composed of several `lensFlare`.
  124797. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124798. */
  124799. export class LensFlareSystem {
  124800. /**
  124801. * Define the name of the lens flare system
  124802. */
  124803. name: string;
  124804. /**
  124805. * List of lens flares used in this system.
  124806. */
  124807. lensFlares: LensFlare[];
  124808. /**
  124809. * Define a limit from the border the lens flare can be visible.
  124810. */
  124811. borderLimit: number;
  124812. /**
  124813. * Define a viewport border we do not want to see the lens flare in.
  124814. */
  124815. viewportBorder: number;
  124816. /**
  124817. * Define a predicate which could limit the list of meshes able to occlude the effect.
  124818. */
  124819. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  124820. /**
  124821. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  124822. */
  124823. layerMask: number;
  124824. /**
  124825. * Define the id of the lens flare system in the scene.
  124826. * (equal to name by default)
  124827. */
  124828. id: string;
  124829. private _scene;
  124830. private _emitter;
  124831. private _vertexBuffers;
  124832. private _indexBuffer;
  124833. private _effect;
  124834. private _positionX;
  124835. private _positionY;
  124836. private _isEnabled;
  124837. /** @hidden */
  124838. static _SceneComponentInitialization: (scene: Scene) => void;
  124839. /**
  124840. * Instantiates a lens flare system.
  124841. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  124842. * It is usually composed of several `lensFlare`.
  124843. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124844. * @param name Define the name of the lens flare system in the scene
  124845. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  124846. * @param scene Define the scene the lens flare system belongs to
  124847. */
  124848. constructor(
  124849. /**
  124850. * Define the name of the lens flare system
  124851. */
  124852. name: string, emitter: any, scene: Scene);
  124853. /**
  124854. * Define if the lens flare system is enabled.
  124855. */
  124856. get isEnabled(): boolean;
  124857. set isEnabled(value: boolean);
  124858. /**
  124859. * Get the scene the effects belongs to.
  124860. * @returns the scene holding the lens flare system
  124861. */
  124862. getScene(): Scene;
  124863. /**
  124864. * Get the emitter of the lens flare system.
  124865. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  124866. * @returns the emitter of the lens flare system
  124867. */
  124868. getEmitter(): any;
  124869. /**
  124870. * Set the emitter of the lens flare system.
  124871. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  124872. * @param newEmitter Define the new emitter of the system
  124873. */
  124874. setEmitter(newEmitter: any): void;
  124875. /**
  124876. * Get the lens flare system emitter position.
  124877. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  124878. * @returns the position
  124879. */
  124880. getEmitterPosition(): Vector3;
  124881. /**
  124882. * @hidden
  124883. */
  124884. computeEffectivePosition(globalViewport: Viewport): boolean;
  124885. /** @hidden */
  124886. _isVisible(): boolean;
  124887. /**
  124888. * @hidden
  124889. */
  124890. render(): boolean;
  124891. /**
  124892. * Dispose and release the lens flare with its associated resources.
  124893. */
  124894. dispose(): void;
  124895. /**
  124896. * Parse a lens flare system from a JSON repressentation
  124897. * @param parsedLensFlareSystem Define the JSON to parse
  124898. * @param scene Define the scene the parsed system should be instantiated in
  124899. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  124900. * @returns the parsed system
  124901. */
  124902. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  124903. /**
  124904. * Serialize the current Lens Flare System into a JSON representation.
  124905. * @returns the serialized JSON
  124906. */
  124907. serialize(): any;
  124908. }
  124909. }
  124910. declare module BABYLON {
  124911. /**
  124912. * This represents one of the lens effect in a `lensFlareSystem`.
  124913. * It controls one of the indiviual texture used in the effect.
  124914. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124915. */
  124916. export class LensFlare {
  124917. /**
  124918. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  124919. */
  124920. size: number;
  124921. /**
  124922. * 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.
  124923. */
  124924. position: number;
  124925. /**
  124926. * Define the lens color.
  124927. */
  124928. color: Color3;
  124929. /**
  124930. * Define the lens texture.
  124931. */
  124932. texture: Nullable<Texture>;
  124933. /**
  124934. * Define the alpha mode to render this particular lens.
  124935. */
  124936. alphaMode: number;
  124937. private _system;
  124938. /**
  124939. * Creates a new Lens Flare.
  124940. * This represents one of the lens effect in a `lensFlareSystem`.
  124941. * It controls one of the indiviual texture used in the effect.
  124942. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124943. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  124944. * @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.
  124945. * @param color Define the lens color
  124946. * @param imgUrl Define the lens texture url
  124947. * @param system Define the `lensFlareSystem` this flare is part of
  124948. * @returns The newly created Lens Flare
  124949. */
  124950. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  124951. /**
  124952. * Instantiates a new Lens Flare.
  124953. * This represents one of the lens effect in a `lensFlareSystem`.
  124954. * It controls one of the indiviual texture used in the effect.
  124955. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124956. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  124957. * @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.
  124958. * @param color Define the lens color
  124959. * @param imgUrl Define the lens texture url
  124960. * @param system Define the `lensFlareSystem` this flare is part of
  124961. */
  124962. constructor(
  124963. /**
  124964. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  124965. */
  124966. size: number,
  124967. /**
  124968. * 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.
  124969. */
  124970. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  124971. /**
  124972. * Dispose and release the lens flare with its associated resources.
  124973. */
  124974. dispose(): void;
  124975. }
  124976. }
  124977. declare module BABYLON {
  124978. interface AbstractScene {
  124979. /**
  124980. * The list of lens flare system added to the scene
  124981. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  124982. */
  124983. lensFlareSystems: Array<LensFlareSystem>;
  124984. /**
  124985. * Removes the given lens flare system from this scene.
  124986. * @param toRemove The lens flare system to remove
  124987. * @returns The index of the removed lens flare system
  124988. */
  124989. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  124990. /**
  124991. * Adds the given lens flare system to this scene
  124992. * @param newLensFlareSystem The lens flare system to add
  124993. */
  124994. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  124995. /**
  124996. * Gets a lens flare system using its name
  124997. * @param name defines the name to look for
  124998. * @returns the lens flare system or null if not found
  124999. */
  125000. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  125001. /**
  125002. * Gets a lens flare system using its id
  125003. * @param id defines the id to look for
  125004. * @returns the lens flare system or null if not found
  125005. */
  125006. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  125007. }
  125008. /**
  125009. * Defines the lens flare scene component responsible to manage any lens flares
  125010. * in a given scene.
  125011. */
  125012. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  125013. /**
  125014. * The component name helpfull to identify the component in the list of scene components.
  125015. */
  125016. readonly name: string;
  125017. /**
  125018. * The scene the component belongs to.
  125019. */
  125020. scene: Scene;
  125021. /**
  125022. * Creates a new instance of the component for the given scene
  125023. * @param scene Defines the scene to register the component in
  125024. */
  125025. constructor(scene: Scene);
  125026. /**
  125027. * Registers the component in a given scene
  125028. */
  125029. register(): void;
  125030. /**
  125031. * Rebuilds the elements related to this component in case of
  125032. * context lost for instance.
  125033. */
  125034. rebuild(): void;
  125035. /**
  125036. * Adds all the elements from the container to the scene
  125037. * @param container the container holding the elements
  125038. */
  125039. addFromContainer(container: AbstractScene): void;
  125040. /**
  125041. * Removes all the elements in the container from the scene
  125042. * @param container contains the elements to remove
  125043. * @param dispose if the removed element should be disposed (default: false)
  125044. */
  125045. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125046. /**
  125047. * Serializes the component data to the specified json object
  125048. * @param serializationObject The object to serialize to
  125049. */
  125050. serialize(serializationObject: any): void;
  125051. /**
  125052. * Disposes the component and the associated ressources.
  125053. */
  125054. dispose(): void;
  125055. private _draw;
  125056. }
  125057. }
  125058. declare module BABYLON {
  125059. /**
  125060. * Defines the shadow generator component responsible to manage any shadow generators
  125061. * in a given scene.
  125062. */
  125063. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  125064. /**
  125065. * The component name helpfull to identify the component in the list of scene components.
  125066. */
  125067. readonly name: string;
  125068. /**
  125069. * The scene the component belongs to.
  125070. */
  125071. scene: Scene;
  125072. /**
  125073. * Creates a new instance of the component for the given scene
  125074. * @param scene Defines the scene to register the component in
  125075. */
  125076. constructor(scene: Scene);
  125077. /**
  125078. * Registers the component in a given scene
  125079. */
  125080. register(): void;
  125081. /**
  125082. * Rebuilds the elements related to this component in case of
  125083. * context lost for instance.
  125084. */
  125085. rebuild(): void;
  125086. /**
  125087. * Serializes the component data to the specified json object
  125088. * @param serializationObject The object to serialize to
  125089. */
  125090. serialize(serializationObject: any): void;
  125091. /**
  125092. * Adds all the elements from the container to the scene
  125093. * @param container the container holding the elements
  125094. */
  125095. addFromContainer(container: AbstractScene): void;
  125096. /**
  125097. * Removes all the elements in the container from the scene
  125098. * @param container contains the elements to remove
  125099. * @param dispose if the removed element should be disposed (default: false)
  125100. */
  125101. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  125102. /**
  125103. * Rebuilds the elements related to this component in case of
  125104. * context lost for instance.
  125105. */
  125106. dispose(): void;
  125107. private _gatherRenderTargets;
  125108. }
  125109. }
  125110. declare module BABYLON {
  125111. /**
  125112. * A point light is a light defined by an unique point in world space.
  125113. * The light is emitted in every direction from this point.
  125114. * A good example of a point light is a standard light bulb.
  125115. * Documentation: https://doc.babylonjs.com/babylon101/lights
  125116. */
  125117. export class PointLight extends ShadowLight {
  125118. private _shadowAngle;
  125119. /**
  125120. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  125121. * This specifies what angle the shadow will use to be created.
  125122. *
  125123. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  125124. */
  125125. get shadowAngle(): number;
  125126. /**
  125127. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  125128. * This specifies what angle the shadow will use to be created.
  125129. *
  125130. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  125131. */
  125132. set shadowAngle(value: number);
  125133. /**
  125134. * Gets the direction if it has been set.
  125135. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  125136. */
  125137. get direction(): Vector3;
  125138. /**
  125139. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  125140. */
  125141. set direction(value: Vector3);
  125142. /**
  125143. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  125144. * A PointLight emits the light in every direction.
  125145. * It can cast shadows.
  125146. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  125147. * ```javascript
  125148. * var pointLight = new PointLight("pl", camera.position, scene);
  125149. * ```
  125150. * Documentation : https://doc.babylonjs.com/babylon101/lights
  125151. * @param name The light friendly name
  125152. * @param position The position of the point light in the scene
  125153. * @param scene The scene the lights belongs to
  125154. */
  125155. constructor(name: string, position: Vector3, scene: Scene);
  125156. /**
  125157. * Returns the string "PointLight"
  125158. * @returns the class name
  125159. */
  125160. getClassName(): string;
  125161. /**
  125162. * Returns the integer 0.
  125163. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  125164. */
  125165. getTypeID(): number;
  125166. /**
  125167. * Specifies wether or not the shadowmap should be a cube texture.
  125168. * @returns true if the shadowmap needs to be a cube texture.
  125169. */
  125170. needCube(): boolean;
  125171. /**
  125172. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  125173. * @param faceIndex The index of the face we are computed the direction to generate shadow
  125174. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  125175. */
  125176. getShadowDirection(faceIndex?: number): Vector3;
  125177. /**
  125178. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  125179. * - fov = PI / 2
  125180. * - aspect ratio : 1.0
  125181. * - z-near and far equal to the active camera minZ and maxZ.
  125182. * Returns the PointLight.
  125183. */
  125184. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  125185. protected _buildUniformLayout(): void;
  125186. /**
  125187. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  125188. * @param effect The effect to update
  125189. * @param lightIndex The index of the light in the effect to update
  125190. * @returns The point light
  125191. */
  125192. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  125193. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  125194. /**
  125195. * Prepares the list of defines specific to the light type.
  125196. * @param defines the list of defines
  125197. * @param lightIndex defines the index of the light for the effect
  125198. */
  125199. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  125200. }
  125201. }
  125202. declare module BABYLON {
  125203. /**
  125204. * Header information of HDR texture files.
  125205. */
  125206. export interface HDRInfo {
  125207. /**
  125208. * The height of the texture in pixels.
  125209. */
  125210. height: number;
  125211. /**
  125212. * The width of the texture in pixels.
  125213. */
  125214. width: number;
  125215. /**
  125216. * The index of the beginning of the data in the binary file.
  125217. */
  125218. dataPosition: number;
  125219. }
  125220. /**
  125221. * This groups tools to convert HDR texture to native colors array.
  125222. */
  125223. export class HDRTools {
  125224. private static Ldexp;
  125225. private static Rgbe2float;
  125226. private static readStringLine;
  125227. /**
  125228. * Reads header information from an RGBE texture stored in a native array.
  125229. * More information on this format are available here:
  125230. * https://en.wikipedia.org/wiki/RGBE_image_format
  125231. *
  125232. * @param uint8array The binary file stored in native array.
  125233. * @return The header information.
  125234. */
  125235. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  125236. /**
  125237. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  125238. * This RGBE texture needs to store the information as a panorama.
  125239. *
  125240. * More information on this format are available here:
  125241. * https://en.wikipedia.org/wiki/RGBE_image_format
  125242. *
  125243. * @param buffer The binary file stored in an array buffer.
  125244. * @param size The expected size of the extracted cubemap.
  125245. * @return The Cube Map information.
  125246. */
  125247. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  125248. /**
  125249. * Returns the pixels data extracted from an RGBE texture.
  125250. * This pixels will be stored left to right up to down in the R G B order in one array.
  125251. *
  125252. * More information on this format are available here:
  125253. * https://en.wikipedia.org/wiki/RGBE_image_format
  125254. *
  125255. * @param uint8array The binary file stored in an array buffer.
  125256. * @param hdrInfo The header information of the file.
  125257. * @return The pixels data in RGB right to left up to down order.
  125258. */
  125259. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  125260. private static RGBE_ReadPixels_RLE;
  125261. }
  125262. }
  125263. declare module BABYLON {
  125264. /**
  125265. * This represents a texture coming from an HDR input.
  125266. *
  125267. * The only supported format is currently panorama picture stored in RGBE format.
  125268. * Example of such files can be found on HDRLib: http://hdrlib.com/
  125269. */
  125270. export class HDRCubeTexture extends BaseTexture {
  125271. private static _facesMapping;
  125272. private _generateHarmonics;
  125273. private _noMipmap;
  125274. private _textureMatrix;
  125275. private _size;
  125276. private _onLoad;
  125277. private _onError;
  125278. /**
  125279. * The texture URL.
  125280. */
  125281. url: string;
  125282. /**
  125283. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  125284. */
  125285. coordinatesMode: number;
  125286. protected _isBlocking: boolean;
  125287. /**
  125288. * Sets wether or not the texture is blocking during loading.
  125289. */
  125290. set isBlocking(value: boolean);
  125291. /**
  125292. * Gets wether or not the texture is blocking during loading.
  125293. */
  125294. get isBlocking(): boolean;
  125295. protected _rotationY: number;
  125296. /**
  125297. * Sets texture matrix rotation angle around Y axis in radians.
  125298. */
  125299. set rotationY(value: number);
  125300. /**
  125301. * Gets texture matrix rotation angle around Y axis radians.
  125302. */
  125303. get rotationY(): number;
  125304. /**
  125305. * Gets or sets the center of the bounding box associated with the cube texture
  125306. * It must define where the camera used to render the texture was set
  125307. */
  125308. boundingBoxPosition: Vector3;
  125309. private _boundingBoxSize;
  125310. /**
  125311. * Gets or sets the size of the bounding box associated with the cube texture
  125312. * When defined, the cubemap will switch to local mode
  125313. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  125314. * @example https://www.babylonjs-playground.com/#RNASML
  125315. */
  125316. set boundingBoxSize(value: Vector3);
  125317. get boundingBoxSize(): Vector3;
  125318. /**
  125319. * Instantiates an HDRTexture from the following parameters.
  125320. *
  125321. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  125322. * @param scene The scene the texture will be used in
  125323. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  125324. * @param noMipmap Forces to not generate the mipmap if true
  125325. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  125326. * @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)
  125327. * @param reserved Reserved flag for internal use.
  125328. */
  125329. 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>);
  125330. /**
  125331. * Get the current class name of the texture useful for serialization or dynamic coding.
  125332. * @returns "HDRCubeTexture"
  125333. */
  125334. getClassName(): string;
  125335. /**
  125336. * Occurs when the file is raw .hdr file.
  125337. */
  125338. private loadTexture;
  125339. clone(): HDRCubeTexture;
  125340. delayLoad(): void;
  125341. /**
  125342. * Get the texture reflection matrix used to rotate/transform the reflection.
  125343. * @returns the reflection matrix
  125344. */
  125345. getReflectionTextureMatrix(): Matrix;
  125346. /**
  125347. * Set the texture reflection matrix used to rotate/transform the reflection.
  125348. * @param value Define the reflection matrix to set
  125349. */
  125350. setReflectionTextureMatrix(value: Matrix): void;
  125351. /**
  125352. * Parses a JSON representation of an HDR Texture in order to create the texture
  125353. * @param parsedTexture Define the JSON representation
  125354. * @param scene Define the scene the texture should be created in
  125355. * @param rootUrl Define the root url in case we need to load relative dependencies
  125356. * @returns the newly created texture after parsing
  125357. */
  125358. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  125359. serialize(): any;
  125360. }
  125361. }
  125362. declare module BABYLON {
  125363. /**
  125364. * Class used to control physics engine
  125365. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  125366. */
  125367. export class PhysicsEngine implements IPhysicsEngine {
  125368. private _physicsPlugin;
  125369. /**
  125370. * Global value used to control the smallest number supported by the simulation
  125371. */
  125372. static Epsilon: number;
  125373. private _impostors;
  125374. private _joints;
  125375. private _subTimeStep;
  125376. /**
  125377. * Gets the gravity vector used by the simulation
  125378. */
  125379. gravity: Vector3;
  125380. /**
  125381. * Factory used to create the default physics plugin.
  125382. * @returns The default physics plugin
  125383. */
  125384. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  125385. /**
  125386. * Creates a new Physics Engine
  125387. * @param gravity defines the gravity vector used by the simulation
  125388. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  125389. */
  125390. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  125391. /**
  125392. * Sets the gravity vector used by the simulation
  125393. * @param gravity defines the gravity vector to use
  125394. */
  125395. setGravity(gravity: Vector3): void;
  125396. /**
  125397. * Set the time step of the physics engine.
  125398. * Default is 1/60.
  125399. * To slow it down, enter 1/600 for example.
  125400. * To speed it up, 1/30
  125401. * @param newTimeStep defines the new timestep to apply to this world.
  125402. */
  125403. setTimeStep(newTimeStep?: number): void;
  125404. /**
  125405. * Get the time step of the physics engine.
  125406. * @returns the current time step
  125407. */
  125408. getTimeStep(): number;
  125409. /**
  125410. * Set the sub time step of the physics engine.
  125411. * Default is 0 meaning there is no sub steps
  125412. * To increase physics resolution precision, set a small value (like 1 ms)
  125413. * @param subTimeStep defines the new sub timestep used for physics resolution.
  125414. */
  125415. setSubTimeStep(subTimeStep?: number): void;
  125416. /**
  125417. * Get the sub time step of the physics engine.
  125418. * @returns the current sub time step
  125419. */
  125420. getSubTimeStep(): number;
  125421. /**
  125422. * Release all resources
  125423. */
  125424. dispose(): void;
  125425. /**
  125426. * Gets the name of the current physics plugin
  125427. * @returns the name of the plugin
  125428. */
  125429. getPhysicsPluginName(): string;
  125430. /**
  125431. * Adding a new impostor for the impostor tracking.
  125432. * This will be done by the impostor itself.
  125433. * @param impostor the impostor to add
  125434. */
  125435. addImpostor(impostor: PhysicsImpostor): void;
  125436. /**
  125437. * Remove an impostor from the engine.
  125438. * This impostor and its mesh will not longer be updated by the physics engine.
  125439. * @param impostor the impostor to remove
  125440. */
  125441. removeImpostor(impostor: PhysicsImpostor): void;
  125442. /**
  125443. * Add a joint to the physics engine
  125444. * @param mainImpostor defines the main impostor to which the joint is added.
  125445. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  125446. * @param joint defines the joint that will connect both impostors.
  125447. */
  125448. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  125449. /**
  125450. * Removes a joint from the simulation
  125451. * @param mainImpostor defines the impostor used with the joint
  125452. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  125453. * @param joint defines the joint to remove
  125454. */
  125455. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  125456. /**
  125457. * Called by the scene. No need to call it.
  125458. * @param delta defines the timespam between frames
  125459. */
  125460. _step(delta: number): void;
  125461. /**
  125462. * Gets the current plugin used to run the simulation
  125463. * @returns current plugin
  125464. */
  125465. getPhysicsPlugin(): IPhysicsEnginePlugin;
  125466. /**
  125467. * Gets the list of physic impostors
  125468. * @returns an array of PhysicsImpostor
  125469. */
  125470. getImpostors(): Array<PhysicsImpostor>;
  125471. /**
  125472. * Gets the impostor for a physics enabled object
  125473. * @param object defines the object impersonated by the impostor
  125474. * @returns the PhysicsImpostor or null if not found
  125475. */
  125476. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  125477. /**
  125478. * Gets the impostor for a physics body object
  125479. * @param body defines physics body used by the impostor
  125480. * @returns the PhysicsImpostor or null if not found
  125481. */
  125482. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  125483. /**
  125484. * Does a raycast in the physics world
  125485. * @param from when should the ray start?
  125486. * @param to when should the ray end?
  125487. * @returns PhysicsRaycastResult
  125488. */
  125489. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  125490. }
  125491. }
  125492. declare module BABYLON {
  125493. /** @hidden */
  125494. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  125495. private _useDeltaForWorldStep;
  125496. world: any;
  125497. name: string;
  125498. private _physicsMaterials;
  125499. private _fixedTimeStep;
  125500. private _cannonRaycastResult;
  125501. private _raycastResult;
  125502. private _physicsBodysToRemoveAfterStep;
  125503. BJSCANNON: any;
  125504. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  125505. setGravity(gravity: Vector3): void;
  125506. setTimeStep(timeStep: number): void;
  125507. getTimeStep(): number;
  125508. executeStep(delta: number): void;
  125509. private _removeMarkedPhysicsBodiesFromWorld;
  125510. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125511. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125512. generatePhysicsBody(impostor: PhysicsImpostor): void;
  125513. private _processChildMeshes;
  125514. removePhysicsBody(impostor: PhysicsImpostor): void;
  125515. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  125516. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  125517. private _addMaterial;
  125518. private _checkWithEpsilon;
  125519. private _createShape;
  125520. private _createHeightmap;
  125521. private _minus90X;
  125522. private _plus90X;
  125523. private _tmpPosition;
  125524. private _tmpDeltaPosition;
  125525. private _tmpUnityRotation;
  125526. private _updatePhysicsBodyTransformation;
  125527. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  125528. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  125529. isSupported(): boolean;
  125530. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125531. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125532. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125533. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125534. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  125535. getBodyMass(impostor: PhysicsImpostor): number;
  125536. getBodyFriction(impostor: PhysicsImpostor): number;
  125537. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  125538. getBodyRestitution(impostor: PhysicsImpostor): number;
  125539. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  125540. sleepBody(impostor: PhysicsImpostor): void;
  125541. wakeUpBody(impostor: PhysicsImpostor): void;
  125542. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  125543. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  125544. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  125545. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  125546. getRadius(impostor: PhysicsImpostor): number;
  125547. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  125548. dispose(): void;
  125549. private _extendNamespace;
  125550. /**
  125551. * Does a raycast in the physics world
  125552. * @param from when should the ray start?
  125553. * @param to when should the ray end?
  125554. * @returns PhysicsRaycastResult
  125555. */
  125556. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  125557. }
  125558. }
  125559. declare module BABYLON {
  125560. /** @hidden */
  125561. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  125562. world: any;
  125563. name: string;
  125564. BJSOIMO: any;
  125565. private _raycastResult;
  125566. constructor(iterations?: number, oimoInjection?: any);
  125567. setGravity(gravity: Vector3): void;
  125568. setTimeStep(timeStep: number): void;
  125569. getTimeStep(): number;
  125570. private _tmpImpostorsArray;
  125571. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  125572. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125573. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125574. generatePhysicsBody(impostor: PhysicsImpostor): void;
  125575. private _tmpPositionVector;
  125576. removePhysicsBody(impostor: PhysicsImpostor): void;
  125577. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  125578. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  125579. isSupported(): boolean;
  125580. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  125581. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  125582. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125583. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125584. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125585. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125586. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  125587. getBodyMass(impostor: PhysicsImpostor): number;
  125588. getBodyFriction(impostor: PhysicsImpostor): number;
  125589. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  125590. getBodyRestitution(impostor: PhysicsImpostor): number;
  125591. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  125592. sleepBody(impostor: PhysicsImpostor): void;
  125593. wakeUpBody(impostor: PhysicsImpostor): void;
  125594. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  125595. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  125596. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  125597. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  125598. getRadius(impostor: PhysicsImpostor): number;
  125599. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  125600. dispose(): void;
  125601. /**
  125602. * Does a raycast in the physics world
  125603. * @param from when should the ray start?
  125604. * @param to when should the ray end?
  125605. * @returns PhysicsRaycastResult
  125606. */
  125607. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  125608. }
  125609. }
  125610. declare module BABYLON {
  125611. /**
  125612. * Class containing static functions to help procedurally build meshes
  125613. */
  125614. export class RibbonBuilder {
  125615. /**
  125616. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  125617. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  125618. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  125619. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  125620. * * 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
  125621. * * 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
  125622. * * 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
  125623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125625. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125626. * * 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
  125627. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  125628. * * 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
  125629. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  125630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125631. * @param name defines the name of the mesh
  125632. * @param options defines the options used to create the mesh
  125633. * @param scene defines the hosting scene
  125634. * @returns the ribbon mesh
  125635. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  125636. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125637. */
  125638. static CreateRibbon(name: string, options: {
  125639. pathArray: Vector3[][];
  125640. closeArray?: boolean;
  125641. closePath?: boolean;
  125642. offset?: number;
  125643. updatable?: boolean;
  125644. sideOrientation?: number;
  125645. frontUVs?: Vector4;
  125646. backUVs?: Vector4;
  125647. instance?: Mesh;
  125648. invertUV?: boolean;
  125649. uvs?: Vector2[];
  125650. colors?: Color4[];
  125651. }, scene?: Nullable<Scene>): Mesh;
  125652. }
  125653. }
  125654. declare module BABYLON {
  125655. /**
  125656. * Class containing static functions to help procedurally build meshes
  125657. */
  125658. export class ShapeBuilder {
  125659. /**
  125660. * 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.
  125661. * * 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.
  125662. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125663. * * 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.
  125664. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  125665. * * 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
  125666. * * 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
  125667. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  125668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125670. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  125671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  125672. * @param name defines the name of the mesh
  125673. * @param options defines the options used to create the mesh
  125674. * @param scene defines the hosting scene
  125675. * @returns the extruded shape mesh
  125676. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125678. */
  125679. static ExtrudeShape(name: string, options: {
  125680. shape: Vector3[];
  125681. path: Vector3[];
  125682. scale?: number;
  125683. rotation?: number;
  125684. cap?: number;
  125685. updatable?: boolean;
  125686. sideOrientation?: number;
  125687. frontUVs?: Vector4;
  125688. backUVs?: Vector4;
  125689. instance?: Mesh;
  125690. invertUV?: boolean;
  125691. }, scene?: Nullable<Scene>): Mesh;
  125692. /**
  125693. * Creates an custom extruded shape mesh.
  125694. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  125695. * * 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.
  125696. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  125697. * * 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
  125698. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  125699. * * 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
  125700. * * It must returns a float value that will be the scale value applied to the shape on each path point
  125701. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  125702. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  125703. * * 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
  125704. * * 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
  125705. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  125706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125708. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  125709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125710. * @param name defines the name of the mesh
  125711. * @param options defines the options used to create the mesh
  125712. * @param scene defines the hosting scene
  125713. * @returns the custom extruded shape mesh
  125714. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  125715. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  125716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  125717. */
  125718. static ExtrudeShapeCustom(name: string, options: {
  125719. shape: Vector3[];
  125720. path: Vector3[];
  125721. scaleFunction?: any;
  125722. rotationFunction?: any;
  125723. ribbonCloseArray?: boolean;
  125724. ribbonClosePath?: boolean;
  125725. cap?: number;
  125726. updatable?: boolean;
  125727. sideOrientation?: number;
  125728. frontUVs?: Vector4;
  125729. backUVs?: Vector4;
  125730. instance?: Mesh;
  125731. invertUV?: boolean;
  125732. }, scene?: Nullable<Scene>): Mesh;
  125733. private static _ExtrudeShapeGeneric;
  125734. }
  125735. }
  125736. declare module BABYLON {
  125737. /**
  125738. * AmmoJS Physics plugin
  125739. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  125740. * @see https://github.com/kripken/ammo.js/
  125741. */
  125742. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  125743. private _useDeltaForWorldStep;
  125744. /**
  125745. * Reference to the Ammo library
  125746. */
  125747. bjsAMMO: any;
  125748. /**
  125749. * Created ammoJS world which physics bodies are added to
  125750. */
  125751. world: any;
  125752. /**
  125753. * Name of the plugin
  125754. */
  125755. name: string;
  125756. private _timeStep;
  125757. private _fixedTimeStep;
  125758. private _maxSteps;
  125759. private _tmpQuaternion;
  125760. private _tmpAmmoTransform;
  125761. private _tmpAmmoQuaternion;
  125762. private _tmpAmmoConcreteContactResultCallback;
  125763. private _collisionConfiguration;
  125764. private _dispatcher;
  125765. private _overlappingPairCache;
  125766. private _solver;
  125767. private _softBodySolver;
  125768. private _tmpAmmoVectorA;
  125769. private _tmpAmmoVectorB;
  125770. private _tmpAmmoVectorC;
  125771. private _tmpAmmoVectorD;
  125772. private _tmpContactCallbackResult;
  125773. private _tmpAmmoVectorRCA;
  125774. private _tmpAmmoVectorRCB;
  125775. private _raycastResult;
  125776. private static readonly DISABLE_COLLISION_FLAG;
  125777. private static readonly KINEMATIC_FLAG;
  125778. private static readonly DISABLE_DEACTIVATION_FLAG;
  125779. /**
  125780. * Initializes the ammoJS plugin
  125781. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  125782. * @param ammoInjection can be used to inject your own ammo reference
  125783. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  125784. */
  125785. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  125786. /**
  125787. * Sets the gravity of the physics world (m/(s^2))
  125788. * @param gravity Gravity to set
  125789. */
  125790. setGravity(gravity: Vector3): void;
  125791. /**
  125792. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  125793. * @param timeStep timestep to use in seconds
  125794. */
  125795. setTimeStep(timeStep: number): void;
  125796. /**
  125797. * 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)
  125798. * @param fixedTimeStep fixedTimeStep to use in seconds
  125799. */
  125800. setFixedTimeStep(fixedTimeStep: number): void;
  125801. /**
  125802. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  125803. * @param maxSteps the maximum number of steps by the physics engine per frame
  125804. */
  125805. setMaxSteps(maxSteps: number): void;
  125806. /**
  125807. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  125808. * @returns the current timestep in seconds
  125809. */
  125810. getTimeStep(): number;
  125811. /**
  125812. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  125813. */
  125814. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  125815. private _isImpostorInContact;
  125816. private _isImpostorPairInContact;
  125817. private _stepSimulation;
  125818. /**
  125819. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  125820. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  125821. * After the step the babylon meshes are set to the position of the physics imposters
  125822. * @param delta amount of time to step forward
  125823. * @param impostors array of imposters to update before/after the step
  125824. */
  125825. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  125826. /**
  125827. * Update babylon mesh to match physics world object
  125828. * @param impostor imposter to match
  125829. */
  125830. private _afterSoftStep;
  125831. /**
  125832. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  125833. * @param impostor imposter to match
  125834. */
  125835. private _ropeStep;
  125836. /**
  125837. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  125838. * @param impostor imposter to match
  125839. */
  125840. private _softbodyOrClothStep;
  125841. private _tmpVector;
  125842. private _tmpMatrix;
  125843. /**
  125844. * Applies an impulse on the imposter
  125845. * @param impostor imposter to apply impulse to
  125846. * @param force amount of force to be applied to the imposter
  125847. * @param contactPoint the location to apply the impulse on the imposter
  125848. */
  125849. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125850. /**
  125851. * Applies a force on the imposter
  125852. * @param impostor imposter to apply force
  125853. * @param force amount of force to be applied to the imposter
  125854. * @param contactPoint the location to apply the force on the imposter
  125855. */
  125856. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  125857. /**
  125858. * Creates a physics body using the plugin
  125859. * @param impostor the imposter to create the physics body on
  125860. */
  125861. generatePhysicsBody(impostor: PhysicsImpostor): void;
  125862. /**
  125863. * Removes the physics body from the imposter and disposes of the body's memory
  125864. * @param impostor imposter to remove the physics body from
  125865. */
  125866. removePhysicsBody(impostor: PhysicsImpostor): void;
  125867. /**
  125868. * Generates a joint
  125869. * @param impostorJoint the imposter joint to create the joint with
  125870. */
  125871. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  125872. /**
  125873. * Removes a joint
  125874. * @param impostorJoint the imposter joint to remove the joint from
  125875. */
  125876. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  125877. private _addMeshVerts;
  125878. /**
  125879. * Initialise the soft body vertices to match its object's (mesh) vertices
  125880. * Softbody vertices (nodes) are in world space and to match this
  125881. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  125882. * @param impostor to create the softbody for
  125883. */
  125884. private _softVertexData;
  125885. /**
  125886. * Create an impostor's soft body
  125887. * @param impostor to create the softbody for
  125888. */
  125889. private _createSoftbody;
  125890. /**
  125891. * Create cloth for an impostor
  125892. * @param impostor to create the softbody for
  125893. */
  125894. private _createCloth;
  125895. /**
  125896. * Create rope for an impostor
  125897. * @param impostor to create the softbody for
  125898. */
  125899. private _createRope;
  125900. /**
  125901. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  125902. * @param impostor to create the custom physics shape for
  125903. */
  125904. private _createCustom;
  125905. private _addHullVerts;
  125906. private _createShape;
  125907. /**
  125908. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  125909. * @param impostor imposter containing the physics body and babylon object
  125910. */
  125911. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  125912. /**
  125913. * Sets the babylon object's position/rotation from the physics body's position/rotation
  125914. * @param impostor imposter containing the physics body and babylon object
  125915. * @param newPosition new position
  125916. * @param newRotation new rotation
  125917. */
  125918. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  125919. /**
  125920. * If this plugin is supported
  125921. * @returns true if its supported
  125922. */
  125923. isSupported(): boolean;
  125924. /**
  125925. * Sets the linear velocity of the physics body
  125926. * @param impostor imposter to set the velocity on
  125927. * @param velocity velocity to set
  125928. */
  125929. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125930. /**
  125931. * Sets the angular velocity of the physics body
  125932. * @param impostor imposter to set the velocity on
  125933. * @param velocity velocity to set
  125934. */
  125935. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  125936. /**
  125937. * gets the linear velocity
  125938. * @param impostor imposter to get linear velocity from
  125939. * @returns linear velocity
  125940. */
  125941. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125942. /**
  125943. * gets the angular velocity
  125944. * @param impostor imposter to get angular velocity from
  125945. * @returns angular velocity
  125946. */
  125947. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  125948. /**
  125949. * Sets the mass of physics body
  125950. * @param impostor imposter to set the mass on
  125951. * @param mass mass to set
  125952. */
  125953. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  125954. /**
  125955. * Gets the mass of the physics body
  125956. * @param impostor imposter to get the mass from
  125957. * @returns mass
  125958. */
  125959. getBodyMass(impostor: PhysicsImpostor): number;
  125960. /**
  125961. * Gets friction of the impostor
  125962. * @param impostor impostor to get friction from
  125963. * @returns friction value
  125964. */
  125965. getBodyFriction(impostor: PhysicsImpostor): number;
  125966. /**
  125967. * Sets friction of the impostor
  125968. * @param impostor impostor to set friction on
  125969. * @param friction friction value
  125970. */
  125971. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  125972. /**
  125973. * Gets restitution of the impostor
  125974. * @param impostor impostor to get restitution from
  125975. * @returns restitution value
  125976. */
  125977. getBodyRestitution(impostor: PhysicsImpostor): number;
  125978. /**
  125979. * Sets resitution of the impostor
  125980. * @param impostor impostor to set resitution on
  125981. * @param restitution resitution value
  125982. */
  125983. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  125984. /**
  125985. * Gets pressure inside the impostor
  125986. * @param impostor impostor to get pressure from
  125987. * @returns pressure value
  125988. */
  125989. getBodyPressure(impostor: PhysicsImpostor): number;
  125990. /**
  125991. * Sets pressure inside a soft body impostor
  125992. * Cloth and rope must remain 0 pressure
  125993. * @param impostor impostor to set pressure on
  125994. * @param pressure pressure value
  125995. */
  125996. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  125997. /**
  125998. * Gets stiffness of the impostor
  125999. * @param impostor impostor to get stiffness from
  126000. * @returns pressure value
  126001. */
  126002. getBodyStiffness(impostor: PhysicsImpostor): number;
  126003. /**
  126004. * Sets stiffness of the impostor
  126005. * @param impostor impostor to set stiffness on
  126006. * @param stiffness stiffness value from 0 to 1
  126007. */
  126008. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  126009. /**
  126010. * Gets velocityIterations of the impostor
  126011. * @param impostor impostor to get velocity iterations from
  126012. * @returns velocityIterations value
  126013. */
  126014. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  126015. /**
  126016. * Sets velocityIterations of the impostor
  126017. * @param impostor impostor to set velocity iterations on
  126018. * @param velocityIterations velocityIterations value
  126019. */
  126020. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  126021. /**
  126022. * Gets positionIterations of the impostor
  126023. * @param impostor impostor to get position iterations from
  126024. * @returns positionIterations value
  126025. */
  126026. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  126027. /**
  126028. * Sets positionIterations of the impostor
  126029. * @param impostor impostor to set position on
  126030. * @param positionIterations positionIterations value
  126031. */
  126032. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  126033. /**
  126034. * Append an anchor to a cloth object
  126035. * @param impostor is the cloth impostor to add anchor to
  126036. * @param otherImpostor is the rigid impostor to anchor to
  126037. * @param width ratio across width from 0 to 1
  126038. * @param height ratio up height from 0 to 1
  126039. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  126040. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  126041. */
  126042. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  126043. /**
  126044. * Append an hook to a rope object
  126045. * @param impostor is the rope impostor to add hook to
  126046. * @param otherImpostor is the rigid impostor to hook to
  126047. * @param length ratio along the rope from 0 to 1
  126048. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  126049. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  126050. */
  126051. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  126052. /**
  126053. * Sleeps the physics body and stops it from being active
  126054. * @param impostor impostor to sleep
  126055. */
  126056. sleepBody(impostor: PhysicsImpostor): void;
  126057. /**
  126058. * Activates the physics body
  126059. * @param impostor impostor to activate
  126060. */
  126061. wakeUpBody(impostor: PhysicsImpostor): void;
  126062. /**
  126063. * Updates the distance parameters of the joint
  126064. * @param joint joint to update
  126065. * @param maxDistance maximum distance of the joint
  126066. * @param minDistance minimum distance of the joint
  126067. */
  126068. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  126069. /**
  126070. * Sets a motor on the joint
  126071. * @param joint joint to set motor on
  126072. * @param speed speed of the motor
  126073. * @param maxForce maximum force of the motor
  126074. * @param motorIndex index of the motor
  126075. */
  126076. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  126077. /**
  126078. * Sets the motors limit
  126079. * @param joint joint to set limit on
  126080. * @param upperLimit upper limit
  126081. * @param lowerLimit lower limit
  126082. */
  126083. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  126084. /**
  126085. * Syncs the position and rotation of a mesh with the impostor
  126086. * @param mesh mesh to sync
  126087. * @param impostor impostor to update the mesh with
  126088. */
  126089. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  126090. /**
  126091. * Gets the radius of the impostor
  126092. * @param impostor impostor to get radius from
  126093. * @returns the radius
  126094. */
  126095. getRadius(impostor: PhysicsImpostor): number;
  126096. /**
  126097. * Gets the box size of the impostor
  126098. * @param impostor impostor to get box size from
  126099. * @param result the resulting box size
  126100. */
  126101. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  126102. /**
  126103. * Disposes of the impostor
  126104. */
  126105. dispose(): void;
  126106. /**
  126107. * Does a raycast in the physics world
  126108. * @param from when should the ray start?
  126109. * @param to when should the ray end?
  126110. * @returns PhysicsRaycastResult
  126111. */
  126112. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  126113. }
  126114. }
  126115. declare module BABYLON {
  126116. interface AbstractScene {
  126117. /**
  126118. * The list of reflection probes added to the scene
  126119. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  126120. */
  126121. reflectionProbes: Array<ReflectionProbe>;
  126122. /**
  126123. * Removes the given reflection probe from this scene.
  126124. * @param toRemove The reflection probe to remove
  126125. * @returns The index of the removed reflection probe
  126126. */
  126127. removeReflectionProbe(toRemove: ReflectionProbe): number;
  126128. /**
  126129. * Adds the given reflection probe to this scene.
  126130. * @param newReflectionProbe The reflection probe to add
  126131. */
  126132. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  126133. }
  126134. /**
  126135. * Class used to generate realtime reflection / refraction cube textures
  126136. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  126137. */
  126138. export class ReflectionProbe {
  126139. /** defines the name of the probe */
  126140. name: string;
  126141. private _scene;
  126142. private _renderTargetTexture;
  126143. private _projectionMatrix;
  126144. private _viewMatrix;
  126145. private _target;
  126146. private _add;
  126147. private _attachedMesh;
  126148. private _invertYAxis;
  126149. /** Gets or sets probe position (center of the cube map) */
  126150. position: Vector3;
  126151. /**
  126152. * Creates a new reflection probe
  126153. * @param name defines the name of the probe
  126154. * @param size defines the texture resolution (for each face)
  126155. * @param scene defines the hosting scene
  126156. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  126157. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  126158. */
  126159. constructor(
  126160. /** defines the name of the probe */
  126161. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  126162. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  126163. get samples(): number;
  126164. set samples(value: number);
  126165. /** Gets or sets the refresh rate to use (on every frame by default) */
  126166. get refreshRate(): number;
  126167. set refreshRate(value: number);
  126168. /**
  126169. * Gets the hosting scene
  126170. * @returns a Scene
  126171. */
  126172. getScene(): Scene;
  126173. /** Gets the internal CubeTexture used to render to */
  126174. get cubeTexture(): RenderTargetTexture;
  126175. /** Gets the list of meshes to render */
  126176. get renderList(): Nullable<AbstractMesh[]>;
  126177. /**
  126178. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  126179. * @param mesh defines the mesh to attach to
  126180. */
  126181. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  126182. /**
  126183. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  126184. * @param renderingGroupId The rendering group id corresponding to its index
  126185. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  126186. */
  126187. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  126188. /**
  126189. * Clean all associated resources
  126190. */
  126191. dispose(): void;
  126192. /**
  126193. * Converts the reflection probe information to a readable string for debug purpose.
  126194. * @param fullDetails Supports for multiple levels of logging within scene loading
  126195. * @returns the human readable reflection probe info
  126196. */
  126197. toString(fullDetails?: boolean): string;
  126198. /**
  126199. * Get the class name of the relfection probe.
  126200. * @returns "ReflectionProbe"
  126201. */
  126202. getClassName(): string;
  126203. /**
  126204. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  126205. * @returns The JSON representation of the texture
  126206. */
  126207. serialize(): any;
  126208. /**
  126209. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  126210. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  126211. * @param scene Define the scene the parsed reflection probe should be instantiated in
  126212. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  126213. * @returns The parsed reflection probe if successful
  126214. */
  126215. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  126216. }
  126217. }
  126218. declare module BABYLON {
  126219. /** @hidden */
  126220. export var _BabylonLoaderRegistered: boolean;
  126221. /**
  126222. * Helps setting up some configuration for the babylon file loader.
  126223. */
  126224. export class BabylonFileLoaderConfiguration {
  126225. /**
  126226. * The loader does not allow injecting custom physix engine into the plugins.
  126227. * Unfortunately in ES6, we need to manually inject them into the plugin.
  126228. * So you could set this variable to your engine import to make it work.
  126229. */
  126230. static LoaderInjectedPhysicsEngine: any;
  126231. }
  126232. }
  126233. declare module BABYLON {
  126234. /**
  126235. * The Physically based simple base material of BJS.
  126236. *
  126237. * This enables better naming and convention enforcements on top of the pbrMaterial.
  126238. * It is used as the base class for both the specGloss and metalRough conventions.
  126239. */
  126240. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  126241. /**
  126242. * Number of Simultaneous lights allowed on the material.
  126243. */
  126244. maxSimultaneousLights: number;
  126245. /**
  126246. * If sets to true, disables all the lights affecting the material.
  126247. */
  126248. disableLighting: boolean;
  126249. /**
  126250. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  126251. */
  126252. environmentTexture: BaseTexture;
  126253. /**
  126254. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  126255. */
  126256. invertNormalMapX: boolean;
  126257. /**
  126258. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  126259. */
  126260. invertNormalMapY: boolean;
  126261. /**
  126262. * Normal map used in the model.
  126263. */
  126264. normalTexture: BaseTexture;
  126265. /**
  126266. * Emissivie color used to self-illuminate the model.
  126267. */
  126268. emissiveColor: Color3;
  126269. /**
  126270. * Emissivie texture used to self-illuminate the model.
  126271. */
  126272. emissiveTexture: BaseTexture;
  126273. /**
  126274. * Occlusion Channel Strenght.
  126275. */
  126276. occlusionStrength: number;
  126277. /**
  126278. * Occlusion Texture of the material (adding extra occlusion effects).
  126279. */
  126280. occlusionTexture: BaseTexture;
  126281. /**
  126282. * Defines the alpha limits in alpha test mode.
  126283. */
  126284. alphaCutOff: number;
  126285. /**
  126286. * Gets the current double sided mode.
  126287. */
  126288. get doubleSided(): boolean;
  126289. /**
  126290. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126291. */
  126292. set doubleSided(value: boolean);
  126293. /**
  126294. * Stores the pre-calculated light information of a mesh in a texture.
  126295. */
  126296. lightmapTexture: BaseTexture;
  126297. /**
  126298. * If true, the light map contains occlusion information instead of lighting info.
  126299. */
  126300. useLightmapAsShadowmap: boolean;
  126301. /**
  126302. * Instantiates a new PBRMaterial instance.
  126303. *
  126304. * @param name The material name
  126305. * @param scene The scene the material will be use in.
  126306. */
  126307. constructor(name: string, scene: Scene);
  126308. getClassName(): string;
  126309. }
  126310. }
  126311. declare module BABYLON {
  126312. /**
  126313. * The PBR material of BJS following the metal roughness convention.
  126314. *
  126315. * This fits to the PBR convention in the GLTF definition:
  126316. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  126317. */
  126318. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  126319. /**
  126320. * The base color has two different interpretations depending on the value of metalness.
  126321. * When the material is a metal, the base color is the specific measured reflectance value
  126322. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  126323. * of the material.
  126324. */
  126325. baseColor: Color3;
  126326. /**
  126327. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  126328. * well as opacity information in the alpha channel.
  126329. */
  126330. baseTexture: BaseTexture;
  126331. /**
  126332. * Specifies the metallic scalar value of the material.
  126333. * Can also be used to scale the metalness values of the metallic texture.
  126334. */
  126335. metallic: number;
  126336. /**
  126337. * Specifies the roughness scalar value of the material.
  126338. * Can also be used to scale the roughness values of the metallic texture.
  126339. */
  126340. roughness: number;
  126341. /**
  126342. * Texture containing both the metallic value in the B channel and the
  126343. * roughness value in the G channel to keep better precision.
  126344. */
  126345. metallicRoughnessTexture: BaseTexture;
  126346. /**
  126347. * Instantiates a new PBRMetalRoughnessMaterial instance.
  126348. *
  126349. * @param name The material name
  126350. * @param scene The scene the material will be use in.
  126351. */
  126352. constructor(name: string, scene: Scene);
  126353. /**
  126354. * Return the currrent class name of the material.
  126355. */
  126356. getClassName(): string;
  126357. /**
  126358. * Makes a duplicate of the current material.
  126359. * @param name - name to use for the new material.
  126360. */
  126361. clone(name: string): PBRMetallicRoughnessMaterial;
  126362. /**
  126363. * Serialize the material to a parsable JSON object.
  126364. */
  126365. serialize(): any;
  126366. /**
  126367. * Parses a JSON object correponding to the serialize function.
  126368. */
  126369. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  126370. }
  126371. }
  126372. declare module BABYLON {
  126373. /**
  126374. * The PBR material of BJS following the specular glossiness convention.
  126375. *
  126376. * This fits to the PBR convention in the GLTF definition:
  126377. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  126378. */
  126379. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  126380. /**
  126381. * Specifies the diffuse color of the material.
  126382. */
  126383. diffuseColor: Color3;
  126384. /**
  126385. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  126386. * channel.
  126387. */
  126388. diffuseTexture: BaseTexture;
  126389. /**
  126390. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  126391. */
  126392. specularColor: Color3;
  126393. /**
  126394. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  126395. */
  126396. glossiness: number;
  126397. /**
  126398. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  126399. */
  126400. specularGlossinessTexture: BaseTexture;
  126401. /**
  126402. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  126403. *
  126404. * @param name The material name
  126405. * @param scene The scene the material will be use in.
  126406. */
  126407. constructor(name: string, scene: Scene);
  126408. /**
  126409. * Return the currrent class name of the material.
  126410. */
  126411. getClassName(): string;
  126412. /**
  126413. * Makes a duplicate of the current material.
  126414. * @param name - name to use for the new material.
  126415. */
  126416. clone(name: string): PBRSpecularGlossinessMaterial;
  126417. /**
  126418. * Serialize the material to a parsable JSON object.
  126419. */
  126420. serialize(): any;
  126421. /**
  126422. * Parses a JSON object correponding to the serialize function.
  126423. */
  126424. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  126425. }
  126426. }
  126427. declare module BABYLON {
  126428. /**
  126429. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  126430. * It can help converting any input color in a desired output one. This can then be used to create effects
  126431. * from sepia, black and white to sixties or futuristic rendering...
  126432. *
  126433. * The only supported format is currently 3dl.
  126434. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  126435. */
  126436. export class ColorGradingTexture extends BaseTexture {
  126437. /**
  126438. * The current texture matrix. (will always be identity in color grading texture)
  126439. */
  126440. private _textureMatrix;
  126441. /**
  126442. * The texture URL.
  126443. */
  126444. url: string;
  126445. /**
  126446. * Empty line regex stored for GC.
  126447. */
  126448. private static _noneEmptyLineRegex;
  126449. private _engine;
  126450. /**
  126451. * Instantiates a ColorGradingTexture from the following parameters.
  126452. *
  126453. * @param url The location of the color gradind data (currently only supporting 3dl)
  126454. * @param scene The scene the texture will be used in
  126455. */
  126456. constructor(url: string, scene: Scene);
  126457. /**
  126458. * Returns the texture matrix used in most of the material.
  126459. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  126460. */
  126461. getTextureMatrix(): Matrix;
  126462. /**
  126463. * Occurs when the file being loaded is a .3dl LUT file.
  126464. */
  126465. private load3dlTexture;
  126466. /**
  126467. * Starts the loading process of the texture.
  126468. */
  126469. private loadTexture;
  126470. /**
  126471. * Clones the color gradind texture.
  126472. */
  126473. clone(): ColorGradingTexture;
  126474. /**
  126475. * Called during delayed load for textures.
  126476. */
  126477. delayLoad(): void;
  126478. /**
  126479. * Parses a color grading texture serialized by Babylon.
  126480. * @param parsedTexture The texture information being parsedTexture
  126481. * @param scene The scene to load the texture in
  126482. * @param rootUrl The root url of the data assets to load
  126483. * @return A color gradind texture
  126484. */
  126485. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  126486. /**
  126487. * Serializes the LUT texture to json format.
  126488. */
  126489. serialize(): any;
  126490. }
  126491. }
  126492. declare module BABYLON {
  126493. /**
  126494. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  126495. */
  126496. export class EquiRectangularCubeTexture extends BaseTexture {
  126497. /** The six faces of the cube. */
  126498. private static _FacesMapping;
  126499. private _noMipmap;
  126500. private _onLoad;
  126501. private _onError;
  126502. /** The size of the cubemap. */
  126503. private _size;
  126504. /** The buffer of the image. */
  126505. private _buffer;
  126506. /** The width of the input image. */
  126507. private _width;
  126508. /** The height of the input image. */
  126509. private _height;
  126510. /** The URL to the image. */
  126511. url: string;
  126512. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  126513. coordinatesMode: number;
  126514. /**
  126515. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  126516. * @param url The location of the image
  126517. * @param scene The scene the texture will be used in
  126518. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  126519. * @param noMipmap Forces to not generate the mipmap if true
  126520. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  126521. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  126522. * @param onLoad — defines a callback called when texture is loaded
  126523. * @param onError — defines a callback called if there is an error
  126524. */
  126525. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  126526. /**
  126527. * Load the image data, by putting the image on a canvas and extracting its buffer.
  126528. */
  126529. private loadImage;
  126530. /**
  126531. * Convert the image buffer into a cubemap and create a CubeTexture.
  126532. */
  126533. private loadTexture;
  126534. /**
  126535. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  126536. * @param buffer The ArrayBuffer that should be converted.
  126537. * @returns The buffer as Float32Array.
  126538. */
  126539. private getFloat32ArrayFromArrayBuffer;
  126540. /**
  126541. * Get the current class name of the texture useful for serialization or dynamic coding.
  126542. * @returns "EquiRectangularCubeTexture"
  126543. */
  126544. getClassName(): string;
  126545. /**
  126546. * Create a clone of the current EquiRectangularCubeTexture and return it.
  126547. * @returns A clone of the current EquiRectangularCubeTexture.
  126548. */
  126549. clone(): EquiRectangularCubeTexture;
  126550. }
  126551. }
  126552. declare module BABYLON {
  126553. /**
  126554. * Based on jsTGALoader - Javascript loader for TGA file
  126555. * By Vincent Thibault
  126556. * @see http://blog.robrowser.com/javascript-tga-loader.html
  126557. */
  126558. export class TGATools {
  126559. private static _TYPE_INDEXED;
  126560. private static _TYPE_RGB;
  126561. private static _TYPE_GREY;
  126562. private static _TYPE_RLE_INDEXED;
  126563. private static _TYPE_RLE_RGB;
  126564. private static _TYPE_RLE_GREY;
  126565. private static _ORIGIN_MASK;
  126566. private static _ORIGIN_SHIFT;
  126567. private static _ORIGIN_BL;
  126568. private static _ORIGIN_BR;
  126569. private static _ORIGIN_UL;
  126570. private static _ORIGIN_UR;
  126571. /**
  126572. * Gets the header of a TGA file
  126573. * @param data defines the TGA data
  126574. * @returns the header
  126575. */
  126576. static GetTGAHeader(data: Uint8Array): any;
  126577. /**
  126578. * Uploads TGA content to a Babylon Texture
  126579. * @hidden
  126580. */
  126581. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  126582. /** @hidden */
  126583. 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;
  126584. /** @hidden */
  126585. 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;
  126586. /** @hidden */
  126587. 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;
  126588. /** @hidden */
  126589. 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;
  126590. /** @hidden */
  126591. 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;
  126592. /** @hidden */
  126593. 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;
  126594. }
  126595. }
  126596. declare module BABYLON {
  126597. /**
  126598. * Implementation of the TGA Texture Loader.
  126599. * @hidden
  126600. */
  126601. export class _TGATextureLoader implements IInternalTextureLoader {
  126602. /**
  126603. * Defines wether the loader supports cascade loading the different faces.
  126604. */
  126605. readonly supportCascades: boolean;
  126606. /**
  126607. * This returns if the loader support the current file information.
  126608. * @param extension defines the file extension of the file being loaded
  126609. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126610. * @param fallback defines the fallback internal texture if any
  126611. * @param isBase64 defines whether the texture is encoded as a base64
  126612. * @param isBuffer defines whether the texture data are stored as a buffer
  126613. * @returns true if the loader can load the specified file
  126614. */
  126615. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  126616. /**
  126617. * Transform the url before loading if required.
  126618. * @param rootUrl the url of the texture
  126619. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126620. * @returns the transformed texture
  126621. */
  126622. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  126623. /**
  126624. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  126625. * @param rootUrl the url of the texture
  126626. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126627. * @returns the fallback texture
  126628. */
  126629. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  126630. /**
  126631. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  126632. * @param data contains the texture data
  126633. * @param texture defines the BabylonJS internal texture
  126634. * @param createPolynomials will be true if polynomials have been requested
  126635. * @param onLoad defines the callback to trigger once the texture is ready
  126636. * @param onError defines the callback to trigger in case of error
  126637. */
  126638. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126639. /**
  126640. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  126641. * @param data contains the texture data
  126642. * @param texture defines the BabylonJS internal texture
  126643. * @param callback defines the method to call once ready to upload
  126644. */
  126645. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126646. }
  126647. }
  126648. declare module BABYLON {
  126649. /**
  126650. * Info about the .basis files
  126651. */
  126652. class BasisFileInfo {
  126653. /**
  126654. * If the file has alpha
  126655. */
  126656. hasAlpha: boolean;
  126657. /**
  126658. * Info about each image of the basis file
  126659. */
  126660. images: Array<{
  126661. levels: Array<{
  126662. width: number;
  126663. height: number;
  126664. transcodedPixels: ArrayBufferView;
  126665. }>;
  126666. }>;
  126667. }
  126668. /**
  126669. * Result of transcoding a basis file
  126670. */
  126671. class TranscodeResult {
  126672. /**
  126673. * Info about the .basis file
  126674. */
  126675. fileInfo: BasisFileInfo;
  126676. /**
  126677. * Format to use when loading the file
  126678. */
  126679. format: number;
  126680. }
  126681. /**
  126682. * Configuration options for the Basis transcoder
  126683. */
  126684. export class BasisTranscodeConfiguration {
  126685. /**
  126686. * Supported compression formats used to determine the supported output format of the transcoder
  126687. */
  126688. supportedCompressionFormats?: {
  126689. /**
  126690. * etc1 compression format
  126691. */
  126692. etc1?: boolean;
  126693. /**
  126694. * s3tc compression format
  126695. */
  126696. s3tc?: boolean;
  126697. /**
  126698. * pvrtc compression format
  126699. */
  126700. pvrtc?: boolean;
  126701. /**
  126702. * etc2 compression format
  126703. */
  126704. etc2?: boolean;
  126705. };
  126706. /**
  126707. * If mipmap levels should be loaded for transcoded images (Default: true)
  126708. */
  126709. loadMipmapLevels?: boolean;
  126710. /**
  126711. * Index of a single image to load (Default: all images)
  126712. */
  126713. loadSingleImage?: number;
  126714. }
  126715. /**
  126716. * Used to load .Basis files
  126717. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  126718. */
  126719. export class BasisTools {
  126720. private static _IgnoreSupportedFormats;
  126721. /**
  126722. * URL to use when loading the basis transcoder
  126723. */
  126724. static JSModuleURL: string;
  126725. /**
  126726. * URL to use when loading the wasm module for the transcoder
  126727. */
  126728. static WasmModuleURL: string;
  126729. /**
  126730. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  126731. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  126732. * @returns internal format corresponding to the Basis format
  126733. */
  126734. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  126735. private static _WorkerPromise;
  126736. private static _Worker;
  126737. private static _actionId;
  126738. private static _CreateWorkerAsync;
  126739. /**
  126740. * Transcodes a loaded image file to compressed pixel data
  126741. * @param imageData image data to transcode
  126742. * @param config configuration options for the transcoding
  126743. * @returns a promise resulting in the transcoded image
  126744. */
  126745. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  126746. /**
  126747. * Loads a texture from the transcode result
  126748. * @param texture texture load to
  126749. * @param transcodeResult the result of transcoding the basis file to load from
  126750. */
  126751. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  126752. }
  126753. }
  126754. declare module BABYLON {
  126755. /**
  126756. * Loader for .basis file format
  126757. */
  126758. export class _BasisTextureLoader implements IInternalTextureLoader {
  126759. /**
  126760. * Defines whether the loader supports cascade loading the different faces.
  126761. */
  126762. readonly supportCascades: boolean;
  126763. /**
  126764. * This returns if the loader support the current file information.
  126765. * @param extension defines the file extension of the file being loaded
  126766. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126767. * @param fallback defines the fallback internal texture if any
  126768. * @param isBase64 defines whether the texture is encoded as a base64
  126769. * @param isBuffer defines whether the texture data are stored as a buffer
  126770. * @returns true if the loader can load the specified file
  126771. */
  126772. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  126773. /**
  126774. * Transform the url before loading if required.
  126775. * @param rootUrl the url of the texture
  126776. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126777. * @returns the transformed texture
  126778. */
  126779. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  126780. /**
  126781. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  126782. * @param rootUrl the url of the texture
  126783. * @param textureFormatInUse defines the current compressed format in use iun the engine
  126784. * @returns the fallback texture
  126785. */
  126786. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  126787. /**
  126788. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  126789. * @param data contains the texture data
  126790. * @param texture defines the BabylonJS internal texture
  126791. * @param createPolynomials will be true if polynomials have been requested
  126792. * @param onLoad defines the callback to trigger once the texture is ready
  126793. * @param onError defines the callback to trigger in case of error
  126794. */
  126795. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126796. /**
  126797. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  126798. * @param data contains the texture data
  126799. * @param texture defines the BabylonJS internal texture
  126800. * @param callback defines the method to call once ready to upload
  126801. */
  126802. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126803. }
  126804. }
  126805. declare module BABYLON {
  126806. /**
  126807. * 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.
  126808. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  126809. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  126810. */
  126811. export class CustomProceduralTexture extends ProceduralTexture {
  126812. private _animate;
  126813. private _time;
  126814. private _config;
  126815. private _texturePath;
  126816. /**
  126817. * Instantiates a new Custom Procedural Texture.
  126818. * 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.
  126819. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  126820. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  126821. * @param name Define the name of the texture
  126822. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  126823. * @param size Define the size of the texture to create
  126824. * @param scene Define the scene the texture belongs to
  126825. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  126826. * @param generateMipMaps Define if the texture should creates mip maps or not
  126827. */
  126828. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  126829. private _loadJson;
  126830. /**
  126831. * Is the texture ready to be used ? (rendered at least once)
  126832. * @returns true if ready, otherwise, false.
  126833. */
  126834. isReady(): boolean;
  126835. /**
  126836. * Render the texture to its associated render target.
  126837. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  126838. */
  126839. render(useCameraPostProcess?: boolean): void;
  126840. /**
  126841. * Update the list of dependant textures samplers in the shader.
  126842. */
  126843. updateTextures(): void;
  126844. /**
  126845. * Update the uniform values of the procedural texture in the shader.
  126846. */
  126847. updateShaderUniforms(): void;
  126848. /**
  126849. * Define if the texture animates or not.
  126850. */
  126851. get animate(): boolean;
  126852. set animate(value: boolean);
  126853. }
  126854. }
  126855. declare module BABYLON {
  126856. /** @hidden */
  126857. export var noisePixelShader: {
  126858. name: string;
  126859. shader: string;
  126860. };
  126861. }
  126862. declare module BABYLON {
  126863. /**
  126864. * Class used to generate noise procedural textures
  126865. */
  126866. export class NoiseProceduralTexture extends ProceduralTexture {
  126867. private _time;
  126868. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  126869. brightness: number;
  126870. /** Defines the number of octaves to process */
  126871. octaves: number;
  126872. /** Defines the level of persistence (0.8 by default) */
  126873. persistence: number;
  126874. /** Gets or sets animation speed factor (default is 1) */
  126875. animationSpeedFactor: number;
  126876. /**
  126877. * Creates a new NoiseProceduralTexture
  126878. * @param name defines the name fo the texture
  126879. * @param size defines the size of the texture (default is 256)
  126880. * @param scene defines the hosting scene
  126881. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  126882. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  126883. */
  126884. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  126885. private _updateShaderUniforms;
  126886. protected _getDefines(): string;
  126887. /** Generate the current state of the procedural texture */
  126888. render(useCameraPostProcess?: boolean): void;
  126889. /**
  126890. * Serializes this noise procedural texture
  126891. * @returns a serialized noise procedural texture object
  126892. */
  126893. serialize(): any;
  126894. /**
  126895. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  126896. * @param parsedTexture defines parsed texture data
  126897. * @param scene defines the current scene
  126898. * @param rootUrl defines the root URL containing noise procedural texture information
  126899. * @returns a parsed NoiseProceduralTexture
  126900. */
  126901. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  126902. }
  126903. }
  126904. declare module BABYLON {
  126905. /**
  126906. * Raw cube texture where the raw buffers are passed in
  126907. */
  126908. export class RawCubeTexture extends CubeTexture {
  126909. /**
  126910. * Creates a cube texture where the raw buffers are passed in.
  126911. * @param scene defines the scene the texture is attached to
  126912. * @param data defines the array of data to use to create each face
  126913. * @param size defines the size of the textures
  126914. * @param format defines the format of the data
  126915. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  126916. * @param generateMipMaps defines if the engine should generate the mip levels
  126917. * @param invertY defines if data must be stored with Y axis inverted
  126918. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  126919. * @param compression defines the compression used (null by default)
  126920. */
  126921. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  126922. /**
  126923. * Updates the raw cube texture.
  126924. * @param data defines the data to store
  126925. * @param format defines the data format
  126926. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  126927. * @param invertY defines if data must be stored with Y axis inverted
  126928. * @param compression defines the compression used (null by default)
  126929. * @param level defines which level of the texture to update
  126930. */
  126931. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  126932. /**
  126933. * Updates a raw cube texture with RGBD encoded data.
  126934. * @param data defines the array of data [mipmap][face] to use to create each face
  126935. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  126936. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  126937. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  126938. * @returns a promsie that resolves when the operation is complete
  126939. */
  126940. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  126941. /**
  126942. * Clones the raw cube texture.
  126943. * @return a new cube texture
  126944. */
  126945. clone(): CubeTexture;
  126946. /** @hidden */
  126947. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  126948. }
  126949. }
  126950. declare module BABYLON {
  126951. /**
  126952. * Class used to store 3D textures containing user data
  126953. */
  126954. export class RawTexture3D extends Texture {
  126955. /** Gets or sets the texture format to use */
  126956. format: number;
  126957. private _engine;
  126958. /**
  126959. * Create a new RawTexture3D
  126960. * @param data defines the data of the texture
  126961. * @param width defines the width of the texture
  126962. * @param height defines the height of the texture
  126963. * @param depth defines the depth of the texture
  126964. * @param format defines the texture format to use
  126965. * @param scene defines the hosting scene
  126966. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  126967. * @param invertY defines if texture must be stored with Y axis inverted
  126968. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  126969. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  126970. */
  126971. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  126972. /** Gets or sets the texture format to use */
  126973. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  126974. /**
  126975. * Update the texture with new data
  126976. * @param data defines the data to store in the texture
  126977. */
  126978. update(data: ArrayBufferView): void;
  126979. }
  126980. }
  126981. declare module BABYLON {
  126982. /**
  126983. * Class used to store 2D array textures containing user data
  126984. */
  126985. export class RawTexture2DArray extends Texture {
  126986. /** Gets or sets the texture format to use */
  126987. format: number;
  126988. private _engine;
  126989. /**
  126990. * Create a new RawTexture2DArray
  126991. * @param data defines the data of the texture
  126992. * @param width defines the width of the texture
  126993. * @param height defines the height of the texture
  126994. * @param depth defines the number of layers of the texture
  126995. * @param format defines the texture format to use
  126996. * @param scene defines the hosting scene
  126997. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  126998. * @param invertY defines if texture must be stored with Y axis inverted
  126999. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  127000. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  127001. */
  127002. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  127003. /** Gets or sets the texture format to use */
  127004. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  127005. /**
  127006. * Update the texture with new data
  127007. * @param data defines the data to store in the texture
  127008. */
  127009. update(data: ArrayBufferView): void;
  127010. }
  127011. }
  127012. declare module BABYLON {
  127013. /**
  127014. * Creates a refraction texture used by refraction channel of the standard material.
  127015. * It is like a mirror but to see through a material.
  127016. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  127017. */
  127018. export class RefractionTexture extends RenderTargetTexture {
  127019. /**
  127020. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  127021. * 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.
  127022. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  127023. */
  127024. refractionPlane: Plane;
  127025. /**
  127026. * Define how deep under the surface we should see.
  127027. */
  127028. depth: number;
  127029. /**
  127030. * Creates a refraction texture used by refraction channel of the standard material.
  127031. * It is like a mirror but to see through a material.
  127032. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  127033. * @param name Define the texture name
  127034. * @param size Define the size of the underlying texture
  127035. * @param scene Define the scene the refraction belongs to
  127036. * @param generateMipMaps Define if we need to generate mips level for the refraction
  127037. */
  127038. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  127039. /**
  127040. * Clone the refraction texture.
  127041. * @returns the cloned texture
  127042. */
  127043. clone(): RefractionTexture;
  127044. /**
  127045. * Serialize the texture to a JSON representation you could use in Parse later on
  127046. * @returns the serialized JSON representation
  127047. */
  127048. serialize(): any;
  127049. }
  127050. }
  127051. declare module BABYLON {
  127052. /**
  127053. * Defines the options related to the creation of an HtmlElementTexture
  127054. */
  127055. export interface IHtmlElementTextureOptions {
  127056. /**
  127057. * Defines wether mip maps should be created or not.
  127058. */
  127059. generateMipMaps?: boolean;
  127060. /**
  127061. * Defines the sampling mode of the texture.
  127062. */
  127063. samplingMode?: number;
  127064. /**
  127065. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  127066. */
  127067. engine: Nullable<ThinEngine>;
  127068. /**
  127069. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  127070. */
  127071. scene: Nullable<Scene>;
  127072. }
  127073. /**
  127074. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  127075. * To be as efficient as possible depending on your constraints nothing aside the first upload
  127076. * is automatically managed.
  127077. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  127078. * in your application.
  127079. *
  127080. * As the update is not automatic, you need to call them manually.
  127081. */
  127082. export class HtmlElementTexture extends BaseTexture {
  127083. /**
  127084. * The texture URL.
  127085. */
  127086. element: HTMLVideoElement | HTMLCanvasElement;
  127087. private static readonly DefaultOptions;
  127088. private _textureMatrix;
  127089. private _engine;
  127090. private _isVideo;
  127091. private _generateMipMaps;
  127092. private _samplingMode;
  127093. /**
  127094. * Instantiates a HtmlElementTexture from the following parameters.
  127095. *
  127096. * @param name Defines the name of the texture
  127097. * @param element Defines the video or canvas the texture is filled with
  127098. * @param options Defines the other none mandatory texture creation options
  127099. */
  127100. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  127101. private _createInternalTexture;
  127102. /**
  127103. * Returns the texture matrix used in most of the material.
  127104. */
  127105. getTextureMatrix(): Matrix;
  127106. /**
  127107. * Updates the content of the texture.
  127108. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  127109. */
  127110. update(invertY?: Nullable<boolean>): void;
  127111. }
  127112. }
  127113. declare module BABYLON {
  127114. /**
  127115. * Enum used to define the target of a block
  127116. */
  127117. export enum NodeMaterialBlockTargets {
  127118. /** Vertex shader */
  127119. Vertex = 1,
  127120. /** Fragment shader */
  127121. Fragment = 2,
  127122. /** Neutral */
  127123. Neutral = 4,
  127124. /** Vertex and Fragment */
  127125. VertexAndFragment = 3
  127126. }
  127127. }
  127128. declare module BABYLON {
  127129. /**
  127130. * Defines the kind of connection point for node based material
  127131. */
  127132. export enum NodeMaterialBlockConnectionPointTypes {
  127133. /** Float */
  127134. Float = 1,
  127135. /** Int */
  127136. Int = 2,
  127137. /** Vector2 */
  127138. Vector2 = 4,
  127139. /** Vector3 */
  127140. Vector3 = 8,
  127141. /** Vector4 */
  127142. Vector4 = 16,
  127143. /** Color3 */
  127144. Color3 = 32,
  127145. /** Color4 */
  127146. Color4 = 64,
  127147. /** Matrix */
  127148. Matrix = 128,
  127149. /** Detect type based on connection */
  127150. AutoDetect = 1024,
  127151. /** Output type that will be defined by input type */
  127152. BasedOnInput = 2048
  127153. }
  127154. }
  127155. declare module BABYLON {
  127156. /**
  127157. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  127158. */
  127159. export enum NodeMaterialBlockConnectionPointMode {
  127160. /** Value is an uniform */
  127161. Uniform = 0,
  127162. /** Value is a mesh attribute */
  127163. Attribute = 1,
  127164. /** Value is a varying between vertex and fragment shaders */
  127165. Varying = 2,
  127166. /** Mode is undefined */
  127167. Undefined = 3
  127168. }
  127169. }
  127170. declare module BABYLON {
  127171. /**
  127172. * Enum used to define system values e.g. values automatically provided by the system
  127173. */
  127174. export enum NodeMaterialSystemValues {
  127175. /** World */
  127176. World = 1,
  127177. /** View */
  127178. View = 2,
  127179. /** Projection */
  127180. Projection = 3,
  127181. /** ViewProjection */
  127182. ViewProjection = 4,
  127183. /** WorldView */
  127184. WorldView = 5,
  127185. /** WorldViewProjection */
  127186. WorldViewProjection = 6,
  127187. /** CameraPosition */
  127188. CameraPosition = 7,
  127189. /** Fog Color */
  127190. FogColor = 8,
  127191. /** Delta time */
  127192. DeltaTime = 9
  127193. }
  127194. }
  127195. declare module BABYLON {
  127196. /**
  127197. * Root class for all node material optimizers
  127198. */
  127199. export class NodeMaterialOptimizer {
  127200. /**
  127201. * Function used to optimize a NodeMaterial graph
  127202. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  127203. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  127204. */
  127205. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  127206. }
  127207. }
  127208. declare module BABYLON {
  127209. /**
  127210. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  127211. */
  127212. export class TransformBlock extends NodeMaterialBlock {
  127213. /**
  127214. * Defines the value to use to complement W value to transform it to a Vector4
  127215. */
  127216. complementW: number;
  127217. /**
  127218. * Defines the value to use to complement z value to transform it to a Vector4
  127219. */
  127220. complementZ: number;
  127221. /**
  127222. * Creates a new TransformBlock
  127223. * @param name defines the block name
  127224. */
  127225. constructor(name: string);
  127226. /**
  127227. * Gets the current class name
  127228. * @returns the class name
  127229. */
  127230. getClassName(): string;
  127231. /**
  127232. * Gets the vector input
  127233. */
  127234. get vector(): NodeMaterialConnectionPoint;
  127235. /**
  127236. * Gets the output component
  127237. */
  127238. get output(): NodeMaterialConnectionPoint;
  127239. /**
  127240. * Gets the matrix transform input
  127241. */
  127242. get transform(): NodeMaterialConnectionPoint;
  127243. protected _buildBlock(state: NodeMaterialBuildState): this;
  127244. serialize(): any;
  127245. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127246. protected _dumpPropertiesCode(): string;
  127247. }
  127248. }
  127249. declare module BABYLON {
  127250. /**
  127251. * Block used to output the vertex position
  127252. */
  127253. export class VertexOutputBlock extends NodeMaterialBlock {
  127254. /**
  127255. * Creates a new VertexOutputBlock
  127256. * @param name defines the block name
  127257. */
  127258. constructor(name: string);
  127259. /**
  127260. * Gets the current class name
  127261. * @returns the class name
  127262. */
  127263. getClassName(): string;
  127264. /**
  127265. * Gets the vector input component
  127266. */
  127267. get vector(): NodeMaterialConnectionPoint;
  127268. protected _buildBlock(state: NodeMaterialBuildState): this;
  127269. }
  127270. }
  127271. declare module BABYLON {
  127272. /**
  127273. * Block used to output the final color
  127274. */
  127275. export class FragmentOutputBlock extends NodeMaterialBlock {
  127276. /**
  127277. * Create a new FragmentOutputBlock
  127278. * @param name defines the block name
  127279. */
  127280. constructor(name: string);
  127281. /**
  127282. * Gets the current class name
  127283. * @returns the class name
  127284. */
  127285. getClassName(): string;
  127286. /**
  127287. * Gets the rgba input component
  127288. */
  127289. get rgba(): NodeMaterialConnectionPoint;
  127290. /**
  127291. * Gets the rgb input component
  127292. */
  127293. get rgb(): NodeMaterialConnectionPoint;
  127294. /**
  127295. * Gets the a input component
  127296. */
  127297. get a(): NodeMaterialConnectionPoint;
  127298. protected _buildBlock(state: NodeMaterialBuildState): this;
  127299. }
  127300. }
  127301. declare module BABYLON {
  127302. /**
  127303. * Block used to read a reflection texture from a sampler
  127304. */
  127305. export class ReflectionTextureBlock extends NodeMaterialBlock {
  127306. private _define3DName;
  127307. private _defineCubicName;
  127308. private _defineExplicitName;
  127309. private _defineProjectionName;
  127310. private _defineLocalCubicName;
  127311. private _defineSphericalName;
  127312. private _definePlanarName;
  127313. private _defineEquirectangularName;
  127314. private _defineMirroredEquirectangularFixedName;
  127315. private _defineEquirectangularFixedName;
  127316. private _defineSkyboxName;
  127317. private _cubeSamplerName;
  127318. private _2DSamplerName;
  127319. private _positionUVWName;
  127320. private _directionWName;
  127321. private _reflectionCoordsName;
  127322. private _reflection2DCoordsName;
  127323. private _reflectionColorName;
  127324. private _reflectionMatrixName;
  127325. /**
  127326. * Gets or sets the texture associated with the node
  127327. */
  127328. texture: Nullable<BaseTexture>;
  127329. /**
  127330. * Create a new TextureBlock
  127331. * @param name defines the block name
  127332. */
  127333. constructor(name: string);
  127334. /**
  127335. * Gets the current class name
  127336. * @returns the class name
  127337. */
  127338. getClassName(): string;
  127339. /**
  127340. * Gets the world position input component
  127341. */
  127342. get position(): NodeMaterialConnectionPoint;
  127343. /**
  127344. * Gets the world position input component
  127345. */
  127346. get worldPosition(): NodeMaterialConnectionPoint;
  127347. /**
  127348. * Gets the world normal input component
  127349. */
  127350. get worldNormal(): NodeMaterialConnectionPoint;
  127351. /**
  127352. * Gets the world input component
  127353. */
  127354. get world(): NodeMaterialConnectionPoint;
  127355. /**
  127356. * Gets the camera (or eye) position component
  127357. */
  127358. get cameraPosition(): NodeMaterialConnectionPoint;
  127359. /**
  127360. * Gets the view input component
  127361. */
  127362. get view(): NodeMaterialConnectionPoint;
  127363. /**
  127364. * Gets the rgb output component
  127365. */
  127366. get rgb(): NodeMaterialConnectionPoint;
  127367. /**
  127368. * Gets the r output component
  127369. */
  127370. get r(): NodeMaterialConnectionPoint;
  127371. /**
  127372. * Gets the g output component
  127373. */
  127374. get g(): NodeMaterialConnectionPoint;
  127375. /**
  127376. * Gets the b output component
  127377. */
  127378. get b(): NodeMaterialConnectionPoint;
  127379. autoConfigure(material: NodeMaterial): void;
  127380. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127381. isReady(): boolean;
  127382. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127383. private _injectVertexCode;
  127384. private _writeOutput;
  127385. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127386. protected _dumpPropertiesCode(): string;
  127387. serialize(): any;
  127388. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127389. }
  127390. }
  127391. declare module BABYLON {
  127392. /**
  127393. * Interface used to configure the node material editor
  127394. */
  127395. export interface INodeMaterialEditorOptions {
  127396. /** Define the URl to load node editor script */
  127397. editorURL?: string;
  127398. }
  127399. /** @hidden */
  127400. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  127401. /** BONES */
  127402. NUM_BONE_INFLUENCERS: number;
  127403. BonesPerMesh: number;
  127404. BONETEXTURE: boolean;
  127405. /** MORPH TARGETS */
  127406. MORPHTARGETS: boolean;
  127407. MORPHTARGETS_NORMAL: boolean;
  127408. MORPHTARGETS_TANGENT: boolean;
  127409. MORPHTARGETS_UV: boolean;
  127410. NUM_MORPH_INFLUENCERS: number;
  127411. /** IMAGE PROCESSING */
  127412. IMAGEPROCESSING: boolean;
  127413. VIGNETTE: boolean;
  127414. VIGNETTEBLENDMODEMULTIPLY: boolean;
  127415. VIGNETTEBLENDMODEOPAQUE: boolean;
  127416. TONEMAPPING: boolean;
  127417. TONEMAPPING_ACES: boolean;
  127418. CONTRAST: boolean;
  127419. EXPOSURE: boolean;
  127420. COLORCURVES: boolean;
  127421. COLORGRADING: boolean;
  127422. COLORGRADING3D: boolean;
  127423. SAMPLER3DGREENDEPTH: boolean;
  127424. SAMPLER3DBGRMAP: boolean;
  127425. IMAGEPROCESSINGPOSTPROCESS: boolean;
  127426. /** MISC. */
  127427. BUMPDIRECTUV: number;
  127428. constructor();
  127429. setValue(name: string, value: boolean): void;
  127430. }
  127431. /**
  127432. * Class used to configure NodeMaterial
  127433. */
  127434. export interface INodeMaterialOptions {
  127435. /**
  127436. * Defines if blocks should emit comments
  127437. */
  127438. emitComments: boolean;
  127439. }
  127440. /**
  127441. * Class used to create a node based material built by assembling shader blocks
  127442. */
  127443. export class NodeMaterial extends PushMaterial {
  127444. private static _BuildIdGenerator;
  127445. private _options;
  127446. private _vertexCompilationState;
  127447. private _fragmentCompilationState;
  127448. private _sharedData;
  127449. private _buildId;
  127450. private _buildWasSuccessful;
  127451. private _cachedWorldViewMatrix;
  127452. private _cachedWorldViewProjectionMatrix;
  127453. private _optimizers;
  127454. private _animationFrame;
  127455. /** Define the URl to load node editor script */
  127456. static EditorURL: string;
  127457. private BJSNODEMATERIALEDITOR;
  127458. /** Get the inspector from bundle or global */
  127459. private _getGlobalNodeMaterialEditor;
  127460. /**
  127461. * Gets or sets data used by visual editor
  127462. * @see https://nme.babylonjs.com
  127463. */
  127464. editorData: any;
  127465. /**
  127466. * 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)
  127467. */
  127468. ignoreAlpha: boolean;
  127469. /**
  127470. * Defines the maximum number of lights that can be used in the material
  127471. */
  127472. maxSimultaneousLights: number;
  127473. /**
  127474. * Observable raised when the material is built
  127475. */
  127476. onBuildObservable: Observable<NodeMaterial>;
  127477. /**
  127478. * Gets or sets the root nodes of the material vertex shader
  127479. */
  127480. _vertexOutputNodes: NodeMaterialBlock[];
  127481. /**
  127482. * Gets or sets the root nodes of the material fragment (pixel) shader
  127483. */
  127484. _fragmentOutputNodes: NodeMaterialBlock[];
  127485. /** Gets or sets options to control the node material overall behavior */
  127486. get options(): INodeMaterialOptions;
  127487. set options(options: INodeMaterialOptions);
  127488. /**
  127489. * Default configuration related to image processing available in the standard Material.
  127490. */
  127491. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  127492. /**
  127493. * Gets the image processing configuration used either in this material.
  127494. */
  127495. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  127496. /**
  127497. * Sets the Default image processing configuration used either in the this material.
  127498. *
  127499. * If sets to null, the scene one is in use.
  127500. */
  127501. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  127502. /**
  127503. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  127504. */
  127505. attachedBlocks: NodeMaterialBlock[];
  127506. /**
  127507. * Create a new node based material
  127508. * @param name defines the material name
  127509. * @param scene defines the hosting scene
  127510. * @param options defines creation option
  127511. */
  127512. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  127513. /**
  127514. * Gets the current class name of the material e.g. "NodeMaterial"
  127515. * @returns the class name
  127516. */
  127517. getClassName(): string;
  127518. /**
  127519. * Keep track of the image processing observer to allow dispose and replace.
  127520. */
  127521. private _imageProcessingObserver;
  127522. /**
  127523. * Attaches a new image processing configuration to the Standard Material.
  127524. * @param configuration
  127525. */
  127526. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  127527. /**
  127528. * Get a block by its name
  127529. * @param name defines the name of the block to retrieve
  127530. * @returns the required block or null if not found
  127531. */
  127532. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  127533. /**
  127534. * Get a block by its name
  127535. * @param predicate defines the predicate used to find the good candidate
  127536. * @returns the required block or null if not found
  127537. */
  127538. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  127539. /**
  127540. * Get an input block by its name
  127541. * @param predicate defines the predicate used to find the good candidate
  127542. * @returns the required input block or null if not found
  127543. */
  127544. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  127545. /**
  127546. * Gets the list of input blocks attached to this material
  127547. * @returns an array of InputBlocks
  127548. */
  127549. getInputBlocks(): InputBlock[];
  127550. /**
  127551. * Adds a new optimizer to the list of optimizers
  127552. * @param optimizer defines the optimizers to add
  127553. * @returns the current material
  127554. */
  127555. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  127556. /**
  127557. * Remove an optimizer from the list of optimizers
  127558. * @param optimizer defines the optimizers to remove
  127559. * @returns the current material
  127560. */
  127561. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  127562. /**
  127563. * Add a new block to the list of output nodes
  127564. * @param node defines the node to add
  127565. * @returns the current material
  127566. */
  127567. addOutputNode(node: NodeMaterialBlock): this;
  127568. /**
  127569. * Remove a block from the list of root nodes
  127570. * @param node defines the node to remove
  127571. * @returns the current material
  127572. */
  127573. removeOutputNode(node: NodeMaterialBlock): this;
  127574. private _addVertexOutputNode;
  127575. private _removeVertexOutputNode;
  127576. private _addFragmentOutputNode;
  127577. private _removeFragmentOutputNode;
  127578. /**
  127579. * Specifies if the material will require alpha blending
  127580. * @returns a boolean specifying if alpha blending is needed
  127581. */
  127582. needAlphaBlending(): boolean;
  127583. /**
  127584. * Specifies if this material should be rendered in alpha test mode
  127585. * @returns a boolean specifying if an alpha test is needed.
  127586. */
  127587. needAlphaTesting(): boolean;
  127588. private _initializeBlock;
  127589. private _resetDualBlocks;
  127590. /**
  127591. * Remove a block from the current node material
  127592. * @param block defines the block to remove
  127593. */
  127594. removeBlock(block: NodeMaterialBlock): void;
  127595. /**
  127596. * Build the material and generates the inner effect
  127597. * @param verbose defines if the build should log activity
  127598. */
  127599. build(verbose?: boolean): void;
  127600. /**
  127601. * Runs an otpimization phase to try to improve the shader code
  127602. */
  127603. optimize(): void;
  127604. private _prepareDefinesForAttributes;
  127605. /**
  127606. * Get if the submesh is ready to be used and all its information available.
  127607. * Child classes can use it to update shaders
  127608. * @param mesh defines the mesh to check
  127609. * @param subMesh defines which submesh to check
  127610. * @param useInstances specifies that instances should be used
  127611. * @returns a boolean indicating that the submesh is ready or not
  127612. */
  127613. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  127614. /**
  127615. * Get a string representing the shaders built by the current node graph
  127616. */
  127617. get compiledShaders(): string;
  127618. /**
  127619. * Binds the world matrix to the material
  127620. * @param world defines the world transformation matrix
  127621. */
  127622. bindOnlyWorldMatrix(world: Matrix): void;
  127623. /**
  127624. * Binds the submesh to this material by preparing the effect and shader to draw
  127625. * @param world defines the world transformation matrix
  127626. * @param mesh defines the mesh containing the submesh
  127627. * @param subMesh defines the submesh to bind the material to
  127628. */
  127629. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  127630. /**
  127631. * Gets the active textures from the material
  127632. * @returns an array of textures
  127633. */
  127634. getActiveTextures(): BaseTexture[];
  127635. /**
  127636. * Gets the list of texture blocks
  127637. * @returns an array of texture blocks
  127638. */
  127639. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  127640. /**
  127641. * Specifies if the material uses a texture
  127642. * @param texture defines the texture to check against the material
  127643. * @returns a boolean specifying if the material uses the texture
  127644. */
  127645. hasTexture(texture: BaseTexture): boolean;
  127646. /**
  127647. * Disposes the material
  127648. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  127649. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  127650. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  127651. */
  127652. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  127653. /** Creates the node editor window. */
  127654. private _createNodeEditor;
  127655. /**
  127656. * Launch the node material editor
  127657. * @param config Define the configuration of the editor
  127658. * @return a promise fulfilled when the node editor is visible
  127659. */
  127660. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  127661. /**
  127662. * Clear the current material
  127663. */
  127664. clear(): void;
  127665. /**
  127666. * Clear the current material and set it to a default state
  127667. */
  127668. setToDefault(): void;
  127669. /**
  127670. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  127671. * @param url defines the url to load from
  127672. * @returns a promise that will fullfil when the material is fully loaded
  127673. */
  127674. loadAsync(url: string): Promise<void>;
  127675. private _gatherBlocks;
  127676. /**
  127677. * Generate a string containing the code declaration required to create an equivalent of this material
  127678. * @returns a string
  127679. */
  127680. generateCode(): string;
  127681. /**
  127682. * Serializes this material in a JSON representation
  127683. * @returns the serialized material object
  127684. */
  127685. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  127686. private _restoreConnections;
  127687. /**
  127688. * Clear the current graph and load a new one from a serialization object
  127689. * @param source defines the JSON representation of the material
  127690. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  127691. */
  127692. loadFromSerialization(source: any, rootUrl?: string): void;
  127693. /**
  127694. * Creates a node material from parsed material data
  127695. * @param source defines the JSON representation of the material
  127696. * @param scene defines the hosting scene
  127697. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  127698. * @returns a new node material
  127699. */
  127700. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  127701. /**
  127702. * Creates a new node material set to default basic configuration
  127703. * @param name defines the name of the material
  127704. * @param scene defines the hosting scene
  127705. * @returns a new NodeMaterial
  127706. */
  127707. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  127708. }
  127709. }
  127710. declare module BABYLON {
  127711. /**
  127712. * Block used to read a texture from a sampler
  127713. */
  127714. export class TextureBlock extends NodeMaterialBlock {
  127715. private _defineName;
  127716. private _linearDefineName;
  127717. private _tempTextureRead;
  127718. private _samplerName;
  127719. private _transformedUVName;
  127720. private _textureTransformName;
  127721. private _textureInfoName;
  127722. private _mainUVName;
  127723. private _mainUVDefineName;
  127724. /**
  127725. * Gets or sets the texture associated with the node
  127726. */
  127727. texture: Nullable<Texture>;
  127728. /**
  127729. * Create a new TextureBlock
  127730. * @param name defines the block name
  127731. */
  127732. constructor(name: string);
  127733. /**
  127734. * Gets the current class name
  127735. * @returns the class name
  127736. */
  127737. getClassName(): string;
  127738. /**
  127739. * Gets the uv input component
  127740. */
  127741. get uv(): NodeMaterialConnectionPoint;
  127742. /**
  127743. * Gets the rgba output component
  127744. */
  127745. get rgba(): NodeMaterialConnectionPoint;
  127746. /**
  127747. * Gets the rgb output component
  127748. */
  127749. get rgb(): NodeMaterialConnectionPoint;
  127750. /**
  127751. * Gets the r output component
  127752. */
  127753. get r(): NodeMaterialConnectionPoint;
  127754. /**
  127755. * Gets the g output component
  127756. */
  127757. get g(): NodeMaterialConnectionPoint;
  127758. /**
  127759. * Gets the b output component
  127760. */
  127761. get b(): NodeMaterialConnectionPoint;
  127762. /**
  127763. * Gets the a output component
  127764. */
  127765. get a(): NodeMaterialConnectionPoint;
  127766. get target(): NodeMaterialBlockTargets;
  127767. autoConfigure(material: NodeMaterial): void;
  127768. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  127769. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  127770. private _getTextureBase;
  127771. isReady(): boolean;
  127772. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  127773. private get _isMixed();
  127774. private _injectVertexCode;
  127775. private _writeTextureRead;
  127776. private _writeOutput;
  127777. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  127778. protected _dumpPropertiesCode(): string;
  127779. serialize(): any;
  127780. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  127781. }
  127782. }
  127783. declare module BABYLON {
  127784. /**
  127785. * Class used to store shared data between 2 NodeMaterialBuildState
  127786. */
  127787. export class NodeMaterialBuildStateSharedData {
  127788. /**
  127789. * Gets the list of emitted varyings
  127790. */
  127791. temps: string[];
  127792. /**
  127793. * Gets the list of emitted varyings
  127794. */
  127795. varyings: string[];
  127796. /**
  127797. * Gets the varying declaration string
  127798. */
  127799. varyingDeclaration: string;
  127800. /**
  127801. * Input blocks
  127802. */
  127803. inputBlocks: InputBlock[];
  127804. /**
  127805. * Input blocks
  127806. */
  127807. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  127808. /**
  127809. * Bindable blocks (Blocks that need to set data to the effect)
  127810. */
  127811. bindableBlocks: NodeMaterialBlock[];
  127812. /**
  127813. * List of blocks that can provide a compilation fallback
  127814. */
  127815. blocksWithFallbacks: NodeMaterialBlock[];
  127816. /**
  127817. * List of blocks that can provide a define update
  127818. */
  127819. blocksWithDefines: NodeMaterialBlock[];
  127820. /**
  127821. * List of blocks that can provide a repeatable content
  127822. */
  127823. repeatableContentBlocks: NodeMaterialBlock[];
  127824. /**
  127825. * List of blocks that can provide a dynamic list of uniforms
  127826. */
  127827. dynamicUniformBlocks: NodeMaterialBlock[];
  127828. /**
  127829. * List of blocks that can block the isReady function for the material
  127830. */
  127831. blockingBlocks: NodeMaterialBlock[];
  127832. /**
  127833. * Gets the list of animated inputs
  127834. */
  127835. animatedInputs: InputBlock[];
  127836. /**
  127837. * Build Id used to avoid multiple recompilations
  127838. */
  127839. buildId: number;
  127840. /** List of emitted variables */
  127841. variableNames: {
  127842. [key: string]: number;
  127843. };
  127844. /** List of emitted defines */
  127845. defineNames: {
  127846. [key: string]: number;
  127847. };
  127848. /** Should emit comments? */
  127849. emitComments: boolean;
  127850. /** Emit build activity */
  127851. verbose: boolean;
  127852. /** Gets or sets the hosting scene */
  127853. scene: Scene;
  127854. /**
  127855. * Gets the compilation hints emitted at compilation time
  127856. */
  127857. hints: {
  127858. needWorldViewMatrix: boolean;
  127859. needWorldViewProjectionMatrix: boolean;
  127860. needAlphaBlending: boolean;
  127861. needAlphaTesting: boolean;
  127862. };
  127863. /**
  127864. * List of compilation checks
  127865. */
  127866. checks: {
  127867. emitVertex: boolean;
  127868. emitFragment: boolean;
  127869. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  127870. };
  127871. /** Creates a new shared data */
  127872. constructor();
  127873. /**
  127874. * Emits console errors and exceptions if there is a failing check
  127875. */
  127876. emitErrors(): void;
  127877. }
  127878. }
  127879. declare module BABYLON {
  127880. /**
  127881. * Class used to store node based material build state
  127882. */
  127883. export class NodeMaterialBuildState {
  127884. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  127885. supportUniformBuffers: boolean;
  127886. /**
  127887. * Gets the list of emitted attributes
  127888. */
  127889. attributes: string[];
  127890. /**
  127891. * Gets the list of emitted uniforms
  127892. */
  127893. uniforms: string[];
  127894. /**
  127895. * Gets the list of emitted constants
  127896. */
  127897. constants: string[];
  127898. /**
  127899. * Gets the list of emitted samplers
  127900. */
  127901. samplers: string[];
  127902. /**
  127903. * Gets the list of emitted functions
  127904. */
  127905. functions: {
  127906. [key: string]: string;
  127907. };
  127908. /**
  127909. * Gets the list of emitted extensions
  127910. */
  127911. extensions: {
  127912. [key: string]: string;
  127913. };
  127914. /**
  127915. * Gets the target of the compilation state
  127916. */
  127917. target: NodeMaterialBlockTargets;
  127918. /**
  127919. * Gets the list of emitted counters
  127920. */
  127921. counters: {
  127922. [key: string]: number;
  127923. };
  127924. /**
  127925. * Shared data between multiple NodeMaterialBuildState instances
  127926. */
  127927. sharedData: NodeMaterialBuildStateSharedData;
  127928. /** @hidden */
  127929. _vertexState: NodeMaterialBuildState;
  127930. /** @hidden */
  127931. _attributeDeclaration: string;
  127932. /** @hidden */
  127933. _uniformDeclaration: string;
  127934. /** @hidden */
  127935. _constantDeclaration: string;
  127936. /** @hidden */
  127937. _samplerDeclaration: string;
  127938. /** @hidden */
  127939. _varyingTransfer: string;
  127940. private _repeatableContentAnchorIndex;
  127941. /** @hidden */
  127942. _builtCompilationString: string;
  127943. /**
  127944. * Gets the emitted compilation strings
  127945. */
  127946. compilationString: string;
  127947. /**
  127948. * Finalize the compilation strings
  127949. * @param state defines the current compilation state
  127950. */
  127951. finalize(state: NodeMaterialBuildState): void;
  127952. /** @hidden */
  127953. get _repeatableContentAnchor(): string;
  127954. /** @hidden */
  127955. _getFreeVariableName(prefix: string): string;
  127956. /** @hidden */
  127957. _getFreeDefineName(prefix: string): string;
  127958. /** @hidden */
  127959. _excludeVariableName(name: string): void;
  127960. /** @hidden */
  127961. _emit2DSampler(name: string): void;
  127962. /** @hidden */
  127963. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  127964. /** @hidden */
  127965. _emitExtension(name: string, extension: string): void;
  127966. /** @hidden */
  127967. _emitFunction(name: string, code: string, comments: string): void;
  127968. /** @hidden */
  127969. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  127970. replaceStrings?: {
  127971. search: RegExp;
  127972. replace: string;
  127973. }[];
  127974. repeatKey?: string;
  127975. }): string;
  127976. /** @hidden */
  127977. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  127978. repeatKey?: string;
  127979. removeAttributes?: boolean;
  127980. removeUniforms?: boolean;
  127981. removeVaryings?: boolean;
  127982. removeIfDef?: boolean;
  127983. replaceStrings?: {
  127984. search: RegExp;
  127985. replace: string;
  127986. }[];
  127987. }, storeKey?: string): void;
  127988. /** @hidden */
  127989. _registerTempVariable(name: string): boolean;
  127990. /** @hidden */
  127991. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  127992. /** @hidden */
  127993. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  127994. /** @hidden */
  127995. _emitFloat(value: number): string;
  127996. }
  127997. }
  127998. declare module BABYLON {
  127999. /**
  128000. * Defines a block that can be used inside a node based material
  128001. */
  128002. export class NodeMaterialBlock {
  128003. private _buildId;
  128004. private _buildTarget;
  128005. private _target;
  128006. private _isFinalMerger;
  128007. private _isInput;
  128008. protected _isUnique: boolean;
  128009. /** @hidden */
  128010. _codeVariableName: string;
  128011. /** @hidden */
  128012. _inputs: NodeMaterialConnectionPoint[];
  128013. /** @hidden */
  128014. _outputs: NodeMaterialConnectionPoint[];
  128015. /** @hidden */
  128016. _preparationId: number;
  128017. /**
  128018. * Gets or sets the name of the block
  128019. */
  128020. name: string;
  128021. /**
  128022. * Gets or sets the unique id of the node
  128023. */
  128024. uniqueId: number;
  128025. /**
  128026. * Gets or sets the comments associated with this block
  128027. */
  128028. comments: string;
  128029. /**
  128030. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  128031. */
  128032. get isUnique(): boolean;
  128033. /**
  128034. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  128035. */
  128036. get isFinalMerger(): boolean;
  128037. /**
  128038. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  128039. */
  128040. get isInput(): boolean;
  128041. /**
  128042. * Gets or sets the build Id
  128043. */
  128044. get buildId(): number;
  128045. set buildId(value: number);
  128046. /**
  128047. * Gets or sets the target of the block
  128048. */
  128049. get target(): NodeMaterialBlockTargets;
  128050. set target(value: NodeMaterialBlockTargets);
  128051. /**
  128052. * Gets the list of input points
  128053. */
  128054. get inputs(): NodeMaterialConnectionPoint[];
  128055. /** Gets the list of output points */
  128056. get outputs(): NodeMaterialConnectionPoint[];
  128057. /**
  128058. * Find an input by its name
  128059. * @param name defines the name of the input to look for
  128060. * @returns the input or null if not found
  128061. */
  128062. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  128063. /**
  128064. * Find an output by its name
  128065. * @param name defines the name of the outputto look for
  128066. * @returns the output or null if not found
  128067. */
  128068. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  128069. /**
  128070. * Creates a new NodeMaterialBlock
  128071. * @param name defines the block name
  128072. * @param target defines the target of that block (Vertex by default)
  128073. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  128074. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  128075. */
  128076. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  128077. /**
  128078. * Initialize the block and prepare the context for build
  128079. * @param state defines the state that will be used for the build
  128080. */
  128081. initialize(state: NodeMaterialBuildState): void;
  128082. /**
  128083. * Bind data to effect. Will only be called for blocks with isBindable === true
  128084. * @param effect defines the effect to bind data to
  128085. * @param nodeMaterial defines the hosting NodeMaterial
  128086. * @param mesh defines the mesh that will be rendered
  128087. */
  128088. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128089. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  128090. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  128091. protected _writeFloat(value: number): string;
  128092. /**
  128093. * Gets the current class name e.g. "NodeMaterialBlock"
  128094. * @returns the class name
  128095. */
  128096. getClassName(): string;
  128097. /**
  128098. * Register a new input. Must be called inside a block constructor
  128099. * @param name defines the connection point name
  128100. * @param type defines the connection point type
  128101. * @param isOptional defines a boolean indicating that this input can be omitted
  128102. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  128103. * @returns the current block
  128104. */
  128105. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  128106. /**
  128107. * Register a new output. Must be called inside a block constructor
  128108. * @param name defines the connection point name
  128109. * @param type defines the connection point type
  128110. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  128111. * @returns the current block
  128112. */
  128113. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  128114. /**
  128115. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  128116. * @param forOutput defines an optional connection point to check compatibility with
  128117. * @returns the first available input or null
  128118. */
  128119. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  128120. /**
  128121. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  128122. * @param forBlock defines an optional block to check compatibility with
  128123. * @returns the first available input or null
  128124. */
  128125. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  128126. /**
  128127. * Gets the sibling of the given output
  128128. * @param current defines the current output
  128129. * @returns the next output in the list or null
  128130. */
  128131. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  128132. /**
  128133. * Connect current block with another block
  128134. * @param other defines the block to connect with
  128135. * @param options define the various options to help pick the right connections
  128136. * @returns the current block
  128137. */
  128138. connectTo(other: NodeMaterialBlock, options?: {
  128139. input?: string;
  128140. output?: string;
  128141. outputSwizzle?: string;
  128142. }): this | undefined;
  128143. protected _buildBlock(state: NodeMaterialBuildState): void;
  128144. /**
  128145. * Add uniforms, samplers and uniform buffers at compilation time
  128146. * @param state defines the state to update
  128147. * @param nodeMaterial defines the node material requesting the update
  128148. * @param defines defines the material defines to update
  128149. * @param uniformBuffers defines the list of uniform buffer names
  128150. */
  128151. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  128152. /**
  128153. * Add potential fallbacks if shader compilation fails
  128154. * @param mesh defines the mesh to be rendered
  128155. * @param fallbacks defines the current prioritized list of fallbacks
  128156. */
  128157. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  128158. /**
  128159. * Initialize defines for shader compilation
  128160. * @param mesh defines the mesh to be rendered
  128161. * @param nodeMaterial defines the node material requesting the update
  128162. * @param defines defines the material defines to update
  128163. * @param useInstances specifies that instances should be used
  128164. */
  128165. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  128166. /**
  128167. * Update defines for shader compilation
  128168. * @param mesh defines the mesh to be rendered
  128169. * @param nodeMaterial defines the node material requesting the update
  128170. * @param defines defines the material defines to update
  128171. * @param useInstances specifies that instances should be used
  128172. */
  128173. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  128174. /**
  128175. * Lets the block try to connect some inputs automatically
  128176. * @param material defines the hosting NodeMaterial
  128177. */
  128178. autoConfigure(material: NodeMaterial): void;
  128179. /**
  128180. * Function called when a block is declared as repeatable content generator
  128181. * @param vertexShaderState defines the current compilation state for the vertex shader
  128182. * @param fragmentShaderState defines the current compilation state for the fragment shader
  128183. * @param mesh defines the mesh to be rendered
  128184. * @param defines defines the material defines to update
  128185. */
  128186. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  128187. /**
  128188. * Checks if the block is ready
  128189. * @param mesh defines the mesh to be rendered
  128190. * @param nodeMaterial defines the node material requesting the update
  128191. * @param defines defines the material defines to update
  128192. * @param useInstances specifies that instances should be used
  128193. * @returns true if the block is ready
  128194. */
  128195. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  128196. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  128197. private _processBuild;
  128198. /**
  128199. * Compile the current node and generate the shader code
  128200. * @param state defines the current compilation state (uniforms, samplers, current string)
  128201. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  128202. * @returns true if already built
  128203. */
  128204. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  128205. protected _inputRename(name: string): string;
  128206. protected _outputRename(name: string): string;
  128207. protected _dumpPropertiesCode(): string;
  128208. /** @hidden */
  128209. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  128210. /** @hidden */
  128211. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  128212. /**
  128213. * Clone the current block to a new identical block
  128214. * @param scene defines the hosting scene
  128215. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  128216. * @returns a copy of the current block
  128217. */
  128218. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  128219. /**
  128220. * Serializes this block in a JSON representation
  128221. * @returns the serialized block object
  128222. */
  128223. serialize(): any;
  128224. /** @hidden */
  128225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128226. /**
  128227. * Release resources
  128228. */
  128229. dispose(): void;
  128230. }
  128231. }
  128232. declare module BABYLON {
  128233. /**
  128234. * Enum defining the type of animations supported by InputBlock
  128235. */
  128236. export enum AnimatedInputBlockTypes {
  128237. /** No animation */
  128238. None = 0,
  128239. /** Time based animation. Will only work for floats */
  128240. Time = 1
  128241. }
  128242. }
  128243. declare module BABYLON {
  128244. /**
  128245. * Block used to expose an input value
  128246. */
  128247. export class InputBlock extends NodeMaterialBlock {
  128248. private _mode;
  128249. private _associatedVariableName;
  128250. private _storedValue;
  128251. private _valueCallback;
  128252. private _type;
  128253. private _animationType;
  128254. /** Gets or set a value used to limit the range of float values */
  128255. min: number;
  128256. /** Gets or set a value used to limit the range of float values */
  128257. max: number;
  128258. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  128259. matrixMode: number;
  128260. /** @hidden */
  128261. _systemValue: Nullable<NodeMaterialSystemValues>;
  128262. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  128263. visibleInInspector: boolean;
  128264. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  128265. isConstant: boolean;
  128266. /** Gets or sets the group to use to display this block in the Inspector */
  128267. groupInInspector: string;
  128268. /**
  128269. * Gets or sets the connection point type (default is float)
  128270. */
  128271. get type(): NodeMaterialBlockConnectionPointTypes;
  128272. /**
  128273. * Creates a new InputBlock
  128274. * @param name defines the block name
  128275. * @param target defines the target of that block (Vertex by default)
  128276. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  128277. */
  128278. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  128279. /**
  128280. * Gets the output component
  128281. */
  128282. get output(): NodeMaterialConnectionPoint;
  128283. /**
  128284. * Set the source of this connection point to a vertex attribute
  128285. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  128286. * @returns the current connection point
  128287. */
  128288. setAsAttribute(attributeName?: string): InputBlock;
  128289. /**
  128290. * Set the source of this connection point to a system value
  128291. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  128292. * @returns the current connection point
  128293. */
  128294. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  128295. /**
  128296. * Gets or sets the value of that point.
  128297. * Please note that this value will be ignored if valueCallback is defined
  128298. */
  128299. get value(): any;
  128300. set value(value: any);
  128301. /**
  128302. * Gets or sets a callback used to get the value of that point.
  128303. * Please note that setting this value will force the connection point to ignore the value property
  128304. */
  128305. get valueCallback(): () => any;
  128306. set valueCallback(value: () => any);
  128307. /**
  128308. * Gets or sets the associated variable name in the shader
  128309. */
  128310. get associatedVariableName(): string;
  128311. set associatedVariableName(value: string);
  128312. /** Gets or sets the type of animation applied to the input */
  128313. get animationType(): AnimatedInputBlockTypes;
  128314. set animationType(value: AnimatedInputBlockTypes);
  128315. /**
  128316. * Gets a boolean indicating that this connection point not defined yet
  128317. */
  128318. get isUndefined(): boolean;
  128319. /**
  128320. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  128321. * In this case the connection point name must be the name of the uniform to use.
  128322. * Can only be set on inputs
  128323. */
  128324. get isUniform(): boolean;
  128325. set isUniform(value: boolean);
  128326. /**
  128327. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  128328. * In this case the connection point name must be the name of the attribute to use
  128329. * Can only be set on inputs
  128330. */
  128331. get isAttribute(): boolean;
  128332. set isAttribute(value: boolean);
  128333. /**
  128334. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  128335. * Can only be set on exit points
  128336. */
  128337. get isVarying(): boolean;
  128338. set isVarying(value: boolean);
  128339. /**
  128340. * Gets a boolean indicating that the current connection point is a system value
  128341. */
  128342. get isSystemValue(): boolean;
  128343. /**
  128344. * Gets or sets the current well known value or null if not defined as a system value
  128345. */
  128346. get systemValue(): Nullable<NodeMaterialSystemValues>;
  128347. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  128348. /**
  128349. * Gets the current class name
  128350. * @returns the class name
  128351. */
  128352. getClassName(): string;
  128353. /**
  128354. * Animate the input if animationType !== None
  128355. * @param scene defines the rendering scene
  128356. */
  128357. animate(scene: Scene): void;
  128358. private _emitDefine;
  128359. initialize(state: NodeMaterialBuildState): void;
  128360. /**
  128361. * Set the input block to its default value (based on its type)
  128362. */
  128363. setDefaultValue(): void;
  128364. private _emitConstant;
  128365. private _emit;
  128366. /** @hidden */
  128367. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  128368. /** @hidden */
  128369. _transmit(effect: Effect, scene: Scene): void;
  128370. protected _buildBlock(state: NodeMaterialBuildState): void;
  128371. protected _dumpPropertiesCode(): string;
  128372. serialize(): any;
  128373. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128374. }
  128375. }
  128376. declare module BABYLON {
  128377. /**
  128378. * Enum used to define the compatibility state between two connection points
  128379. */
  128380. export enum NodeMaterialConnectionPointCompatibilityStates {
  128381. /** Points are compatibles */
  128382. Compatible = 0,
  128383. /** Points are incompatible because of their types */
  128384. TypeIncompatible = 1,
  128385. /** Points are incompatible because of their targets (vertex vs fragment) */
  128386. TargetIncompatible = 2
  128387. }
  128388. /**
  128389. * Defines the direction of a connection point
  128390. */
  128391. export enum NodeMaterialConnectionPointDirection {
  128392. /** Input */
  128393. Input = 0,
  128394. /** Output */
  128395. Output = 1
  128396. }
  128397. /**
  128398. * Defines a connection point for a block
  128399. */
  128400. export class NodeMaterialConnectionPoint {
  128401. /** @hidden */
  128402. _ownerBlock: NodeMaterialBlock;
  128403. /** @hidden */
  128404. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  128405. private _endpoints;
  128406. private _associatedVariableName;
  128407. private _direction;
  128408. /** @hidden */
  128409. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  128410. /** @hidden */
  128411. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  128412. private _type;
  128413. /** @hidden */
  128414. _enforceAssociatedVariableName: boolean;
  128415. /** Gets the direction of the point */
  128416. get direction(): NodeMaterialConnectionPointDirection;
  128417. /**
  128418. * Gets or sets the additional types supported by this connection point
  128419. */
  128420. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  128421. /**
  128422. * Gets or sets the additional types excluded by this connection point
  128423. */
  128424. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  128425. /**
  128426. * Observable triggered when this point is connected
  128427. */
  128428. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  128429. /**
  128430. * Gets or sets the associated variable name in the shader
  128431. */
  128432. get associatedVariableName(): string;
  128433. set associatedVariableName(value: string);
  128434. /**
  128435. * Gets or sets the connection point type (default is float)
  128436. */
  128437. get type(): NodeMaterialBlockConnectionPointTypes;
  128438. set type(value: NodeMaterialBlockConnectionPointTypes);
  128439. /**
  128440. * Gets or sets the connection point name
  128441. */
  128442. name: string;
  128443. /**
  128444. * Gets or sets a boolean indicating that this connection point can be omitted
  128445. */
  128446. isOptional: boolean;
  128447. /**
  128448. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  128449. */
  128450. define: string;
  128451. /** @hidden */
  128452. _prioritizeVertex: boolean;
  128453. private _target;
  128454. /** Gets or sets the target of that connection point */
  128455. get target(): NodeMaterialBlockTargets;
  128456. set target(value: NodeMaterialBlockTargets);
  128457. /**
  128458. * Gets a boolean indicating that the current point is connected
  128459. */
  128460. get isConnected(): boolean;
  128461. /**
  128462. * Gets a boolean indicating that the current point is connected to an input block
  128463. */
  128464. get isConnectedToInputBlock(): boolean;
  128465. /**
  128466. * Gets a the connected input block (if any)
  128467. */
  128468. get connectInputBlock(): Nullable<InputBlock>;
  128469. /** Get the other side of the connection (if any) */
  128470. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  128471. /** Get the block that owns this connection point */
  128472. get ownerBlock(): NodeMaterialBlock;
  128473. /** Get the block connected on the other side of this connection (if any) */
  128474. get sourceBlock(): Nullable<NodeMaterialBlock>;
  128475. /** Get the block connected on the endpoints of this connection (if any) */
  128476. get connectedBlocks(): Array<NodeMaterialBlock>;
  128477. /** Gets the list of connected endpoints */
  128478. get endpoints(): NodeMaterialConnectionPoint[];
  128479. /** Gets a boolean indicating if that output point is connected to at least one input */
  128480. get hasEndpoints(): boolean;
  128481. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  128482. get isConnectedInVertexShader(): boolean;
  128483. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  128484. get isConnectedInFragmentShader(): boolean;
  128485. /**
  128486. * Creates a new connection point
  128487. * @param name defines the connection point name
  128488. * @param ownerBlock defines the block hosting this connection point
  128489. * @param direction defines the direction of the connection point
  128490. */
  128491. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  128492. /**
  128493. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  128494. * @returns the class name
  128495. */
  128496. getClassName(): string;
  128497. /**
  128498. * Gets a boolean indicating if the current point can be connected to another point
  128499. * @param connectionPoint defines the other connection point
  128500. * @returns a boolean
  128501. */
  128502. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  128503. /**
  128504. * Gets a number indicating if the current point can be connected to another point
  128505. * @param connectionPoint defines the other connection point
  128506. * @returns a number defining the compatibility state
  128507. */
  128508. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  128509. /**
  128510. * Connect this point to another connection point
  128511. * @param connectionPoint defines the other connection point
  128512. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  128513. * @returns the current connection point
  128514. */
  128515. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  128516. /**
  128517. * Disconnect this point from one of his endpoint
  128518. * @param endpoint defines the other connection point
  128519. * @returns the current connection point
  128520. */
  128521. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  128522. /**
  128523. * Serializes this point in a JSON representation
  128524. * @returns the serialized point object
  128525. */
  128526. serialize(): any;
  128527. /**
  128528. * Release resources
  128529. */
  128530. dispose(): void;
  128531. }
  128532. }
  128533. declare module BABYLON {
  128534. /**
  128535. * Block used to add support for vertex skinning (bones)
  128536. */
  128537. export class BonesBlock extends NodeMaterialBlock {
  128538. /**
  128539. * Creates a new BonesBlock
  128540. * @param name defines the block name
  128541. */
  128542. constructor(name: string);
  128543. /**
  128544. * Initialize the block and prepare the context for build
  128545. * @param state defines the state that will be used for the build
  128546. */
  128547. initialize(state: NodeMaterialBuildState): void;
  128548. /**
  128549. * Gets the current class name
  128550. * @returns the class name
  128551. */
  128552. getClassName(): string;
  128553. /**
  128554. * Gets the matrix indices input component
  128555. */
  128556. get matricesIndices(): NodeMaterialConnectionPoint;
  128557. /**
  128558. * Gets the matrix weights input component
  128559. */
  128560. get matricesWeights(): NodeMaterialConnectionPoint;
  128561. /**
  128562. * Gets the extra matrix indices input component
  128563. */
  128564. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  128565. /**
  128566. * Gets the extra matrix weights input component
  128567. */
  128568. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  128569. /**
  128570. * Gets the world input component
  128571. */
  128572. get world(): NodeMaterialConnectionPoint;
  128573. /**
  128574. * Gets the output component
  128575. */
  128576. get output(): NodeMaterialConnectionPoint;
  128577. autoConfigure(material: NodeMaterial): void;
  128578. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  128579. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128580. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128581. protected _buildBlock(state: NodeMaterialBuildState): this;
  128582. }
  128583. }
  128584. declare module BABYLON {
  128585. /**
  128586. * Block used to add support for instances
  128587. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  128588. */
  128589. export class InstancesBlock extends NodeMaterialBlock {
  128590. /**
  128591. * Creates a new InstancesBlock
  128592. * @param name defines the block name
  128593. */
  128594. constructor(name: string);
  128595. /**
  128596. * Gets the current class name
  128597. * @returns the class name
  128598. */
  128599. getClassName(): string;
  128600. /**
  128601. * Gets the first world row input component
  128602. */
  128603. get world0(): NodeMaterialConnectionPoint;
  128604. /**
  128605. * Gets the second world row input component
  128606. */
  128607. get world1(): NodeMaterialConnectionPoint;
  128608. /**
  128609. * Gets the third world row input component
  128610. */
  128611. get world2(): NodeMaterialConnectionPoint;
  128612. /**
  128613. * Gets the forth world row input component
  128614. */
  128615. get world3(): NodeMaterialConnectionPoint;
  128616. /**
  128617. * Gets the world input component
  128618. */
  128619. get world(): NodeMaterialConnectionPoint;
  128620. /**
  128621. * Gets the output component
  128622. */
  128623. get output(): NodeMaterialConnectionPoint;
  128624. autoConfigure(material: NodeMaterial): void;
  128625. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  128626. protected _buildBlock(state: NodeMaterialBuildState): this;
  128627. }
  128628. }
  128629. declare module BABYLON {
  128630. /**
  128631. * Block used to add morph targets support to vertex shader
  128632. */
  128633. export class MorphTargetsBlock extends NodeMaterialBlock {
  128634. private _repeatableContentAnchor;
  128635. private _repeatebleContentGenerated;
  128636. /**
  128637. * Create a new MorphTargetsBlock
  128638. * @param name defines the block name
  128639. */
  128640. constructor(name: string);
  128641. /**
  128642. * Gets the current class name
  128643. * @returns the class name
  128644. */
  128645. getClassName(): string;
  128646. /**
  128647. * Gets the position input component
  128648. */
  128649. get position(): NodeMaterialConnectionPoint;
  128650. /**
  128651. * Gets the normal input component
  128652. */
  128653. get normal(): NodeMaterialConnectionPoint;
  128654. /**
  128655. * Gets the tangent input component
  128656. */
  128657. get tangent(): NodeMaterialConnectionPoint;
  128658. /**
  128659. * Gets the tangent input component
  128660. */
  128661. get uv(): NodeMaterialConnectionPoint;
  128662. /**
  128663. * Gets the position output component
  128664. */
  128665. get positionOutput(): NodeMaterialConnectionPoint;
  128666. /**
  128667. * Gets the normal output component
  128668. */
  128669. get normalOutput(): NodeMaterialConnectionPoint;
  128670. /**
  128671. * Gets the tangent output component
  128672. */
  128673. get tangentOutput(): NodeMaterialConnectionPoint;
  128674. /**
  128675. * Gets the tangent output component
  128676. */
  128677. get uvOutput(): NodeMaterialConnectionPoint;
  128678. initialize(state: NodeMaterialBuildState): void;
  128679. autoConfigure(material: NodeMaterial): void;
  128680. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128681. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128682. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  128683. protected _buildBlock(state: NodeMaterialBuildState): this;
  128684. }
  128685. }
  128686. declare module BABYLON {
  128687. /**
  128688. * Block used to get data information from a light
  128689. */
  128690. export class LightInformationBlock extends NodeMaterialBlock {
  128691. private _lightDataUniformName;
  128692. private _lightColorUniformName;
  128693. private _lightTypeDefineName;
  128694. /**
  128695. * Gets or sets the light associated with this block
  128696. */
  128697. light: Nullable<Light>;
  128698. /**
  128699. * Creates a new LightInformationBlock
  128700. * @param name defines the block name
  128701. */
  128702. constructor(name: string);
  128703. /**
  128704. * Gets the current class name
  128705. * @returns the class name
  128706. */
  128707. getClassName(): string;
  128708. /**
  128709. * Gets the world position input component
  128710. */
  128711. get worldPosition(): NodeMaterialConnectionPoint;
  128712. /**
  128713. * Gets the direction output component
  128714. */
  128715. get direction(): NodeMaterialConnectionPoint;
  128716. /**
  128717. * Gets the direction output component
  128718. */
  128719. get color(): NodeMaterialConnectionPoint;
  128720. /**
  128721. * Gets the direction output component
  128722. */
  128723. get intensity(): NodeMaterialConnectionPoint;
  128724. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128726. protected _buildBlock(state: NodeMaterialBuildState): this;
  128727. serialize(): any;
  128728. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128729. }
  128730. }
  128731. declare module BABYLON {
  128732. /**
  128733. * Block used to add image processing support to fragment shader
  128734. */
  128735. export class ImageProcessingBlock extends NodeMaterialBlock {
  128736. /**
  128737. * Create a new ImageProcessingBlock
  128738. * @param name defines the block name
  128739. */
  128740. constructor(name: string);
  128741. /**
  128742. * Gets the current class name
  128743. * @returns the class name
  128744. */
  128745. getClassName(): string;
  128746. /**
  128747. * Gets the color input component
  128748. */
  128749. get color(): NodeMaterialConnectionPoint;
  128750. /**
  128751. * Gets the output component
  128752. */
  128753. get output(): NodeMaterialConnectionPoint;
  128754. /**
  128755. * Initialize the block and prepare the context for build
  128756. * @param state defines the state that will be used for the build
  128757. */
  128758. initialize(state: NodeMaterialBuildState): void;
  128759. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  128760. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128761. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128762. protected _buildBlock(state: NodeMaterialBuildState): this;
  128763. }
  128764. }
  128765. declare module BABYLON {
  128766. /**
  128767. * Block used to pertub normals based on a normal map
  128768. */
  128769. export class PerturbNormalBlock extends NodeMaterialBlock {
  128770. private _tangentSpaceParameterName;
  128771. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  128772. invertX: boolean;
  128773. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  128774. invertY: boolean;
  128775. /**
  128776. * Create a new PerturbNormalBlock
  128777. * @param name defines the block name
  128778. */
  128779. constructor(name: string);
  128780. /**
  128781. * Gets the current class name
  128782. * @returns the class name
  128783. */
  128784. getClassName(): string;
  128785. /**
  128786. * Gets the world position input component
  128787. */
  128788. get worldPosition(): NodeMaterialConnectionPoint;
  128789. /**
  128790. * Gets the world normal input component
  128791. */
  128792. get worldNormal(): NodeMaterialConnectionPoint;
  128793. /**
  128794. * Gets the uv input component
  128795. */
  128796. get uv(): NodeMaterialConnectionPoint;
  128797. /**
  128798. * Gets the normal map color input component
  128799. */
  128800. get normalMapColor(): NodeMaterialConnectionPoint;
  128801. /**
  128802. * Gets the strength input component
  128803. */
  128804. get strength(): NodeMaterialConnectionPoint;
  128805. /**
  128806. * Gets the output component
  128807. */
  128808. get output(): NodeMaterialConnectionPoint;
  128809. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128810. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128811. autoConfigure(material: NodeMaterial): void;
  128812. protected _buildBlock(state: NodeMaterialBuildState): this;
  128813. protected _dumpPropertiesCode(): string;
  128814. serialize(): any;
  128815. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  128816. }
  128817. }
  128818. declare module BABYLON {
  128819. /**
  128820. * Block used to discard a pixel if a value is smaller than a cutoff
  128821. */
  128822. export class DiscardBlock extends NodeMaterialBlock {
  128823. /**
  128824. * Create a new DiscardBlock
  128825. * @param name defines the block name
  128826. */
  128827. constructor(name: string);
  128828. /**
  128829. * Gets the current class name
  128830. * @returns the class name
  128831. */
  128832. getClassName(): string;
  128833. /**
  128834. * Gets the color input component
  128835. */
  128836. get value(): NodeMaterialConnectionPoint;
  128837. /**
  128838. * Gets the cutoff input component
  128839. */
  128840. get cutoff(): NodeMaterialConnectionPoint;
  128841. protected _buildBlock(state: NodeMaterialBuildState): this;
  128842. }
  128843. }
  128844. declare module BABYLON {
  128845. /**
  128846. * Block used to test if the fragment shader is front facing
  128847. */
  128848. export class FrontFacingBlock extends NodeMaterialBlock {
  128849. /**
  128850. * Creates a new FrontFacingBlock
  128851. * @param name defines the block name
  128852. */
  128853. constructor(name: string);
  128854. /**
  128855. * Gets the current class name
  128856. * @returns the class name
  128857. */
  128858. getClassName(): string;
  128859. /**
  128860. * Gets the output component
  128861. */
  128862. get output(): NodeMaterialConnectionPoint;
  128863. protected _buildBlock(state: NodeMaterialBuildState): this;
  128864. }
  128865. }
  128866. declare module BABYLON {
  128867. /**
  128868. * Block used to get the derivative value on x and y of a given input
  128869. */
  128870. export class DerivativeBlock extends NodeMaterialBlock {
  128871. /**
  128872. * Create a new DerivativeBlock
  128873. * @param name defines the block name
  128874. */
  128875. constructor(name: string);
  128876. /**
  128877. * Gets the current class name
  128878. * @returns the class name
  128879. */
  128880. getClassName(): string;
  128881. /**
  128882. * Gets the input component
  128883. */
  128884. get input(): NodeMaterialConnectionPoint;
  128885. /**
  128886. * Gets the derivative output on x
  128887. */
  128888. get dx(): NodeMaterialConnectionPoint;
  128889. /**
  128890. * Gets the derivative output on y
  128891. */
  128892. get dy(): NodeMaterialConnectionPoint;
  128893. protected _buildBlock(state: NodeMaterialBuildState): this;
  128894. }
  128895. }
  128896. declare module BABYLON {
  128897. /**
  128898. * Block used to add support for scene fog
  128899. */
  128900. export class FogBlock extends NodeMaterialBlock {
  128901. private _fogDistanceName;
  128902. private _fogParameters;
  128903. /**
  128904. * Create a new FogBlock
  128905. * @param name defines the block name
  128906. */
  128907. constructor(name: string);
  128908. /**
  128909. * Gets the current class name
  128910. * @returns the class name
  128911. */
  128912. getClassName(): string;
  128913. /**
  128914. * Gets the world position input component
  128915. */
  128916. get worldPosition(): NodeMaterialConnectionPoint;
  128917. /**
  128918. * Gets the view input component
  128919. */
  128920. get view(): NodeMaterialConnectionPoint;
  128921. /**
  128922. * Gets the color input component
  128923. */
  128924. get input(): NodeMaterialConnectionPoint;
  128925. /**
  128926. * Gets the fog color input component
  128927. */
  128928. get fogColor(): NodeMaterialConnectionPoint;
  128929. /**
  128930. * Gets the output component
  128931. */
  128932. get output(): NodeMaterialConnectionPoint;
  128933. autoConfigure(material: NodeMaterial): void;
  128934. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  128935. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  128936. protected _buildBlock(state: NodeMaterialBuildState): this;
  128937. }
  128938. }
  128939. declare module BABYLON {
  128940. /**
  128941. * Block used to add light in the fragment shader
  128942. */
  128943. export class LightBlock extends NodeMaterialBlock {
  128944. private _lightId;
  128945. /**
  128946. * Gets or sets the light associated with this block
  128947. */
  128948. light: Nullable<Light>;
  128949. /**
  128950. * Create a new LightBlock
  128951. * @param name defines the block name
  128952. */
  128953. constructor(name: string);
  128954. /**
  128955. * Gets the current class name
  128956. * @returns the class name
  128957. */
  128958. getClassName(): string;
  128959. /**
  128960. * Gets the world position input component
  128961. */
  128962. get worldPosition(): NodeMaterialConnectionPoint;
  128963. /**
  128964. * Gets the world normal input component
  128965. */
  128966. get worldNormal(): NodeMaterialConnectionPoint;
  128967. /**
  128968. * Gets the camera (or eye) position component
  128969. */
  128970. get cameraPosition(): NodeMaterialConnectionPoint;
  128971. /**
  128972. * Gets the glossiness component
  128973. */
  128974. get glossiness(): NodeMaterialConnectionPoint;
  128975. /**
  128976. * Gets the glossinness power component
  128977. */
  128978. get glossPower(): NodeMaterialConnectionPoint;
  128979. /**
  128980. * Gets the diffuse color component
  128981. */
  128982. get diffuseColor(): NodeMaterialConnectionPoint;
  128983. /**
  128984. * Gets the specular color component
  128985. */
  128986. get specularColor(): NodeMaterialConnectionPoint;
  128987. /**
  128988. * Gets the diffuse output component
  128989. */
  128990. get diffuseOutput(): NodeMaterialConnectionPoint;
  128991. /**
  128992. * Gets the specular output component
  128993. */
  128994. get specularOutput(): NodeMaterialConnectionPoint;
  128995. /**
  128996. * Gets the shadow output component
  128997. */
  128998. get shadow(): NodeMaterialConnectionPoint;
  128999. autoConfigure(material: NodeMaterial): void;
  129000. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  129001. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  129002. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  129003. private _injectVertexCode;
  129004. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129005. serialize(): any;
  129006. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129007. }
  129008. }
  129009. declare module BABYLON {
  129010. /**
  129011. * Block used to multiply 2 values
  129012. */
  129013. export class MultiplyBlock extends NodeMaterialBlock {
  129014. /**
  129015. * Creates a new MultiplyBlock
  129016. * @param name defines the block name
  129017. */
  129018. constructor(name: string);
  129019. /**
  129020. * Gets the current class name
  129021. * @returns the class name
  129022. */
  129023. getClassName(): string;
  129024. /**
  129025. * Gets the left operand input component
  129026. */
  129027. get left(): NodeMaterialConnectionPoint;
  129028. /**
  129029. * Gets the right operand input component
  129030. */
  129031. get right(): NodeMaterialConnectionPoint;
  129032. /**
  129033. * Gets the output component
  129034. */
  129035. get output(): NodeMaterialConnectionPoint;
  129036. protected _buildBlock(state: NodeMaterialBuildState): this;
  129037. }
  129038. }
  129039. declare module BABYLON {
  129040. /**
  129041. * Block used to add 2 vectors
  129042. */
  129043. export class AddBlock extends NodeMaterialBlock {
  129044. /**
  129045. * Creates a new AddBlock
  129046. * @param name defines the block name
  129047. */
  129048. constructor(name: string);
  129049. /**
  129050. * Gets the current class name
  129051. * @returns the class name
  129052. */
  129053. getClassName(): string;
  129054. /**
  129055. * Gets the left operand input component
  129056. */
  129057. get left(): NodeMaterialConnectionPoint;
  129058. /**
  129059. * Gets the right operand input component
  129060. */
  129061. get right(): NodeMaterialConnectionPoint;
  129062. /**
  129063. * Gets the output component
  129064. */
  129065. get output(): NodeMaterialConnectionPoint;
  129066. protected _buildBlock(state: NodeMaterialBuildState): this;
  129067. }
  129068. }
  129069. declare module BABYLON {
  129070. /**
  129071. * Block used to scale a vector by a float
  129072. */
  129073. export class ScaleBlock extends NodeMaterialBlock {
  129074. /**
  129075. * Creates a new ScaleBlock
  129076. * @param name defines the block name
  129077. */
  129078. constructor(name: string);
  129079. /**
  129080. * Gets the current class name
  129081. * @returns the class name
  129082. */
  129083. getClassName(): string;
  129084. /**
  129085. * Gets the input component
  129086. */
  129087. get input(): NodeMaterialConnectionPoint;
  129088. /**
  129089. * Gets the factor input component
  129090. */
  129091. get factor(): NodeMaterialConnectionPoint;
  129092. /**
  129093. * Gets the output component
  129094. */
  129095. get output(): NodeMaterialConnectionPoint;
  129096. protected _buildBlock(state: NodeMaterialBuildState): this;
  129097. }
  129098. }
  129099. declare module BABYLON {
  129100. /**
  129101. * Block used to clamp a float
  129102. */
  129103. export class ClampBlock extends NodeMaterialBlock {
  129104. /** Gets or sets the minimum range */
  129105. minimum: number;
  129106. /** Gets or sets the maximum range */
  129107. maximum: number;
  129108. /**
  129109. * Creates a new ClampBlock
  129110. * @param name defines the block name
  129111. */
  129112. constructor(name: string);
  129113. /**
  129114. * Gets the current class name
  129115. * @returns the class name
  129116. */
  129117. getClassName(): string;
  129118. /**
  129119. * Gets the value input component
  129120. */
  129121. get value(): NodeMaterialConnectionPoint;
  129122. /**
  129123. * Gets the output component
  129124. */
  129125. get output(): NodeMaterialConnectionPoint;
  129126. protected _buildBlock(state: NodeMaterialBuildState): this;
  129127. protected _dumpPropertiesCode(): string;
  129128. serialize(): any;
  129129. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129130. }
  129131. }
  129132. declare module BABYLON {
  129133. /**
  129134. * Block used to apply a cross product between 2 vectors
  129135. */
  129136. export class CrossBlock extends NodeMaterialBlock {
  129137. /**
  129138. * Creates a new CrossBlock
  129139. * @param name defines the block name
  129140. */
  129141. constructor(name: string);
  129142. /**
  129143. * Gets the current class name
  129144. * @returns the class name
  129145. */
  129146. getClassName(): string;
  129147. /**
  129148. * Gets the left operand input component
  129149. */
  129150. get left(): NodeMaterialConnectionPoint;
  129151. /**
  129152. * Gets the right operand input component
  129153. */
  129154. get right(): NodeMaterialConnectionPoint;
  129155. /**
  129156. * Gets the output component
  129157. */
  129158. get output(): NodeMaterialConnectionPoint;
  129159. protected _buildBlock(state: NodeMaterialBuildState): this;
  129160. }
  129161. }
  129162. declare module BABYLON {
  129163. /**
  129164. * Block used to apply a dot product between 2 vectors
  129165. */
  129166. export class DotBlock extends NodeMaterialBlock {
  129167. /**
  129168. * Creates a new DotBlock
  129169. * @param name defines the block name
  129170. */
  129171. constructor(name: string);
  129172. /**
  129173. * Gets the current class name
  129174. * @returns the class name
  129175. */
  129176. getClassName(): string;
  129177. /**
  129178. * Gets the left operand input component
  129179. */
  129180. get left(): NodeMaterialConnectionPoint;
  129181. /**
  129182. * Gets the right operand input component
  129183. */
  129184. get right(): NodeMaterialConnectionPoint;
  129185. /**
  129186. * Gets the output component
  129187. */
  129188. get output(): NodeMaterialConnectionPoint;
  129189. protected _buildBlock(state: NodeMaterialBuildState): this;
  129190. }
  129191. }
  129192. declare module BABYLON {
  129193. /**
  129194. * Block used to remap a float from a range to a new one
  129195. */
  129196. export class RemapBlock extends NodeMaterialBlock {
  129197. /**
  129198. * Gets or sets the source range
  129199. */
  129200. sourceRange: Vector2;
  129201. /**
  129202. * Gets or sets the target range
  129203. */
  129204. targetRange: Vector2;
  129205. /**
  129206. * Creates a new RemapBlock
  129207. * @param name defines the block name
  129208. */
  129209. constructor(name: string);
  129210. /**
  129211. * Gets the current class name
  129212. * @returns the class name
  129213. */
  129214. getClassName(): string;
  129215. /**
  129216. * Gets the input component
  129217. */
  129218. get input(): NodeMaterialConnectionPoint;
  129219. /**
  129220. * Gets the source min input component
  129221. */
  129222. get sourceMin(): NodeMaterialConnectionPoint;
  129223. /**
  129224. * Gets the source max input component
  129225. */
  129226. get sourceMax(): NodeMaterialConnectionPoint;
  129227. /**
  129228. * Gets the target min input component
  129229. */
  129230. get targetMin(): NodeMaterialConnectionPoint;
  129231. /**
  129232. * Gets the target max input component
  129233. */
  129234. get targetMax(): NodeMaterialConnectionPoint;
  129235. /**
  129236. * Gets the output component
  129237. */
  129238. get output(): NodeMaterialConnectionPoint;
  129239. protected _buildBlock(state: NodeMaterialBuildState): this;
  129240. protected _dumpPropertiesCode(): string;
  129241. serialize(): any;
  129242. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129243. }
  129244. }
  129245. declare module BABYLON {
  129246. /**
  129247. * Block used to normalize a vector
  129248. */
  129249. export class NormalizeBlock extends NodeMaterialBlock {
  129250. /**
  129251. * Creates a new NormalizeBlock
  129252. * @param name defines the block name
  129253. */
  129254. constructor(name: string);
  129255. /**
  129256. * Gets the current class name
  129257. * @returns the class name
  129258. */
  129259. getClassName(): string;
  129260. /**
  129261. * Gets the input component
  129262. */
  129263. get input(): NodeMaterialConnectionPoint;
  129264. /**
  129265. * Gets the output component
  129266. */
  129267. get output(): NodeMaterialConnectionPoint;
  129268. protected _buildBlock(state: NodeMaterialBuildState): this;
  129269. }
  129270. }
  129271. declare module BABYLON {
  129272. /**
  129273. * Operations supported by the Trigonometry block
  129274. */
  129275. export enum TrigonometryBlockOperations {
  129276. /** Cos */
  129277. Cos = 0,
  129278. /** Sin */
  129279. Sin = 1,
  129280. /** Abs */
  129281. Abs = 2,
  129282. /** Exp */
  129283. Exp = 3,
  129284. /** Exp2 */
  129285. Exp2 = 4,
  129286. /** Round */
  129287. Round = 5,
  129288. /** Floor */
  129289. Floor = 6,
  129290. /** Ceiling */
  129291. Ceiling = 7,
  129292. /** Square root */
  129293. Sqrt = 8,
  129294. /** Log */
  129295. Log = 9,
  129296. /** Tangent */
  129297. Tan = 10,
  129298. /** Arc tangent */
  129299. ArcTan = 11,
  129300. /** Arc cosinus */
  129301. ArcCos = 12,
  129302. /** Arc sinus */
  129303. ArcSin = 13,
  129304. /** Fraction */
  129305. Fract = 14,
  129306. /** Sign */
  129307. Sign = 15,
  129308. /** To radians (from degrees) */
  129309. Radians = 16,
  129310. /** To degrees (from radians) */
  129311. Degrees = 17
  129312. }
  129313. /**
  129314. * Block used to apply trigonometry operation to floats
  129315. */
  129316. export class TrigonometryBlock extends NodeMaterialBlock {
  129317. /**
  129318. * Gets or sets the operation applied by the block
  129319. */
  129320. operation: TrigonometryBlockOperations;
  129321. /**
  129322. * Creates a new TrigonometryBlock
  129323. * @param name defines the block name
  129324. */
  129325. constructor(name: string);
  129326. /**
  129327. * Gets the current class name
  129328. * @returns the class name
  129329. */
  129330. getClassName(): string;
  129331. /**
  129332. * Gets the input component
  129333. */
  129334. get input(): NodeMaterialConnectionPoint;
  129335. /**
  129336. * Gets the output component
  129337. */
  129338. get output(): NodeMaterialConnectionPoint;
  129339. protected _buildBlock(state: NodeMaterialBuildState): this;
  129340. serialize(): any;
  129341. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129342. protected _dumpPropertiesCode(): string;
  129343. }
  129344. }
  129345. declare module BABYLON {
  129346. /**
  129347. * Block used to create a Color3/4 out of individual inputs (one for each component)
  129348. */
  129349. export class ColorMergerBlock extends NodeMaterialBlock {
  129350. /**
  129351. * Create a new ColorMergerBlock
  129352. * @param name defines the block name
  129353. */
  129354. constructor(name: string);
  129355. /**
  129356. * Gets the current class name
  129357. * @returns the class name
  129358. */
  129359. getClassName(): string;
  129360. /**
  129361. * Gets the rgb component (input)
  129362. */
  129363. get rgbIn(): NodeMaterialConnectionPoint;
  129364. /**
  129365. * Gets the r component (input)
  129366. */
  129367. get r(): NodeMaterialConnectionPoint;
  129368. /**
  129369. * Gets the g component (input)
  129370. */
  129371. get g(): NodeMaterialConnectionPoint;
  129372. /**
  129373. * Gets the b component (input)
  129374. */
  129375. get b(): NodeMaterialConnectionPoint;
  129376. /**
  129377. * Gets the a component (input)
  129378. */
  129379. get a(): NodeMaterialConnectionPoint;
  129380. /**
  129381. * Gets the rgba component (output)
  129382. */
  129383. get rgba(): NodeMaterialConnectionPoint;
  129384. /**
  129385. * Gets the rgb component (output)
  129386. */
  129387. get rgbOut(): NodeMaterialConnectionPoint;
  129388. /**
  129389. * Gets the rgb component (output)
  129390. * @deprecated Please use rgbOut instead.
  129391. */
  129392. get rgb(): NodeMaterialConnectionPoint;
  129393. protected _buildBlock(state: NodeMaterialBuildState): this;
  129394. }
  129395. }
  129396. declare module BABYLON {
  129397. /**
  129398. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  129399. */
  129400. export class VectorMergerBlock extends NodeMaterialBlock {
  129401. /**
  129402. * Create a new VectorMergerBlock
  129403. * @param name defines the block name
  129404. */
  129405. constructor(name: string);
  129406. /**
  129407. * Gets the current class name
  129408. * @returns the class name
  129409. */
  129410. getClassName(): string;
  129411. /**
  129412. * Gets the xyz component (input)
  129413. */
  129414. get xyzIn(): NodeMaterialConnectionPoint;
  129415. /**
  129416. * Gets the xy component (input)
  129417. */
  129418. get xyIn(): NodeMaterialConnectionPoint;
  129419. /**
  129420. * Gets the x component (input)
  129421. */
  129422. get x(): NodeMaterialConnectionPoint;
  129423. /**
  129424. * Gets the y component (input)
  129425. */
  129426. get y(): NodeMaterialConnectionPoint;
  129427. /**
  129428. * Gets the z component (input)
  129429. */
  129430. get z(): NodeMaterialConnectionPoint;
  129431. /**
  129432. * Gets the w component (input)
  129433. */
  129434. get w(): NodeMaterialConnectionPoint;
  129435. /**
  129436. * Gets the xyzw component (output)
  129437. */
  129438. get xyzw(): NodeMaterialConnectionPoint;
  129439. /**
  129440. * Gets the xyz component (output)
  129441. */
  129442. get xyzOut(): NodeMaterialConnectionPoint;
  129443. /**
  129444. * Gets the xy component (output)
  129445. */
  129446. get xyOut(): NodeMaterialConnectionPoint;
  129447. /**
  129448. * Gets the xy component (output)
  129449. * @deprecated Please use xyOut instead.
  129450. */
  129451. get xy(): NodeMaterialConnectionPoint;
  129452. /**
  129453. * Gets the xyz component (output)
  129454. * @deprecated Please use xyzOut instead.
  129455. */
  129456. get xyz(): NodeMaterialConnectionPoint;
  129457. protected _buildBlock(state: NodeMaterialBuildState): this;
  129458. }
  129459. }
  129460. declare module BABYLON {
  129461. /**
  129462. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  129463. */
  129464. export class ColorSplitterBlock extends NodeMaterialBlock {
  129465. /**
  129466. * Create a new ColorSplitterBlock
  129467. * @param name defines the block name
  129468. */
  129469. constructor(name: string);
  129470. /**
  129471. * Gets the current class name
  129472. * @returns the class name
  129473. */
  129474. getClassName(): string;
  129475. /**
  129476. * Gets the rgba component (input)
  129477. */
  129478. get rgba(): NodeMaterialConnectionPoint;
  129479. /**
  129480. * Gets the rgb component (input)
  129481. */
  129482. get rgbIn(): NodeMaterialConnectionPoint;
  129483. /**
  129484. * Gets the rgb component (output)
  129485. */
  129486. get rgbOut(): NodeMaterialConnectionPoint;
  129487. /**
  129488. * Gets the r component (output)
  129489. */
  129490. get r(): NodeMaterialConnectionPoint;
  129491. /**
  129492. * Gets the g component (output)
  129493. */
  129494. get g(): NodeMaterialConnectionPoint;
  129495. /**
  129496. * Gets the b component (output)
  129497. */
  129498. get b(): NodeMaterialConnectionPoint;
  129499. /**
  129500. * Gets the a component (output)
  129501. */
  129502. get a(): NodeMaterialConnectionPoint;
  129503. protected _inputRename(name: string): string;
  129504. protected _outputRename(name: string): string;
  129505. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  129506. }
  129507. }
  129508. declare module BABYLON {
  129509. /**
  129510. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  129511. */
  129512. export class VectorSplitterBlock extends NodeMaterialBlock {
  129513. /**
  129514. * Create a new VectorSplitterBlock
  129515. * @param name defines the block name
  129516. */
  129517. constructor(name: string);
  129518. /**
  129519. * Gets the current class name
  129520. * @returns the class name
  129521. */
  129522. getClassName(): string;
  129523. /**
  129524. * Gets the xyzw component (input)
  129525. */
  129526. get xyzw(): NodeMaterialConnectionPoint;
  129527. /**
  129528. * Gets the xyz component (input)
  129529. */
  129530. get xyzIn(): NodeMaterialConnectionPoint;
  129531. /**
  129532. * Gets the xy component (input)
  129533. */
  129534. get xyIn(): NodeMaterialConnectionPoint;
  129535. /**
  129536. * Gets the xyz component (output)
  129537. */
  129538. get xyzOut(): NodeMaterialConnectionPoint;
  129539. /**
  129540. * Gets the xy component (output)
  129541. */
  129542. get xyOut(): NodeMaterialConnectionPoint;
  129543. /**
  129544. * Gets the x component (output)
  129545. */
  129546. get x(): NodeMaterialConnectionPoint;
  129547. /**
  129548. * Gets the y component (output)
  129549. */
  129550. get y(): NodeMaterialConnectionPoint;
  129551. /**
  129552. * Gets the z component (output)
  129553. */
  129554. get z(): NodeMaterialConnectionPoint;
  129555. /**
  129556. * Gets the w component (output)
  129557. */
  129558. get w(): NodeMaterialConnectionPoint;
  129559. protected _inputRename(name: string): string;
  129560. protected _outputRename(name: string): string;
  129561. protected _buildBlock(state: NodeMaterialBuildState): this;
  129562. }
  129563. }
  129564. declare module BABYLON {
  129565. /**
  129566. * Block used to lerp between 2 values
  129567. */
  129568. export class LerpBlock extends NodeMaterialBlock {
  129569. /**
  129570. * Creates a new LerpBlock
  129571. * @param name defines the block name
  129572. */
  129573. constructor(name: string);
  129574. /**
  129575. * Gets the current class name
  129576. * @returns the class name
  129577. */
  129578. getClassName(): string;
  129579. /**
  129580. * Gets the left operand input component
  129581. */
  129582. get left(): NodeMaterialConnectionPoint;
  129583. /**
  129584. * Gets the right operand input component
  129585. */
  129586. get right(): NodeMaterialConnectionPoint;
  129587. /**
  129588. * Gets the gradient operand input component
  129589. */
  129590. get gradient(): NodeMaterialConnectionPoint;
  129591. /**
  129592. * Gets the output component
  129593. */
  129594. get output(): NodeMaterialConnectionPoint;
  129595. protected _buildBlock(state: NodeMaterialBuildState): this;
  129596. }
  129597. }
  129598. declare module BABYLON {
  129599. /**
  129600. * Block used to divide 2 vectors
  129601. */
  129602. export class DivideBlock extends NodeMaterialBlock {
  129603. /**
  129604. * Creates a new DivideBlock
  129605. * @param name defines the block name
  129606. */
  129607. constructor(name: string);
  129608. /**
  129609. * Gets the current class name
  129610. * @returns the class name
  129611. */
  129612. getClassName(): string;
  129613. /**
  129614. * Gets the left operand input component
  129615. */
  129616. get left(): NodeMaterialConnectionPoint;
  129617. /**
  129618. * Gets the right operand input component
  129619. */
  129620. get right(): NodeMaterialConnectionPoint;
  129621. /**
  129622. * Gets the output component
  129623. */
  129624. get output(): NodeMaterialConnectionPoint;
  129625. protected _buildBlock(state: NodeMaterialBuildState): this;
  129626. }
  129627. }
  129628. declare module BABYLON {
  129629. /**
  129630. * Block used to subtract 2 vectors
  129631. */
  129632. export class SubtractBlock extends NodeMaterialBlock {
  129633. /**
  129634. * Creates a new SubtractBlock
  129635. * @param name defines the block name
  129636. */
  129637. constructor(name: string);
  129638. /**
  129639. * Gets the current class name
  129640. * @returns the class name
  129641. */
  129642. getClassName(): string;
  129643. /**
  129644. * Gets the left operand input component
  129645. */
  129646. get left(): NodeMaterialConnectionPoint;
  129647. /**
  129648. * Gets the right operand input component
  129649. */
  129650. get right(): NodeMaterialConnectionPoint;
  129651. /**
  129652. * Gets the output component
  129653. */
  129654. get output(): NodeMaterialConnectionPoint;
  129655. protected _buildBlock(state: NodeMaterialBuildState): this;
  129656. }
  129657. }
  129658. declare module BABYLON {
  129659. /**
  129660. * Block used to step a value
  129661. */
  129662. export class StepBlock extends NodeMaterialBlock {
  129663. /**
  129664. * Creates a new StepBlock
  129665. * @param name defines the block name
  129666. */
  129667. constructor(name: string);
  129668. /**
  129669. * Gets the current class name
  129670. * @returns the class name
  129671. */
  129672. getClassName(): string;
  129673. /**
  129674. * Gets the value operand input component
  129675. */
  129676. get value(): NodeMaterialConnectionPoint;
  129677. /**
  129678. * Gets the edge operand input component
  129679. */
  129680. get edge(): NodeMaterialConnectionPoint;
  129681. /**
  129682. * Gets the output component
  129683. */
  129684. get output(): NodeMaterialConnectionPoint;
  129685. protected _buildBlock(state: NodeMaterialBuildState): this;
  129686. }
  129687. }
  129688. declare module BABYLON {
  129689. /**
  129690. * Block used to get the opposite (1 - x) of a value
  129691. */
  129692. export class OneMinusBlock extends NodeMaterialBlock {
  129693. /**
  129694. * Creates a new OneMinusBlock
  129695. * @param name defines the block name
  129696. */
  129697. constructor(name: string);
  129698. /**
  129699. * Gets the current class name
  129700. * @returns the class name
  129701. */
  129702. getClassName(): string;
  129703. /**
  129704. * Gets the input component
  129705. */
  129706. get input(): NodeMaterialConnectionPoint;
  129707. /**
  129708. * Gets the output component
  129709. */
  129710. get output(): NodeMaterialConnectionPoint;
  129711. protected _buildBlock(state: NodeMaterialBuildState): this;
  129712. }
  129713. }
  129714. declare module BABYLON {
  129715. /**
  129716. * Block used to get the view direction
  129717. */
  129718. export class ViewDirectionBlock extends NodeMaterialBlock {
  129719. /**
  129720. * Creates a new ViewDirectionBlock
  129721. * @param name defines the block name
  129722. */
  129723. constructor(name: string);
  129724. /**
  129725. * Gets the current class name
  129726. * @returns the class name
  129727. */
  129728. getClassName(): string;
  129729. /**
  129730. * Gets the world position component
  129731. */
  129732. get worldPosition(): NodeMaterialConnectionPoint;
  129733. /**
  129734. * Gets the camera position component
  129735. */
  129736. get cameraPosition(): NodeMaterialConnectionPoint;
  129737. /**
  129738. * Gets the output component
  129739. */
  129740. get output(): NodeMaterialConnectionPoint;
  129741. autoConfigure(material: NodeMaterial): void;
  129742. protected _buildBlock(state: NodeMaterialBuildState): this;
  129743. }
  129744. }
  129745. declare module BABYLON {
  129746. /**
  129747. * Block used to compute fresnel value
  129748. */
  129749. export class FresnelBlock extends NodeMaterialBlock {
  129750. /**
  129751. * Create a new FresnelBlock
  129752. * @param name defines the block name
  129753. */
  129754. constructor(name: string);
  129755. /**
  129756. * Gets the current class name
  129757. * @returns the class name
  129758. */
  129759. getClassName(): string;
  129760. /**
  129761. * Gets the world normal input component
  129762. */
  129763. get worldNormal(): NodeMaterialConnectionPoint;
  129764. /**
  129765. * Gets the view direction input component
  129766. */
  129767. get viewDirection(): NodeMaterialConnectionPoint;
  129768. /**
  129769. * Gets the bias input component
  129770. */
  129771. get bias(): NodeMaterialConnectionPoint;
  129772. /**
  129773. * Gets the camera (or eye) position component
  129774. */
  129775. get power(): NodeMaterialConnectionPoint;
  129776. /**
  129777. * Gets the fresnel output component
  129778. */
  129779. get fresnel(): NodeMaterialConnectionPoint;
  129780. autoConfigure(material: NodeMaterial): void;
  129781. protected _buildBlock(state: NodeMaterialBuildState): this;
  129782. }
  129783. }
  129784. declare module BABYLON {
  129785. /**
  129786. * Block used to get the max of 2 values
  129787. */
  129788. export class MaxBlock extends NodeMaterialBlock {
  129789. /**
  129790. * Creates a new MaxBlock
  129791. * @param name defines the block name
  129792. */
  129793. constructor(name: string);
  129794. /**
  129795. * Gets the current class name
  129796. * @returns the class name
  129797. */
  129798. getClassName(): string;
  129799. /**
  129800. * Gets the left operand input component
  129801. */
  129802. get left(): NodeMaterialConnectionPoint;
  129803. /**
  129804. * Gets the right operand input component
  129805. */
  129806. get right(): NodeMaterialConnectionPoint;
  129807. /**
  129808. * Gets the output component
  129809. */
  129810. get output(): NodeMaterialConnectionPoint;
  129811. protected _buildBlock(state: NodeMaterialBuildState): this;
  129812. }
  129813. }
  129814. declare module BABYLON {
  129815. /**
  129816. * Block used to get the min of 2 values
  129817. */
  129818. export class MinBlock extends NodeMaterialBlock {
  129819. /**
  129820. * Creates a new MinBlock
  129821. * @param name defines the block name
  129822. */
  129823. constructor(name: string);
  129824. /**
  129825. * Gets the current class name
  129826. * @returns the class name
  129827. */
  129828. getClassName(): string;
  129829. /**
  129830. * Gets the left operand input component
  129831. */
  129832. get left(): NodeMaterialConnectionPoint;
  129833. /**
  129834. * Gets the right operand input component
  129835. */
  129836. get right(): NodeMaterialConnectionPoint;
  129837. /**
  129838. * Gets the output component
  129839. */
  129840. get output(): NodeMaterialConnectionPoint;
  129841. protected _buildBlock(state: NodeMaterialBuildState): this;
  129842. }
  129843. }
  129844. declare module BABYLON {
  129845. /**
  129846. * Block used to get the distance between 2 values
  129847. */
  129848. export class DistanceBlock extends NodeMaterialBlock {
  129849. /**
  129850. * Creates a new DistanceBlock
  129851. * @param name defines the block name
  129852. */
  129853. constructor(name: string);
  129854. /**
  129855. * Gets the current class name
  129856. * @returns the class name
  129857. */
  129858. getClassName(): string;
  129859. /**
  129860. * Gets the left operand input component
  129861. */
  129862. get left(): NodeMaterialConnectionPoint;
  129863. /**
  129864. * Gets the right operand input component
  129865. */
  129866. get right(): NodeMaterialConnectionPoint;
  129867. /**
  129868. * Gets the output component
  129869. */
  129870. get output(): NodeMaterialConnectionPoint;
  129871. protected _buildBlock(state: NodeMaterialBuildState): this;
  129872. }
  129873. }
  129874. declare module BABYLON {
  129875. /**
  129876. * Block used to get the length of a vector
  129877. */
  129878. export class LengthBlock extends NodeMaterialBlock {
  129879. /**
  129880. * Creates a new LengthBlock
  129881. * @param name defines the block name
  129882. */
  129883. constructor(name: string);
  129884. /**
  129885. * Gets the current class name
  129886. * @returns the class name
  129887. */
  129888. getClassName(): string;
  129889. /**
  129890. * Gets the value input component
  129891. */
  129892. get value(): NodeMaterialConnectionPoint;
  129893. /**
  129894. * Gets the output component
  129895. */
  129896. get output(): NodeMaterialConnectionPoint;
  129897. protected _buildBlock(state: NodeMaterialBuildState): this;
  129898. }
  129899. }
  129900. declare module BABYLON {
  129901. /**
  129902. * Block used to get negative version of a value (i.e. x * -1)
  129903. */
  129904. export class NegateBlock extends NodeMaterialBlock {
  129905. /**
  129906. * Creates a new NegateBlock
  129907. * @param name defines the block name
  129908. */
  129909. constructor(name: string);
  129910. /**
  129911. * Gets the current class name
  129912. * @returns the class name
  129913. */
  129914. getClassName(): string;
  129915. /**
  129916. * Gets the value input component
  129917. */
  129918. get value(): NodeMaterialConnectionPoint;
  129919. /**
  129920. * Gets the output component
  129921. */
  129922. get output(): NodeMaterialConnectionPoint;
  129923. protected _buildBlock(state: NodeMaterialBuildState): this;
  129924. }
  129925. }
  129926. declare module BABYLON {
  129927. /**
  129928. * Block used to get the value of the first parameter raised to the power of the second
  129929. */
  129930. export class PowBlock extends NodeMaterialBlock {
  129931. /**
  129932. * Creates a new PowBlock
  129933. * @param name defines the block name
  129934. */
  129935. constructor(name: string);
  129936. /**
  129937. * Gets the current class name
  129938. * @returns the class name
  129939. */
  129940. getClassName(): string;
  129941. /**
  129942. * Gets the value operand input component
  129943. */
  129944. get value(): NodeMaterialConnectionPoint;
  129945. /**
  129946. * Gets the power operand input component
  129947. */
  129948. get power(): NodeMaterialConnectionPoint;
  129949. /**
  129950. * Gets the output component
  129951. */
  129952. get output(): NodeMaterialConnectionPoint;
  129953. protected _buildBlock(state: NodeMaterialBuildState): this;
  129954. }
  129955. }
  129956. declare module BABYLON {
  129957. /**
  129958. * Block used to get a random number
  129959. */
  129960. export class RandomNumberBlock extends NodeMaterialBlock {
  129961. /**
  129962. * Creates a new RandomNumberBlock
  129963. * @param name defines the block name
  129964. */
  129965. constructor(name: string);
  129966. /**
  129967. * Gets the current class name
  129968. * @returns the class name
  129969. */
  129970. getClassName(): string;
  129971. /**
  129972. * Gets the seed input component
  129973. */
  129974. get seed(): NodeMaterialConnectionPoint;
  129975. /**
  129976. * Gets the output component
  129977. */
  129978. get output(): NodeMaterialConnectionPoint;
  129979. protected _buildBlock(state: NodeMaterialBuildState): this;
  129980. }
  129981. }
  129982. declare module BABYLON {
  129983. /**
  129984. * Block used to compute arc tangent of 2 values
  129985. */
  129986. export class ArcTan2Block extends NodeMaterialBlock {
  129987. /**
  129988. * Creates a new ArcTan2Block
  129989. * @param name defines the block name
  129990. */
  129991. constructor(name: string);
  129992. /**
  129993. * Gets the current class name
  129994. * @returns the class name
  129995. */
  129996. getClassName(): string;
  129997. /**
  129998. * Gets the x operand input component
  129999. */
  130000. get x(): NodeMaterialConnectionPoint;
  130001. /**
  130002. * Gets the y operand input component
  130003. */
  130004. get y(): NodeMaterialConnectionPoint;
  130005. /**
  130006. * Gets the output component
  130007. */
  130008. get output(): NodeMaterialConnectionPoint;
  130009. protected _buildBlock(state: NodeMaterialBuildState): this;
  130010. }
  130011. }
  130012. declare module BABYLON {
  130013. /**
  130014. * Block used to smooth step a value
  130015. */
  130016. export class SmoothStepBlock extends NodeMaterialBlock {
  130017. /**
  130018. * Creates a new SmoothStepBlock
  130019. * @param name defines the block name
  130020. */
  130021. constructor(name: string);
  130022. /**
  130023. * Gets the current class name
  130024. * @returns the class name
  130025. */
  130026. getClassName(): string;
  130027. /**
  130028. * Gets the value operand input component
  130029. */
  130030. get value(): NodeMaterialConnectionPoint;
  130031. /**
  130032. * Gets the first edge operand input component
  130033. */
  130034. get edge0(): NodeMaterialConnectionPoint;
  130035. /**
  130036. * Gets the second edge operand input component
  130037. */
  130038. get edge1(): NodeMaterialConnectionPoint;
  130039. /**
  130040. * Gets the output component
  130041. */
  130042. get output(): NodeMaterialConnectionPoint;
  130043. protected _buildBlock(state: NodeMaterialBuildState): this;
  130044. }
  130045. }
  130046. declare module BABYLON {
  130047. /**
  130048. * Block used to get the reciprocal (1 / x) of a value
  130049. */
  130050. export class ReciprocalBlock extends NodeMaterialBlock {
  130051. /**
  130052. * Creates a new ReciprocalBlock
  130053. * @param name defines the block name
  130054. */
  130055. constructor(name: string);
  130056. /**
  130057. * Gets the current class name
  130058. * @returns the class name
  130059. */
  130060. getClassName(): string;
  130061. /**
  130062. * Gets the input component
  130063. */
  130064. get input(): NodeMaterialConnectionPoint;
  130065. /**
  130066. * Gets the output component
  130067. */
  130068. get output(): NodeMaterialConnectionPoint;
  130069. protected _buildBlock(state: NodeMaterialBuildState): this;
  130070. }
  130071. }
  130072. declare module BABYLON {
  130073. /**
  130074. * Block used to replace a color by another one
  130075. */
  130076. export class ReplaceColorBlock extends NodeMaterialBlock {
  130077. /**
  130078. * Creates a new ReplaceColorBlock
  130079. * @param name defines the block name
  130080. */
  130081. constructor(name: string);
  130082. /**
  130083. * Gets the current class name
  130084. * @returns the class name
  130085. */
  130086. getClassName(): string;
  130087. /**
  130088. * Gets the value input component
  130089. */
  130090. get value(): NodeMaterialConnectionPoint;
  130091. /**
  130092. * Gets the reference input component
  130093. */
  130094. get reference(): NodeMaterialConnectionPoint;
  130095. /**
  130096. * Gets the distance input component
  130097. */
  130098. get distance(): NodeMaterialConnectionPoint;
  130099. /**
  130100. * Gets the replacement input component
  130101. */
  130102. get replacement(): NodeMaterialConnectionPoint;
  130103. /**
  130104. * Gets the output component
  130105. */
  130106. get output(): NodeMaterialConnectionPoint;
  130107. protected _buildBlock(state: NodeMaterialBuildState): this;
  130108. }
  130109. }
  130110. declare module BABYLON {
  130111. /**
  130112. * Block used to posterize a value
  130113. * @see https://en.wikipedia.org/wiki/Posterization
  130114. */
  130115. export class PosterizeBlock extends NodeMaterialBlock {
  130116. /**
  130117. * Creates a new PosterizeBlock
  130118. * @param name defines the block name
  130119. */
  130120. constructor(name: string);
  130121. /**
  130122. * Gets the current class name
  130123. * @returns the class name
  130124. */
  130125. getClassName(): string;
  130126. /**
  130127. * Gets the value input component
  130128. */
  130129. get value(): NodeMaterialConnectionPoint;
  130130. /**
  130131. * Gets the steps input component
  130132. */
  130133. get steps(): NodeMaterialConnectionPoint;
  130134. /**
  130135. * Gets the output component
  130136. */
  130137. get output(): NodeMaterialConnectionPoint;
  130138. protected _buildBlock(state: NodeMaterialBuildState): this;
  130139. }
  130140. }
  130141. declare module BABYLON {
  130142. /**
  130143. * Operations supported by the Wave block
  130144. */
  130145. export enum WaveBlockKind {
  130146. /** SawTooth */
  130147. SawTooth = 0,
  130148. /** Square */
  130149. Square = 1,
  130150. /** Triangle */
  130151. Triangle = 2
  130152. }
  130153. /**
  130154. * Block used to apply wave operation to floats
  130155. */
  130156. export class WaveBlock extends NodeMaterialBlock {
  130157. /**
  130158. * Gets or sets the kibnd of wave to be applied by the block
  130159. */
  130160. kind: WaveBlockKind;
  130161. /**
  130162. * Creates a new WaveBlock
  130163. * @param name defines the block name
  130164. */
  130165. constructor(name: string);
  130166. /**
  130167. * Gets the current class name
  130168. * @returns the class name
  130169. */
  130170. getClassName(): string;
  130171. /**
  130172. * Gets the input component
  130173. */
  130174. get input(): NodeMaterialConnectionPoint;
  130175. /**
  130176. * Gets the output component
  130177. */
  130178. get output(): NodeMaterialConnectionPoint;
  130179. protected _buildBlock(state: NodeMaterialBuildState): this;
  130180. serialize(): any;
  130181. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130182. }
  130183. }
  130184. declare module BABYLON {
  130185. /**
  130186. * Class used to store a color step for the GradientBlock
  130187. */
  130188. export class GradientBlockColorStep {
  130189. /**
  130190. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  130191. */
  130192. step: number;
  130193. /**
  130194. * Gets or sets the color associated with this step
  130195. */
  130196. color: Color3;
  130197. /**
  130198. * Creates a new GradientBlockColorStep
  130199. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  130200. * @param color defines the color associated with this step
  130201. */
  130202. constructor(
  130203. /**
  130204. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  130205. */
  130206. step: number,
  130207. /**
  130208. * Gets or sets the color associated with this step
  130209. */
  130210. color: Color3);
  130211. }
  130212. /**
  130213. * Block used to return a color from a gradient based on an input value between 0 and 1
  130214. */
  130215. export class GradientBlock extends NodeMaterialBlock {
  130216. /**
  130217. * Gets or sets the list of color steps
  130218. */
  130219. colorSteps: GradientBlockColorStep[];
  130220. /**
  130221. * Creates a new GradientBlock
  130222. * @param name defines the block name
  130223. */
  130224. constructor(name: string);
  130225. /**
  130226. * Gets the current class name
  130227. * @returns the class name
  130228. */
  130229. getClassName(): string;
  130230. /**
  130231. * Gets the gradient input component
  130232. */
  130233. get gradient(): NodeMaterialConnectionPoint;
  130234. /**
  130235. * Gets the output component
  130236. */
  130237. get output(): NodeMaterialConnectionPoint;
  130238. private _writeColorConstant;
  130239. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130240. serialize(): any;
  130241. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130242. protected _dumpPropertiesCode(): string;
  130243. }
  130244. }
  130245. declare module BABYLON {
  130246. /**
  130247. * Block used to normalize lerp between 2 values
  130248. */
  130249. export class NLerpBlock extends NodeMaterialBlock {
  130250. /**
  130251. * Creates a new NLerpBlock
  130252. * @param name defines the block name
  130253. */
  130254. constructor(name: string);
  130255. /**
  130256. * Gets the current class name
  130257. * @returns the class name
  130258. */
  130259. getClassName(): string;
  130260. /**
  130261. * Gets the left operand input component
  130262. */
  130263. get left(): NodeMaterialConnectionPoint;
  130264. /**
  130265. * Gets the right operand input component
  130266. */
  130267. get right(): NodeMaterialConnectionPoint;
  130268. /**
  130269. * Gets the gradient operand input component
  130270. */
  130271. get gradient(): NodeMaterialConnectionPoint;
  130272. /**
  130273. * Gets the output component
  130274. */
  130275. get output(): NodeMaterialConnectionPoint;
  130276. protected _buildBlock(state: NodeMaterialBuildState): this;
  130277. }
  130278. }
  130279. declare module BABYLON {
  130280. /**
  130281. * block used to Generate a Worley Noise 3D Noise Pattern
  130282. */
  130283. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  130284. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  130285. manhattanDistance: boolean;
  130286. /**
  130287. * Creates a new WorleyNoise3DBlock
  130288. * @param name defines the block name
  130289. */
  130290. constructor(name: string);
  130291. /**
  130292. * Gets the current class name
  130293. * @returns the class name
  130294. */
  130295. getClassName(): string;
  130296. /**
  130297. * Gets the seed input component
  130298. */
  130299. get seed(): NodeMaterialConnectionPoint;
  130300. /**
  130301. * Gets the jitter input component
  130302. */
  130303. get jitter(): NodeMaterialConnectionPoint;
  130304. /**
  130305. * Gets the output component
  130306. */
  130307. get output(): NodeMaterialConnectionPoint;
  130308. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130309. /**
  130310. * Exposes the properties to the UI?
  130311. */
  130312. protected _dumpPropertiesCode(): string;
  130313. /**
  130314. * Exposes the properties to the Seralize?
  130315. */
  130316. serialize(): any;
  130317. /**
  130318. * Exposes the properties to the deseralize?
  130319. */
  130320. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130321. }
  130322. }
  130323. declare module BABYLON {
  130324. /**
  130325. * block used to Generate a Simplex Perlin 3d Noise Pattern
  130326. */
  130327. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  130328. /**
  130329. * Creates a new SimplexPerlin3DBlock
  130330. * @param name defines the block name
  130331. */
  130332. constructor(name: string);
  130333. /**
  130334. * Gets the current class name
  130335. * @returns the class name
  130336. */
  130337. getClassName(): string;
  130338. /**
  130339. * Gets the seed operand input component
  130340. */
  130341. get seed(): NodeMaterialConnectionPoint;
  130342. /**
  130343. * Gets the output component
  130344. */
  130345. get output(): NodeMaterialConnectionPoint;
  130346. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130347. }
  130348. }
  130349. declare module BABYLON {
  130350. /**
  130351. * Block used to blend normals
  130352. */
  130353. export class NormalBlendBlock extends NodeMaterialBlock {
  130354. /**
  130355. * Creates a new NormalBlendBlock
  130356. * @param name defines the block name
  130357. */
  130358. constructor(name: string);
  130359. /**
  130360. * Gets the current class name
  130361. * @returns the class name
  130362. */
  130363. getClassName(): string;
  130364. /**
  130365. * Gets the first input component
  130366. */
  130367. get normalMap0(): NodeMaterialConnectionPoint;
  130368. /**
  130369. * Gets the second input component
  130370. */
  130371. get normalMap1(): NodeMaterialConnectionPoint;
  130372. /**
  130373. * Gets the output component
  130374. */
  130375. get output(): NodeMaterialConnectionPoint;
  130376. protected _buildBlock(state: NodeMaterialBuildState): this;
  130377. }
  130378. }
  130379. declare module BABYLON {
  130380. /**
  130381. * Block used to rotate a 2d vector by a given angle
  130382. */
  130383. export class Rotate2dBlock extends NodeMaterialBlock {
  130384. /**
  130385. * Creates a new Rotate2dBlock
  130386. * @param name defines the block name
  130387. */
  130388. constructor(name: string);
  130389. /**
  130390. * Gets the current class name
  130391. * @returns the class name
  130392. */
  130393. getClassName(): string;
  130394. /**
  130395. * Gets the input vector
  130396. */
  130397. get input(): NodeMaterialConnectionPoint;
  130398. /**
  130399. * Gets the input angle
  130400. */
  130401. get angle(): NodeMaterialConnectionPoint;
  130402. /**
  130403. * Gets the output component
  130404. */
  130405. get output(): NodeMaterialConnectionPoint;
  130406. autoConfigure(material: NodeMaterial): void;
  130407. protected _buildBlock(state: NodeMaterialBuildState): this;
  130408. }
  130409. }
  130410. declare module BABYLON {
  130411. /**
  130412. * Block used to get the reflected vector from a direction and a normal
  130413. */
  130414. export class ReflectBlock extends NodeMaterialBlock {
  130415. /**
  130416. * Creates a new ReflectBlock
  130417. * @param name defines the block name
  130418. */
  130419. constructor(name: string);
  130420. /**
  130421. * Gets the current class name
  130422. * @returns the class name
  130423. */
  130424. getClassName(): string;
  130425. /**
  130426. * Gets the incident component
  130427. */
  130428. get incident(): NodeMaterialConnectionPoint;
  130429. /**
  130430. * Gets the normal component
  130431. */
  130432. get normal(): NodeMaterialConnectionPoint;
  130433. /**
  130434. * Gets the output component
  130435. */
  130436. get output(): NodeMaterialConnectionPoint;
  130437. protected _buildBlock(state: NodeMaterialBuildState): this;
  130438. }
  130439. }
  130440. declare module BABYLON {
  130441. /**
  130442. * Block used to get the refracted vector from a direction and a normal
  130443. */
  130444. export class RefractBlock extends NodeMaterialBlock {
  130445. /**
  130446. * Creates a new RefractBlock
  130447. * @param name defines the block name
  130448. */
  130449. constructor(name: string);
  130450. /**
  130451. * Gets the current class name
  130452. * @returns the class name
  130453. */
  130454. getClassName(): string;
  130455. /**
  130456. * Gets the incident component
  130457. */
  130458. get incident(): NodeMaterialConnectionPoint;
  130459. /**
  130460. * Gets the normal component
  130461. */
  130462. get normal(): NodeMaterialConnectionPoint;
  130463. /**
  130464. * Gets the index of refraction component
  130465. */
  130466. get ior(): NodeMaterialConnectionPoint;
  130467. /**
  130468. * Gets the output component
  130469. */
  130470. get output(): NodeMaterialConnectionPoint;
  130471. protected _buildBlock(state: NodeMaterialBuildState): this;
  130472. }
  130473. }
  130474. declare module BABYLON {
  130475. /**
  130476. * Block used to desaturate a color
  130477. */
  130478. export class DesaturateBlock extends NodeMaterialBlock {
  130479. /**
  130480. * Creates a new DesaturateBlock
  130481. * @param name defines the block name
  130482. */
  130483. constructor(name: string);
  130484. /**
  130485. * Gets the current class name
  130486. * @returns the class name
  130487. */
  130488. getClassName(): string;
  130489. /**
  130490. * Gets the color operand input component
  130491. */
  130492. get color(): NodeMaterialConnectionPoint;
  130493. /**
  130494. * Gets the level operand input component
  130495. */
  130496. get level(): NodeMaterialConnectionPoint;
  130497. /**
  130498. * Gets the output component
  130499. */
  130500. get output(): NodeMaterialConnectionPoint;
  130501. protected _buildBlock(state: NodeMaterialBuildState): this;
  130502. }
  130503. }
  130504. declare module BABYLON {
  130505. /**
  130506. * Effect Render Options
  130507. */
  130508. export interface IEffectRendererOptions {
  130509. /**
  130510. * Defines the vertices positions.
  130511. */
  130512. positions?: number[];
  130513. /**
  130514. * Defines the indices.
  130515. */
  130516. indices?: number[];
  130517. }
  130518. /**
  130519. * Helper class to render one or more effects
  130520. */
  130521. export class EffectRenderer {
  130522. private engine;
  130523. private static _DefaultOptions;
  130524. private _vertexBuffers;
  130525. private _indexBuffer;
  130526. private _ringBufferIndex;
  130527. private _ringScreenBuffer;
  130528. private _fullscreenViewport;
  130529. private _getNextFrameBuffer;
  130530. /**
  130531. * Creates an effect renderer
  130532. * @param engine the engine to use for rendering
  130533. * @param options defines the options of the effect renderer
  130534. */
  130535. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  130536. /**
  130537. * Sets the current viewport in normalized coordinates 0-1
  130538. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  130539. */
  130540. setViewport(viewport?: Viewport): void;
  130541. /**
  130542. * Binds the embedded attributes buffer to the effect.
  130543. * @param effect Defines the effect to bind the attributes for
  130544. */
  130545. bindBuffers(effect: Effect): void;
  130546. /**
  130547. * Sets the current effect wrapper to use during draw.
  130548. * The effect needs to be ready before calling this api.
  130549. * This also sets the default full screen position attribute.
  130550. * @param effectWrapper Defines the effect to draw with
  130551. */
  130552. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  130553. /**
  130554. * Draws a full screen quad.
  130555. */
  130556. draw(): void;
  130557. /**
  130558. * renders one or more effects to a specified texture
  130559. * @param effectWrappers list of effects to renderer
  130560. * @param outputTexture texture to draw to, if null it will render to the screen
  130561. */
  130562. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  130563. /**
  130564. * Disposes of the effect renderer
  130565. */
  130566. dispose(): void;
  130567. }
  130568. /**
  130569. * Options to create an EffectWrapper
  130570. */
  130571. interface EffectWrapperCreationOptions {
  130572. /**
  130573. * Engine to use to create the effect
  130574. */
  130575. engine: ThinEngine;
  130576. /**
  130577. * Fragment shader for the effect
  130578. */
  130579. fragmentShader: string;
  130580. /**
  130581. * Vertex shader for the effect
  130582. */
  130583. vertexShader?: string;
  130584. /**
  130585. * Attributes to use in the shader
  130586. */
  130587. attributeNames?: Array<string>;
  130588. /**
  130589. * Uniforms to use in the shader
  130590. */
  130591. uniformNames?: Array<string>;
  130592. /**
  130593. * Texture sampler names to use in the shader
  130594. */
  130595. samplerNames?: Array<string>;
  130596. /**
  130597. * The friendly name of the effect displayed in Spector.
  130598. */
  130599. name?: string;
  130600. }
  130601. /**
  130602. * Wraps an effect to be used for rendering
  130603. */
  130604. export class EffectWrapper {
  130605. /**
  130606. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  130607. */
  130608. onApplyObservable: Observable<{}>;
  130609. /**
  130610. * The underlying effect
  130611. */
  130612. effect: Effect;
  130613. /**
  130614. * Creates an effect to be renderer
  130615. * @param creationOptions options to create the effect
  130616. */
  130617. constructor(creationOptions: EffectWrapperCreationOptions);
  130618. /**
  130619. * Disposes of the effect wrapper
  130620. */
  130621. dispose(): void;
  130622. }
  130623. }
  130624. declare module BABYLON {
  130625. /**
  130626. * Helper class to push actions to a pool of workers.
  130627. */
  130628. export class WorkerPool implements IDisposable {
  130629. private _workerInfos;
  130630. private _pendingActions;
  130631. /**
  130632. * Constructor
  130633. * @param workers Array of workers to use for actions
  130634. */
  130635. constructor(workers: Array<Worker>);
  130636. /**
  130637. * Terminates all workers and clears any pending actions.
  130638. */
  130639. dispose(): void;
  130640. /**
  130641. * Pushes an action to the worker pool. If all the workers are active, the action will be
  130642. * pended until a worker has completed its action.
  130643. * @param action The action to perform. Call onComplete when the action is complete.
  130644. */
  130645. push(action: (worker: Worker, onComplete: () => void) => void): void;
  130646. private _execute;
  130647. }
  130648. }
  130649. declare module BABYLON {
  130650. /**
  130651. * Configuration for Draco compression
  130652. */
  130653. export interface IDracoCompressionConfiguration {
  130654. /**
  130655. * Configuration for the decoder.
  130656. */
  130657. decoder: {
  130658. /**
  130659. * The url to the WebAssembly module.
  130660. */
  130661. wasmUrl?: string;
  130662. /**
  130663. * The url to the WebAssembly binary.
  130664. */
  130665. wasmBinaryUrl?: string;
  130666. /**
  130667. * The url to the fallback JavaScript module.
  130668. */
  130669. fallbackUrl?: string;
  130670. };
  130671. }
  130672. /**
  130673. * Draco compression (https://google.github.io/draco/)
  130674. *
  130675. * This class wraps the Draco module.
  130676. *
  130677. * **Encoder**
  130678. *
  130679. * The encoder is not currently implemented.
  130680. *
  130681. * **Decoder**
  130682. *
  130683. * 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.
  130684. *
  130685. * To update the configuration, use the following code:
  130686. * ```javascript
  130687. * DracoCompression.Configuration = {
  130688. * decoder: {
  130689. * wasmUrl: "<url to the WebAssembly library>",
  130690. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  130691. * fallbackUrl: "<url to the fallback JavaScript library>",
  130692. * }
  130693. * };
  130694. * ```
  130695. *
  130696. * 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.
  130697. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  130698. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  130699. *
  130700. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  130701. * ```javascript
  130702. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  130703. * ```
  130704. *
  130705. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  130706. */
  130707. export class DracoCompression implements IDisposable {
  130708. private _workerPoolPromise?;
  130709. private _decoderModulePromise?;
  130710. /**
  130711. * The configuration. Defaults to the following urls:
  130712. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  130713. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  130714. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  130715. */
  130716. static Configuration: IDracoCompressionConfiguration;
  130717. /**
  130718. * Returns true if the decoder configuration is available.
  130719. */
  130720. static get DecoderAvailable(): boolean;
  130721. /**
  130722. * Default number of workers to create when creating the draco compression object.
  130723. */
  130724. static DefaultNumWorkers: number;
  130725. private static GetDefaultNumWorkers;
  130726. private static _Default;
  130727. /**
  130728. * Default instance for the draco compression object.
  130729. */
  130730. static get Default(): DracoCompression;
  130731. /**
  130732. * Constructor
  130733. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  130734. */
  130735. constructor(numWorkers?: number);
  130736. /**
  130737. * Stop all async operations and release resources.
  130738. */
  130739. dispose(): void;
  130740. /**
  130741. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  130742. * @returns a promise that resolves when ready
  130743. */
  130744. whenReadyAsync(): Promise<void>;
  130745. /**
  130746. * Decode Draco compressed mesh data to vertex data.
  130747. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  130748. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  130749. * @returns A promise that resolves with the decoded vertex data
  130750. */
  130751. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  130752. [kind: string]: number;
  130753. }): Promise<VertexData>;
  130754. }
  130755. }
  130756. declare module BABYLON {
  130757. /**
  130758. * Class for building Constructive Solid Geometry
  130759. */
  130760. export class CSG {
  130761. private polygons;
  130762. /**
  130763. * The world matrix
  130764. */
  130765. matrix: Matrix;
  130766. /**
  130767. * Stores the position
  130768. */
  130769. position: Vector3;
  130770. /**
  130771. * Stores the rotation
  130772. */
  130773. rotation: Vector3;
  130774. /**
  130775. * Stores the rotation quaternion
  130776. */
  130777. rotationQuaternion: Nullable<Quaternion>;
  130778. /**
  130779. * Stores the scaling vector
  130780. */
  130781. scaling: Vector3;
  130782. /**
  130783. * Convert the Mesh to CSG
  130784. * @param mesh The Mesh to convert to CSG
  130785. * @returns A new CSG from the Mesh
  130786. */
  130787. static FromMesh(mesh: Mesh): CSG;
  130788. /**
  130789. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  130790. * @param polygons Polygons used to construct a CSG solid
  130791. */
  130792. private static FromPolygons;
  130793. /**
  130794. * Clones, or makes a deep copy, of the CSG
  130795. * @returns A new CSG
  130796. */
  130797. clone(): CSG;
  130798. /**
  130799. * Unions this CSG with another CSG
  130800. * @param csg The CSG to union against this CSG
  130801. * @returns The unioned CSG
  130802. */
  130803. union(csg: CSG): CSG;
  130804. /**
  130805. * Unions this CSG with another CSG in place
  130806. * @param csg The CSG to union against this CSG
  130807. */
  130808. unionInPlace(csg: CSG): void;
  130809. /**
  130810. * Subtracts this CSG with another CSG
  130811. * @param csg The CSG to subtract against this CSG
  130812. * @returns A new CSG
  130813. */
  130814. subtract(csg: CSG): CSG;
  130815. /**
  130816. * Subtracts this CSG with another CSG in place
  130817. * @param csg The CSG to subtact against this CSG
  130818. */
  130819. subtractInPlace(csg: CSG): void;
  130820. /**
  130821. * Intersect this CSG with another CSG
  130822. * @param csg The CSG to intersect against this CSG
  130823. * @returns A new CSG
  130824. */
  130825. intersect(csg: CSG): CSG;
  130826. /**
  130827. * Intersects this CSG with another CSG in place
  130828. * @param csg The CSG to intersect against this CSG
  130829. */
  130830. intersectInPlace(csg: CSG): void;
  130831. /**
  130832. * Return a new CSG solid with solid and empty space switched. This solid is
  130833. * not modified.
  130834. * @returns A new CSG solid with solid and empty space switched
  130835. */
  130836. inverse(): CSG;
  130837. /**
  130838. * Inverses the CSG in place
  130839. */
  130840. inverseInPlace(): void;
  130841. /**
  130842. * This is used to keep meshes transformations so they can be restored
  130843. * when we build back a Babylon Mesh
  130844. * NB : All CSG operations are performed in world coordinates
  130845. * @param csg The CSG to copy the transform attributes from
  130846. * @returns This CSG
  130847. */
  130848. copyTransformAttributes(csg: CSG): CSG;
  130849. /**
  130850. * Build Raw mesh from CSG
  130851. * Coordinates here are in world space
  130852. * @param name The name of the mesh geometry
  130853. * @param scene The Scene
  130854. * @param keepSubMeshes Specifies if the submeshes should be kept
  130855. * @returns A new Mesh
  130856. */
  130857. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  130858. /**
  130859. * Build Mesh from CSG taking material and transforms into account
  130860. * @param name The name of the Mesh
  130861. * @param material The material of the Mesh
  130862. * @param scene The Scene
  130863. * @param keepSubMeshes Specifies if submeshes should be kept
  130864. * @returns The new Mesh
  130865. */
  130866. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  130867. }
  130868. }
  130869. declare module BABYLON {
  130870. /**
  130871. * Class used to create a trail following a mesh
  130872. */
  130873. export class TrailMesh extends Mesh {
  130874. private _generator;
  130875. private _autoStart;
  130876. private _running;
  130877. private _diameter;
  130878. private _length;
  130879. private _sectionPolygonPointsCount;
  130880. private _sectionVectors;
  130881. private _sectionNormalVectors;
  130882. private _beforeRenderObserver;
  130883. /**
  130884. * @constructor
  130885. * @param name The value used by scene.getMeshByName() to do a lookup.
  130886. * @param generator The mesh to generate a trail.
  130887. * @param scene The scene to add this mesh to.
  130888. * @param diameter Diameter of trailing mesh. Default is 1.
  130889. * @param length Length of trailing mesh. Default is 60.
  130890. * @param autoStart Automatically start trailing mesh. Default true.
  130891. */
  130892. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  130893. /**
  130894. * "TrailMesh"
  130895. * @returns "TrailMesh"
  130896. */
  130897. getClassName(): string;
  130898. private _createMesh;
  130899. /**
  130900. * Start trailing mesh.
  130901. */
  130902. start(): void;
  130903. /**
  130904. * Stop trailing mesh.
  130905. */
  130906. stop(): void;
  130907. /**
  130908. * Update trailing mesh geometry.
  130909. */
  130910. update(): void;
  130911. /**
  130912. * Returns a new TrailMesh object.
  130913. * @param name is a string, the name given to the new mesh
  130914. * @param newGenerator use new generator object for cloned trail mesh
  130915. * @returns a new mesh
  130916. */
  130917. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  130918. /**
  130919. * Serializes this trail mesh
  130920. * @param serializationObject object to write serialization to
  130921. */
  130922. serialize(serializationObject: any): void;
  130923. /**
  130924. * Parses a serialized trail mesh
  130925. * @param parsedMesh the serialized mesh
  130926. * @param scene the scene to create the trail mesh in
  130927. * @returns the created trail mesh
  130928. */
  130929. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  130930. }
  130931. }
  130932. declare module BABYLON {
  130933. /**
  130934. * Class containing static functions to help procedurally build meshes
  130935. */
  130936. export class TiledBoxBuilder {
  130937. /**
  130938. * Creates a box mesh
  130939. * 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)
  130940. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  130941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130944. * @param name defines the name of the mesh
  130945. * @param options defines the options used to create the mesh
  130946. * @param scene defines the hosting scene
  130947. * @returns the box mesh
  130948. */
  130949. static CreateTiledBox(name: string, options: {
  130950. pattern?: number;
  130951. width?: number;
  130952. height?: number;
  130953. depth?: number;
  130954. tileSize?: number;
  130955. tileWidth?: number;
  130956. tileHeight?: number;
  130957. alignHorizontal?: number;
  130958. alignVertical?: number;
  130959. faceUV?: Vector4[];
  130960. faceColors?: Color4[];
  130961. sideOrientation?: number;
  130962. updatable?: boolean;
  130963. }, scene?: Nullable<Scene>): Mesh;
  130964. }
  130965. }
  130966. declare module BABYLON {
  130967. /**
  130968. * Class containing static functions to help procedurally build meshes
  130969. */
  130970. export class TorusKnotBuilder {
  130971. /**
  130972. * Creates a torus knot mesh
  130973. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  130974. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  130975. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  130976. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  130977. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130978. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  130980. * @param name defines the name of the mesh
  130981. * @param options defines the options used to create the mesh
  130982. * @param scene defines the hosting scene
  130983. * @returns the torus knot mesh
  130984. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  130985. */
  130986. static CreateTorusKnot(name: string, options: {
  130987. radius?: number;
  130988. tube?: number;
  130989. radialSegments?: number;
  130990. tubularSegments?: number;
  130991. p?: number;
  130992. q?: number;
  130993. updatable?: boolean;
  130994. sideOrientation?: number;
  130995. frontUVs?: Vector4;
  130996. backUVs?: Vector4;
  130997. }, scene: any): Mesh;
  130998. }
  130999. }
  131000. declare module BABYLON {
  131001. /**
  131002. * Polygon
  131003. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  131004. */
  131005. export class Polygon {
  131006. /**
  131007. * Creates a rectangle
  131008. * @param xmin bottom X coord
  131009. * @param ymin bottom Y coord
  131010. * @param xmax top X coord
  131011. * @param ymax top Y coord
  131012. * @returns points that make the resulting rectation
  131013. */
  131014. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  131015. /**
  131016. * Creates a circle
  131017. * @param radius radius of circle
  131018. * @param cx scale in x
  131019. * @param cy scale in y
  131020. * @param numberOfSides number of sides that make up the circle
  131021. * @returns points that make the resulting circle
  131022. */
  131023. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  131024. /**
  131025. * Creates a polygon from input string
  131026. * @param input Input polygon data
  131027. * @returns the parsed points
  131028. */
  131029. static Parse(input: string): Vector2[];
  131030. /**
  131031. * Starts building a polygon from x and y coordinates
  131032. * @param x x coordinate
  131033. * @param y y coordinate
  131034. * @returns the started path2
  131035. */
  131036. static StartingAt(x: number, y: number): Path2;
  131037. }
  131038. /**
  131039. * Builds a polygon
  131040. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  131041. */
  131042. export class PolygonMeshBuilder {
  131043. private _points;
  131044. private _outlinepoints;
  131045. private _holes;
  131046. private _name;
  131047. private _scene;
  131048. private _epoints;
  131049. private _eholes;
  131050. private _addToepoint;
  131051. /**
  131052. * Babylon reference to the earcut plugin.
  131053. */
  131054. bjsEarcut: any;
  131055. /**
  131056. * Creates a PolygonMeshBuilder
  131057. * @param name name of the builder
  131058. * @param contours Path of the polygon
  131059. * @param scene scene to add to when creating the mesh
  131060. * @param earcutInjection can be used to inject your own earcut reference
  131061. */
  131062. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  131063. /**
  131064. * Adds a whole within the polygon
  131065. * @param hole Array of points defining the hole
  131066. * @returns this
  131067. */
  131068. addHole(hole: Vector2[]): PolygonMeshBuilder;
  131069. /**
  131070. * Creates the polygon
  131071. * @param updatable If the mesh should be updatable
  131072. * @param depth The depth of the mesh created
  131073. * @returns the created mesh
  131074. */
  131075. build(updatable?: boolean, depth?: number): Mesh;
  131076. /**
  131077. * Creates the polygon
  131078. * @param depth The depth of the mesh created
  131079. * @returns the created VertexData
  131080. */
  131081. buildVertexData(depth?: number): VertexData;
  131082. /**
  131083. * Adds a side to the polygon
  131084. * @param positions points that make the polygon
  131085. * @param normals normals of the polygon
  131086. * @param uvs uvs of the polygon
  131087. * @param indices indices of the polygon
  131088. * @param bounds bounds of the polygon
  131089. * @param points points of the polygon
  131090. * @param depth depth of the polygon
  131091. * @param flip flip of the polygon
  131092. */
  131093. private addSide;
  131094. }
  131095. }
  131096. declare module BABYLON {
  131097. /**
  131098. * Class containing static functions to help procedurally build meshes
  131099. */
  131100. export class PolygonBuilder {
  131101. /**
  131102. * Creates a polygon mesh
  131103. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  131104. * * 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
  131105. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  131106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  131108. * * Remember you can only change the shape positions, not their number when updating a polygon
  131109. * @param name defines the name of the mesh
  131110. * @param options defines the options used to create the mesh
  131111. * @param scene defines the hosting scene
  131112. * @param earcutInjection can be used to inject your own earcut reference
  131113. * @returns the polygon mesh
  131114. */
  131115. static CreatePolygon(name: string, options: {
  131116. shape: Vector3[];
  131117. holes?: Vector3[][];
  131118. depth?: number;
  131119. faceUV?: Vector4[];
  131120. faceColors?: Color4[];
  131121. updatable?: boolean;
  131122. sideOrientation?: number;
  131123. frontUVs?: Vector4;
  131124. backUVs?: Vector4;
  131125. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  131126. /**
  131127. * Creates an extruded polygon mesh, with depth in the Y direction.
  131128. * * 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)
  131129. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131130. * @param name defines the name of the mesh
  131131. * @param options defines the options used to create the mesh
  131132. * @param scene defines the hosting scene
  131133. * @param earcutInjection can be used to inject your own earcut reference
  131134. * @returns the polygon mesh
  131135. */
  131136. static ExtrudePolygon(name: string, options: {
  131137. shape: Vector3[];
  131138. holes?: Vector3[][];
  131139. depth?: number;
  131140. faceUV?: Vector4[];
  131141. faceColors?: Color4[];
  131142. updatable?: boolean;
  131143. sideOrientation?: number;
  131144. frontUVs?: Vector4;
  131145. backUVs?: Vector4;
  131146. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  131147. }
  131148. }
  131149. declare module BABYLON {
  131150. /**
  131151. * Class containing static functions to help procedurally build meshes
  131152. */
  131153. export class LatheBuilder {
  131154. /**
  131155. * Creates lathe mesh.
  131156. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  131157. * * 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
  131158. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  131159. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  131160. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  131161. * * 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
  131162. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  131163. * * 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
  131164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131166. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131168. * @param name defines the name of the mesh
  131169. * @param options defines the options used to create the mesh
  131170. * @param scene defines the hosting scene
  131171. * @returns the lathe mesh
  131172. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  131173. */
  131174. static CreateLathe(name: string, options: {
  131175. shape: Vector3[];
  131176. radius?: number;
  131177. tessellation?: number;
  131178. clip?: number;
  131179. arc?: number;
  131180. closed?: boolean;
  131181. updatable?: boolean;
  131182. sideOrientation?: number;
  131183. frontUVs?: Vector4;
  131184. backUVs?: Vector4;
  131185. cap?: number;
  131186. invertUV?: boolean;
  131187. }, scene?: Nullable<Scene>): Mesh;
  131188. }
  131189. }
  131190. declare module BABYLON {
  131191. /**
  131192. * Class containing static functions to help procedurally build meshes
  131193. */
  131194. export class TiledPlaneBuilder {
  131195. /**
  131196. * Creates a tiled plane mesh
  131197. * * The parameter `pattern` will, depending on value, do nothing or
  131198. * * * flip (reflect about central vertical) alternate tiles across and up
  131199. * * * flip every tile on alternate rows
  131200. * * * rotate (180 degs) alternate tiles across and up
  131201. * * * rotate every tile on alternate rows
  131202. * * * flip and rotate alternate tiles across and up
  131203. * * * flip and rotate every tile on alternate rows
  131204. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  131205. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  131206. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  131208. * * 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)
  131209. * * 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)
  131210. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131211. * @param name defines the name of the mesh
  131212. * @param options defines the options used to create the mesh
  131213. * @param scene defines the hosting scene
  131214. * @returns the box mesh
  131215. */
  131216. static CreateTiledPlane(name: string, options: {
  131217. pattern?: number;
  131218. tileSize?: number;
  131219. tileWidth?: number;
  131220. tileHeight?: number;
  131221. size?: number;
  131222. width?: number;
  131223. height?: number;
  131224. alignHorizontal?: number;
  131225. alignVertical?: number;
  131226. sideOrientation?: number;
  131227. frontUVs?: Vector4;
  131228. backUVs?: Vector4;
  131229. updatable?: boolean;
  131230. }, scene?: Nullable<Scene>): Mesh;
  131231. }
  131232. }
  131233. declare module BABYLON {
  131234. /**
  131235. * Class containing static functions to help procedurally build meshes
  131236. */
  131237. export class TubeBuilder {
  131238. /**
  131239. * Creates a tube mesh.
  131240. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131241. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  131242. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  131243. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  131244. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  131245. * * 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)
  131246. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  131247. * * 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
  131248. * * 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
  131249. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131250. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131251. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131253. * @param name defines the name of the mesh
  131254. * @param options defines the options used to create the mesh
  131255. * @param scene defines the hosting scene
  131256. * @returns the tube mesh
  131257. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131258. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  131259. */
  131260. static CreateTube(name: string, options: {
  131261. path: Vector3[];
  131262. radius?: number;
  131263. tessellation?: number;
  131264. radiusFunction?: {
  131265. (i: number, distance: number): number;
  131266. };
  131267. cap?: number;
  131268. arc?: number;
  131269. updatable?: boolean;
  131270. sideOrientation?: number;
  131271. frontUVs?: Vector4;
  131272. backUVs?: Vector4;
  131273. instance?: Mesh;
  131274. invertUV?: boolean;
  131275. }, scene?: Nullable<Scene>): Mesh;
  131276. }
  131277. }
  131278. declare module BABYLON {
  131279. /**
  131280. * Class containing static functions to help procedurally build meshes
  131281. */
  131282. export class IcoSphereBuilder {
  131283. /**
  131284. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  131285. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  131286. * * 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`)
  131287. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  131288. * * 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
  131289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131290. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131292. * @param name defines the name of the mesh
  131293. * @param options defines the options used to create the mesh
  131294. * @param scene defines the hosting scene
  131295. * @returns the icosahedron mesh
  131296. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  131297. */
  131298. static CreateIcoSphere(name: string, options: {
  131299. radius?: number;
  131300. radiusX?: number;
  131301. radiusY?: number;
  131302. radiusZ?: number;
  131303. flat?: boolean;
  131304. subdivisions?: number;
  131305. sideOrientation?: number;
  131306. frontUVs?: Vector4;
  131307. backUVs?: Vector4;
  131308. updatable?: boolean;
  131309. }, scene?: Nullable<Scene>): Mesh;
  131310. }
  131311. }
  131312. declare module BABYLON {
  131313. /**
  131314. * Class containing static functions to help procedurally build meshes
  131315. */
  131316. export class DecalBuilder {
  131317. /**
  131318. * Creates a decal mesh.
  131319. * 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
  131320. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  131321. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  131322. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  131323. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  131324. * @param name defines the name of the mesh
  131325. * @param sourceMesh defines the mesh where the decal must be applied
  131326. * @param options defines the options used to create the mesh
  131327. * @param scene defines the hosting scene
  131328. * @returns the decal mesh
  131329. * @see https://doc.babylonjs.com/how_to/decals
  131330. */
  131331. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  131332. position?: Vector3;
  131333. normal?: Vector3;
  131334. size?: Vector3;
  131335. angle?: number;
  131336. }): Mesh;
  131337. }
  131338. }
  131339. declare module BABYLON {
  131340. /**
  131341. * Class containing static functions to help procedurally build meshes
  131342. */
  131343. export class MeshBuilder {
  131344. /**
  131345. * Creates a box mesh
  131346. * * The parameter `size` sets the size (float) of each box side (default 1)
  131347. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  131348. * * 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)
  131349. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131353. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131354. * @param name defines the name of the mesh
  131355. * @param options defines the options used to create the mesh
  131356. * @param scene defines the hosting scene
  131357. * @returns the box mesh
  131358. */
  131359. static CreateBox(name: string, options: {
  131360. size?: number;
  131361. width?: number;
  131362. height?: number;
  131363. depth?: number;
  131364. faceUV?: Vector4[];
  131365. faceColors?: Color4[];
  131366. sideOrientation?: number;
  131367. frontUVs?: Vector4;
  131368. backUVs?: Vector4;
  131369. updatable?: boolean;
  131370. }, scene?: Nullable<Scene>): Mesh;
  131371. /**
  131372. * Creates a tiled box mesh
  131373. * * faceTiles sets the pattern, tile size and number of tiles for a face
  131374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131375. * @param name defines the name of the mesh
  131376. * @param options defines the options used to create the mesh
  131377. * @param scene defines the hosting scene
  131378. * @returns the tiled box mesh
  131379. */
  131380. static CreateTiledBox(name: string, options: {
  131381. pattern?: number;
  131382. size?: number;
  131383. width?: number;
  131384. height?: number;
  131385. depth: number;
  131386. tileSize?: number;
  131387. tileWidth?: number;
  131388. tileHeight?: number;
  131389. faceUV?: Vector4[];
  131390. faceColors?: Color4[];
  131391. alignHorizontal?: number;
  131392. alignVertical?: number;
  131393. sideOrientation?: number;
  131394. updatable?: boolean;
  131395. }, scene?: Nullable<Scene>): Mesh;
  131396. /**
  131397. * Creates a sphere mesh
  131398. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  131399. * * 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`)
  131400. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  131401. * * 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
  131402. * * 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)
  131403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131406. * @param name defines the name of the mesh
  131407. * @param options defines the options used to create the mesh
  131408. * @param scene defines the hosting scene
  131409. * @returns the sphere mesh
  131410. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  131411. */
  131412. static CreateSphere(name: string, options: {
  131413. segments?: number;
  131414. diameter?: number;
  131415. diameterX?: number;
  131416. diameterY?: number;
  131417. diameterZ?: number;
  131418. arc?: number;
  131419. slice?: number;
  131420. sideOrientation?: number;
  131421. frontUVs?: Vector4;
  131422. backUVs?: Vector4;
  131423. updatable?: boolean;
  131424. }, scene?: Nullable<Scene>): Mesh;
  131425. /**
  131426. * Creates a plane polygonal mesh. By default, this is a disc
  131427. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  131428. * * 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
  131429. * * 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
  131430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131433. * @param name defines the name of the mesh
  131434. * @param options defines the options used to create the mesh
  131435. * @param scene defines the hosting scene
  131436. * @returns the plane polygonal mesh
  131437. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  131438. */
  131439. static CreateDisc(name: string, options: {
  131440. radius?: number;
  131441. tessellation?: number;
  131442. arc?: number;
  131443. updatable?: boolean;
  131444. sideOrientation?: number;
  131445. frontUVs?: Vector4;
  131446. backUVs?: Vector4;
  131447. }, scene?: Nullable<Scene>): Mesh;
  131448. /**
  131449. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  131450. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  131451. * * 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`)
  131452. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  131453. * * 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
  131454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131457. * @param name defines the name of the mesh
  131458. * @param options defines the options used to create the mesh
  131459. * @param scene defines the hosting scene
  131460. * @returns the icosahedron mesh
  131461. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  131462. */
  131463. static CreateIcoSphere(name: string, options: {
  131464. radius?: number;
  131465. radiusX?: number;
  131466. radiusY?: number;
  131467. radiusZ?: number;
  131468. flat?: boolean;
  131469. subdivisions?: number;
  131470. sideOrientation?: number;
  131471. frontUVs?: Vector4;
  131472. backUVs?: Vector4;
  131473. updatable?: boolean;
  131474. }, scene?: Nullable<Scene>): Mesh;
  131475. /**
  131476. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131477. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131478. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131479. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131480. * * 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
  131481. * * 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
  131482. * * 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
  131483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131485. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131486. * * 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
  131487. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131488. * * 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
  131489. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131491. * @param name defines the name of the mesh
  131492. * @param options defines the options used to create the mesh
  131493. * @param scene defines the hosting scene
  131494. * @returns the ribbon mesh
  131495. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131497. */
  131498. static CreateRibbon(name: string, options: {
  131499. pathArray: Vector3[][];
  131500. closeArray?: boolean;
  131501. closePath?: boolean;
  131502. offset?: number;
  131503. updatable?: boolean;
  131504. sideOrientation?: number;
  131505. frontUVs?: Vector4;
  131506. backUVs?: Vector4;
  131507. instance?: Mesh;
  131508. invertUV?: boolean;
  131509. uvs?: Vector2[];
  131510. colors?: Color4[];
  131511. }, scene?: Nullable<Scene>): Mesh;
  131512. /**
  131513. * Creates a cylinder or a cone mesh
  131514. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  131515. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  131516. * * 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.
  131517. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  131518. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  131519. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  131520. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  131521. * * 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).
  131522. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  131523. * * 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).
  131524. * * 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
  131525. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  131526. * * 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
  131527. * * 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.
  131528. * * If `enclose` is false, a ring surface is one element.
  131529. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  131530. * * 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
  131531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131534. * @param name defines the name of the mesh
  131535. * @param options defines the options used to create the mesh
  131536. * @param scene defines the hosting scene
  131537. * @returns the cylinder mesh
  131538. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  131539. */
  131540. static CreateCylinder(name: string, options: {
  131541. height?: number;
  131542. diameterTop?: number;
  131543. diameterBottom?: number;
  131544. diameter?: number;
  131545. tessellation?: number;
  131546. subdivisions?: number;
  131547. arc?: number;
  131548. faceColors?: Color4[];
  131549. faceUV?: Vector4[];
  131550. updatable?: boolean;
  131551. hasRings?: boolean;
  131552. enclose?: boolean;
  131553. cap?: number;
  131554. sideOrientation?: number;
  131555. frontUVs?: Vector4;
  131556. backUVs?: Vector4;
  131557. }, scene?: Nullable<Scene>): Mesh;
  131558. /**
  131559. * Creates a torus mesh
  131560. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  131561. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  131562. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  131563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131566. * @param name defines the name of the mesh
  131567. * @param options defines the options used to create the mesh
  131568. * @param scene defines the hosting scene
  131569. * @returns the torus mesh
  131570. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  131571. */
  131572. static CreateTorus(name: string, options: {
  131573. diameter?: number;
  131574. thickness?: number;
  131575. tessellation?: number;
  131576. updatable?: boolean;
  131577. sideOrientation?: number;
  131578. frontUVs?: Vector4;
  131579. backUVs?: Vector4;
  131580. }, scene?: Nullable<Scene>): Mesh;
  131581. /**
  131582. * Creates a torus knot mesh
  131583. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  131584. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  131585. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  131586. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  131587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131590. * @param name defines the name of the mesh
  131591. * @param options defines the options used to create the mesh
  131592. * @param scene defines the hosting scene
  131593. * @returns the torus knot mesh
  131594. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  131595. */
  131596. static CreateTorusKnot(name: string, options: {
  131597. radius?: number;
  131598. tube?: number;
  131599. radialSegments?: number;
  131600. tubularSegments?: number;
  131601. p?: number;
  131602. q?: number;
  131603. updatable?: boolean;
  131604. sideOrientation?: number;
  131605. frontUVs?: Vector4;
  131606. backUVs?: Vector4;
  131607. }, scene?: Nullable<Scene>): Mesh;
  131608. /**
  131609. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  131610. * * 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
  131611. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  131612. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  131613. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  131614. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  131615. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  131616. * * 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
  131617. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  131618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  131620. * @param name defines the name of the new line system
  131621. * @param options defines the options used to create the line system
  131622. * @param scene defines the hosting scene
  131623. * @returns a new line system mesh
  131624. */
  131625. static CreateLineSystem(name: string, options: {
  131626. lines: Vector3[][];
  131627. updatable?: boolean;
  131628. instance?: Nullable<LinesMesh>;
  131629. colors?: Nullable<Color4[][]>;
  131630. useVertexAlpha?: boolean;
  131631. }, scene: Nullable<Scene>): LinesMesh;
  131632. /**
  131633. * Creates a line mesh
  131634. * 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
  131635. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  131636. * * The parameter `points` is an array successive Vector3
  131637. * * 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
  131638. * * The optional parameter `colors` is an array of successive Color4, one per line point
  131639. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  131640. * * When updating an instance, remember that only point positions can change, not the number of points
  131641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  131643. * @param name defines the name of the new line system
  131644. * @param options defines the options used to create the line system
  131645. * @param scene defines the hosting scene
  131646. * @returns a new line mesh
  131647. */
  131648. static CreateLines(name: string, options: {
  131649. points: Vector3[];
  131650. updatable?: boolean;
  131651. instance?: Nullable<LinesMesh>;
  131652. colors?: Color4[];
  131653. useVertexAlpha?: boolean;
  131654. }, scene?: Nullable<Scene>): LinesMesh;
  131655. /**
  131656. * Creates a dashed line mesh
  131657. * * 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
  131658. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  131659. * * The parameter `points` is an array successive Vector3
  131660. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  131661. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  131662. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  131663. * * 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
  131664. * * When updating an instance, remember that only point positions can change, not the number of points
  131665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131666. * @param name defines the name of the mesh
  131667. * @param options defines the options used to create the mesh
  131668. * @param scene defines the hosting scene
  131669. * @returns the dashed line mesh
  131670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  131671. */
  131672. static CreateDashedLines(name: string, options: {
  131673. points: Vector3[];
  131674. dashSize?: number;
  131675. gapSize?: number;
  131676. dashNb?: number;
  131677. updatable?: boolean;
  131678. instance?: LinesMesh;
  131679. }, scene?: Nullable<Scene>): LinesMesh;
  131680. /**
  131681. * 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.
  131682. * * 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.
  131683. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131684. * * 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.
  131685. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131686. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  131687. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  131688. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131691. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131693. * @param name defines the name of the mesh
  131694. * @param options defines the options used to create the mesh
  131695. * @param scene defines the hosting scene
  131696. * @returns the extruded shape mesh
  131697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131699. */
  131700. static ExtrudeShape(name: string, options: {
  131701. shape: Vector3[];
  131702. path: Vector3[];
  131703. scale?: number;
  131704. rotation?: number;
  131705. cap?: number;
  131706. updatable?: boolean;
  131707. sideOrientation?: number;
  131708. frontUVs?: Vector4;
  131709. backUVs?: Vector4;
  131710. instance?: Mesh;
  131711. invertUV?: boolean;
  131712. }, scene?: Nullable<Scene>): Mesh;
  131713. /**
  131714. * Creates an custom extruded shape mesh.
  131715. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131716. * * 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.
  131717. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131718. * * 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
  131719. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131720. * * 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
  131721. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131722. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131723. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131724. * * 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
  131725. * * 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
  131726. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131729. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131731. * @param name defines the name of the mesh
  131732. * @param options defines the options used to create the mesh
  131733. * @param scene defines the hosting scene
  131734. * @returns the custom extruded shape mesh
  131735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131736. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131737. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131738. */
  131739. static ExtrudeShapeCustom(name: string, options: {
  131740. shape: Vector3[];
  131741. path: Vector3[];
  131742. scaleFunction?: any;
  131743. rotationFunction?: any;
  131744. ribbonCloseArray?: boolean;
  131745. ribbonClosePath?: boolean;
  131746. cap?: number;
  131747. updatable?: boolean;
  131748. sideOrientation?: number;
  131749. frontUVs?: Vector4;
  131750. backUVs?: Vector4;
  131751. instance?: Mesh;
  131752. invertUV?: boolean;
  131753. }, scene?: Nullable<Scene>): Mesh;
  131754. /**
  131755. * Creates lathe mesh.
  131756. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  131757. * * 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
  131758. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  131759. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  131760. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  131761. * * 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
  131762. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  131763. * * 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
  131764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131768. * @param name defines the name of the mesh
  131769. * @param options defines the options used to create the mesh
  131770. * @param scene defines the hosting scene
  131771. * @returns the lathe mesh
  131772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  131773. */
  131774. static CreateLathe(name: string, options: {
  131775. shape: Vector3[];
  131776. radius?: number;
  131777. tessellation?: number;
  131778. clip?: number;
  131779. arc?: number;
  131780. closed?: boolean;
  131781. updatable?: boolean;
  131782. sideOrientation?: number;
  131783. frontUVs?: Vector4;
  131784. backUVs?: Vector4;
  131785. cap?: number;
  131786. invertUV?: boolean;
  131787. }, scene?: Nullable<Scene>): Mesh;
  131788. /**
  131789. * Creates a tiled plane mesh
  131790. * * You can set a limited pattern arrangement with the tiles
  131791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131794. * @param name defines the name of the mesh
  131795. * @param options defines the options used to create the mesh
  131796. * @param scene defines the hosting scene
  131797. * @returns the plane mesh
  131798. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  131799. */
  131800. static CreateTiledPlane(name: string, options: {
  131801. pattern?: number;
  131802. tileSize?: number;
  131803. tileWidth?: number;
  131804. tileHeight?: number;
  131805. size?: number;
  131806. width?: number;
  131807. height?: number;
  131808. alignHorizontal?: number;
  131809. alignVertical?: number;
  131810. sideOrientation?: number;
  131811. frontUVs?: Vector4;
  131812. backUVs?: Vector4;
  131813. updatable?: boolean;
  131814. }, scene?: Nullable<Scene>): Mesh;
  131815. /**
  131816. * Creates a plane mesh
  131817. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  131818. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  131819. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  131820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131823. * @param name defines the name of the mesh
  131824. * @param options defines the options used to create the mesh
  131825. * @param scene defines the hosting scene
  131826. * @returns the plane mesh
  131827. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  131828. */
  131829. static CreatePlane(name: string, options: {
  131830. size?: number;
  131831. width?: number;
  131832. height?: number;
  131833. sideOrientation?: number;
  131834. frontUVs?: Vector4;
  131835. backUVs?: Vector4;
  131836. updatable?: boolean;
  131837. sourcePlane?: Plane;
  131838. }, scene?: Nullable<Scene>): Mesh;
  131839. /**
  131840. * Creates a ground mesh
  131841. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  131842. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  131843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131844. * @param name defines the name of the mesh
  131845. * @param options defines the options used to create the mesh
  131846. * @param scene defines the hosting scene
  131847. * @returns the ground mesh
  131848. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  131849. */
  131850. static CreateGround(name: string, options: {
  131851. width?: number;
  131852. height?: number;
  131853. subdivisions?: number;
  131854. subdivisionsX?: number;
  131855. subdivisionsY?: number;
  131856. updatable?: boolean;
  131857. }, scene?: Nullable<Scene>): Mesh;
  131858. /**
  131859. * Creates a tiled ground mesh
  131860. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  131861. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  131862. * * 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
  131863. * * 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
  131864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131865. * @param name defines the name of the mesh
  131866. * @param options defines the options used to create the mesh
  131867. * @param scene defines the hosting scene
  131868. * @returns the tiled ground mesh
  131869. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  131870. */
  131871. static CreateTiledGround(name: string, options: {
  131872. xmin: number;
  131873. zmin: number;
  131874. xmax: number;
  131875. zmax: number;
  131876. subdivisions?: {
  131877. w: number;
  131878. h: number;
  131879. };
  131880. precision?: {
  131881. w: number;
  131882. h: number;
  131883. };
  131884. updatable?: boolean;
  131885. }, scene?: Nullable<Scene>): Mesh;
  131886. /**
  131887. * Creates a ground mesh from a height map
  131888. * * The parameter `url` sets the URL of the height map image resource.
  131889. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  131890. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  131891. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  131892. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  131893. * * 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.
  131894. * * 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).
  131895. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  131896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131897. * @param name defines the name of the mesh
  131898. * @param url defines the url to the height map
  131899. * @param options defines the options used to create the mesh
  131900. * @param scene defines the hosting scene
  131901. * @returns the ground mesh
  131902. * @see https://doc.babylonjs.com/babylon101/height_map
  131903. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  131904. */
  131905. static CreateGroundFromHeightMap(name: string, url: string, options: {
  131906. width?: number;
  131907. height?: number;
  131908. subdivisions?: number;
  131909. minHeight?: number;
  131910. maxHeight?: number;
  131911. colorFilter?: Color3;
  131912. alphaFilter?: number;
  131913. updatable?: boolean;
  131914. onReady?: (mesh: GroundMesh) => void;
  131915. }, scene?: Nullable<Scene>): GroundMesh;
  131916. /**
  131917. * Creates a polygon mesh
  131918. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  131919. * * 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
  131920. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  131921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  131923. * * Remember you can only change the shape positions, not their number when updating a polygon
  131924. * @param name defines the name of the mesh
  131925. * @param options defines the options used to create the mesh
  131926. * @param scene defines the hosting scene
  131927. * @param earcutInjection can be used to inject your own earcut reference
  131928. * @returns the polygon mesh
  131929. */
  131930. static CreatePolygon(name: string, options: {
  131931. shape: Vector3[];
  131932. holes?: Vector3[][];
  131933. depth?: number;
  131934. faceUV?: Vector4[];
  131935. faceColors?: Color4[];
  131936. updatable?: boolean;
  131937. sideOrientation?: number;
  131938. frontUVs?: Vector4;
  131939. backUVs?: Vector4;
  131940. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  131941. /**
  131942. * Creates an extruded polygon mesh, with depth in the Y direction.
  131943. * * 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)
  131944. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131945. * @param name defines the name of the mesh
  131946. * @param options defines the options used to create the mesh
  131947. * @param scene defines the hosting scene
  131948. * @param earcutInjection can be used to inject your own earcut reference
  131949. * @returns the polygon mesh
  131950. */
  131951. static ExtrudePolygon(name: string, options: {
  131952. shape: Vector3[];
  131953. holes?: Vector3[][];
  131954. depth?: number;
  131955. faceUV?: Vector4[];
  131956. faceColors?: Color4[];
  131957. updatable?: boolean;
  131958. sideOrientation?: number;
  131959. frontUVs?: Vector4;
  131960. backUVs?: Vector4;
  131961. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  131962. /**
  131963. * Creates a tube mesh.
  131964. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131965. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  131966. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  131967. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  131968. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  131969. * * 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)
  131970. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  131971. * * 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
  131972. * * 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
  131973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131977. * @param name defines the name of the mesh
  131978. * @param options defines the options used to create the mesh
  131979. * @param scene defines the hosting scene
  131980. * @returns the tube mesh
  131981. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131982. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  131983. */
  131984. static CreateTube(name: string, options: {
  131985. path: Vector3[];
  131986. radius?: number;
  131987. tessellation?: number;
  131988. radiusFunction?: {
  131989. (i: number, distance: number): number;
  131990. };
  131991. cap?: number;
  131992. arc?: number;
  131993. updatable?: boolean;
  131994. sideOrientation?: number;
  131995. frontUVs?: Vector4;
  131996. backUVs?: Vector4;
  131997. instance?: Mesh;
  131998. invertUV?: boolean;
  131999. }, scene?: Nullable<Scene>): Mesh;
  132000. /**
  132001. * Creates a polyhedron mesh
  132002. * * 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
  132003. * * The parameter `size` (positive float, default 1) sets the polygon size
  132004. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  132005. * * 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`
  132006. * * 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
  132007. * * 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)`)
  132008. * * 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
  132009. * * 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
  132010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  132012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132013. * @param name defines the name of the mesh
  132014. * @param options defines the options used to create the mesh
  132015. * @param scene defines the hosting scene
  132016. * @returns the polyhedron mesh
  132017. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  132018. */
  132019. static CreatePolyhedron(name: string, options: {
  132020. type?: number;
  132021. size?: number;
  132022. sizeX?: number;
  132023. sizeY?: number;
  132024. sizeZ?: number;
  132025. custom?: any;
  132026. faceUV?: Vector4[];
  132027. faceColors?: Color4[];
  132028. flat?: boolean;
  132029. updatable?: boolean;
  132030. sideOrientation?: number;
  132031. frontUVs?: Vector4;
  132032. backUVs?: Vector4;
  132033. }, scene?: Nullable<Scene>): Mesh;
  132034. /**
  132035. * Creates a decal mesh.
  132036. * 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
  132037. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  132038. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  132039. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  132040. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  132041. * @param name defines the name of the mesh
  132042. * @param sourceMesh defines the mesh where the decal must be applied
  132043. * @param options defines the options used to create the mesh
  132044. * @param scene defines the hosting scene
  132045. * @returns the decal mesh
  132046. * @see https://doc.babylonjs.com/how_to/decals
  132047. */
  132048. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  132049. position?: Vector3;
  132050. normal?: Vector3;
  132051. size?: Vector3;
  132052. angle?: number;
  132053. }): Mesh;
  132054. }
  132055. }
  132056. declare module BABYLON {
  132057. /**
  132058. * A simplifier interface for future simplification implementations
  132059. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132060. */
  132061. export interface ISimplifier {
  132062. /**
  132063. * Simplification of a given mesh according to the given settings.
  132064. * Since this requires computation, it is assumed that the function runs async.
  132065. * @param settings The settings of the simplification, including quality and distance
  132066. * @param successCallback A callback that will be called after the mesh was simplified.
  132067. * @param errorCallback in case of an error, this callback will be called. optional.
  132068. */
  132069. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  132070. }
  132071. /**
  132072. * Expected simplification settings.
  132073. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  132074. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132075. */
  132076. export interface ISimplificationSettings {
  132077. /**
  132078. * Gets or sets the expected quality
  132079. */
  132080. quality: number;
  132081. /**
  132082. * Gets or sets the distance when this optimized version should be used
  132083. */
  132084. distance: number;
  132085. /**
  132086. * Gets an already optimized mesh
  132087. */
  132088. optimizeMesh?: boolean;
  132089. }
  132090. /**
  132091. * Class used to specify simplification options
  132092. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132093. */
  132094. export class SimplificationSettings implements ISimplificationSettings {
  132095. /** expected quality */
  132096. quality: number;
  132097. /** distance when this optimized version should be used */
  132098. distance: number;
  132099. /** already optimized mesh */
  132100. optimizeMesh?: boolean | undefined;
  132101. /**
  132102. * Creates a SimplificationSettings
  132103. * @param quality expected quality
  132104. * @param distance distance when this optimized version should be used
  132105. * @param optimizeMesh already optimized mesh
  132106. */
  132107. constructor(
  132108. /** expected quality */
  132109. quality: number,
  132110. /** distance when this optimized version should be used */
  132111. distance: number,
  132112. /** already optimized mesh */
  132113. optimizeMesh?: boolean | undefined);
  132114. }
  132115. /**
  132116. * Interface used to define a simplification task
  132117. */
  132118. export interface ISimplificationTask {
  132119. /**
  132120. * Array of settings
  132121. */
  132122. settings: Array<ISimplificationSettings>;
  132123. /**
  132124. * Simplification type
  132125. */
  132126. simplificationType: SimplificationType;
  132127. /**
  132128. * Mesh to simplify
  132129. */
  132130. mesh: Mesh;
  132131. /**
  132132. * Callback called on success
  132133. */
  132134. successCallback?: () => void;
  132135. /**
  132136. * Defines if parallel processing can be used
  132137. */
  132138. parallelProcessing: boolean;
  132139. }
  132140. /**
  132141. * Queue used to order the simplification tasks
  132142. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132143. */
  132144. export class SimplificationQueue {
  132145. private _simplificationArray;
  132146. /**
  132147. * Gets a boolean indicating that the process is still running
  132148. */
  132149. running: boolean;
  132150. /**
  132151. * Creates a new queue
  132152. */
  132153. constructor();
  132154. /**
  132155. * Adds a new simplification task
  132156. * @param task defines a task to add
  132157. */
  132158. addTask(task: ISimplificationTask): void;
  132159. /**
  132160. * Execute next task
  132161. */
  132162. executeNext(): void;
  132163. /**
  132164. * Execute a simplification task
  132165. * @param task defines the task to run
  132166. */
  132167. runSimplification(task: ISimplificationTask): void;
  132168. private getSimplifier;
  132169. }
  132170. /**
  132171. * The implemented types of simplification
  132172. * At the moment only Quadratic Error Decimation is implemented
  132173. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132174. */
  132175. export enum SimplificationType {
  132176. /** Quadratic error decimation */
  132177. QUADRATIC = 0
  132178. }
  132179. }
  132180. declare module BABYLON {
  132181. interface Scene {
  132182. /** @hidden (Backing field) */
  132183. _simplificationQueue: SimplificationQueue;
  132184. /**
  132185. * Gets or sets the simplification queue attached to the scene
  132186. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  132187. */
  132188. simplificationQueue: SimplificationQueue;
  132189. }
  132190. interface Mesh {
  132191. /**
  132192. * Simplify the mesh according to the given array of settings.
  132193. * Function will return immediately and will simplify async
  132194. * @param settings a collection of simplification settings
  132195. * @param parallelProcessing should all levels calculate parallel or one after the other
  132196. * @param simplificationType the type of simplification to run
  132197. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  132198. * @returns the current mesh
  132199. */
  132200. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  132201. }
  132202. /**
  132203. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  132204. * created in a scene
  132205. */
  132206. export class SimplicationQueueSceneComponent implements ISceneComponent {
  132207. /**
  132208. * The component name helpfull to identify the component in the list of scene components.
  132209. */
  132210. readonly name: string;
  132211. /**
  132212. * The scene the component belongs to.
  132213. */
  132214. scene: Scene;
  132215. /**
  132216. * Creates a new instance of the component for the given scene
  132217. * @param scene Defines the scene to register the component in
  132218. */
  132219. constructor(scene: Scene);
  132220. /**
  132221. * Registers the component in a given scene
  132222. */
  132223. register(): void;
  132224. /**
  132225. * Rebuilds the elements related to this component in case of
  132226. * context lost for instance.
  132227. */
  132228. rebuild(): void;
  132229. /**
  132230. * Disposes the component and the associated ressources
  132231. */
  132232. dispose(): void;
  132233. private _beforeCameraUpdate;
  132234. }
  132235. }
  132236. declare module BABYLON {
  132237. /**
  132238. * Navigation plugin interface to add navigation constrained by a navigation mesh
  132239. */
  132240. export interface INavigationEnginePlugin {
  132241. /**
  132242. * plugin name
  132243. */
  132244. name: string;
  132245. /**
  132246. * Creates a navigation mesh
  132247. * @param meshes array of all the geometry used to compute the navigatio mesh
  132248. * @param parameters bunch of parameters used to filter geometry
  132249. */
  132250. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  132251. /**
  132252. * Create a navigation mesh debug mesh
  132253. * @param scene is where the mesh will be added
  132254. * @returns debug display mesh
  132255. */
  132256. createDebugNavMesh(scene: Scene): Mesh;
  132257. /**
  132258. * Get a navigation mesh constrained position, closest to the parameter position
  132259. * @param position world position
  132260. * @returns the closest point to position constrained by the navigation mesh
  132261. */
  132262. getClosestPoint(position: Vector3): Vector3;
  132263. /**
  132264. * Get a navigation mesh constrained position, within a particular radius
  132265. * @param position world position
  132266. * @param maxRadius the maximum distance to the constrained world position
  132267. * @returns the closest point to position constrained by the navigation mesh
  132268. */
  132269. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  132270. /**
  132271. * Compute the final position from a segment made of destination-position
  132272. * @param position world position
  132273. * @param destination world position
  132274. * @returns the resulting point along the navmesh
  132275. */
  132276. moveAlong(position: Vector3, destination: Vector3): Vector3;
  132277. /**
  132278. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  132279. * @param start world position
  132280. * @param end world position
  132281. * @returns array containing world position composing the path
  132282. */
  132283. computePath(start: Vector3, end: Vector3): Vector3[];
  132284. /**
  132285. * If this plugin is supported
  132286. * @returns true if plugin is supported
  132287. */
  132288. isSupported(): boolean;
  132289. /**
  132290. * Create a new Crowd so you can add agents
  132291. * @param maxAgents the maximum agent count in the crowd
  132292. * @param maxAgentRadius the maximum radius an agent can have
  132293. * @param scene to attach the crowd to
  132294. * @returns the crowd you can add agents to
  132295. */
  132296. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  132297. /**
  132298. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  132299. * The queries will try to find a solution within those bounds
  132300. * default is (1,1,1)
  132301. * @param extent x,y,z value that define the extent around the queries point of reference
  132302. */
  132303. setDefaultQueryExtent(extent: Vector3): void;
  132304. /**
  132305. * Get the Bounding box extent specified by setDefaultQueryExtent
  132306. * @returns the box extent values
  132307. */
  132308. getDefaultQueryExtent(): Vector3;
  132309. /**
  132310. * Release all resources
  132311. */
  132312. dispose(): void;
  132313. }
  132314. /**
  132315. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  132316. */
  132317. export interface ICrowd {
  132318. /**
  132319. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  132320. * You can attach anything to that node. The node position is updated in the scene update tick.
  132321. * @param pos world position that will be constrained by the navigation mesh
  132322. * @param parameters agent parameters
  132323. * @param transform hooked to the agent that will be update by the scene
  132324. * @returns agent index
  132325. */
  132326. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  132327. /**
  132328. * Returns the agent position in world space
  132329. * @param index agent index returned by addAgent
  132330. * @returns world space position
  132331. */
  132332. getAgentPosition(index: number): Vector3;
  132333. /**
  132334. * Gets the agent velocity in world space
  132335. * @param index agent index returned by addAgent
  132336. * @returns world space velocity
  132337. */
  132338. getAgentVelocity(index: number): Vector3;
  132339. /**
  132340. * remove a particular agent previously created
  132341. * @param index agent index returned by addAgent
  132342. */
  132343. removeAgent(index: number): void;
  132344. /**
  132345. * get the list of all agents attached to this crowd
  132346. * @returns list of agent indices
  132347. */
  132348. getAgents(): number[];
  132349. /**
  132350. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  132351. * @param deltaTime in seconds
  132352. */
  132353. update(deltaTime: number): void;
  132354. /**
  132355. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  132356. * @param index agent index returned by addAgent
  132357. * @param destination targeted world position
  132358. */
  132359. agentGoto(index: number, destination: Vector3): void;
  132360. /**
  132361. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  132362. * The queries will try to find a solution within those bounds
  132363. * default is (1,1,1)
  132364. * @param extent x,y,z value that define the extent around the queries point of reference
  132365. */
  132366. setDefaultQueryExtent(extent: Vector3): void;
  132367. /**
  132368. * Get the Bounding box extent specified by setDefaultQueryExtent
  132369. * @returns the box extent values
  132370. */
  132371. getDefaultQueryExtent(): Vector3;
  132372. /**
  132373. * Release all resources
  132374. */
  132375. dispose(): void;
  132376. }
  132377. /**
  132378. * Configures an agent
  132379. */
  132380. export interface IAgentParameters {
  132381. /**
  132382. * Agent radius. [Limit: >= 0]
  132383. */
  132384. radius: number;
  132385. /**
  132386. * Agent height. [Limit: > 0]
  132387. */
  132388. height: number;
  132389. /**
  132390. * Maximum allowed acceleration. [Limit: >= 0]
  132391. */
  132392. maxAcceleration: number;
  132393. /**
  132394. * Maximum allowed speed. [Limit: >= 0]
  132395. */
  132396. maxSpeed: number;
  132397. /**
  132398. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  132399. */
  132400. collisionQueryRange: number;
  132401. /**
  132402. * The path visibility optimization range. [Limit: > 0]
  132403. */
  132404. pathOptimizationRange: number;
  132405. /**
  132406. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  132407. */
  132408. separationWeight: number;
  132409. }
  132410. /**
  132411. * Configures the navigation mesh creation
  132412. */
  132413. export interface INavMeshParameters {
  132414. /**
  132415. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  132416. */
  132417. cs: number;
  132418. /**
  132419. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  132420. */
  132421. ch: number;
  132422. /**
  132423. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  132424. */
  132425. walkableSlopeAngle: number;
  132426. /**
  132427. * Minimum floor to 'ceiling' height that will still allow the floor area to
  132428. * be considered walkable. [Limit: >= 3] [Units: vx]
  132429. */
  132430. walkableHeight: number;
  132431. /**
  132432. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  132433. */
  132434. walkableClimb: number;
  132435. /**
  132436. * The distance to erode/shrink the walkable area of the heightfield away from
  132437. * obstructions. [Limit: >=0] [Units: vx]
  132438. */
  132439. walkableRadius: number;
  132440. /**
  132441. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  132442. */
  132443. maxEdgeLen: number;
  132444. /**
  132445. * The maximum distance a simplfied contour's border edges should deviate
  132446. * the original raw contour. [Limit: >=0] [Units: vx]
  132447. */
  132448. maxSimplificationError: number;
  132449. /**
  132450. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  132451. */
  132452. minRegionArea: number;
  132453. /**
  132454. * Any regions with a span count smaller than this value will, if possible,
  132455. * be merged with larger regions. [Limit: >=0] [Units: vx]
  132456. */
  132457. mergeRegionArea: number;
  132458. /**
  132459. * The maximum number of vertices allowed for polygons generated during the
  132460. * contour to polygon conversion process. [Limit: >= 3]
  132461. */
  132462. maxVertsPerPoly: number;
  132463. /**
  132464. * Sets the sampling distance to use when generating the detail mesh.
  132465. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  132466. */
  132467. detailSampleDist: number;
  132468. /**
  132469. * The maximum distance the detail mesh surface should deviate from heightfield
  132470. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  132471. */
  132472. detailSampleMaxError: number;
  132473. }
  132474. }
  132475. declare module BABYLON {
  132476. /**
  132477. * RecastJS navigation plugin
  132478. */
  132479. export class RecastJSPlugin implements INavigationEnginePlugin {
  132480. /**
  132481. * Reference to the Recast library
  132482. */
  132483. bjsRECAST: any;
  132484. /**
  132485. * plugin name
  132486. */
  132487. name: string;
  132488. /**
  132489. * the first navmesh created. We might extend this to support multiple navmeshes
  132490. */
  132491. navMesh: any;
  132492. /**
  132493. * Initializes the recastJS plugin
  132494. * @param recastInjection can be used to inject your own recast reference
  132495. */
  132496. constructor(recastInjection?: any);
  132497. /**
  132498. * Creates a navigation mesh
  132499. * @param meshes array of all the geometry used to compute the navigatio mesh
  132500. * @param parameters bunch of parameters used to filter geometry
  132501. */
  132502. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  132503. /**
  132504. * Create a navigation mesh debug mesh
  132505. * @param scene is where the mesh will be added
  132506. * @returns debug display mesh
  132507. */
  132508. createDebugNavMesh(scene: Scene): Mesh;
  132509. /**
  132510. * Get a navigation mesh constrained position, closest to the parameter position
  132511. * @param position world position
  132512. * @returns the closest point to position constrained by the navigation mesh
  132513. */
  132514. getClosestPoint(position: Vector3): Vector3;
  132515. /**
  132516. * Get a navigation mesh constrained position, within a particular radius
  132517. * @param position world position
  132518. * @param maxRadius the maximum distance to the constrained world position
  132519. * @returns the closest point to position constrained by the navigation mesh
  132520. */
  132521. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  132522. /**
  132523. * Compute the final position from a segment made of destination-position
  132524. * @param position world position
  132525. * @param destination world position
  132526. * @returns the resulting point along the navmesh
  132527. */
  132528. moveAlong(position: Vector3, destination: Vector3): Vector3;
  132529. /**
  132530. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  132531. * @param start world position
  132532. * @param end world position
  132533. * @returns array containing world position composing the path
  132534. */
  132535. computePath(start: Vector3, end: Vector3): Vector3[];
  132536. /**
  132537. * Create a new Crowd so you can add agents
  132538. * @param maxAgents the maximum agent count in the crowd
  132539. * @param maxAgentRadius the maximum radius an agent can have
  132540. * @param scene to attach the crowd to
  132541. * @returns the crowd you can add agents to
  132542. */
  132543. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  132544. /**
  132545. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  132546. * The queries will try to find a solution within those bounds
  132547. * default is (1,1,1)
  132548. * @param extent x,y,z value that define the extent around the queries point of reference
  132549. */
  132550. setDefaultQueryExtent(extent: Vector3): void;
  132551. /**
  132552. * Get the Bounding box extent specified by setDefaultQueryExtent
  132553. * @returns the box extent values
  132554. */
  132555. getDefaultQueryExtent(): Vector3;
  132556. /**
  132557. * Disposes
  132558. */
  132559. dispose(): void;
  132560. /**
  132561. * If this plugin is supported
  132562. * @returns true if plugin is supported
  132563. */
  132564. isSupported(): boolean;
  132565. }
  132566. /**
  132567. * Recast detour crowd implementation
  132568. */
  132569. export class RecastJSCrowd implements ICrowd {
  132570. /**
  132571. * Recast/detour plugin
  132572. */
  132573. bjsRECASTPlugin: RecastJSPlugin;
  132574. /**
  132575. * Link to the detour crowd
  132576. */
  132577. recastCrowd: any;
  132578. /**
  132579. * One transform per agent
  132580. */
  132581. transforms: TransformNode[];
  132582. /**
  132583. * All agents created
  132584. */
  132585. agents: number[];
  132586. /**
  132587. * Link to the scene is kept to unregister the crowd from the scene
  132588. */
  132589. private _scene;
  132590. /**
  132591. * Observer for crowd updates
  132592. */
  132593. private _onBeforeAnimationsObserver;
  132594. /**
  132595. * Constructor
  132596. * @param plugin recastJS plugin
  132597. * @param maxAgents the maximum agent count in the crowd
  132598. * @param maxAgentRadius the maximum radius an agent can have
  132599. * @param scene to attach the crowd to
  132600. * @returns the crowd you can add agents to
  132601. */
  132602. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  132603. /**
  132604. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  132605. * You can attach anything to that node. The node position is updated in the scene update tick.
  132606. * @param pos world position that will be constrained by the navigation mesh
  132607. * @param parameters agent parameters
  132608. * @param transform hooked to the agent that will be update by the scene
  132609. * @returns agent index
  132610. */
  132611. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  132612. /**
  132613. * Returns the agent position in world space
  132614. * @param index agent index returned by addAgent
  132615. * @returns world space position
  132616. */
  132617. getAgentPosition(index: number): Vector3;
  132618. /**
  132619. * Returns the agent velocity in world space
  132620. * @param index agent index returned by addAgent
  132621. * @returns world space velocity
  132622. */
  132623. getAgentVelocity(index: number): Vector3;
  132624. /**
  132625. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  132626. * @param index agent index returned by addAgent
  132627. * @param destination targeted world position
  132628. */
  132629. agentGoto(index: number, destination: Vector3): void;
  132630. /**
  132631. * remove a particular agent previously created
  132632. * @param index agent index returned by addAgent
  132633. */
  132634. removeAgent(index: number): void;
  132635. /**
  132636. * get the list of all agents attached to this crowd
  132637. * @returns list of agent indices
  132638. */
  132639. getAgents(): number[];
  132640. /**
  132641. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  132642. * @param deltaTime in seconds
  132643. */
  132644. update(deltaTime: number): void;
  132645. /**
  132646. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  132647. * The queries will try to find a solution within those bounds
  132648. * default is (1,1,1)
  132649. * @param extent x,y,z value that define the extent around the queries point of reference
  132650. */
  132651. setDefaultQueryExtent(extent: Vector3): void;
  132652. /**
  132653. * Get the Bounding box extent specified by setDefaultQueryExtent
  132654. * @returns the box extent values
  132655. */
  132656. getDefaultQueryExtent(): Vector3;
  132657. /**
  132658. * Release all resources
  132659. */
  132660. dispose(): void;
  132661. }
  132662. }
  132663. declare module BABYLON {
  132664. /**
  132665. * Class used to enable access to IndexedDB
  132666. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  132667. */
  132668. export class Database implements IOfflineProvider {
  132669. private _callbackManifestChecked;
  132670. private _currentSceneUrl;
  132671. private _db;
  132672. private _enableSceneOffline;
  132673. private _enableTexturesOffline;
  132674. private _manifestVersionFound;
  132675. private _mustUpdateRessources;
  132676. private _hasReachedQuota;
  132677. private _isSupported;
  132678. private _idbFactory;
  132679. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  132680. private static IsUASupportingBlobStorage;
  132681. /**
  132682. * Gets a boolean indicating if Database storate is enabled (off by default)
  132683. */
  132684. static IDBStorageEnabled: boolean;
  132685. /**
  132686. * Gets a boolean indicating if scene must be saved in the database
  132687. */
  132688. get enableSceneOffline(): boolean;
  132689. /**
  132690. * Gets a boolean indicating if textures must be saved in the database
  132691. */
  132692. get enableTexturesOffline(): boolean;
  132693. /**
  132694. * Creates a new Database
  132695. * @param urlToScene defines the url to load the scene
  132696. * @param callbackManifestChecked defines the callback to use when manifest is checked
  132697. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  132698. */
  132699. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  132700. private static _ParseURL;
  132701. private static _ReturnFullUrlLocation;
  132702. private _checkManifestFile;
  132703. /**
  132704. * Open the database and make it available
  132705. * @param successCallback defines the callback to call on success
  132706. * @param errorCallback defines the callback to call on error
  132707. */
  132708. open(successCallback: () => void, errorCallback: () => void): void;
  132709. /**
  132710. * Loads an image from the database
  132711. * @param url defines the url to load from
  132712. * @param image defines the target DOM image
  132713. */
  132714. loadImage(url: string, image: HTMLImageElement): void;
  132715. private _loadImageFromDBAsync;
  132716. private _saveImageIntoDBAsync;
  132717. private _checkVersionFromDB;
  132718. private _loadVersionFromDBAsync;
  132719. private _saveVersionIntoDBAsync;
  132720. /**
  132721. * Loads a file from database
  132722. * @param url defines the URL to load from
  132723. * @param sceneLoaded defines a callback to call on success
  132724. * @param progressCallBack defines a callback to call when progress changed
  132725. * @param errorCallback defines a callback to call on error
  132726. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  132727. */
  132728. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  132729. private _loadFileAsync;
  132730. private _saveFileAsync;
  132731. /**
  132732. * Validates if xhr data is correct
  132733. * @param xhr defines the request to validate
  132734. * @param dataType defines the expected data type
  132735. * @returns true if data is correct
  132736. */
  132737. private static _ValidateXHRData;
  132738. }
  132739. }
  132740. declare module BABYLON {
  132741. /** @hidden */
  132742. export var gpuUpdateParticlesPixelShader: {
  132743. name: string;
  132744. shader: string;
  132745. };
  132746. }
  132747. declare module BABYLON {
  132748. /** @hidden */
  132749. export var gpuUpdateParticlesVertexShader: {
  132750. name: string;
  132751. shader: string;
  132752. };
  132753. }
  132754. declare module BABYLON {
  132755. /** @hidden */
  132756. export var clipPlaneFragmentDeclaration2: {
  132757. name: string;
  132758. shader: string;
  132759. };
  132760. }
  132761. declare module BABYLON {
  132762. /** @hidden */
  132763. export var gpuRenderParticlesPixelShader: {
  132764. name: string;
  132765. shader: string;
  132766. };
  132767. }
  132768. declare module BABYLON {
  132769. /** @hidden */
  132770. export var clipPlaneVertexDeclaration2: {
  132771. name: string;
  132772. shader: string;
  132773. };
  132774. }
  132775. declare module BABYLON {
  132776. /** @hidden */
  132777. export var gpuRenderParticlesVertexShader: {
  132778. name: string;
  132779. shader: string;
  132780. };
  132781. }
  132782. declare module BABYLON {
  132783. /**
  132784. * This represents a GPU particle system in Babylon
  132785. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  132786. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  132787. */
  132788. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  132789. /**
  132790. * The layer mask we are rendering the particles through.
  132791. */
  132792. layerMask: number;
  132793. private _capacity;
  132794. private _activeCount;
  132795. private _currentActiveCount;
  132796. private _accumulatedCount;
  132797. private _renderEffect;
  132798. private _updateEffect;
  132799. private _buffer0;
  132800. private _buffer1;
  132801. private _spriteBuffer;
  132802. private _updateVAO;
  132803. private _renderVAO;
  132804. private _targetIndex;
  132805. private _sourceBuffer;
  132806. private _targetBuffer;
  132807. private _engine;
  132808. private _currentRenderId;
  132809. private _started;
  132810. private _stopped;
  132811. private _timeDelta;
  132812. private _randomTexture;
  132813. private _randomTexture2;
  132814. private _attributesStrideSize;
  132815. private _updateEffectOptions;
  132816. private _randomTextureSize;
  132817. private _actualFrame;
  132818. private readonly _rawTextureWidth;
  132819. /**
  132820. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  132821. */
  132822. static get IsSupported(): boolean;
  132823. /**
  132824. * An event triggered when the system is disposed.
  132825. */
  132826. onDisposeObservable: Observable<GPUParticleSystem>;
  132827. /**
  132828. * Gets the maximum number of particles active at the same time.
  132829. * @returns The max number of active particles.
  132830. */
  132831. getCapacity(): number;
  132832. /**
  132833. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  132834. * to override the particles.
  132835. */
  132836. forceDepthWrite: boolean;
  132837. /**
  132838. * Gets or set the number of active particles
  132839. */
  132840. get activeParticleCount(): number;
  132841. set activeParticleCount(value: number);
  132842. private _preWarmDone;
  132843. /**
  132844. * Is this system ready to be used/rendered
  132845. * @return true if the system is ready
  132846. */
  132847. isReady(): boolean;
  132848. /**
  132849. * Gets if the system has been started. (Note: this will still be true after stop is called)
  132850. * @returns True if it has been started, otherwise false.
  132851. */
  132852. isStarted(): boolean;
  132853. /**
  132854. * Starts the particle system and begins to emit
  132855. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  132856. */
  132857. start(delay?: number): void;
  132858. /**
  132859. * Stops the particle system.
  132860. */
  132861. stop(): void;
  132862. /**
  132863. * Remove all active particles
  132864. */
  132865. reset(): void;
  132866. /**
  132867. * Returns the string "GPUParticleSystem"
  132868. * @returns a string containing the class name
  132869. */
  132870. getClassName(): string;
  132871. private _colorGradientsTexture;
  132872. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  132873. /**
  132874. * Adds a new color gradient
  132875. * @param gradient defines the gradient to use (between 0 and 1)
  132876. * @param color1 defines the color to affect to the specified gradient
  132877. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  132878. * @returns the current particle system
  132879. */
  132880. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  132881. /**
  132882. * Remove a specific color gradient
  132883. * @param gradient defines the gradient to remove
  132884. * @returns the current particle system
  132885. */
  132886. removeColorGradient(gradient: number): GPUParticleSystem;
  132887. private _angularSpeedGradientsTexture;
  132888. private _sizeGradientsTexture;
  132889. private _velocityGradientsTexture;
  132890. private _limitVelocityGradientsTexture;
  132891. private _dragGradientsTexture;
  132892. private _addFactorGradient;
  132893. /**
  132894. * Adds a new size gradient
  132895. * @param gradient defines the gradient to use (between 0 and 1)
  132896. * @param factor defines the size factor to affect to the specified gradient
  132897. * @returns the current particle system
  132898. */
  132899. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  132900. /**
  132901. * Remove a specific size gradient
  132902. * @param gradient defines the gradient to remove
  132903. * @returns the current particle system
  132904. */
  132905. removeSizeGradient(gradient: number): GPUParticleSystem;
  132906. /**
  132907. * Adds a new angular speed gradient
  132908. * @param gradient defines the gradient to use (between 0 and 1)
  132909. * @param factor defines the angular speed to affect to the specified gradient
  132910. * @returns the current particle system
  132911. */
  132912. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  132913. /**
  132914. * Remove a specific angular speed gradient
  132915. * @param gradient defines the gradient to remove
  132916. * @returns the current particle system
  132917. */
  132918. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  132919. /**
  132920. * Adds a new velocity gradient
  132921. * @param gradient defines the gradient to use (between 0 and 1)
  132922. * @param factor defines the velocity to affect to the specified gradient
  132923. * @returns the current particle system
  132924. */
  132925. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  132926. /**
  132927. * Remove a specific velocity gradient
  132928. * @param gradient defines the gradient to remove
  132929. * @returns the current particle system
  132930. */
  132931. removeVelocityGradient(gradient: number): GPUParticleSystem;
  132932. /**
  132933. * Adds a new limit velocity gradient
  132934. * @param gradient defines the gradient to use (between 0 and 1)
  132935. * @param factor defines the limit velocity value to affect to the specified gradient
  132936. * @returns the current particle system
  132937. */
  132938. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  132939. /**
  132940. * Remove a specific limit velocity gradient
  132941. * @param gradient defines the gradient to remove
  132942. * @returns the current particle system
  132943. */
  132944. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  132945. /**
  132946. * Adds a new drag gradient
  132947. * @param gradient defines the gradient to use (between 0 and 1)
  132948. * @param factor defines the drag value to affect to the specified gradient
  132949. * @returns the current particle system
  132950. */
  132951. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  132952. /**
  132953. * Remove a specific drag gradient
  132954. * @param gradient defines the gradient to remove
  132955. * @returns the current particle system
  132956. */
  132957. removeDragGradient(gradient: number): GPUParticleSystem;
  132958. /**
  132959. * Not supported by GPUParticleSystem
  132960. * @param gradient defines the gradient to use (between 0 and 1)
  132961. * @param factor defines the emit rate value to affect to the specified gradient
  132962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  132963. * @returns the current particle system
  132964. */
  132965. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  132966. /**
  132967. * Not supported by GPUParticleSystem
  132968. * @param gradient defines the gradient to remove
  132969. * @returns the current particle system
  132970. */
  132971. removeEmitRateGradient(gradient: number): IParticleSystem;
  132972. /**
  132973. * Not supported by GPUParticleSystem
  132974. * @param gradient defines the gradient to use (between 0 and 1)
  132975. * @param factor defines the start size value to affect to the specified gradient
  132976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  132977. * @returns the current particle system
  132978. */
  132979. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  132980. /**
  132981. * Not supported by GPUParticleSystem
  132982. * @param gradient defines the gradient to remove
  132983. * @returns the current particle system
  132984. */
  132985. removeStartSizeGradient(gradient: number): IParticleSystem;
  132986. /**
  132987. * Not supported by GPUParticleSystem
  132988. * @param gradient defines the gradient to use (between 0 and 1)
  132989. * @param min defines the color remap minimal range
  132990. * @param max defines the color remap maximal range
  132991. * @returns the current particle system
  132992. */
  132993. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  132994. /**
  132995. * Not supported by GPUParticleSystem
  132996. * @param gradient defines the gradient to remove
  132997. * @returns the current particle system
  132998. */
  132999. removeColorRemapGradient(): IParticleSystem;
  133000. /**
  133001. * Not supported by GPUParticleSystem
  133002. * @param gradient defines the gradient to use (between 0 and 1)
  133003. * @param min defines the alpha remap minimal range
  133004. * @param max defines the alpha remap maximal range
  133005. * @returns the current particle system
  133006. */
  133007. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  133008. /**
  133009. * Not supported by GPUParticleSystem
  133010. * @param gradient defines the gradient to remove
  133011. * @returns the current particle system
  133012. */
  133013. removeAlphaRemapGradient(): IParticleSystem;
  133014. /**
  133015. * Not supported by GPUParticleSystem
  133016. * @param gradient defines the gradient to use (between 0 and 1)
  133017. * @param color defines the color to affect to the specified gradient
  133018. * @returns the current particle system
  133019. */
  133020. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  133021. /**
  133022. * Not supported by GPUParticleSystem
  133023. * @param gradient defines the gradient to remove
  133024. * @returns the current particle system
  133025. */
  133026. removeRampGradient(): IParticleSystem;
  133027. /**
  133028. * Not supported by GPUParticleSystem
  133029. * @returns the list of ramp gradients
  133030. */
  133031. getRampGradients(): Nullable<Array<Color3Gradient>>;
  133032. /**
  133033. * Not supported by GPUParticleSystem
  133034. * Gets or sets a boolean indicating that ramp gradients must be used
  133035. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  133036. */
  133037. get useRampGradients(): boolean;
  133038. set useRampGradients(value: boolean);
  133039. /**
  133040. * Not supported by GPUParticleSystem
  133041. * @param gradient defines the gradient to use (between 0 and 1)
  133042. * @param factor defines the life time factor to affect to the specified gradient
  133043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  133044. * @returns the current particle system
  133045. */
  133046. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  133047. /**
  133048. * Not supported by GPUParticleSystem
  133049. * @param gradient defines the gradient to remove
  133050. * @returns the current particle system
  133051. */
  133052. removeLifeTimeGradient(gradient: number): IParticleSystem;
  133053. /**
  133054. * Instantiates a GPU particle system.
  133055. * 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.
  133056. * @param name The name of the particle system
  133057. * @param options The options used to create the system
  133058. * @param scene The scene the particle system belongs to
  133059. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  133060. */
  133061. constructor(name: string, options: Partial<{
  133062. capacity: number;
  133063. randomTextureSize: number;
  133064. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  133065. protected _reset(): void;
  133066. private _createUpdateVAO;
  133067. private _createRenderVAO;
  133068. private _initialize;
  133069. /** @hidden */
  133070. _recreateUpdateEffect(): void;
  133071. /** @hidden */
  133072. _recreateRenderEffect(): void;
  133073. /**
  133074. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  133075. * @param preWarm defines if we are in the pre-warmimg phase
  133076. */
  133077. animate(preWarm?: boolean): void;
  133078. private _createFactorGradientTexture;
  133079. private _createSizeGradientTexture;
  133080. private _createAngularSpeedGradientTexture;
  133081. private _createVelocityGradientTexture;
  133082. private _createLimitVelocityGradientTexture;
  133083. private _createDragGradientTexture;
  133084. private _createColorGradientTexture;
  133085. /**
  133086. * Renders the particle system in its current state
  133087. * @param preWarm defines if the system should only update the particles but not render them
  133088. * @returns the current number of particles
  133089. */
  133090. render(preWarm?: boolean): number;
  133091. /**
  133092. * Rebuilds the particle system
  133093. */
  133094. rebuild(): void;
  133095. private _releaseBuffers;
  133096. private _releaseVAOs;
  133097. /**
  133098. * Disposes the particle system and free the associated resources
  133099. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  133100. */
  133101. dispose(disposeTexture?: boolean): void;
  133102. /**
  133103. * Clones the particle system.
  133104. * @param name The name of the cloned object
  133105. * @param newEmitter The new emitter to use
  133106. * @returns the cloned particle system
  133107. */
  133108. clone(name: string, newEmitter: any): GPUParticleSystem;
  133109. /**
  133110. * Serializes the particle system to a JSON object.
  133111. * @returns the JSON object
  133112. */
  133113. serialize(): any;
  133114. /**
  133115. * Parses a JSON object to create a GPU particle system.
  133116. * @param parsedParticleSystem The JSON object to parse
  133117. * @param scene The scene to create the particle system in
  133118. * @param rootUrl The root url to use to load external dependencies like texture
  133119. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  133120. * @returns the parsed GPU particle system
  133121. */
  133122. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  133123. }
  133124. }
  133125. declare module BABYLON {
  133126. /**
  133127. * Represents a set of particle systems working together to create a specific effect
  133128. */
  133129. export class ParticleSystemSet implements IDisposable {
  133130. /**
  133131. * Gets or sets base Assets URL
  133132. */
  133133. static BaseAssetsUrl: string;
  133134. private _emitterCreationOptions;
  133135. private _emitterNode;
  133136. /**
  133137. * Gets the particle system list
  133138. */
  133139. systems: IParticleSystem[];
  133140. /**
  133141. * Gets the emitter node used with this set
  133142. */
  133143. get emitterNode(): Nullable<TransformNode>;
  133144. /**
  133145. * Creates a new emitter mesh as a sphere
  133146. * @param options defines the options used to create the sphere
  133147. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  133148. * @param scene defines the hosting scene
  133149. */
  133150. setEmitterAsSphere(options: {
  133151. diameter: number;
  133152. segments: number;
  133153. color: Color3;
  133154. }, renderingGroupId: number, scene: Scene): void;
  133155. /**
  133156. * Starts all particle systems of the set
  133157. * @param emitter defines an optional mesh to use as emitter for the particle systems
  133158. */
  133159. start(emitter?: AbstractMesh): void;
  133160. /**
  133161. * Release all associated resources
  133162. */
  133163. dispose(): void;
  133164. /**
  133165. * Serialize the set into a JSON compatible object
  133166. * @returns a JSON compatible representation of the set
  133167. */
  133168. serialize(): any;
  133169. /**
  133170. * Parse a new ParticleSystemSet from a serialized source
  133171. * @param data defines a JSON compatible representation of the set
  133172. * @param scene defines the hosting scene
  133173. * @param gpu defines if we want GPU particles or CPU particles
  133174. * @returns a new ParticleSystemSet
  133175. */
  133176. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  133177. }
  133178. }
  133179. declare module BABYLON {
  133180. /**
  133181. * This class is made for on one-liner static method to help creating particle system set.
  133182. */
  133183. export class ParticleHelper {
  133184. /**
  133185. * Gets or sets base Assets URL
  133186. */
  133187. static BaseAssetsUrl: string;
  133188. /**
  133189. * Create a default particle system that you can tweak
  133190. * @param emitter defines the emitter to use
  133191. * @param capacity defines the system capacity (default is 500 particles)
  133192. * @param scene defines the hosting scene
  133193. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  133194. * @returns the new Particle system
  133195. */
  133196. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  133197. /**
  133198. * This is the main static method (one-liner) of this helper to create different particle systems
  133199. * @param type This string represents the type to the particle system to create
  133200. * @param scene The scene where the particle system should live
  133201. * @param gpu If the system will use gpu
  133202. * @returns the ParticleSystemSet created
  133203. */
  133204. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  133205. /**
  133206. * Static function used to export a particle system to a ParticleSystemSet variable.
  133207. * Please note that the emitter shape is not exported
  133208. * @param systems defines the particle systems to export
  133209. * @returns the created particle system set
  133210. */
  133211. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  133212. }
  133213. }
  133214. declare module BABYLON {
  133215. interface Engine {
  133216. /**
  133217. * Create an effect to use with particle systems.
  133218. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  133219. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  133220. * @param uniformsNames defines a list of attribute names
  133221. * @param samplers defines an array of string used to represent textures
  133222. * @param defines defines the string containing the defines to use to compile the shaders
  133223. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  133224. * @param onCompiled defines a function to call when the effect creation is successful
  133225. * @param onError defines a function to call when the effect creation has failed
  133226. * @returns the new Effect
  133227. */
  133228. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  133229. }
  133230. interface Mesh {
  133231. /**
  133232. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  133233. * @returns an array of IParticleSystem
  133234. */
  133235. getEmittedParticleSystems(): IParticleSystem[];
  133236. /**
  133237. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  133238. * @returns an array of IParticleSystem
  133239. */
  133240. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  133241. }
  133242. /**
  133243. * @hidden
  133244. */
  133245. export var _IDoNeedToBeInTheBuild: number;
  133246. }
  133247. declare module BABYLON {
  133248. /** Defines the 4 color options */
  133249. export enum PointColor {
  133250. /** color value */
  133251. Color = 2,
  133252. /** uv value */
  133253. UV = 1,
  133254. /** random value */
  133255. Random = 0,
  133256. /** stated value */
  133257. Stated = 3
  133258. }
  133259. /**
  133260. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  133261. * 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.
  133262. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  133263. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  133264. *
  133265. * Full documentation here : TO BE ENTERED
  133266. */
  133267. export class PointsCloudSystem implements IDisposable {
  133268. /**
  133269. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  133270. * Example : var p = SPS.particles[i];
  133271. */
  133272. particles: CloudPoint[];
  133273. /**
  133274. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  133275. */
  133276. nbParticles: number;
  133277. /**
  133278. * This a counter for your own usage. It's not set by any SPS functions.
  133279. */
  133280. counter: number;
  133281. /**
  133282. * The PCS name. This name is also given to the underlying mesh.
  133283. */
  133284. name: string;
  133285. /**
  133286. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  133287. */
  133288. mesh: Mesh;
  133289. /**
  133290. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  133291. * Please read :
  133292. */
  133293. vars: any;
  133294. /**
  133295. * @hidden
  133296. */
  133297. _size: number;
  133298. private _scene;
  133299. private _promises;
  133300. private _positions;
  133301. private _indices;
  133302. private _normals;
  133303. private _colors;
  133304. private _uvs;
  133305. private _indices32;
  133306. private _positions32;
  133307. private _colors32;
  133308. private _uvs32;
  133309. private _updatable;
  133310. private _isVisibilityBoxLocked;
  133311. private _alwaysVisible;
  133312. private _groups;
  133313. private _groupCounter;
  133314. private _computeParticleColor;
  133315. private _computeParticleTexture;
  133316. private _computeParticleRotation;
  133317. private _computeBoundingBox;
  133318. private _isReady;
  133319. /**
  133320. * Creates a PCS (Points Cloud System) object
  133321. * @param name (String) is the PCS name, this will be the underlying mesh name
  133322. * @param pointSize (number) is the size for each point
  133323. * @param scene (Scene) is the scene in which the PCS is added
  133324. * @param options defines the options of the PCS e.g.
  133325. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  133326. */
  133327. constructor(name: string, pointSize: number, scene: Scene, options?: {
  133328. updatable?: boolean;
  133329. });
  133330. /**
  133331. * Builds the PCS underlying mesh. Returns a standard Mesh.
  133332. * If no points were added to the PCS, the returned mesh is just a single point.
  133333. * @returns a promise for the created mesh
  133334. */
  133335. buildMeshAsync(): Promise<Mesh>;
  133336. /**
  133337. * @hidden
  133338. */
  133339. private _buildMesh;
  133340. private _addParticle;
  133341. private _randomUnitVector;
  133342. private _getColorIndicesForCoord;
  133343. private _setPointsColorOrUV;
  133344. private _colorFromTexture;
  133345. private _calculateDensity;
  133346. /**
  133347. * Adds points to the PCS in random positions within a unit sphere
  133348. * @param nb (positive integer) the number of particles to be created from this model
  133349. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  133350. * @returns the number of groups in the system
  133351. */
  133352. addPoints(nb: number, pointFunction?: any): number;
  133353. /**
  133354. * Adds points to the PCS from the surface of the model shape
  133355. * @param mesh is any Mesh object that will be used as a surface model for the points
  133356. * @param nb (positive integer) the number of particles to be created from this model
  133357. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  133358. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  133359. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  133360. * @returns the number of groups in the system
  133361. */
  133362. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  133363. /**
  133364. * Adds points to the PCS inside the model shape
  133365. * @param mesh is any Mesh object that will be used as a surface model for the points
  133366. * @param nb (positive integer) the number of particles to be created from this model
  133367. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  133368. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  133369. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  133370. * @returns the number of groups in the system
  133371. */
  133372. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  133373. /**
  133374. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  133375. * This method calls `updateParticle()` for each particle of the SPS.
  133376. * For an animated SPS, it is usually called within the render loop.
  133377. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  133378. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  133379. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  133380. * @returns the PCS.
  133381. */
  133382. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  133383. /**
  133384. * Disposes the PCS.
  133385. */
  133386. dispose(): void;
  133387. /**
  133388. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  133389. * doc :
  133390. * @returns the PCS.
  133391. */
  133392. refreshVisibleSize(): PointsCloudSystem;
  133393. /**
  133394. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  133395. * @param size the size (float) of the visibility box
  133396. * note : this doesn't lock the PCS mesh bounding box.
  133397. * doc :
  133398. */
  133399. setVisibilityBox(size: number): void;
  133400. /**
  133401. * Gets whether the PCS is always visible or not
  133402. * doc :
  133403. */
  133404. get isAlwaysVisible(): boolean;
  133405. /**
  133406. * Sets the PCS as always visible or not
  133407. * doc :
  133408. */
  133409. set isAlwaysVisible(val: boolean);
  133410. /**
  133411. * Tells to `setParticles()` to compute the particle rotations or not
  133412. * Default value : false. The PCS is faster when it's set to false
  133413. * Note : particle rotations are only applied to parent particles
  133414. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  133415. */
  133416. set computeParticleRotation(val: boolean);
  133417. /**
  133418. * Tells to `setParticles()` to compute the particle colors or not.
  133419. * Default value : true. The PCS is faster when it's set to false.
  133420. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  133421. */
  133422. set computeParticleColor(val: boolean);
  133423. set computeParticleTexture(val: boolean);
  133424. /**
  133425. * Gets if `setParticles()` computes the particle colors or not.
  133426. * Default value : false. The PCS is faster when it's set to false.
  133427. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  133428. */
  133429. get computeParticleColor(): boolean;
  133430. /**
  133431. * Gets if `setParticles()` computes the particle textures or not.
  133432. * Default value : false. The PCS is faster when it's set to false.
  133433. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  133434. */
  133435. get computeParticleTexture(): boolean;
  133436. /**
  133437. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  133438. */
  133439. set computeBoundingBox(val: boolean);
  133440. /**
  133441. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  133442. */
  133443. get computeBoundingBox(): boolean;
  133444. /**
  133445. * This function does nothing. It may be overwritten to set all the particle first values.
  133446. * The PCS doesn't call this function, you may have to call it by your own.
  133447. * doc :
  133448. */
  133449. initParticles(): void;
  133450. /**
  133451. * This function does nothing. It may be overwritten to recycle a particle
  133452. * The PCS doesn't call this function, you can to call it
  133453. * doc :
  133454. * @param particle The particle to recycle
  133455. * @returns the recycled particle
  133456. */
  133457. recycleParticle(particle: CloudPoint): CloudPoint;
  133458. /**
  133459. * Updates a particle : this function should be overwritten by the user.
  133460. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  133461. * doc :
  133462. * @example : just set a particle position or velocity and recycle conditions
  133463. * @param particle The particle to update
  133464. * @returns the updated particle
  133465. */
  133466. updateParticle(particle: CloudPoint): CloudPoint;
  133467. /**
  133468. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  133469. * This does nothing and may be overwritten by the user.
  133470. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  133471. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  133472. * @param update the boolean update value actually passed to setParticles()
  133473. */
  133474. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  133475. /**
  133476. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  133477. * This will be passed three parameters.
  133478. * This does nothing and may be overwritten by the user.
  133479. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  133480. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  133481. * @param update the boolean update value actually passed to setParticles()
  133482. */
  133483. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  133484. }
  133485. }
  133486. declare module BABYLON {
  133487. /**
  133488. * Represents one particle of a points cloud system.
  133489. */
  133490. export class CloudPoint {
  133491. /**
  133492. * particle global index
  133493. */
  133494. idx: number;
  133495. /**
  133496. * The color of the particle
  133497. */
  133498. color: Nullable<Color4>;
  133499. /**
  133500. * The world space position of the particle.
  133501. */
  133502. position: Vector3;
  133503. /**
  133504. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  133505. */
  133506. rotation: Vector3;
  133507. /**
  133508. * The world space rotation quaternion of the particle.
  133509. */
  133510. rotationQuaternion: Nullable<Quaternion>;
  133511. /**
  133512. * The uv of the particle.
  133513. */
  133514. uv: Nullable<Vector2>;
  133515. /**
  133516. * The current speed of the particle.
  133517. */
  133518. velocity: Vector3;
  133519. /**
  133520. * The pivot point in the particle local space.
  133521. */
  133522. pivot: Vector3;
  133523. /**
  133524. * Must the particle be translated from its pivot point in its local space ?
  133525. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  133526. * Default : false
  133527. */
  133528. translateFromPivot: boolean;
  133529. /**
  133530. * Index of this particle in the global "positions" array (Internal use)
  133531. * @hidden
  133532. */
  133533. _pos: number;
  133534. /**
  133535. * @hidden Index of this particle in the global "indices" array (Internal use)
  133536. */
  133537. _ind: number;
  133538. /**
  133539. * Group this particle belongs to
  133540. */
  133541. _group: PointsGroup;
  133542. /**
  133543. * Group id of this particle
  133544. */
  133545. groupId: number;
  133546. /**
  133547. * Index of the particle in its group id (Internal use)
  133548. */
  133549. idxInGroup: number;
  133550. /**
  133551. * @hidden Particle BoundingInfo object (Internal use)
  133552. */
  133553. _boundingInfo: BoundingInfo;
  133554. /**
  133555. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  133556. */
  133557. _pcs: PointsCloudSystem;
  133558. /**
  133559. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  133560. */
  133561. _stillInvisible: boolean;
  133562. /**
  133563. * @hidden Last computed particle rotation matrix
  133564. */
  133565. _rotationMatrix: number[];
  133566. /**
  133567. * Parent particle Id, if any.
  133568. * Default null.
  133569. */
  133570. parentId: Nullable<number>;
  133571. /**
  133572. * @hidden Internal global position in the PCS.
  133573. */
  133574. _globalPosition: Vector3;
  133575. /**
  133576. * Creates a Point Cloud object.
  133577. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  133578. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  133579. * @param group (PointsGroup) is the group the particle belongs to
  133580. * @param groupId (integer) is the group identifier in the PCS.
  133581. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  133582. * @param pcs defines the PCS it is associated to
  133583. */
  133584. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  133585. /**
  133586. * get point size
  133587. */
  133588. get size(): Vector3;
  133589. /**
  133590. * Set point size
  133591. */
  133592. set size(scale: Vector3);
  133593. /**
  133594. * Legacy support, changed quaternion to rotationQuaternion
  133595. */
  133596. get quaternion(): Nullable<Quaternion>;
  133597. /**
  133598. * Legacy support, changed quaternion to rotationQuaternion
  133599. */
  133600. set quaternion(q: Nullable<Quaternion>);
  133601. /**
  133602. * Returns a boolean. True if the particle intersects a mesh, else false
  133603. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  133604. * @param target is the object (point or mesh) what the intersection is computed against
  133605. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  133606. * @returns true if it intersects
  133607. */
  133608. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  133609. /**
  133610. * get the rotation matrix of the particle
  133611. * @hidden
  133612. */
  133613. getRotationMatrix(m: Matrix): void;
  133614. }
  133615. /**
  133616. * Represents a group of points in a points cloud system
  133617. * * PCS internal tool, don't use it manually.
  133618. */
  133619. export class PointsGroup {
  133620. /**
  133621. * The group id
  133622. * @hidden
  133623. */
  133624. groupID: number;
  133625. /**
  133626. * image data for group (internal use)
  133627. * @hidden
  133628. */
  133629. _groupImageData: Nullable<ArrayBufferView>;
  133630. /**
  133631. * Image Width (internal use)
  133632. * @hidden
  133633. */
  133634. _groupImgWidth: number;
  133635. /**
  133636. * Image Height (internal use)
  133637. * @hidden
  133638. */
  133639. _groupImgHeight: number;
  133640. /**
  133641. * Custom position function (internal use)
  133642. * @hidden
  133643. */
  133644. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  133645. /**
  133646. * density per facet for surface points
  133647. * @hidden
  133648. */
  133649. _groupDensity: number[];
  133650. /**
  133651. * Only when points are colored by texture carries pointer to texture list array
  133652. * @hidden
  133653. */
  133654. _textureNb: number;
  133655. /**
  133656. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  133657. * PCS internal tool, don't use it manually.
  133658. * @hidden
  133659. */
  133660. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  133661. }
  133662. }
  133663. declare module BABYLON {
  133664. interface Scene {
  133665. /** @hidden (Backing field) */
  133666. _physicsEngine: Nullable<IPhysicsEngine>;
  133667. /** @hidden */
  133668. _physicsTimeAccumulator: number;
  133669. /**
  133670. * Gets the current physics engine
  133671. * @returns a IPhysicsEngine or null if none attached
  133672. */
  133673. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  133674. /**
  133675. * Enables physics to the current scene
  133676. * @param gravity defines the scene's gravity for the physics engine
  133677. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  133678. * @return a boolean indicating if the physics engine was initialized
  133679. */
  133680. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  133681. /**
  133682. * Disables and disposes the physics engine associated with the scene
  133683. */
  133684. disablePhysicsEngine(): void;
  133685. /**
  133686. * Gets a boolean indicating if there is an active physics engine
  133687. * @returns a boolean indicating if there is an active physics engine
  133688. */
  133689. isPhysicsEnabled(): boolean;
  133690. /**
  133691. * Deletes a physics compound impostor
  133692. * @param compound defines the compound to delete
  133693. */
  133694. deleteCompoundImpostor(compound: any): void;
  133695. /**
  133696. * An event triggered when physic simulation is about to be run
  133697. */
  133698. onBeforePhysicsObservable: Observable<Scene>;
  133699. /**
  133700. * An event triggered when physic simulation has been done
  133701. */
  133702. onAfterPhysicsObservable: Observable<Scene>;
  133703. }
  133704. interface AbstractMesh {
  133705. /** @hidden */
  133706. _physicsImpostor: Nullable<PhysicsImpostor>;
  133707. /**
  133708. * Gets or sets impostor used for physic simulation
  133709. * @see http://doc.babylonjs.com/features/physics_engine
  133710. */
  133711. physicsImpostor: Nullable<PhysicsImpostor>;
  133712. /**
  133713. * Gets the current physics impostor
  133714. * @see http://doc.babylonjs.com/features/physics_engine
  133715. * @returns a physics impostor or null
  133716. */
  133717. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  133718. /** Apply a physic impulse to the mesh
  133719. * @param force defines the force to apply
  133720. * @param contactPoint defines where to apply the force
  133721. * @returns the current mesh
  133722. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  133723. */
  133724. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  133725. /**
  133726. * Creates a physic joint between two meshes
  133727. * @param otherMesh defines the other mesh to use
  133728. * @param pivot1 defines the pivot to use on this mesh
  133729. * @param pivot2 defines the pivot to use on the other mesh
  133730. * @param options defines additional options (can be plugin dependent)
  133731. * @returns the current mesh
  133732. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  133733. */
  133734. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  133735. /** @hidden */
  133736. _disposePhysicsObserver: Nullable<Observer<Node>>;
  133737. }
  133738. /**
  133739. * Defines the physics engine scene component responsible to manage a physics engine
  133740. */
  133741. export class PhysicsEngineSceneComponent implements ISceneComponent {
  133742. /**
  133743. * The component name helpful to identify the component in the list of scene components.
  133744. */
  133745. readonly name: string;
  133746. /**
  133747. * The scene the component belongs to.
  133748. */
  133749. scene: Scene;
  133750. /**
  133751. * Creates a new instance of the component for the given scene
  133752. * @param scene Defines the scene to register the component in
  133753. */
  133754. constructor(scene: Scene);
  133755. /**
  133756. * Registers the component in a given scene
  133757. */
  133758. register(): void;
  133759. /**
  133760. * Rebuilds the elements related to this component in case of
  133761. * context lost for instance.
  133762. */
  133763. rebuild(): void;
  133764. /**
  133765. * Disposes the component and the associated ressources
  133766. */
  133767. dispose(): void;
  133768. }
  133769. }
  133770. declare module BABYLON {
  133771. /**
  133772. * A helper for physics simulations
  133773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  133774. */
  133775. export class PhysicsHelper {
  133776. private _scene;
  133777. private _physicsEngine;
  133778. /**
  133779. * Initializes the Physics helper
  133780. * @param scene Babylon.js scene
  133781. */
  133782. constructor(scene: Scene);
  133783. /**
  133784. * Applies a radial explosion impulse
  133785. * @param origin the origin of the explosion
  133786. * @param radiusOrEventOptions the radius or the options of radial explosion
  133787. * @param strength the explosion strength
  133788. * @param falloff possible options: Constant & Linear. Defaults to Constant
  133789. * @returns A physics radial explosion event, or null
  133790. */
  133791. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  133792. /**
  133793. * Applies a radial explosion force
  133794. * @param origin the origin of the explosion
  133795. * @param radiusOrEventOptions the radius or the options of radial explosion
  133796. * @param strength the explosion strength
  133797. * @param falloff possible options: Constant & Linear. Defaults to Constant
  133798. * @returns A physics radial explosion event, or null
  133799. */
  133800. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  133801. /**
  133802. * Creates a gravitational field
  133803. * @param origin the origin of the explosion
  133804. * @param radiusOrEventOptions the radius or the options of radial explosion
  133805. * @param strength the explosion strength
  133806. * @param falloff possible options: Constant & Linear. Defaults to Constant
  133807. * @returns A physics gravitational field event, or null
  133808. */
  133809. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  133810. /**
  133811. * Creates a physics updraft event
  133812. * @param origin the origin of the updraft
  133813. * @param radiusOrEventOptions the radius or the options of the updraft
  133814. * @param strength the strength of the updraft
  133815. * @param height the height of the updraft
  133816. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  133817. * @returns A physics updraft event, or null
  133818. */
  133819. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  133820. /**
  133821. * Creates a physics vortex event
  133822. * @param origin the of the vortex
  133823. * @param radiusOrEventOptions the radius or the options of the vortex
  133824. * @param strength the strength of the vortex
  133825. * @param height the height of the vortex
  133826. * @returns a Physics vortex event, or null
  133827. * A physics vortex event or null
  133828. */
  133829. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  133830. }
  133831. /**
  133832. * Represents a physics radial explosion event
  133833. */
  133834. class PhysicsRadialExplosionEvent {
  133835. private _scene;
  133836. private _options;
  133837. private _sphere;
  133838. private _dataFetched;
  133839. /**
  133840. * Initializes a radial explosioin event
  133841. * @param _scene BabylonJS scene
  133842. * @param _options The options for the vortex event
  133843. */
  133844. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  133845. /**
  133846. * Returns the data related to the radial explosion event (sphere).
  133847. * @returns The radial explosion event data
  133848. */
  133849. getData(): PhysicsRadialExplosionEventData;
  133850. /**
  133851. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  133852. * @param impostor A physics imposter
  133853. * @param origin the origin of the explosion
  133854. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  133855. */
  133856. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  133857. /**
  133858. * Triggers affecterd impostors callbacks
  133859. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  133860. */
  133861. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  133862. /**
  133863. * Disposes the sphere.
  133864. * @param force Specifies if the sphere should be disposed by force
  133865. */
  133866. dispose(force?: boolean): void;
  133867. /*** Helpers ***/
  133868. private _prepareSphere;
  133869. private _intersectsWithSphere;
  133870. }
  133871. /**
  133872. * Represents a gravitational field event
  133873. */
  133874. class PhysicsGravitationalFieldEvent {
  133875. private _physicsHelper;
  133876. private _scene;
  133877. private _origin;
  133878. private _options;
  133879. private _tickCallback;
  133880. private _sphere;
  133881. private _dataFetched;
  133882. /**
  133883. * Initializes the physics gravitational field event
  133884. * @param _physicsHelper A physics helper
  133885. * @param _scene BabylonJS scene
  133886. * @param _origin The origin position of the gravitational field event
  133887. * @param _options The options for the vortex event
  133888. */
  133889. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  133890. /**
  133891. * Returns the data related to the gravitational field event (sphere).
  133892. * @returns A gravitational field event
  133893. */
  133894. getData(): PhysicsGravitationalFieldEventData;
  133895. /**
  133896. * Enables the gravitational field.
  133897. */
  133898. enable(): void;
  133899. /**
  133900. * Disables the gravitational field.
  133901. */
  133902. disable(): void;
  133903. /**
  133904. * Disposes the sphere.
  133905. * @param force The force to dispose from the gravitational field event
  133906. */
  133907. dispose(force?: boolean): void;
  133908. private _tick;
  133909. }
  133910. /**
  133911. * Represents a physics updraft event
  133912. */
  133913. class PhysicsUpdraftEvent {
  133914. private _scene;
  133915. private _origin;
  133916. private _options;
  133917. private _physicsEngine;
  133918. private _originTop;
  133919. private _originDirection;
  133920. private _tickCallback;
  133921. private _cylinder;
  133922. private _cylinderPosition;
  133923. private _dataFetched;
  133924. /**
  133925. * Initializes the physics updraft event
  133926. * @param _scene BabylonJS scene
  133927. * @param _origin The origin position of the updraft
  133928. * @param _options The options for the updraft event
  133929. */
  133930. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  133931. /**
  133932. * Returns the data related to the updraft event (cylinder).
  133933. * @returns A physics updraft event
  133934. */
  133935. getData(): PhysicsUpdraftEventData;
  133936. /**
  133937. * Enables the updraft.
  133938. */
  133939. enable(): void;
  133940. /**
  133941. * Disables the updraft.
  133942. */
  133943. disable(): void;
  133944. /**
  133945. * Disposes the cylinder.
  133946. * @param force Specifies if the updraft should be disposed by force
  133947. */
  133948. dispose(force?: boolean): void;
  133949. private getImpostorHitData;
  133950. private _tick;
  133951. /*** Helpers ***/
  133952. private _prepareCylinder;
  133953. private _intersectsWithCylinder;
  133954. }
  133955. /**
  133956. * Represents a physics vortex event
  133957. */
  133958. class PhysicsVortexEvent {
  133959. private _scene;
  133960. private _origin;
  133961. private _options;
  133962. private _physicsEngine;
  133963. private _originTop;
  133964. private _tickCallback;
  133965. private _cylinder;
  133966. private _cylinderPosition;
  133967. private _dataFetched;
  133968. /**
  133969. * Initializes the physics vortex event
  133970. * @param _scene The BabylonJS scene
  133971. * @param _origin The origin position of the vortex
  133972. * @param _options The options for the vortex event
  133973. */
  133974. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  133975. /**
  133976. * Returns the data related to the vortex event (cylinder).
  133977. * @returns The physics vortex event data
  133978. */
  133979. getData(): PhysicsVortexEventData;
  133980. /**
  133981. * Enables the vortex.
  133982. */
  133983. enable(): void;
  133984. /**
  133985. * Disables the cortex.
  133986. */
  133987. disable(): void;
  133988. /**
  133989. * Disposes the sphere.
  133990. * @param force
  133991. */
  133992. dispose(force?: boolean): void;
  133993. private getImpostorHitData;
  133994. private _tick;
  133995. /*** Helpers ***/
  133996. private _prepareCylinder;
  133997. private _intersectsWithCylinder;
  133998. }
  133999. /**
  134000. * Options fot the radial explosion event
  134001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134002. */
  134003. export class PhysicsRadialExplosionEventOptions {
  134004. /**
  134005. * The radius of the sphere for the radial explosion.
  134006. */
  134007. radius: number;
  134008. /**
  134009. * The strenth of the explosion.
  134010. */
  134011. strength: number;
  134012. /**
  134013. * The strenght of the force in correspondence to the distance of the affected object
  134014. */
  134015. falloff: PhysicsRadialImpulseFalloff;
  134016. /**
  134017. * Sphere options for the radial explosion.
  134018. */
  134019. sphere: {
  134020. segments: number;
  134021. diameter: number;
  134022. };
  134023. /**
  134024. * Sphere options for the radial explosion.
  134025. */
  134026. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  134027. }
  134028. /**
  134029. * Options fot the updraft event
  134030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134031. */
  134032. export class PhysicsUpdraftEventOptions {
  134033. /**
  134034. * The radius of the cylinder for the vortex
  134035. */
  134036. radius: number;
  134037. /**
  134038. * The strenth of the updraft.
  134039. */
  134040. strength: number;
  134041. /**
  134042. * The height of the cylinder for the updraft.
  134043. */
  134044. height: number;
  134045. /**
  134046. * The mode for the the updraft.
  134047. */
  134048. updraftMode: PhysicsUpdraftMode;
  134049. }
  134050. /**
  134051. * Options fot the vortex event
  134052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134053. */
  134054. export class PhysicsVortexEventOptions {
  134055. /**
  134056. * The radius of the cylinder for the vortex
  134057. */
  134058. radius: number;
  134059. /**
  134060. * The strenth of the vortex.
  134061. */
  134062. strength: number;
  134063. /**
  134064. * The height of the cylinder for the vortex.
  134065. */
  134066. height: number;
  134067. /**
  134068. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  134069. */
  134070. centripetalForceThreshold: number;
  134071. /**
  134072. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  134073. */
  134074. centripetalForceMultiplier: number;
  134075. /**
  134076. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  134077. */
  134078. centrifugalForceMultiplier: number;
  134079. /**
  134080. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  134081. */
  134082. updraftForceMultiplier: number;
  134083. }
  134084. /**
  134085. * The strenght of the force in correspondence to the distance of the affected object
  134086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134087. */
  134088. export enum PhysicsRadialImpulseFalloff {
  134089. /** Defines that impulse is constant in strength across it's whole radius */
  134090. Constant = 0,
  134091. /** Defines that impulse gets weaker if it's further from the origin */
  134092. Linear = 1
  134093. }
  134094. /**
  134095. * The strength of the force in correspondence to the distance of the affected object
  134096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134097. */
  134098. export enum PhysicsUpdraftMode {
  134099. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  134100. Center = 0,
  134101. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  134102. Perpendicular = 1
  134103. }
  134104. /**
  134105. * Interface for a physics hit data
  134106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134107. */
  134108. export interface PhysicsHitData {
  134109. /**
  134110. * The force applied at the contact point
  134111. */
  134112. force: Vector3;
  134113. /**
  134114. * The contact point
  134115. */
  134116. contactPoint: Vector3;
  134117. /**
  134118. * The distance from the origin to the contact point
  134119. */
  134120. distanceFromOrigin: number;
  134121. }
  134122. /**
  134123. * Interface for radial explosion event data
  134124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134125. */
  134126. export interface PhysicsRadialExplosionEventData {
  134127. /**
  134128. * A sphere used for the radial explosion event
  134129. */
  134130. sphere: Mesh;
  134131. }
  134132. /**
  134133. * Interface for gravitational field event data
  134134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134135. */
  134136. export interface PhysicsGravitationalFieldEventData {
  134137. /**
  134138. * A sphere mesh used for the gravitational field event
  134139. */
  134140. sphere: Mesh;
  134141. }
  134142. /**
  134143. * Interface for updraft event data
  134144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134145. */
  134146. export interface PhysicsUpdraftEventData {
  134147. /**
  134148. * A cylinder used for the updraft event
  134149. */
  134150. cylinder: Mesh;
  134151. }
  134152. /**
  134153. * Interface for vortex event data
  134154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134155. */
  134156. export interface PhysicsVortexEventData {
  134157. /**
  134158. * A cylinder used for the vortex event
  134159. */
  134160. cylinder: Mesh;
  134161. }
  134162. /**
  134163. * Interface for an affected physics impostor
  134164. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  134165. */
  134166. export interface PhysicsAffectedImpostorWithData {
  134167. /**
  134168. * The impostor affected by the effect
  134169. */
  134170. impostor: PhysicsImpostor;
  134171. /**
  134172. * The data about the hit/horce from the explosion
  134173. */
  134174. hitData: PhysicsHitData;
  134175. }
  134176. }
  134177. declare module BABYLON {
  134178. /** @hidden */
  134179. export var blackAndWhitePixelShader: {
  134180. name: string;
  134181. shader: string;
  134182. };
  134183. }
  134184. declare module BABYLON {
  134185. /**
  134186. * Post process used to render in black and white
  134187. */
  134188. export class BlackAndWhitePostProcess extends PostProcess {
  134189. /**
  134190. * Linear about to convert he result to black and white (default: 1)
  134191. */
  134192. degree: number;
  134193. /**
  134194. * Creates a black and white post process
  134195. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  134196. * @param name The name of the effect.
  134197. * @param options The required width/height ratio to downsize to before computing the render pass.
  134198. * @param camera The camera to apply the render pass to.
  134199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134200. * @param engine The engine which the post process will be applied. (default: current engine)
  134201. * @param reusable If the post process can be reused on the same frame. (default: false)
  134202. */
  134203. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  134204. }
  134205. }
  134206. declare module BABYLON {
  134207. /**
  134208. * This represents a set of one or more post processes in Babylon.
  134209. * A post process can be used to apply a shader to a texture after it is rendered.
  134210. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  134211. */
  134212. export class PostProcessRenderEffect {
  134213. private _postProcesses;
  134214. private _getPostProcesses;
  134215. private _singleInstance;
  134216. private _cameras;
  134217. private _indicesForCamera;
  134218. /**
  134219. * Name of the effect
  134220. * @hidden
  134221. */
  134222. _name: string;
  134223. /**
  134224. * Instantiates a post process render effect.
  134225. * A post process can be used to apply a shader to a texture after it is rendered.
  134226. * @param engine The engine the effect is tied to
  134227. * @param name The name of the effect
  134228. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  134229. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  134230. */
  134231. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  134232. /**
  134233. * Checks if all the post processes in the effect are supported.
  134234. */
  134235. get isSupported(): boolean;
  134236. /**
  134237. * Updates the current state of the effect
  134238. * @hidden
  134239. */
  134240. _update(): void;
  134241. /**
  134242. * Attaches the effect on cameras
  134243. * @param cameras The camera to attach to.
  134244. * @hidden
  134245. */
  134246. _attachCameras(cameras: Camera): void;
  134247. /**
  134248. * Attaches the effect on cameras
  134249. * @param cameras The camera to attach to.
  134250. * @hidden
  134251. */
  134252. _attachCameras(cameras: Camera[]): void;
  134253. /**
  134254. * Detaches the effect on cameras
  134255. * @param cameras The camera to detatch from.
  134256. * @hidden
  134257. */
  134258. _detachCameras(cameras: Camera): void;
  134259. /**
  134260. * Detatches the effect on cameras
  134261. * @param cameras The camera to detatch from.
  134262. * @hidden
  134263. */
  134264. _detachCameras(cameras: Camera[]): void;
  134265. /**
  134266. * Enables the effect on given cameras
  134267. * @param cameras The camera to enable.
  134268. * @hidden
  134269. */
  134270. _enable(cameras: Camera): void;
  134271. /**
  134272. * Enables the effect on given cameras
  134273. * @param cameras The camera to enable.
  134274. * @hidden
  134275. */
  134276. _enable(cameras: Nullable<Camera[]>): void;
  134277. /**
  134278. * Disables the effect on the given cameras
  134279. * @param cameras The camera to disable.
  134280. * @hidden
  134281. */
  134282. _disable(cameras: Camera): void;
  134283. /**
  134284. * Disables the effect on the given cameras
  134285. * @param cameras The camera to disable.
  134286. * @hidden
  134287. */
  134288. _disable(cameras: Nullable<Camera[]>): void;
  134289. /**
  134290. * Gets a list of the post processes contained in the effect.
  134291. * @param camera The camera to get the post processes on.
  134292. * @returns The list of the post processes in the effect.
  134293. */
  134294. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  134295. }
  134296. }
  134297. declare module BABYLON {
  134298. /** @hidden */
  134299. export var extractHighlightsPixelShader: {
  134300. name: string;
  134301. shader: string;
  134302. };
  134303. }
  134304. declare module BABYLON {
  134305. /**
  134306. * 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.
  134307. */
  134308. export class ExtractHighlightsPostProcess extends PostProcess {
  134309. /**
  134310. * The luminance threshold, pixels below this value will be set to black.
  134311. */
  134312. threshold: number;
  134313. /** @hidden */
  134314. _exposure: number;
  134315. /**
  134316. * Post process which has the input texture to be used when performing highlight extraction
  134317. * @hidden
  134318. */
  134319. _inputPostProcess: Nullable<PostProcess>;
  134320. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134321. }
  134322. }
  134323. declare module BABYLON {
  134324. /** @hidden */
  134325. export var bloomMergePixelShader: {
  134326. name: string;
  134327. shader: string;
  134328. };
  134329. }
  134330. declare module BABYLON {
  134331. /**
  134332. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  134333. */
  134334. export class BloomMergePostProcess extends PostProcess {
  134335. /** Weight of the bloom to be added to the original input. */
  134336. weight: number;
  134337. /**
  134338. * Creates a new instance of @see BloomMergePostProcess
  134339. * @param name The name of the effect.
  134340. * @param originalFromInput Post process which's input will be used for the merge.
  134341. * @param blurred Blurred highlights post process which's output will be used.
  134342. * @param weight Weight of the bloom to be added to the original input.
  134343. * @param options The required width/height ratio to downsize to before computing the render pass.
  134344. * @param camera The camera to apply the render pass to.
  134345. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134346. * @param engine The engine which the post process will be applied. (default: current engine)
  134347. * @param reusable If the post process can be reused on the same frame. (default: false)
  134348. * @param textureType Type of textures used when performing the post process. (default: 0)
  134349. * @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)
  134350. */
  134351. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  134352. /** Weight of the bloom to be added to the original input. */
  134353. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134354. }
  134355. }
  134356. declare module BABYLON {
  134357. /**
  134358. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  134359. */
  134360. export class BloomEffect extends PostProcessRenderEffect {
  134361. private bloomScale;
  134362. /**
  134363. * @hidden Internal
  134364. */
  134365. _effects: Array<PostProcess>;
  134366. /**
  134367. * @hidden Internal
  134368. */
  134369. _downscale: ExtractHighlightsPostProcess;
  134370. private _blurX;
  134371. private _blurY;
  134372. private _merge;
  134373. /**
  134374. * The luminance threshold to find bright areas of the image to bloom.
  134375. */
  134376. get threshold(): number;
  134377. set threshold(value: number);
  134378. /**
  134379. * The strength of the bloom.
  134380. */
  134381. get weight(): number;
  134382. set weight(value: number);
  134383. /**
  134384. * Specifies the size of the bloom blur kernel, relative to the final output size
  134385. */
  134386. get kernel(): number;
  134387. set kernel(value: number);
  134388. /**
  134389. * Creates a new instance of @see BloomEffect
  134390. * @param scene The scene the effect belongs to.
  134391. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  134392. * @param bloomKernel The size of the kernel to be used when applying the blur.
  134393. * @param bloomWeight The the strength of bloom.
  134394. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  134395. * @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)
  134396. */
  134397. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  134398. /**
  134399. * Disposes each of the internal effects for a given camera.
  134400. * @param camera The camera to dispose the effect on.
  134401. */
  134402. disposeEffects(camera: Camera): void;
  134403. /**
  134404. * @hidden Internal
  134405. */
  134406. _updateEffects(): void;
  134407. /**
  134408. * Internal
  134409. * @returns if all the contained post processes are ready.
  134410. * @hidden
  134411. */
  134412. _isReady(): boolean;
  134413. }
  134414. }
  134415. declare module BABYLON {
  134416. /** @hidden */
  134417. export var chromaticAberrationPixelShader: {
  134418. name: string;
  134419. shader: string;
  134420. };
  134421. }
  134422. declare module BABYLON {
  134423. /**
  134424. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  134425. */
  134426. export class ChromaticAberrationPostProcess extends PostProcess {
  134427. /**
  134428. * The amount of seperation of rgb channels (default: 30)
  134429. */
  134430. aberrationAmount: number;
  134431. /**
  134432. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  134433. */
  134434. radialIntensity: number;
  134435. /**
  134436. * 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))
  134437. */
  134438. direction: Vector2;
  134439. /**
  134440. * 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))
  134441. */
  134442. centerPosition: Vector2;
  134443. /**
  134444. * Creates a new instance ChromaticAberrationPostProcess
  134445. * @param name The name of the effect.
  134446. * @param screenWidth The width of the screen to apply the effect on.
  134447. * @param screenHeight The height of the screen to apply the effect on.
  134448. * @param options The required width/height ratio to downsize to before computing the render pass.
  134449. * @param camera The camera to apply the render pass to.
  134450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134451. * @param engine The engine which the post process will be applied. (default: current engine)
  134452. * @param reusable If the post process can be reused on the same frame. (default: false)
  134453. * @param textureType Type of textures used when performing the post process. (default: 0)
  134454. * @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)
  134455. */
  134456. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134457. }
  134458. }
  134459. declare module BABYLON {
  134460. /** @hidden */
  134461. export var circleOfConfusionPixelShader: {
  134462. name: string;
  134463. shader: string;
  134464. };
  134465. }
  134466. declare module BABYLON {
  134467. /**
  134468. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  134469. */
  134470. export class CircleOfConfusionPostProcess extends PostProcess {
  134471. /**
  134472. * 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.
  134473. */
  134474. lensSize: number;
  134475. /**
  134476. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  134477. */
  134478. fStop: number;
  134479. /**
  134480. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  134481. */
  134482. focusDistance: number;
  134483. /**
  134484. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  134485. */
  134486. focalLength: number;
  134487. private _depthTexture;
  134488. /**
  134489. * Creates a new instance CircleOfConfusionPostProcess
  134490. * @param name The name of the effect.
  134491. * @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.
  134492. * @param options The required width/height ratio to downsize to before computing the render pass.
  134493. * @param camera The camera to apply the render pass to.
  134494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134495. * @param engine The engine which the post process will be applied. (default: current engine)
  134496. * @param reusable If the post process can be reused on the same frame. (default: false)
  134497. * @param textureType Type of textures used when performing the post process. (default: 0)
  134498. * @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)
  134499. */
  134500. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134501. /**
  134502. * 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.
  134503. */
  134504. set depthTexture(value: RenderTargetTexture);
  134505. }
  134506. }
  134507. declare module BABYLON {
  134508. /** @hidden */
  134509. export var colorCorrectionPixelShader: {
  134510. name: string;
  134511. shader: string;
  134512. };
  134513. }
  134514. declare module BABYLON {
  134515. /**
  134516. *
  134517. * This post-process allows the modification of rendered colors by using
  134518. * a 'look-up table' (LUT). This effect is also called Color Grading.
  134519. *
  134520. * The object needs to be provided an url to a texture containing the color
  134521. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  134522. * Use an image editing software to tweak the LUT to match your needs.
  134523. *
  134524. * For an example of a color LUT, see here:
  134525. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  134526. * For explanations on color grading, see here:
  134527. * @see http://udn.epicgames.com/Three/ColorGrading.html
  134528. *
  134529. */
  134530. export class ColorCorrectionPostProcess extends PostProcess {
  134531. private _colorTableTexture;
  134532. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  134533. }
  134534. }
  134535. declare module BABYLON {
  134536. /** @hidden */
  134537. export var convolutionPixelShader: {
  134538. name: string;
  134539. shader: string;
  134540. };
  134541. }
  134542. declare module BABYLON {
  134543. /**
  134544. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  134545. * input texture to perform effects such as edge detection or sharpening
  134546. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  134547. */
  134548. export class ConvolutionPostProcess extends PostProcess {
  134549. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  134550. kernel: number[];
  134551. /**
  134552. * Creates a new instance ConvolutionPostProcess
  134553. * @param name The name of the effect.
  134554. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  134555. * @param options The required width/height ratio to downsize to before computing the render pass.
  134556. * @param camera The camera to apply the render pass to.
  134557. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134558. * @param engine The engine which the post process will be applied. (default: current engine)
  134559. * @param reusable If the post process can be reused on the same frame. (default: false)
  134560. * @param textureType Type of textures used when performing the post process. (default: 0)
  134561. */
  134562. constructor(name: string,
  134563. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  134564. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  134565. /**
  134566. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134567. */
  134568. static EdgeDetect0Kernel: number[];
  134569. /**
  134570. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134571. */
  134572. static EdgeDetect1Kernel: number[];
  134573. /**
  134574. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134575. */
  134576. static EdgeDetect2Kernel: number[];
  134577. /**
  134578. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134579. */
  134580. static SharpenKernel: number[];
  134581. /**
  134582. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134583. */
  134584. static EmbossKernel: number[];
  134585. /**
  134586. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  134587. */
  134588. static GaussianKernel: number[];
  134589. }
  134590. }
  134591. declare module BABYLON {
  134592. /**
  134593. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  134594. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  134595. * based on samples that have a large difference in distance than the center pixel.
  134596. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  134597. */
  134598. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  134599. direction: Vector2;
  134600. /**
  134601. * Creates a new instance CircleOfConfusionPostProcess
  134602. * @param name The name of the effect.
  134603. * @param scene The scene the effect belongs to.
  134604. * @param direction The direction the blur should be applied.
  134605. * @param kernel The size of the kernel used to blur.
  134606. * @param options The required width/height ratio to downsize to before computing the render pass.
  134607. * @param camera The camera to apply the render pass to.
  134608. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  134609. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  134610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134611. * @param engine The engine which the post process will be applied. (default: current engine)
  134612. * @param reusable If the post process can be reused on the same frame. (default: false)
  134613. * @param textureType Type of textures used when performing the post process. (default: 0)
  134614. * @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)
  134615. */
  134616. 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);
  134617. }
  134618. }
  134619. declare module BABYLON {
  134620. /** @hidden */
  134621. export var depthOfFieldMergePixelShader: {
  134622. name: string;
  134623. shader: string;
  134624. };
  134625. }
  134626. declare module BABYLON {
  134627. /**
  134628. * Options to be set when merging outputs from the default pipeline.
  134629. */
  134630. export class DepthOfFieldMergePostProcessOptions {
  134631. /**
  134632. * The original image to merge on top of
  134633. */
  134634. originalFromInput: PostProcess;
  134635. /**
  134636. * Parameters to perform the merge of the depth of field effect
  134637. */
  134638. depthOfField?: {
  134639. circleOfConfusion: PostProcess;
  134640. blurSteps: Array<PostProcess>;
  134641. };
  134642. /**
  134643. * Parameters to perform the merge of bloom effect
  134644. */
  134645. bloom?: {
  134646. blurred: PostProcess;
  134647. weight: number;
  134648. };
  134649. }
  134650. /**
  134651. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  134652. */
  134653. export class DepthOfFieldMergePostProcess extends PostProcess {
  134654. private blurSteps;
  134655. /**
  134656. * Creates a new instance of DepthOfFieldMergePostProcess
  134657. * @param name The name of the effect.
  134658. * @param originalFromInput Post process which's input will be used for the merge.
  134659. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  134660. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  134661. * @param options The required width/height ratio to downsize to before computing the render pass.
  134662. * @param camera The camera to apply the render pass to.
  134663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134664. * @param engine The engine which the post process will be applied. (default: current engine)
  134665. * @param reusable If the post process can be reused on the same frame. (default: false)
  134666. * @param textureType Type of textures used when performing the post process. (default: 0)
  134667. * @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)
  134668. */
  134669. 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);
  134670. /**
  134671. * Updates the effect with the current post process compile time values and recompiles the shader.
  134672. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  134673. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  134674. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  134675. * @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
  134676. * @param onCompiled Called when the shader has been compiled.
  134677. * @param onError Called if there is an error when compiling a shader.
  134678. */
  134679. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  134680. }
  134681. }
  134682. declare module BABYLON {
  134683. /**
  134684. * Specifies the level of max blur that should be applied when using the depth of field effect
  134685. */
  134686. export enum DepthOfFieldEffectBlurLevel {
  134687. /**
  134688. * Subtle blur
  134689. */
  134690. Low = 0,
  134691. /**
  134692. * Medium blur
  134693. */
  134694. Medium = 1,
  134695. /**
  134696. * Large blur
  134697. */
  134698. High = 2
  134699. }
  134700. /**
  134701. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  134702. */
  134703. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  134704. private _circleOfConfusion;
  134705. /**
  134706. * @hidden Internal, blurs from high to low
  134707. */
  134708. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  134709. private _depthOfFieldBlurY;
  134710. private _dofMerge;
  134711. /**
  134712. * @hidden Internal post processes in depth of field effect
  134713. */
  134714. _effects: Array<PostProcess>;
  134715. /**
  134716. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  134717. */
  134718. set focalLength(value: number);
  134719. get focalLength(): number;
  134720. /**
  134721. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  134722. */
  134723. set fStop(value: number);
  134724. get fStop(): number;
  134725. /**
  134726. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  134727. */
  134728. set focusDistance(value: number);
  134729. get focusDistance(): number;
  134730. /**
  134731. * 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.
  134732. */
  134733. set lensSize(value: number);
  134734. get lensSize(): number;
  134735. /**
  134736. * Creates a new instance DepthOfFieldEffect
  134737. * @param scene The scene the effect belongs to.
  134738. * @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.
  134739. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  134740. * @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)
  134741. */
  134742. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  134743. /**
  134744. * Get the current class name of the current effet
  134745. * @returns "DepthOfFieldEffect"
  134746. */
  134747. getClassName(): string;
  134748. /**
  134749. * 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.
  134750. */
  134751. set depthTexture(value: RenderTargetTexture);
  134752. /**
  134753. * Disposes each of the internal effects for a given camera.
  134754. * @param camera The camera to dispose the effect on.
  134755. */
  134756. disposeEffects(camera: Camera): void;
  134757. /**
  134758. * @hidden Internal
  134759. */
  134760. _updateEffects(): void;
  134761. /**
  134762. * Internal
  134763. * @returns if all the contained post processes are ready.
  134764. * @hidden
  134765. */
  134766. _isReady(): boolean;
  134767. }
  134768. }
  134769. declare module BABYLON {
  134770. /** @hidden */
  134771. export var displayPassPixelShader: {
  134772. name: string;
  134773. shader: string;
  134774. };
  134775. }
  134776. declare module BABYLON {
  134777. /**
  134778. * DisplayPassPostProcess which produces an output the same as it's input
  134779. */
  134780. export class DisplayPassPostProcess extends PostProcess {
  134781. /**
  134782. * Creates the DisplayPassPostProcess
  134783. * @param name The name of the effect.
  134784. * @param options The required width/height ratio to downsize to before computing the render pass.
  134785. * @param camera The camera to apply the render pass to.
  134786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134787. * @param engine The engine which the post process will be applied. (default: current engine)
  134788. * @param reusable If the post process can be reused on the same frame. (default: false)
  134789. */
  134790. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  134791. }
  134792. }
  134793. declare module BABYLON {
  134794. /** @hidden */
  134795. export var filterPixelShader: {
  134796. name: string;
  134797. shader: string;
  134798. };
  134799. }
  134800. declare module BABYLON {
  134801. /**
  134802. * Applies a kernel filter to the image
  134803. */
  134804. export class FilterPostProcess extends PostProcess {
  134805. /** The matrix to be applied to the image */
  134806. kernelMatrix: Matrix;
  134807. /**
  134808. *
  134809. * @param name The name of the effect.
  134810. * @param kernelMatrix The matrix to be applied to the image
  134811. * @param options The required width/height ratio to downsize to before computing the render pass.
  134812. * @param camera The camera to apply the render pass to.
  134813. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134814. * @param engine The engine which the post process will be applied. (default: current engine)
  134815. * @param reusable If the post process can be reused on the same frame. (default: false)
  134816. */
  134817. constructor(name: string,
  134818. /** The matrix to be applied to the image */
  134819. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  134820. }
  134821. }
  134822. declare module BABYLON {
  134823. /** @hidden */
  134824. export var fxaaPixelShader: {
  134825. name: string;
  134826. shader: string;
  134827. };
  134828. }
  134829. declare module BABYLON {
  134830. /** @hidden */
  134831. export var fxaaVertexShader: {
  134832. name: string;
  134833. shader: string;
  134834. };
  134835. }
  134836. declare module BABYLON {
  134837. /**
  134838. * Fxaa post process
  134839. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  134840. */
  134841. export class FxaaPostProcess extends PostProcess {
  134842. /** @hidden */
  134843. texelWidth: number;
  134844. /** @hidden */
  134845. texelHeight: number;
  134846. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  134847. private _getDefines;
  134848. }
  134849. }
  134850. declare module BABYLON {
  134851. /** @hidden */
  134852. export var grainPixelShader: {
  134853. name: string;
  134854. shader: string;
  134855. };
  134856. }
  134857. declare module BABYLON {
  134858. /**
  134859. * The GrainPostProcess adds noise to the image at mid luminance levels
  134860. */
  134861. export class GrainPostProcess extends PostProcess {
  134862. /**
  134863. * The intensity of the grain added (default: 30)
  134864. */
  134865. intensity: number;
  134866. /**
  134867. * If the grain should be randomized on every frame
  134868. */
  134869. animated: boolean;
  134870. /**
  134871. * Creates a new instance of @see GrainPostProcess
  134872. * @param name The name of the effect.
  134873. * @param options The required width/height ratio to downsize to before computing the render pass.
  134874. * @param camera The camera to apply the render pass to.
  134875. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134876. * @param engine The engine which the post process will be applied. (default: current engine)
  134877. * @param reusable If the post process can be reused on the same frame. (default: false)
  134878. * @param textureType Type of textures used when performing the post process. (default: 0)
  134879. * @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)
  134880. */
  134881. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  134882. }
  134883. }
  134884. declare module BABYLON {
  134885. /** @hidden */
  134886. export var highlightsPixelShader: {
  134887. name: string;
  134888. shader: string;
  134889. };
  134890. }
  134891. declare module BABYLON {
  134892. /**
  134893. * Extracts highlights from the image
  134894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  134895. */
  134896. export class HighlightsPostProcess extends PostProcess {
  134897. /**
  134898. * Extracts highlights from the image
  134899. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  134900. * @param name The name of the effect.
  134901. * @param options The required width/height ratio to downsize to before computing the render pass.
  134902. * @param camera The camera to apply the render pass to.
  134903. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  134904. * @param engine The engine which the post process will be applied. (default: current engine)
  134905. * @param reusable If the post process can be reused on the same frame. (default: false)
  134906. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  134907. */
  134908. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  134909. }
  134910. }
  134911. declare module BABYLON {
  134912. /** @hidden */
  134913. export var mrtFragmentDeclaration: {
  134914. name: string;
  134915. shader: string;
  134916. };
  134917. }
  134918. declare module BABYLON {
  134919. /** @hidden */
  134920. export var geometryPixelShader: {
  134921. name: string;
  134922. shader: string;
  134923. };
  134924. }
  134925. declare module BABYLON {
  134926. /** @hidden */
  134927. export var geometryVertexShader: {
  134928. name: string;
  134929. shader: string;
  134930. };
  134931. }
  134932. declare module BABYLON {
  134933. /** @hidden */
  134934. interface ISavedTransformationMatrix {
  134935. world: Matrix;
  134936. viewProjection: Matrix;
  134937. }
  134938. /**
  134939. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  134940. */
  134941. export class GeometryBufferRenderer {
  134942. /**
  134943. * Constant used to retrieve the position texture index in the G-Buffer textures array
  134944. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  134945. */
  134946. static readonly POSITION_TEXTURE_TYPE: number;
  134947. /**
  134948. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  134949. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  134950. */
  134951. static readonly VELOCITY_TEXTURE_TYPE: number;
  134952. /**
  134953. * Dictionary used to store the previous transformation matrices of each rendered mesh
  134954. * in order to compute objects velocities when enableVelocity is set to "true"
  134955. * @hidden
  134956. */
  134957. _previousTransformationMatrices: {
  134958. [index: number]: ISavedTransformationMatrix;
  134959. };
  134960. /**
  134961. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  134962. * in order to compute objects velocities when enableVelocity is set to "true"
  134963. * @hidden
  134964. */
  134965. _previousBonesTransformationMatrices: {
  134966. [index: number]: Float32Array;
  134967. };
  134968. /**
  134969. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  134970. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  134971. */
  134972. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  134973. private _scene;
  134974. private _multiRenderTarget;
  134975. private _ratio;
  134976. private _enablePosition;
  134977. private _enableVelocity;
  134978. private _positionIndex;
  134979. private _velocityIndex;
  134980. protected _effect: Effect;
  134981. protected _cachedDefines: string;
  134982. /**
  134983. * Set the render list (meshes to be rendered) used in the G buffer.
  134984. */
  134985. set renderList(meshes: Mesh[]);
  134986. /**
  134987. * Gets wether or not G buffer are supported by the running hardware.
  134988. * This requires draw buffer supports
  134989. */
  134990. get isSupported(): boolean;
  134991. /**
  134992. * Returns the index of the given texture type in the G-Buffer textures array
  134993. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  134994. * @returns the index of the given texture type in the G-Buffer textures array
  134995. */
  134996. getTextureIndex(textureType: number): number;
  134997. /**
  134998. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  134999. */
  135000. get enablePosition(): boolean;
  135001. /**
  135002. * Sets whether or not objects positions are enabled for the G buffer.
  135003. */
  135004. set enablePosition(enable: boolean);
  135005. /**
  135006. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  135007. */
  135008. get enableVelocity(): boolean;
  135009. /**
  135010. * Sets wether or not objects velocities are enabled for the G buffer.
  135011. */
  135012. set enableVelocity(enable: boolean);
  135013. /**
  135014. * Gets the scene associated with the buffer.
  135015. */
  135016. get scene(): Scene;
  135017. /**
  135018. * Gets the ratio used by the buffer during its creation.
  135019. * How big is the buffer related to the main canvas.
  135020. */
  135021. get ratio(): number;
  135022. /** @hidden */
  135023. static _SceneComponentInitialization: (scene: Scene) => void;
  135024. /**
  135025. * Creates a new G Buffer for the scene
  135026. * @param scene The scene the buffer belongs to
  135027. * @param ratio How big is the buffer related to the main canvas.
  135028. */
  135029. constructor(scene: Scene, ratio?: number);
  135030. /**
  135031. * Checks wether everything is ready to render a submesh to the G buffer.
  135032. * @param subMesh the submesh to check readiness for
  135033. * @param useInstances is the mesh drawn using instance or not
  135034. * @returns true if ready otherwise false
  135035. */
  135036. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135037. /**
  135038. * Gets the current underlying G Buffer.
  135039. * @returns the buffer
  135040. */
  135041. getGBuffer(): MultiRenderTarget;
  135042. /**
  135043. * Gets the number of samples used to render the buffer (anti aliasing).
  135044. */
  135045. get samples(): number;
  135046. /**
  135047. * Sets the number of samples used to render the buffer (anti aliasing).
  135048. */
  135049. set samples(value: number);
  135050. /**
  135051. * Disposes the renderer and frees up associated resources.
  135052. */
  135053. dispose(): void;
  135054. protected _createRenderTargets(): void;
  135055. private _copyBonesTransformationMatrices;
  135056. }
  135057. }
  135058. declare module BABYLON {
  135059. interface Scene {
  135060. /** @hidden (Backing field) */
  135061. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  135062. /**
  135063. * Gets or Sets the current geometry buffer associated to the scene.
  135064. */
  135065. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  135066. /**
  135067. * Enables a GeometryBufferRender and associates it with the scene
  135068. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  135069. * @returns the GeometryBufferRenderer
  135070. */
  135071. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  135072. /**
  135073. * Disables the GeometryBufferRender associated with the scene
  135074. */
  135075. disableGeometryBufferRenderer(): void;
  135076. }
  135077. /**
  135078. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  135079. * in several rendering techniques.
  135080. */
  135081. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  135082. /**
  135083. * The component name helpful to identify the component in the list of scene components.
  135084. */
  135085. readonly name: string;
  135086. /**
  135087. * The scene the component belongs to.
  135088. */
  135089. scene: Scene;
  135090. /**
  135091. * Creates a new instance of the component for the given scene
  135092. * @param scene Defines the scene to register the component in
  135093. */
  135094. constructor(scene: Scene);
  135095. /**
  135096. * Registers the component in a given scene
  135097. */
  135098. register(): void;
  135099. /**
  135100. * Rebuilds the elements related to this component in case of
  135101. * context lost for instance.
  135102. */
  135103. rebuild(): void;
  135104. /**
  135105. * Disposes the component and the associated ressources
  135106. */
  135107. dispose(): void;
  135108. private _gatherRenderTargets;
  135109. }
  135110. }
  135111. declare module BABYLON {
  135112. /** @hidden */
  135113. export var motionBlurPixelShader: {
  135114. name: string;
  135115. shader: string;
  135116. };
  135117. }
  135118. declare module BABYLON {
  135119. /**
  135120. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  135121. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  135122. * As an example, all you have to do is to create the post-process:
  135123. * var mb = new BABYLON.MotionBlurPostProcess(
  135124. * 'mb', // The name of the effect.
  135125. * scene, // The scene containing the objects to blur according to their velocity.
  135126. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  135127. * camera // The camera to apply the render pass to.
  135128. * );
  135129. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  135130. */
  135131. export class MotionBlurPostProcess extends PostProcess {
  135132. /**
  135133. * Defines how much the image is blurred by the movement. Default value is equal to 1
  135134. */
  135135. motionStrength: number;
  135136. /**
  135137. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  135138. */
  135139. get motionBlurSamples(): number;
  135140. /**
  135141. * Sets the number of iterations to be used for motion blur quality
  135142. */
  135143. set motionBlurSamples(samples: number);
  135144. private _motionBlurSamples;
  135145. private _geometryBufferRenderer;
  135146. /**
  135147. * Creates a new instance MotionBlurPostProcess
  135148. * @param name The name of the effect.
  135149. * @param scene The scene containing the objects to blur according to their velocity.
  135150. * @param options The required width/height ratio to downsize to before computing the render pass.
  135151. * @param camera The camera to apply the render pass to.
  135152. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135153. * @param engine The engine which the post process will be applied. (default: current engine)
  135154. * @param reusable If the post process can be reused on the same frame. (default: false)
  135155. * @param textureType Type of textures used when performing the post process. (default: 0)
  135156. * @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)
  135157. */
  135158. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  135159. /**
  135160. * Excludes the given skinned mesh from computing bones velocities.
  135161. * 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.
  135162. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  135163. */
  135164. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  135165. /**
  135166. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  135167. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  135168. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  135169. */
  135170. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  135171. /**
  135172. * Disposes the post process.
  135173. * @param camera The camera to dispose the post process on.
  135174. */
  135175. dispose(camera?: Camera): void;
  135176. }
  135177. }
  135178. declare module BABYLON {
  135179. /** @hidden */
  135180. export var refractionPixelShader: {
  135181. name: string;
  135182. shader: string;
  135183. };
  135184. }
  135185. declare module BABYLON {
  135186. /**
  135187. * Post process which applies a refractin texture
  135188. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  135189. */
  135190. export class RefractionPostProcess extends PostProcess {
  135191. /** the base color of the refraction (used to taint the rendering) */
  135192. color: Color3;
  135193. /** simulated refraction depth */
  135194. depth: number;
  135195. /** the coefficient of the base color (0 to remove base color tainting) */
  135196. colorLevel: number;
  135197. private _refTexture;
  135198. private _ownRefractionTexture;
  135199. /**
  135200. * Gets or sets the refraction texture
  135201. * Please note that you are responsible for disposing the texture if you set it manually
  135202. */
  135203. get refractionTexture(): Texture;
  135204. set refractionTexture(value: Texture);
  135205. /**
  135206. * Initializes the RefractionPostProcess
  135207. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  135208. * @param name The name of the effect.
  135209. * @param refractionTextureUrl Url of the refraction texture to use
  135210. * @param color the base color of the refraction (used to taint the rendering)
  135211. * @param depth simulated refraction depth
  135212. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  135213. * @param camera The camera to apply the render pass to.
  135214. * @param options The required width/height ratio to downsize to before computing the render pass.
  135215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135216. * @param engine The engine which the post process will be applied. (default: current engine)
  135217. * @param reusable If the post process can be reused on the same frame. (default: false)
  135218. */
  135219. constructor(name: string, refractionTextureUrl: string,
  135220. /** the base color of the refraction (used to taint the rendering) */
  135221. color: Color3,
  135222. /** simulated refraction depth */
  135223. depth: number,
  135224. /** the coefficient of the base color (0 to remove base color tainting) */
  135225. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  135226. /**
  135227. * Disposes of the post process
  135228. * @param camera Camera to dispose post process on
  135229. */
  135230. dispose(camera: Camera): void;
  135231. }
  135232. }
  135233. declare module BABYLON {
  135234. /** @hidden */
  135235. export var sharpenPixelShader: {
  135236. name: string;
  135237. shader: string;
  135238. };
  135239. }
  135240. declare module BABYLON {
  135241. /**
  135242. * The SharpenPostProcess applies a sharpen kernel to every pixel
  135243. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  135244. */
  135245. export class SharpenPostProcess extends PostProcess {
  135246. /**
  135247. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  135248. */
  135249. colorAmount: number;
  135250. /**
  135251. * How much sharpness should be applied (default: 0.3)
  135252. */
  135253. edgeAmount: number;
  135254. /**
  135255. * Creates a new instance ConvolutionPostProcess
  135256. * @param name The name of the effect.
  135257. * @param options The required width/height ratio to downsize to before computing the render pass.
  135258. * @param camera The camera to apply the render pass to.
  135259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  135260. * @param engine The engine which the post process will be applied. (default: current engine)
  135261. * @param reusable If the post process can be reused on the same frame. (default: false)
  135262. * @param textureType Type of textures used when performing the post process. (default: 0)
  135263. * @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)
  135264. */
  135265. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  135266. }
  135267. }
  135268. declare module BABYLON {
  135269. /**
  135270. * PostProcessRenderPipeline
  135271. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  135272. */
  135273. export class PostProcessRenderPipeline {
  135274. private engine;
  135275. private _renderEffects;
  135276. private _renderEffectsForIsolatedPass;
  135277. /**
  135278. * List of inspectable custom properties (used by the Inspector)
  135279. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  135280. */
  135281. inspectableCustomProperties: IInspectable[];
  135282. /**
  135283. * @hidden
  135284. */
  135285. protected _cameras: Camera[];
  135286. /** @hidden */
  135287. _name: string;
  135288. /**
  135289. * Gets pipeline name
  135290. */
  135291. get name(): string;
  135292. /** Gets the list of attached cameras */
  135293. get cameras(): Camera[];
  135294. /**
  135295. * Initializes a PostProcessRenderPipeline
  135296. * @param engine engine to add the pipeline to
  135297. * @param name name of the pipeline
  135298. */
  135299. constructor(engine: Engine, name: string);
  135300. /**
  135301. * Gets the class name
  135302. * @returns "PostProcessRenderPipeline"
  135303. */
  135304. getClassName(): string;
  135305. /**
  135306. * If all the render effects in the pipeline are supported
  135307. */
  135308. get isSupported(): boolean;
  135309. /**
  135310. * Adds an effect to the pipeline
  135311. * @param renderEffect the effect to add
  135312. */
  135313. addEffect(renderEffect: PostProcessRenderEffect): void;
  135314. /** @hidden */
  135315. _rebuild(): void;
  135316. /** @hidden */
  135317. _enableEffect(renderEffectName: string, cameras: Camera): void;
  135318. /** @hidden */
  135319. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  135320. /** @hidden */
  135321. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  135322. /** @hidden */
  135323. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  135324. /** @hidden */
  135325. _attachCameras(cameras: Camera, unique: boolean): void;
  135326. /** @hidden */
  135327. _attachCameras(cameras: Camera[], unique: boolean): void;
  135328. /** @hidden */
  135329. _detachCameras(cameras: Camera): void;
  135330. /** @hidden */
  135331. _detachCameras(cameras: Nullable<Camera[]>): void;
  135332. /** @hidden */
  135333. _update(): void;
  135334. /** @hidden */
  135335. _reset(): void;
  135336. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  135337. /**
  135338. * Disposes of the pipeline
  135339. */
  135340. dispose(): void;
  135341. }
  135342. }
  135343. declare module BABYLON {
  135344. /**
  135345. * PostProcessRenderPipelineManager class
  135346. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  135347. */
  135348. export class PostProcessRenderPipelineManager {
  135349. private _renderPipelines;
  135350. /**
  135351. * Initializes a PostProcessRenderPipelineManager
  135352. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  135353. */
  135354. constructor();
  135355. /**
  135356. * Gets the list of supported render pipelines
  135357. */
  135358. get supportedPipelines(): PostProcessRenderPipeline[];
  135359. /**
  135360. * Adds a pipeline to the manager
  135361. * @param renderPipeline The pipeline to add
  135362. */
  135363. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  135364. /**
  135365. * Attaches a camera to the pipeline
  135366. * @param renderPipelineName The name of the pipeline to attach to
  135367. * @param cameras the camera to attach
  135368. * @param unique if the camera can be attached multiple times to the pipeline
  135369. */
  135370. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  135371. /**
  135372. * Detaches a camera from the pipeline
  135373. * @param renderPipelineName The name of the pipeline to detach from
  135374. * @param cameras the camera to detach
  135375. */
  135376. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  135377. /**
  135378. * Enables an effect by name on a pipeline
  135379. * @param renderPipelineName the name of the pipeline to enable the effect in
  135380. * @param renderEffectName the name of the effect to enable
  135381. * @param cameras the cameras that the effect should be enabled on
  135382. */
  135383. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  135384. /**
  135385. * Disables an effect by name on a pipeline
  135386. * @param renderPipelineName the name of the pipeline to disable the effect in
  135387. * @param renderEffectName the name of the effect to disable
  135388. * @param cameras the cameras that the effect should be disabled on
  135389. */
  135390. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  135391. /**
  135392. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  135393. */
  135394. update(): void;
  135395. /** @hidden */
  135396. _rebuild(): void;
  135397. /**
  135398. * Disposes of the manager and pipelines
  135399. */
  135400. dispose(): void;
  135401. }
  135402. }
  135403. declare module BABYLON {
  135404. interface Scene {
  135405. /** @hidden (Backing field) */
  135406. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  135407. /**
  135408. * Gets the postprocess render pipeline manager
  135409. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  135410. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  135411. */
  135412. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  135413. }
  135414. /**
  135415. * Defines the Render Pipeline scene component responsible to rendering pipelines
  135416. */
  135417. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  135418. /**
  135419. * The component name helpfull to identify the component in the list of scene components.
  135420. */
  135421. readonly name: string;
  135422. /**
  135423. * The scene the component belongs to.
  135424. */
  135425. scene: Scene;
  135426. /**
  135427. * Creates a new instance of the component for the given scene
  135428. * @param scene Defines the scene to register the component in
  135429. */
  135430. constructor(scene: Scene);
  135431. /**
  135432. * Registers the component in a given scene
  135433. */
  135434. register(): void;
  135435. /**
  135436. * Rebuilds the elements related to this component in case of
  135437. * context lost for instance.
  135438. */
  135439. rebuild(): void;
  135440. /**
  135441. * Disposes the component and the associated ressources
  135442. */
  135443. dispose(): void;
  135444. private _gatherRenderTargets;
  135445. }
  135446. }
  135447. declare module BABYLON {
  135448. /**
  135449. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  135450. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  135451. */
  135452. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  135453. private _scene;
  135454. private _camerasToBeAttached;
  135455. /**
  135456. * ID of the sharpen post process,
  135457. */
  135458. private readonly SharpenPostProcessId;
  135459. /**
  135460. * @ignore
  135461. * ID of the image processing post process;
  135462. */
  135463. readonly ImageProcessingPostProcessId: string;
  135464. /**
  135465. * @ignore
  135466. * ID of the Fast Approximate Anti-Aliasing post process;
  135467. */
  135468. readonly FxaaPostProcessId: string;
  135469. /**
  135470. * ID of the chromatic aberration post process,
  135471. */
  135472. private readonly ChromaticAberrationPostProcessId;
  135473. /**
  135474. * ID of the grain post process
  135475. */
  135476. private readonly GrainPostProcessId;
  135477. /**
  135478. * Sharpen post process which will apply a sharpen convolution to enhance edges
  135479. */
  135480. sharpen: SharpenPostProcess;
  135481. private _sharpenEffect;
  135482. private bloom;
  135483. /**
  135484. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  135485. */
  135486. depthOfField: DepthOfFieldEffect;
  135487. /**
  135488. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  135489. */
  135490. fxaa: FxaaPostProcess;
  135491. /**
  135492. * Image post processing pass used to perform operations such as tone mapping or color grading.
  135493. */
  135494. imageProcessing: ImageProcessingPostProcess;
  135495. /**
  135496. * Chromatic aberration post process which will shift rgb colors in the image
  135497. */
  135498. chromaticAberration: ChromaticAberrationPostProcess;
  135499. private _chromaticAberrationEffect;
  135500. /**
  135501. * Grain post process which add noise to the image
  135502. */
  135503. grain: GrainPostProcess;
  135504. private _grainEffect;
  135505. /**
  135506. * Glow post process which adds a glow to emissive areas of the image
  135507. */
  135508. private _glowLayer;
  135509. /**
  135510. * Animations which can be used to tweak settings over a period of time
  135511. */
  135512. animations: Animation[];
  135513. private _imageProcessingConfigurationObserver;
  135514. private _sharpenEnabled;
  135515. private _bloomEnabled;
  135516. private _depthOfFieldEnabled;
  135517. private _depthOfFieldBlurLevel;
  135518. private _fxaaEnabled;
  135519. private _imageProcessingEnabled;
  135520. private _defaultPipelineTextureType;
  135521. private _bloomScale;
  135522. private _chromaticAberrationEnabled;
  135523. private _grainEnabled;
  135524. private _buildAllowed;
  135525. /**
  135526. * Gets active scene
  135527. */
  135528. get scene(): Scene;
  135529. /**
  135530. * Enable or disable the sharpen process from the pipeline
  135531. */
  135532. set sharpenEnabled(enabled: boolean);
  135533. get sharpenEnabled(): boolean;
  135534. private _resizeObserver;
  135535. private _hardwareScaleLevel;
  135536. private _bloomKernel;
  135537. /**
  135538. * Specifies the size of the bloom blur kernel, relative to the final output size
  135539. */
  135540. get bloomKernel(): number;
  135541. set bloomKernel(value: number);
  135542. /**
  135543. * Specifies the weight of the bloom in the final rendering
  135544. */
  135545. private _bloomWeight;
  135546. /**
  135547. * Specifies the luma threshold for the area that will be blurred by the bloom
  135548. */
  135549. private _bloomThreshold;
  135550. private _hdr;
  135551. /**
  135552. * The strength of the bloom.
  135553. */
  135554. set bloomWeight(value: number);
  135555. get bloomWeight(): number;
  135556. /**
  135557. * The strength of the bloom.
  135558. */
  135559. set bloomThreshold(value: number);
  135560. get bloomThreshold(): number;
  135561. /**
  135562. * The scale of the bloom, lower value will provide better performance.
  135563. */
  135564. set bloomScale(value: number);
  135565. get bloomScale(): number;
  135566. /**
  135567. * Enable or disable the bloom from the pipeline
  135568. */
  135569. set bloomEnabled(enabled: boolean);
  135570. get bloomEnabled(): boolean;
  135571. private _rebuildBloom;
  135572. /**
  135573. * If the depth of field is enabled.
  135574. */
  135575. get depthOfFieldEnabled(): boolean;
  135576. set depthOfFieldEnabled(enabled: boolean);
  135577. /**
  135578. * Blur level of the depth of field effect. (Higher blur will effect performance)
  135579. */
  135580. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  135581. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  135582. /**
  135583. * If the anti aliasing is enabled.
  135584. */
  135585. set fxaaEnabled(enabled: boolean);
  135586. get fxaaEnabled(): boolean;
  135587. private _samples;
  135588. /**
  135589. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  135590. */
  135591. set samples(sampleCount: number);
  135592. get samples(): number;
  135593. /**
  135594. * If image processing is enabled.
  135595. */
  135596. set imageProcessingEnabled(enabled: boolean);
  135597. get imageProcessingEnabled(): boolean;
  135598. /**
  135599. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  135600. */
  135601. set glowLayerEnabled(enabled: boolean);
  135602. get glowLayerEnabled(): boolean;
  135603. /**
  135604. * Gets the glow layer (or null if not defined)
  135605. */
  135606. get glowLayer(): Nullable<GlowLayer>;
  135607. /**
  135608. * Enable or disable the chromaticAberration process from the pipeline
  135609. */
  135610. set chromaticAberrationEnabled(enabled: boolean);
  135611. get chromaticAberrationEnabled(): boolean;
  135612. /**
  135613. * Enable or disable the grain process from the pipeline
  135614. */
  135615. set grainEnabled(enabled: boolean);
  135616. get grainEnabled(): boolean;
  135617. /**
  135618. * @constructor
  135619. * @param name - The rendering pipeline name (default: "")
  135620. * @param hdr - If high dynamic range textures should be used (default: true)
  135621. * @param scene - The scene linked to this pipeline (default: the last created scene)
  135622. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  135623. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  135624. */
  135625. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  135626. /**
  135627. * Get the class name
  135628. * @returns "DefaultRenderingPipeline"
  135629. */
  135630. getClassName(): string;
  135631. /**
  135632. * Force the compilation of the entire pipeline.
  135633. */
  135634. prepare(): void;
  135635. private _hasCleared;
  135636. private _prevPostProcess;
  135637. private _prevPrevPostProcess;
  135638. private _setAutoClearAndTextureSharing;
  135639. private _depthOfFieldSceneObserver;
  135640. private _buildPipeline;
  135641. private _disposePostProcesses;
  135642. /**
  135643. * Adds a camera to the pipeline
  135644. * @param camera the camera to be added
  135645. */
  135646. addCamera(camera: Camera): void;
  135647. /**
  135648. * Removes a camera from the pipeline
  135649. * @param camera the camera to remove
  135650. */
  135651. removeCamera(camera: Camera): void;
  135652. /**
  135653. * Dispose of the pipeline and stop all post processes
  135654. */
  135655. dispose(): void;
  135656. /**
  135657. * Serialize the rendering pipeline (Used when exporting)
  135658. * @returns the serialized object
  135659. */
  135660. serialize(): any;
  135661. /**
  135662. * Parse the serialized pipeline
  135663. * @param source Source pipeline.
  135664. * @param scene The scene to load the pipeline to.
  135665. * @param rootUrl The URL of the serialized pipeline.
  135666. * @returns An instantiated pipeline from the serialized object.
  135667. */
  135668. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  135669. }
  135670. }
  135671. declare module BABYLON {
  135672. /** @hidden */
  135673. export var lensHighlightsPixelShader: {
  135674. name: string;
  135675. shader: string;
  135676. };
  135677. }
  135678. declare module BABYLON {
  135679. /** @hidden */
  135680. export var depthOfFieldPixelShader: {
  135681. name: string;
  135682. shader: string;
  135683. };
  135684. }
  135685. declare module BABYLON {
  135686. /**
  135687. * BABYLON.JS Chromatic Aberration GLSL Shader
  135688. * Author: Olivier Guyot
  135689. * Separates very slightly R, G and B colors on the edges of the screen
  135690. * Inspired by Francois Tarlier & Martins Upitis
  135691. */
  135692. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  135693. /**
  135694. * @ignore
  135695. * The chromatic aberration PostProcess id in the pipeline
  135696. */
  135697. LensChromaticAberrationEffect: string;
  135698. /**
  135699. * @ignore
  135700. * The highlights enhancing PostProcess id in the pipeline
  135701. */
  135702. HighlightsEnhancingEffect: string;
  135703. /**
  135704. * @ignore
  135705. * The depth-of-field PostProcess id in the pipeline
  135706. */
  135707. LensDepthOfFieldEffect: string;
  135708. private _scene;
  135709. private _depthTexture;
  135710. private _grainTexture;
  135711. private _chromaticAberrationPostProcess;
  135712. private _highlightsPostProcess;
  135713. private _depthOfFieldPostProcess;
  135714. private _edgeBlur;
  135715. private _grainAmount;
  135716. private _chromaticAberration;
  135717. private _distortion;
  135718. private _highlightsGain;
  135719. private _highlightsThreshold;
  135720. private _dofDistance;
  135721. private _dofAperture;
  135722. private _dofDarken;
  135723. private _dofPentagon;
  135724. private _blurNoise;
  135725. /**
  135726. * @constructor
  135727. *
  135728. * Effect parameters are as follow:
  135729. * {
  135730. * chromatic_aberration: number; // from 0 to x (1 for realism)
  135731. * edge_blur: number; // from 0 to x (1 for realism)
  135732. * distortion: number; // from 0 to x (1 for realism)
  135733. * grain_amount: number; // from 0 to 1
  135734. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  135735. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  135736. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  135737. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  135738. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  135739. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  135740. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  135741. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  135742. * }
  135743. * Note: if an effect parameter is unset, effect is disabled
  135744. *
  135745. * @param name The rendering pipeline name
  135746. * @param parameters - An object containing all parameters (see above)
  135747. * @param scene The scene linked to this pipeline
  135748. * @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)
  135749. * @param cameras The array of cameras that the rendering pipeline will be attached to
  135750. */
  135751. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  135752. /**
  135753. * Get the class name
  135754. * @returns "LensRenderingPipeline"
  135755. */
  135756. getClassName(): string;
  135757. /**
  135758. * Gets associated scene
  135759. */
  135760. get scene(): Scene;
  135761. /**
  135762. * Gets or sets the edge blur
  135763. */
  135764. get edgeBlur(): number;
  135765. set edgeBlur(value: number);
  135766. /**
  135767. * Gets or sets the grain amount
  135768. */
  135769. get grainAmount(): number;
  135770. set grainAmount(value: number);
  135771. /**
  135772. * Gets or sets the chromatic aberration amount
  135773. */
  135774. get chromaticAberration(): number;
  135775. set chromaticAberration(value: number);
  135776. /**
  135777. * Gets or sets the depth of field aperture
  135778. */
  135779. get dofAperture(): number;
  135780. set dofAperture(value: number);
  135781. /**
  135782. * Gets or sets the edge distortion
  135783. */
  135784. get edgeDistortion(): number;
  135785. set edgeDistortion(value: number);
  135786. /**
  135787. * Gets or sets the depth of field distortion
  135788. */
  135789. get dofDistortion(): number;
  135790. set dofDistortion(value: number);
  135791. /**
  135792. * Gets or sets the darken out of focus amount
  135793. */
  135794. get darkenOutOfFocus(): number;
  135795. set darkenOutOfFocus(value: number);
  135796. /**
  135797. * Gets or sets a boolean indicating if blur noise is enabled
  135798. */
  135799. get blurNoise(): boolean;
  135800. set blurNoise(value: boolean);
  135801. /**
  135802. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  135803. */
  135804. get pentagonBokeh(): boolean;
  135805. set pentagonBokeh(value: boolean);
  135806. /**
  135807. * Gets or sets the highlight grain amount
  135808. */
  135809. get highlightsGain(): number;
  135810. set highlightsGain(value: number);
  135811. /**
  135812. * Gets or sets the highlight threshold
  135813. */
  135814. get highlightsThreshold(): number;
  135815. set highlightsThreshold(value: number);
  135816. /**
  135817. * Sets the amount of blur at the edges
  135818. * @param amount blur amount
  135819. */
  135820. setEdgeBlur(amount: number): void;
  135821. /**
  135822. * Sets edge blur to 0
  135823. */
  135824. disableEdgeBlur(): void;
  135825. /**
  135826. * Sets the amout of grain
  135827. * @param amount Amount of grain
  135828. */
  135829. setGrainAmount(amount: number): void;
  135830. /**
  135831. * Set grain amount to 0
  135832. */
  135833. disableGrain(): void;
  135834. /**
  135835. * Sets the chromatic aberration amount
  135836. * @param amount amount of chromatic aberration
  135837. */
  135838. setChromaticAberration(amount: number): void;
  135839. /**
  135840. * Sets chromatic aberration amount to 0
  135841. */
  135842. disableChromaticAberration(): void;
  135843. /**
  135844. * Sets the EdgeDistortion amount
  135845. * @param amount amount of EdgeDistortion
  135846. */
  135847. setEdgeDistortion(amount: number): void;
  135848. /**
  135849. * Sets edge distortion to 0
  135850. */
  135851. disableEdgeDistortion(): void;
  135852. /**
  135853. * Sets the FocusDistance amount
  135854. * @param amount amount of FocusDistance
  135855. */
  135856. setFocusDistance(amount: number): void;
  135857. /**
  135858. * Disables depth of field
  135859. */
  135860. disableDepthOfField(): void;
  135861. /**
  135862. * Sets the Aperture amount
  135863. * @param amount amount of Aperture
  135864. */
  135865. setAperture(amount: number): void;
  135866. /**
  135867. * Sets the DarkenOutOfFocus amount
  135868. * @param amount amount of DarkenOutOfFocus
  135869. */
  135870. setDarkenOutOfFocus(amount: number): void;
  135871. private _pentagonBokehIsEnabled;
  135872. /**
  135873. * Creates a pentagon bokeh effect
  135874. */
  135875. enablePentagonBokeh(): void;
  135876. /**
  135877. * Disables the pentagon bokeh effect
  135878. */
  135879. disablePentagonBokeh(): void;
  135880. /**
  135881. * Enables noise blur
  135882. */
  135883. enableNoiseBlur(): void;
  135884. /**
  135885. * Disables noise blur
  135886. */
  135887. disableNoiseBlur(): void;
  135888. /**
  135889. * Sets the HighlightsGain amount
  135890. * @param amount amount of HighlightsGain
  135891. */
  135892. setHighlightsGain(amount: number): void;
  135893. /**
  135894. * Sets the HighlightsThreshold amount
  135895. * @param amount amount of HighlightsThreshold
  135896. */
  135897. setHighlightsThreshold(amount: number): void;
  135898. /**
  135899. * Disables highlights
  135900. */
  135901. disableHighlights(): void;
  135902. /**
  135903. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  135904. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  135905. */
  135906. dispose(disableDepthRender?: boolean): void;
  135907. private _createChromaticAberrationPostProcess;
  135908. private _createHighlightsPostProcess;
  135909. private _createDepthOfFieldPostProcess;
  135910. private _createGrainTexture;
  135911. }
  135912. }
  135913. declare module BABYLON {
  135914. /** @hidden */
  135915. export var ssao2PixelShader: {
  135916. name: string;
  135917. shader: string;
  135918. };
  135919. }
  135920. declare module BABYLON {
  135921. /** @hidden */
  135922. export var ssaoCombinePixelShader: {
  135923. name: string;
  135924. shader: string;
  135925. };
  135926. }
  135927. declare module BABYLON {
  135928. /**
  135929. * Render pipeline to produce ssao effect
  135930. */
  135931. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  135932. /**
  135933. * @ignore
  135934. * The PassPostProcess id in the pipeline that contains the original scene color
  135935. */
  135936. SSAOOriginalSceneColorEffect: string;
  135937. /**
  135938. * @ignore
  135939. * The SSAO PostProcess id in the pipeline
  135940. */
  135941. SSAORenderEffect: string;
  135942. /**
  135943. * @ignore
  135944. * The horizontal blur PostProcess id in the pipeline
  135945. */
  135946. SSAOBlurHRenderEffect: string;
  135947. /**
  135948. * @ignore
  135949. * The vertical blur PostProcess id in the pipeline
  135950. */
  135951. SSAOBlurVRenderEffect: string;
  135952. /**
  135953. * @ignore
  135954. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  135955. */
  135956. SSAOCombineRenderEffect: string;
  135957. /**
  135958. * The output strength of the SSAO post-process. Default value is 1.0.
  135959. */
  135960. totalStrength: number;
  135961. /**
  135962. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  135963. */
  135964. maxZ: number;
  135965. /**
  135966. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  135967. */
  135968. minZAspect: number;
  135969. private _samples;
  135970. /**
  135971. * Number of samples used for the SSAO calculations. Default value is 8
  135972. */
  135973. set samples(n: number);
  135974. get samples(): number;
  135975. private _textureSamples;
  135976. /**
  135977. * Number of samples to use for antialiasing
  135978. */
  135979. set textureSamples(n: number);
  135980. get textureSamples(): number;
  135981. /**
  135982. * Ratio object used for SSAO ratio and blur ratio
  135983. */
  135984. private _ratio;
  135985. /**
  135986. * Dynamically generated sphere sampler.
  135987. */
  135988. private _sampleSphere;
  135989. /**
  135990. * Blur filter offsets
  135991. */
  135992. private _samplerOffsets;
  135993. private _expensiveBlur;
  135994. /**
  135995. * If bilateral blur should be used
  135996. */
  135997. set expensiveBlur(b: boolean);
  135998. get expensiveBlur(): boolean;
  135999. /**
  136000. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  136001. */
  136002. radius: number;
  136003. /**
  136004. * The base color of the SSAO post-process
  136005. * The final result is "base + ssao" between [0, 1]
  136006. */
  136007. base: number;
  136008. /**
  136009. * Support test.
  136010. */
  136011. static get IsSupported(): boolean;
  136012. private _scene;
  136013. private _depthTexture;
  136014. private _normalTexture;
  136015. private _randomTexture;
  136016. private _originalColorPostProcess;
  136017. private _ssaoPostProcess;
  136018. private _blurHPostProcess;
  136019. private _blurVPostProcess;
  136020. private _ssaoCombinePostProcess;
  136021. /**
  136022. * Gets active scene
  136023. */
  136024. get scene(): Scene;
  136025. /**
  136026. * @constructor
  136027. * @param name The rendering pipeline name
  136028. * @param scene The scene linked to this pipeline
  136029. * @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 }
  136030. * @param cameras The array of cameras that the rendering pipeline will be attached to
  136031. */
  136032. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  136033. /**
  136034. * Get the class name
  136035. * @returns "SSAO2RenderingPipeline"
  136036. */
  136037. getClassName(): string;
  136038. /**
  136039. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  136040. */
  136041. dispose(disableGeometryBufferRenderer?: boolean): void;
  136042. private _createBlurPostProcess;
  136043. /** @hidden */
  136044. _rebuild(): void;
  136045. private _bits;
  136046. private _radicalInverse_VdC;
  136047. private _hammersley;
  136048. private _hemisphereSample_uniform;
  136049. private _generateHemisphere;
  136050. private _createSSAOPostProcess;
  136051. private _createSSAOCombinePostProcess;
  136052. private _createRandomTexture;
  136053. /**
  136054. * Serialize the rendering pipeline (Used when exporting)
  136055. * @returns the serialized object
  136056. */
  136057. serialize(): any;
  136058. /**
  136059. * Parse the serialized pipeline
  136060. * @param source Source pipeline.
  136061. * @param scene The scene to load the pipeline to.
  136062. * @param rootUrl The URL of the serialized pipeline.
  136063. * @returns An instantiated pipeline from the serialized object.
  136064. */
  136065. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  136066. }
  136067. }
  136068. declare module BABYLON {
  136069. /** @hidden */
  136070. export var ssaoPixelShader: {
  136071. name: string;
  136072. shader: string;
  136073. };
  136074. }
  136075. declare module BABYLON {
  136076. /**
  136077. * Render pipeline to produce ssao effect
  136078. */
  136079. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  136080. /**
  136081. * @ignore
  136082. * The PassPostProcess id in the pipeline that contains the original scene color
  136083. */
  136084. SSAOOriginalSceneColorEffect: string;
  136085. /**
  136086. * @ignore
  136087. * The SSAO PostProcess id in the pipeline
  136088. */
  136089. SSAORenderEffect: string;
  136090. /**
  136091. * @ignore
  136092. * The horizontal blur PostProcess id in the pipeline
  136093. */
  136094. SSAOBlurHRenderEffect: string;
  136095. /**
  136096. * @ignore
  136097. * The vertical blur PostProcess id in the pipeline
  136098. */
  136099. SSAOBlurVRenderEffect: string;
  136100. /**
  136101. * @ignore
  136102. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  136103. */
  136104. SSAOCombineRenderEffect: string;
  136105. /**
  136106. * The output strength of the SSAO post-process. Default value is 1.0.
  136107. */
  136108. totalStrength: number;
  136109. /**
  136110. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  136111. */
  136112. radius: number;
  136113. /**
  136114. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  136115. * Must not be equal to fallOff and superior to fallOff.
  136116. * Default value is 0.0075
  136117. */
  136118. area: number;
  136119. /**
  136120. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  136121. * Must not be equal to area and inferior to area.
  136122. * Default value is 0.000001
  136123. */
  136124. fallOff: number;
  136125. /**
  136126. * The base color of the SSAO post-process
  136127. * The final result is "base + ssao" between [0, 1]
  136128. */
  136129. base: number;
  136130. private _scene;
  136131. private _depthTexture;
  136132. private _randomTexture;
  136133. private _originalColorPostProcess;
  136134. private _ssaoPostProcess;
  136135. private _blurHPostProcess;
  136136. private _blurVPostProcess;
  136137. private _ssaoCombinePostProcess;
  136138. private _firstUpdate;
  136139. /**
  136140. * Gets active scene
  136141. */
  136142. get scene(): Scene;
  136143. /**
  136144. * @constructor
  136145. * @param name - The rendering pipeline name
  136146. * @param scene - The scene linked to this pipeline
  136147. * @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 }
  136148. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  136149. */
  136150. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  136151. /**
  136152. * Get the class name
  136153. * @returns "SSAORenderingPipeline"
  136154. */
  136155. getClassName(): string;
  136156. /**
  136157. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  136158. */
  136159. dispose(disableDepthRender?: boolean): void;
  136160. private _createBlurPostProcess;
  136161. /** @hidden */
  136162. _rebuild(): void;
  136163. private _createSSAOPostProcess;
  136164. private _createSSAOCombinePostProcess;
  136165. private _createRandomTexture;
  136166. }
  136167. }
  136168. declare module BABYLON {
  136169. /** @hidden */
  136170. export var standardPixelShader: {
  136171. name: string;
  136172. shader: string;
  136173. };
  136174. }
  136175. declare module BABYLON {
  136176. /**
  136177. * Standard rendering pipeline
  136178. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  136179. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  136180. */
  136181. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  136182. /**
  136183. * Public members
  136184. */
  136185. /**
  136186. * Post-process which contains the original scene color before the pipeline applies all the effects
  136187. */
  136188. originalPostProcess: Nullable<PostProcess>;
  136189. /**
  136190. * Post-process used to down scale an image x4
  136191. */
  136192. downSampleX4PostProcess: Nullable<PostProcess>;
  136193. /**
  136194. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  136195. */
  136196. brightPassPostProcess: Nullable<PostProcess>;
  136197. /**
  136198. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  136199. */
  136200. blurHPostProcesses: PostProcess[];
  136201. /**
  136202. * Post-process array storing all the vertical blur post-processes used by the pipeline
  136203. */
  136204. blurVPostProcesses: PostProcess[];
  136205. /**
  136206. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  136207. */
  136208. textureAdderPostProcess: Nullable<PostProcess>;
  136209. /**
  136210. * Post-process used to create volumetric lighting effect
  136211. */
  136212. volumetricLightPostProcess: Nullable<PostProcess>;
  136213. /**
  136214. * Post-process used to smooth the previous volumetric light post-process on the X axis
  136215. */
  136216. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  136217. /**
  136218. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  136219. */
  136220. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  136221. /**
  136222. * Post-process used to merge the volumetric light effect and the real scene color
  136223. */
  136224. volumetricLightMergePostProces: Nullable<PostProcess>;
  136225. /**
  136226. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  136227. */
  136228. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  136229. /**
  136230. * Base post-process used to calculate the average luminance of the final image for HDR
  136231. */
  136232. luminancePostProcess: Nullable<PostProcess>;
  136233. /**
  136234. * Post-processes used to create down sample post-processes in order to get
  136235. * the average luminance of the final image for HDR
  136236. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  136237. */
  136238. luminanceDownSamplePostProcesses: PostProcess[];
  136239. /**
  136240. * Post-process used to create a HDR effect (light adaptation)
  136241. */
  136242. hdrPostProcess: Nullable<PostProcess>;
  136243. /**
  136244. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  136245. */
  136246. textureAdderFinalPostProcess: Nullable<PostProcess>;
  136247. /**
  136248. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  136249. */
  136250. lensFlareFinalPostProcess: Nullable<PostProcess>;
  136251. /**
  136252. * Post-process used to merge the final HDR post-process and the real scene color
  136253. */
  136254. hdrFinalPostProcess: Nullable<PostProcess>;
  136255. /**
  136256. * Post-process used to create a lens flare effect
  136257. */
  136258. lensFlarePostProcess: Nullable<PostProcess>;
  136259. /**
  136260. * Post-process that merges the result of the lens flare post-process and the real scene color
  136261. */
  136262. lensFlareComposePostProcess: Nullable<PostProcess>;
  136263. /**
  136264. * Post-process used to create a motion blur effect
  136265. */
  136266. motionBlurPostProcess: Nullable<PostProcess>;
  136267. /**
  136268. * Post-process used to create a depth of field effect
  136269. */
  136270. depthOfFieldPostProcess: Nullable<PostProcess>;
  136271. /**
  136272. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  136273. */
  136274. fxaaPostProcess: Nullable<FxaaPostProcess>;
  136275. /**
  136276. * Represents the brightness threshold in order to configure the illuminated surfaces
  136277. */
  136278. brightThreshold: number;
  136279. /**
  136280. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  136281. */
  136282. blurWidth: number;
  136283. /**
  136284. * Sets if the blur for highlighted surfaces must be only horizontal
  136285. */
  136286. horizontalBlur: boolean;
  136287. /**
  136288. * Gets the overall exposure used by the pipeline
  136289. */
  136290. get exposure(): number;
  136291. /**
  136292. * Sets the overall exposure used by the pipeline
  136293. */
  136294. set exposure(value: number);
  136295. /**
  136296. * Texture used typically to simulate "dirty" on camera lens
  136297. */
  136298. lensTexture: Nullable<Texture>;
  136299. /**
  136300. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  136301. */
  136302. volumetricLightCoefficient: number;
  136303. /**
  136304. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  136305. */
  136306. volumetricLightPower: number;
  136307. /**
  136308. * Used the set the blur intensity to smooth the volumetric lights
  136309. */
  136310. volumetricLightBlurScale: number;
  136311. /**
  136312. * Light (spot or directional) used to generate the volumetric lights rays
  136313. * The source light must have a shadow generate so the pipeline can get its
  136314. * depth map
  136315. */
  136316. sourceLight: Nullable<SpotLight | DirectionalLight>;
  136317. /**
  136318. * For eye adaptation, represents the minimum luminance the eye can see
  136319. */
  136320. hdrMinimumLuminance: number;
  136321. /**
  136322. * For eye adaptation, represents the decrease luminance speed
  136323. */
  136324. hdrDecreaseRate: number;
  136325. /**
  136326. * For eye adaptation, represents the increase luminance speed
  136327. */
  136328. hdrIncreaseRate: number;
  136329. /**
  136330. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  136331. */
  136332. get hdrAutoExposure(): boolean;
  136333. /**
  136334. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  136335. */
  136336. set hdrAutoExposure(value: boolean);
  136337. /**
  136338. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  136339. */
  136340. lensColorTexture: Nullable<Texture>;
  136341. /**
  136342. * The overall strengh for the lens flare effect
  136343. */
  136344. lensFlareStrength: number;
  136345. /**
  136346. * Dispersion coefficient for lens flare ghosts
  136347. */
  136348. lensFlareGhostDispersal: number;
  136349. /**
  136350. * Main lens flare halo width
  136351. */
  136352. lensFlareHaloWidth: number;
  136353. /**
  136354. * Based on the lens distortion effect, defines how much the lens flare result
  136355. * is distorted
  136356. */
  136357. lensFlareDistortionStrength: number;
  136358. /**
  136359. * Configures the blur intensity used for for lens flare (halo)
  136360. */
  136361. lensFlareBlurWidth: number;
  136362. /**
  136363. * Lens star texture must be used to simulate rays on the flares and is available
  136364. * in the documentation
  136365. */
  136366. lensStarTexture: Nullable<Texture>;
  136367. /**
  136368. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  136369. * flare effect by taking account of the dirt texture
  136370. */
  136371. lensFlareDirtTexture: Nullable<Texture>;
  136372. /**
  136373. * Represents the focal length for the depth of field effect
  136374. */
  136375. depthOfFieldDistance: number;
  136376. /**
  136377. * Represents the blur intensity for the blurred part of the depth of field effect
  136378. */
  136379. depthOfFieldBlurWidth: number;
  136380. /**
  136381. * Gets how much the image is blurred by the movement while using the motion blur post-process
  136382. */
  136383. get motionStrength(): number;
  136384. /**
  136385. * Sets how much the image is blurred by the movement while using the motion blur post-process
  136386. */
  136387. set motionStrength(strength: number);
  136388. /**
  136389. * Gets wether or not the motion blur post-process is object based or screen based.
  136390. */
  136391. get objectBasedMotionBlur(): boolean;
  136392. /**
  136393. * Sets wether or not the motion blur post-process should be object based or screen based
  136394. */
  136395. set objectBasedMotionBlur(value: boolean);
  136396. /**
  136397. * List of animations for the pipeline (IAnimatable implementation)
  136398. */
  136399. animations: Animation[];
  136400. /**
  136401. * Private members
  136402. */
  136403. private _scene;
  136404. private _currentDepthOfFieldSource;
  136405. private _basePostProcess;
  136406. private _fixedExposure;
  136407. private _currentExposure;
  136408. private _hdrAutoExposure;
  136409. private _hdrCurrentLuminance;
  136410. private _motionStrength;
  136411. private _isObjectBasedMotionBlur;
  136412. private _floatTextureType;
  136413. private _camerasToBeAttached;
  136414. private _ratio;
  136415. private _bloomEnabled;
  136416. private _depthOfFieldEnabled;
  136417. private _vlsEnabled;
  136418. private _lensFlareEnabled;
  136419. private _hdrEnabled;
  136420. private _motionBlurEnabled;
  136421. private _fxaaEnabled;
  136422. private _motionBlurSamples;
  136423. private _volumetricLightStepsCount;
  136424. private _samples;
  136425. /**
  136426. * @ignore
  136427. * Specifies if the bloom pipeline is enabled
  136428. */
  136429. get BloomEnabled(): boolean;
  136430. set BloomEnabled(enabled: boolean);
  136431. /**
  136432. * @ignore
  136433. * Specifies if the depth of field pipeline is enabed
  136434. */
  136435. get DepthOfFieldEnabled(): boolean;
  136436. set DepthOfFieldEnabled(enabled: boolean);
  136437. /**
  136438. * @ignore
  136439. * Specifies if the lens flare pipeline is enabed
  136440. */
  136441. get LensFlareEnabled(): boolean;
  136442. set LensFlareEnabled(enabled: boolean);
  136443. /**
  136444. * @ignore
  136445. * Specifies if the HDR pipeline is enabled
  136446. */
  136447. get HDREnabled(): boolean;
  136448. set HDREnabled(enabled: boolean);
  136449. /**
  136450. * @ignore
  136451. * Specifies if the volumetric lights scattering effect is enabled
  136452. */
  136453. get VLSEnabled(): boolean;
  136454. set VLSEnabled(enabled: boolean);
  136455. /**
  136456. * @ignore
  136457. * Specifies if the motion blur effect is enabled
  136458. */
  136459. get MotionBlurEnabled(): boolean;
  136460. set MotionBlurEnabled(enabled: boolean);
  136461. /**
  136462. * Specifies if anti-aliasing is enabled
  136463. */
  136464. get fxaaEnabled(): boolean;
  136465. set fxaaEnabled(enabled: boolean);
  136466. /**
  136467. * Specifies the number of steps used to calculate the volumetric lights
  136468. * Typically in interval [50, 200]
  136469. */
  136470. get volumetricLightStepsCount(): number;
  136471. set volumetricLightStepsCount(count: number);
  136472. /**
  136473. * Specifies the number of samples used for the motion blur effect
  136474. * Typically in interval [16, 64]
  136475. */
  136476. get motionBlurSamples(): number;
  136477. set motionBlurSamples(samples: number);
  136478. /**
  136479. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  136480. */
  136481. get samples(): number;
  136482. set samples(sampleCount: number);
  136483. /**
  136484. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  136485. * @constructor
  136486. * @param name The rendering pipeline name
  136487. * @param scene The scene linked to this pipeline
  136488. * @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)
  136489. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  136490. * @param cameras The array of cameras that the rendering pipeline will be attached to
  136491. */
  136492. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  136493. private _buildPipeline;
  136494. private _createDownSampleX4PostProcess;
  136495. private _createBrightPassPostProcess;
  136496. private _createBlurPostProcesses;
  136497. private _createTextureAdderPostProcess;
  136498. private _createVolumetricLightPostProcess;
  136499. private _createLuminancePostProcesses;
  136500. private _createHdrPostProcess;
  136501. private _createLensFlarePostProcess;
  136502. private _createDepthOfFieldPostProcess;
  136503. private _createMotionBlurPostProcess;
  136504. private _getDepthTexture;
  136505. private _disposePostProcesses;
  136506. /**
  136507. * Dispose of the pipeline and stop all post processes
  136508. */
  136509. dispose(): void;
  136510. /**
  136511. * Serialize the rendering pipeline (Used when exporting)
  136512. * @returns the serialized object
  136513. */
  136514. serialize(): any;
  136515. /**
  136516. * Parse the serialized pipeline
  136517. * @param source Source pipeline.
  136518. * @param scene The scene to load the pipeline to.
  136519. * @param rootUrl The URL of the serialized pipeline.
  136520. * @returns An instantiated pipeline from the serialized object.
  136521. */
  136522. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  136523. /**
  136524. * Luminance steps
  136525. */
  136526. static LuminanceSteps: number;
  136527. }
  136528. }
  136529. declare module BABYLON {
  136530. /** @hidden */
  136531. export var tonemapPixelShader: {
  136532. name: string;
  136533. shader: string;
  136534. };
  136535. }
  136536. declare module BABYLON {
  136537. /** Defines operator used for tonemapping */
  136538. export enum TonemappingOperator {
  136539. /** Hable */
  136540. Hable = 0,
  136541. /** Reinhard */
  136542. Reinhard = 1,
  136543. /** HejiDawson */
  136544. HejiDawson = 2,
  136545. /** Photographic */
  136546. Photographic = 3
  136547. }
  136548. /**
  136549. * Defines a post process to apply tone mapping
  136550. */
  136551. export class TonemapPostProcess extends PostProcess {
  136552. private _operator;
  136553. /** Defines the required exposure adjustement */
  136554. exposureAdjustment: number;
  136555. /**
  136556. * Creates a new TonemapPostProcess
  136557. * @param name defines the name of the postprocess
  136558. * @param _operator defines the operator to use
  136559. * @param exposureAdjustment defines the required exposure adjustement
  136560. * @param camera defines the camera to use (can be null)
  136561. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  136562. * @param engine defines the hosting engine (can be ignore if camera is set)
  136563. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  136564. */
  136565. constructor(name: string, _operator: TonemappingOperator,
  136566. /** Defines the required exposure adjustement */
  136567. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  136568. }
  136569. }
  136570. declare module BABYLON {
  136571. /** @hidden */
  136572. export var depthVertexShader: {
  136573. name: string;
  136574. shader: string;
  136575. };
  136576. }
  136577. declare module BABYLON {
  136578. /** @hidden */
  136579. export var volumetricLightScatteringPixelShader: {
  136580. name: string;
  136581. shader: string;
  136582. };
  136583. }
  136584. declare module BABYLON {
  136585. /** @hidden */
  136586. export var volumetricLightScatteringPassVertexShader: {
  136587. name: string;
  136588. shader: string;
  136589. };
  136590. }
  136591. declare module BABYLON {
  136592. /** @hidden */
  136593. export var volumetricLightScatteringPassPixelShader: {
  136594. name: string;
  136595. shader: string;
  136596. };
  136597. }
  136598. declare module BABYLON {
  136599. /**
  136600. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  136601. */
  136602. export class VolumetricLightScatteringPostProcess extends PostProcess {
  136603. private _volumetricLightScatteringPass;
  136604. private _volumetricLightScatteringRTT;
  136605. private _viewPort;
  136606. private _screenCoordinates;
  136607. private _cachedDefines;
  136608. /**
  136609. * If not undefined, the mesh position is computed from the attached node position
  136610. */
  136611. attachedNode: {
  136612. position: Vector3;
  136613. };
  136614. /**
  136615. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  136616. */
  136617. customMeshPosition: Vector3;
  136618. /**
  136619. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  136620. */
  136621. useCustomMeshPosition: boolean;
  136622. /**
  136623. * If the post-process should inverse the light scattering direction
  136624. */
  136625. invert: boolean;
  136626. /**
  136627. * The internal mesh used by the post-process
  136628. */
  136629. mesh: Mesh;
  136630. /**
  136631. * @hidden
  136632. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  136633. */
  136634. get useDiffuseColor(): boolean;
  136635. set useDiffuseColor(useDiffuseColor: boolean);
  136636. /**
  136637. * Array containing the excluded meshes not rendered in the internal pass
  136638. */
  136639. excludedMeshes: AbstractMesh[];
  136640. /**
  136641. * Controls the overall intensity of the post-process
  136642. */
  136643. exposure: number;
  136644. /**
  136645. * Dissipates each sample's contribution in range [0, 1]
  136646. */
  136647. decay: number;
  136648. /**
  136649. * Controls the overall intensity of each sample
  136650. */
  136651. weight: number;
  136652. /**
  136653. * Controls the density of each sample
  136654. */
  136655. density: number;
  136656. /**
  136657. * @constructor
  136658. * @param name The post-process name
  136659. * @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)
  136660. * @param camera The camera that the post-process will be attached to
  136661. * @param mesh The mesh used to create the light scattering
  136662. * @param samples The post-process quality, default 100
  136663. * @param samplingModeThe post-process filtering mode
  136664. * @param engine The babylon engine
  136665. * @param reusable If the post-process is reusable
  136666. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  136667. */
  136668. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  136669. /**
  136670. * Returns the string "VolumetricLightScatteringPostProcess"
  136671. * @returns "VolumetricLightScatteringPostProcess"
  136672. */
  136673. getClassName(): string;
  136674. private _isReady;
  136675. /**
  136676. * Sets the new light position for light scattering effect
  136677. * @param position The new custom light position
  136678. */
  136679. setCustomMeshPosition(position: Vector3): void;
  136680. /**
  136681. * Returns the light position for light scattering effect
  136682. * @return Vector3 The custom light position
  136683. */
  136684. getCustomMeshPosition(): Vector3;
  136685. /**
  136686. * Disposes the internal assets and detaches the post-process from the camera
  136687. */
  136688. dispose(camera: Camera): void;
  136689. /**
  136690. * Returns the render target texture used by the post-process
  136691. * @return the render target texture used by the post-process
  136692. */
  136693. getPass(): RenderTargetTexture;
  136694. private _meshExcluded;
  136695. private _createPass;
  136696. private _updateMeshScreenCoordinates;
  136697. /**
  136698. * Creates a default mesh for the Volumeric Light Scattering post-process
  136699. * @param name The mesh name
  136700. * @param scene The scene where to create the mesh
  136701. * @return the default mesh
  136702. */
  136703. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  136704. }
  136705. }
  136706. declare module BABYLON {
  136707. interface Scene {
  136708. /** @hidden (Backing field) */
  136709. _boundingBoxRenderer: BoundingBoxRenderer;
  136710. /** @hidden (Backing field) */
  136711. _forceShowBoundingBoxes: boolean;
  136712. /**
  136713. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  136714. */
  136715. forceShowBoundingBoxes: boolean;
  136716. /**
  136717. * Gets the bounding box renderer associated with the scene
  136718. * @returns a BoundingBoxRenderer
  136719. */
  136720. getBoundingBoxRenderer(): BoundingBoxRenderer;
  136721. }
  136722. interface AbstractMesh {
  136723. /** @hidden (Backing field) */
  136724. _showBoundingBox: boolean;
  136725. /**
  136726. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  136727. */
  136728. showBoundingBox: boolean;
  136729. }
  136730. /**
  136731. * Component responsible of rendering the bounding box of the meshes in a scene.
  136732. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  136733. */
  136734. export class BoundingBoxRenderer implements ISceneComponent {
  136735. /**
  136736. * The component name helpfull to identify the component in the list of scene components.
  136737. */
  136738. readonly name: string;
  136739. /**
  136740. * The scene the component belongs to.
  136741. */
  136742. scene: Scene;
  136743. /**
  136744. * Color of the bounding box lines placed in front of an object
  136745. */
  136746. frontColor: Color3;
  136747. /**
  136748. * Color of the bounding box lines placed behind an object
  136749. */
  136750. backColor: Color3;
  136751. /**
  136752. * Defines if the renderer should show the back lines or not
  136753. */
  136754. showBackLines: boolean;
  136755. /**
  136756. * @hidden
  136757. */
  136758. renderList: SmartArray<BoundingBox>;
  136759. private _colorShader;
  136760. private _vertexBuffers;
  136761. private _indexBuffer;
  136762. private _fillIndexBuffer;
  136763. private _fillIndexData;
  136764. /**
  136765. * Instantiates a new bounding box renderer in a scene.
  136766. * @param scene the scene the renderer renders in
  136767. */
  136768. constructor(scene: Scene);
  136769. /**
  136770. * Registers the component in a given scene
  136771. */
  136772. register(): void;
  136773. private _evaluateSubMesh;
  136774. private _activeMesh;
  136775. private _prepareRessources;
  136776. private _createIndexBuffer;
  136777. /**
  136778. * Rebuilds the elements related to this component in case of
  136779. * context lost for instance.
  136780. */
  136781. rebuild(): void;
  136782. /**
  136783. * @hidden
  136784. */
  136785. reset(): void;
  136786. /**
  136787. * Render the bounding boxes of a specific rendering group
  136788. * @param renderingGroupId defines the rendering group to render
  136789. */
  136790. render(renderingGroupId: number): void;
  136791. /**
  136792. * In case of occlusion queries, we can render the occlusion bounding box through this method
  136793. * @param mesh Define the mesh to render the occlusion bounding box for
  136794. */
  136795. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  136796. /**
  136797. * Dispose and release the resources attached to this renderer.
  136798. */
  136799. dispose(): void;
  136800. }
  136801. }
  136802. declare module BABYLON {
  136803. /** @hidden */
  136804. export var depthPixelShader: {
  136805. name: string;
  136806. shader: string;
  136807. };
  136808. }
  136809. declare module BABYLON {
  136810. /**
  136811. * This represents a depth renderer in Babylon.
  136812. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  136813. */
  136814. export class DepthRenderer {
  136815. private _scene;
  136816. private _depthMap;
  136817. private _effect;
  136818. private readonly _storeNonLinearDepth;
  136819. private readonly _clearColor;
  136820. /** Get if the depth renderer is using packed depth or not */
  136821. readonly isPacked: boolean;
  136822. private _cachedDefines;
  136823. private _camera;
  136824. /**
  136825. * Specifiess that the depth renderer will only be used within
  136826. * the camera it is created for.
  136827. * This can help forcing its rendering during the camera processing.
  136828. */
  136829. useOnlyInActiveCamera: boolean;
  136830. /** @hidden */
  136831. static _SceneComponentInitialization: (scene: Scene) => void;
  136832. /**
  136833. * Instantiates a depth renderer
  136834. * @param scene The scene the renderer belongs to
  136835. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  136836. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  136837. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136838. */
  136839. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  136840. /**
  136841. * Creates the depth rendering effect and checks if the effect is ready.
  136842. * @param subMesh The submesh to be used to render the depth map of
  136843. * @param useInstances If multiple world instances should be used
  136844. * @returns if the depth renderer is ready to render the depth map
  136845. */
  136846. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136847. /**
  136848. * Gets the texture which the depth map will be written to.
  136849. * @returns The depth map texture
  136850. */
  136851. getDepthMap(): RenderTargetTexture;
  136852. /**
  136853. * Disposes of the depth renderer.
  136854. */
  136855. dispose(): void;
  136856. }
  136857. }
  136858. declare module BABYLON {
  136859. interface Scene {
  136860. /** @hidden (Backing field) */
  136861. _depthRenderer: {
  136862. [id: string]: DepthRenderer;
  136863. };
  136864. /**
  136865. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  136866. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  136867. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136868. * @returns the created depth renderer
  136869. */
  136870. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  136871. /**
  136872. * Disables a depth renderer for a given camera
  136873. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  136874. */
  136875. disableDepthRenderer(camera?: Nullable<Camera>): void;
  136876. }
  136877. /**
  136878. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  136879. * in several rendering techniques.
  136880. */
  136881. export class DepthRendererSceneComponent implements ISceneComponent {
  136882. /**
  136883. * The component name helpfull to identify the component in the list of scene components.
  136884. */
  136885. readonly name: string;
  136886. /**
  136887. * The scene the component belongs to.
  136888. */
  136889. scene: Scene;
  136890. /**
  136891. * Creates a new instance of the component for the given scene
  136892. * @param scene Defines the scene to register the component in
  136893. */
  136894. constructor(scene: Scene);
  136895. /**
  136896. * Registers the component in a given scene
  136897. */
  136898. register(): void;
  136899. /**
  136900. * Rebuilds the elements related to this component in case of
  136901. * context lost for instance.
  136902. */
  136903. rebuild(): void;
  136904. /**
  136905. * Disposes the component and the associated ressources
  136906. */
  136907. dispose(): void;
  136908. private _gatherRenderTargets;
  136909. private _gatherActiveCameraRenderTargets;
  136910. }
  136911. }
  136912. declare module BABYLON {
  136913. /** @hidden */
  136914. export var outlinePixelShader: {
  136915. name: string;
  136916. shader: string;
  136917. };
  136918. }
  136919. declare module BABYLON {
  136920. /** @hidden */
  136921. export var outlineVertexShader: {
  136922. name: string;
  136923. shader: string;
  136924. };
  136925. }
  136926. declare module BABYLON {
  136927. interface Scene {
  136928. /** @hidden */
  136929. _outlineRenderer: OutlineRenderer;
  136930. /**
  136931. * Gets the outline renderer associated with the scene
  136932. * @returns a OutlineRenderer
  136933. */
  136934. getOutlineRenderer(): OutlineRenderer;
  136935. }
  136936. interface AbstractMesh {
  136937. /** @hidden (Backing field) */
  136938. _renderOutline: boolean;
  136939. /**
  136940. * Gets or sets a boolean indicating if the outline must be rendered as well
  136941. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  136942. */
  136943. renderOutline: boolean;
  136944. /** @hidden (Backing field) */
  136945. _renderOverlay: boolean;
  136946. /**
  136947. * Gets or sets a boolean indicating if the overlay must be rendered as well
  136948. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  136949. */
  136950. renderOverlay: boolean;
  136951. }
  136952. /**
  136953. * This class is responsible to draw bothe outline/overlay of meshes.
  136954. * It should not be used directly but through the available method on mesh.
  136955. */
  136956. export class OutlineRenderer implements ISceneComponent {
  136957. /**
  136958. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  136959. */
  136960. private static _StencilReference;
  136961. /**
  136962. * The name of the component. Each component must have a unique name.
  136963. */
  136964. name: string;
  136965. /**
  136966. * The scene the component belongs to.
  136967. */
  136968. scene: Scene;
  136969. /**
  136970. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  136971. */
  136972. zOffset: number;
  136973. private _engine;
  136974. private _effect;
  136975. private _cachedDefines;
  136976. private _savedDepthWrite;
  136977. /**
  136978. * Instantiates a new outline renderer. (There could be only one per scene).
  136979. * @param scene Defines the scene it belongs to
  136980. */
  136981. constructor(scene: Scene);
  136982. /**
  136983. * Register the component to one instance of a scene.
  136984. */
  136985. register(): void;
  136986. /**
  136987. * Rebuilds the elements related to this component in case of
  136988. * context lost for instance.
  136989. */
  136990. rebuild(): void;
  136991. /**
  136992. * Disposes the component and the associated ressources.
  136993. */
  136994. dispose(): void;
  136995. /**
  136996. * Renders the outline in the canvas.
  136997. * @param subMesh Defines the sumesh to render
  136998. * @param batch Defines the batch of meshes in case of instances
  136999. * @param useOverlay Defines if the rendering is for the overlay or the outline
  137000. */
  137001. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  137002. /**
  137003. * Returns whether or not the outline renderer is ready for a given submesh.
  137004. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  137005. * @param subMesh Defines the submesh to check readyness for
  137006. * @param useInstances Defines wheter wee are trying to render instances or not
  137007. * @returns true if ready otherwise false
  137008. */
  137009. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137010. private _beforeRenderingMesh;
  137011. private _afterRenderingMesh;
  137012. }
  137013. }
  137014. declare module BABYLON {
  137015. /**
  137016. * Defines the basic options interface of a Sprite Frame Source Size.
  137017. */
  137018. export interface ISpriteJSONSpriteSourceSize {
  137019. /**
  137020. * number of the original width of the Frame
  137021. */
  137022. w: number;
  137023. /**
  137024. * number of the original height of the Frame
  137025. */
  137026. h: number;
  137027. }
  137028. /**
  137029. * Defines the basic options interface of a Sprite Frame Data.
  137030. */
  137031. export interface ISpriteJSONSpriteFrameData {
  137032. /**
  137033. * number of the x offset of the Frame
  137034. */
  137035. x: number;
  137036. /**
  137037. * number of the y offset of the Frame
  137038. */
  137039. y: number;
  137040. /**
  137041. * number of the width of the Frame
  137042. */
  137043. w: number;
  137044. /**
  137045. * number of the height of the Frame
  137046. */
  137047. h: number;
  137048. }
  137049. /**
  137050. * Defines the basic options interface of a JSON Sprite.
  137051. */
  137052. export interface ISpriteJSONSprite {
  137053. /**
  137054. * string name of the Frame
  137055. */
  137056. filename: string;
  137057. /**
  137058. * ISpriteJSONSpriteFrame basic object of the frame data
  137059. */
  137060. frame: ISpriteJSONSpriteFrameData;
  137061. /**
  137062. * boolean to flag is the frame was rotated.
  137063. */
  137064. rotated: boolean;
  137065. /**
  137066. * boolean to flag is the frame was trimmed.
  137067. */
  137068. trimmed: boolean;
  137069. /**
  137070. * ISpriteJSONSpriteFrame basic object of the source data
  137071. */
  137072. spriteSourceSize: ISpriteJSONSpriteFrameData;
  137073. /**
  137074. * ISpriteJSONSpriteFrame basic object of the source data
  137075. */
  137076. sourceSize: ISpriteJSONSpriteSourceSize;
  137077. }
  137078. /**
  137079. * Defines the basic options interface of a JSON atlas.
  137080. */
  137081. export interface ISpriteJSONAtlas {
  137082. /**
  137083. * Array of objects that contain the frame data.
  137084. */
  137085. frames: Array<ISpriteJSONSprite>;
  137086. /**
  137087. * object basic object containing the sprite meta data.
  137088. */
  137089. meta?: object;
  137090. }
  137091. }
  137092. declare module BABYLON {
  137093. /** @hidden */
  137094. export var spriteMapPixelShader: {
  137095. name: string;
  137096. shader: string;
  137097. };
  137098. }
  137099. declare module BABYLON {
  137100. /** @hidden */
  137101. export var spriteMapVertexShader: {
  137102. name: string;
  137103. shader: string;
  137104. };
  137105. }
  137106. declare module BABYLON {
  137107. /**
  137108. * Defines the basic options interface of a SpriteMap
  137109. */
  137110. export interface ISpriteMapOptions {
  137111. /**
  137112. * Vector2 of the number of cells in the grid.
  137113. */
  137114. stageSize?: Vector2;
  137115. /**
  137116. * Vector2 of the size of the output plane in World Units.
  137117. */
  137118. outputSize?: Vector2;
  137119. /**
  137120. * Vector3 of the position of the output plane in World Units.
  137121. */
  137122. outputPosition?: Vector3;
  137123. /**
  137124. * Vector3 of the rotation of the output plane.
  137125. */
  137126. outputRotation?: Vector3;
  137127. /**
  137128. * number of layers that the system will reserve in resources.
  137129. */
  137130. layerCount?: number;
  137131. /**
  137132. * number of max animation frames a single cell will reserve in resources.
  137133. */
  137134. maxAnimationFrames?: number;
  137135. /**
  137136. * number cell index of the base tile when the system compiles.
  137137. */
  137138. baseTile?: number;
  137139. /**
  137140. * boolean flip the sprite after its been repositioned by the framing data.
  137141. */
  137142. flipU?: boolean;
  137143. /**
  137144. * Vector3 scalar of the global RGB values of the SpriteMap.
  137145. */
  137146. colorMultiply?: Vector3;
  137147. }
  137148. /**
  137149. * Defines the IDisposable interface in order to be cleanable from resources.
  137150. */
  137151. export interface ISpriteMap extends IDisposable {
  137152. /**
  137153. * String name of the SpriteMap.
  137154. */
  137155. name: string;
  137156. /**
  137157. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  137158. */
  137159. atlasJSON: ISpriteJSONAtlas;
  137160. /**
  137161. * Texture of the SpriteMap.
  137162. */
  137163. spriteSheet: Texture;
  137164. /**
  137165. * The parameters to initialize the SpriteMap with.
  137166. */
  137167. options: ISpriteMapOptions;
  137168. }
  137169. /**
  137170. * Class used to manage a grid restricted sprite deployment on an Output plane.
  137171. */
  137172. export class SpriteMap implements ISpriteMap {
  137173. /** The Name of the spriteMap */
  137174. name: string;
  137175. /** The JSON file with the frame and meta data */
  137176. atlasJSON: ISpriteJSONAtlas;
  137177. /** The systems Sprite Sheet Texture */
  137178. spriteSheet: Texture;
  137179. /** Arguments passed with the Constructor */
  137180. options: ISpriteMapOptions;
  137181. /** Public Sprite Storage array, parsed from atlasJSON */
  137182. sprites: Array<ISpriteJSONSprite>;
  137183. /** Returns the Number of Sprites in the System */
  137184. get spriteCount(): number;
  137185. /** Returns the Position of Output Plane*/
  137186. get position(): Vector3;
  137187. /** Returns the Position of Output Plane*/
  137188. set position(v: Vector3);
  137189. /** Returns the Rotation of Output Plane*/
  137190. get rotation(): Vector3;
  137191. /** Returns the Rotation of Output Plane*/
  137192. set rotation(v: Vector3);
  137193. /** Sets the AnimationMap*/
  137194. get animationMap(): RawTexture;
  137195. /** Sets the AnimationMap*/
  137196. set animationMap(v: RawTexture);
  137197. /** Scene that the SpriteMap was created in */
  137198. private _scene;
  137199. /** Texture Buffer of Float32 that holds tile frame data*/
  137200. private _frameMap;
  137201. /** Texture Buffers of Float32 that holds tileMap data*/
  137202. private _tileMaps;
  137203. /** Texture Buffer of Float32 that holds Animation Data*/
  137204. private _animationMap;
  137205. /** Custom ShaderMaterial Central to the System*/
  137206. private _material;
  137207. /** Custom ShaderMaterial Central to the System*/
  137208. private _output;
  137209. /** Systems Time Ticker*/
  137210. private _time;
  137211. /**
  137212. * Creates a new SpriteMap
  137213. * @param name defines the SpriteMaps Name
  137214. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  137215. * @param spriteSheet is the Texture that the Sprites are on.
  137216. * @param options a basic deployment configuration
  137217. * @param scene The Scene that the map is deployed on
  137218. */
  137219. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  137220. /**
  137221. * Returns tileID location
  137222. * @returns Vector2 the cell position ID
  137223. */
  137224. getTileID(): Vector2;
  137225. /**
  137226. * Gets the UV location of the mouse over the SpriteMap.
  137227. * @returns Vector2 the UV position of the mouse interaction
  137228. */
  137229. getMousePosition(): Vector2;
  137230. /**
  137231. * Creates the "frame" texture Buffer
  137232. * -------------------------------------
  137233. * Structure of frames
  137234. * "filename": "Falling-Water-2.png",
  137235. * "frame": {"x":69,"y":103,"w":24,"h":32},
  137236. * "rotated": true,
  137237. * "trimmed": true,
  137238. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  137239. * "sourceSize": {"w":32,"h":32}
  137240. * @returns RawTexture of the frameMap
  137241. */
  137242. private _createFrameBuffer;
  137243. /**
  137244. * Creates the tileMap texture Buffer
  137245. * @param buffer normally and array of numbers, or a false to generate from scratch
  137246. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  137247. * @returns RawTexture of the tileMap
  137248. */
  137249. private _createTileBuffer;
  137250. /**
  137251. * Modifies the data of the tileMaps
  137252. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  137253. * @param pos is the iVector2 Coordinates of the Tile
  137254. * @param tile The SpriteIndex of the new Tile
  137255. */
  137256. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  137257. /**
  137258. * Creates the animationMap texture Buffer
  137259. * @param buffer normally and array of numbers, or a false to generate from scratch
  137260. * @returns RawTexture of the animationMap
  137261. */
  137262. private _createTileAnimationBuffer;
  137263. /**
  137264. * Modifies the data of the animationMap
  137265. * @param cellID is the Index of the Sprite
  137266. * @param _frame is the target Animation frame
  137267. * @param toCell is the Target Index of the next frame of the animation
  137268. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  137269. * @param speed is a global scalar of the time variable on the map.
  137270. */
  137271. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  137272. /**
  137273. * Exports the .tilemaps file
  137274. */
  137275. saveTileMaps(): void;
  137276. /**
  137277. * Imports the .tilemaps file
  137278. * @param url of the .tilemaps file
  137279. */
  137280. loadTileMaps(url: string): void;
  137281. /**
  137282. * Release associated resources
  137283. */
  137284. dispose(): void;
  137285. }
  137286. }
  137287. declare module BABYLON {
  137288. /**
  137289. * Class used to manage multiple sprites of different sizes on the same spritesheet
  137290. * @see http://doc.babylonjs.com/babylon101/sprites
  137291. */
  137292. export class SpritePackedManager extends SpriteManager {
  137293. /** defines the packed manager's name */
  137294. name: string;
  137295. /**
  137296. * Creates a new sprite manager from a packed sprite sheet
  137297. * @param name defines the manager's name
  137298. * @param imgUrl defines the sprite sheet url
  137299. * @param capacity defines the maximum allowed number of sprites
  137300. * @param scene defines the hosting scene
  137301. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  137302. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  137303. * @param samplingMode defines the smapling mode to use with spritesheet
  137304. * @param fromPacked set to true; do not alter
  137305. */
  137306. constructor(
  137307. /** defines the packed manager's name */
  137308. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  137309. }
  137310. }
  137311. declare module BABYLON {
  137312. /**
  137313. * Defines the list of states available for a task inside a AssetsManager
  137314. */
  137315. export enum AssetTaskState {
  137316. /**
  137317. * Initialization
  137318. */
  137319. INIT = 0,
  137320. /**
  137321. * Running
  137322. */
  137323. RUNNING = 1,
  137324. /**
  137325. * Done
  137326. */
  137327. DONE = 2,
  137328. /**
  137329. * Error
  137330. */
  137331. ERROR = 3
  137332. }
  137333. /**
  137334. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  137335. */
  137336. export abstract class AbstractAssetTask {
  137337. /**
  137338. * Task name
  137339. */ name: string;
  137340. /**
  137341. * Callback called when the task is successful
  137342. */
  137343. onSuccess: (task: any) => void;
  137344. /**
  137345. * Callback called when the task is not successful
  137346. */
  137347. onError: (task: any, message?: string, exception?: any) => void;
  137348. /**
  137349. * Creates a new AssetsManager
  137350. * @param name defines the name of the task
  137351. */
  137352. constructor(
  137353. /**
  137354. * Task name
  137355. */ name: string);
  137356. private _isCompleted;
  137357. private _taskState;
  137358. private _errorObject;
  137359. /**
  137360. * Get if the task is completed
  137361. */
  137362. get isCompleted(): boolean;
  137363. /**
  137364. * Gets the current state of the task
  137365. */
  137366. get taskState(): AssetTaskState;
  137367. /**
  137368. * Gets the current error object (if task is in error)
  137369. */
  137370. get errorObject(): {
  137371. message?: string;
  137372. exception?: any;
  137373. };
  137374. /**
  137375. * Internal only
  137376. * @hidden
  137377. */
  137378. _setErrorObject(message?: string, exception?: any): void;
  137379. /**
  137380. * Execute the current task
  137381. * @param scene defines the scene where you want your assets to be loaded
  137382. * @param onSuccess is a callback called when the task is successfully executed
  137383. * @param onError is a callback called if an error occurs
  137384. */
  137385. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137386. /**
  137387. * Execute the current task
  137388. * @param scene defines the scene where you want your assets to be loaded
  137389. * @param onSuccess is a callback called when the task is successfully executed
  137390. * @param onError is a callback called if an error occurs
  137391. */
  137392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137393. /**
  137394. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  137395. * This can be used with failed tasks that have the reason for failure fixed.
  137396. */
  137397. reset(): void;
  137398. private onErrorCallback;
  137399. private onDoneCallback;
  137400. }
  137401. /**
  137402. * Define the interface used by progress events raised during assets loading
  137403. */
  137404. export interface IAssetsProgressEvent {
  137405. /**
  137406. * Defines the number of remaining tasks to process
  137407. */
  137408. remainingCount: number;
  137409. /**
  137410. * Defines the total number of tasks
  137411. */
  137412. totalCount: number;
  137413. /**
  137414. * Defines the task that was just processed
  137415. */
  137416. task: AbstractAssetTask;
  137417. }
  137418. /**
  137419. * Class used to share progress information about assets loading
  137420. */
  137421. export class AssetsProgressEvent implements IAssetsProgressEvent {
  137422. /**
  137423. * Defines the number of remaining tasks to process
  137424. */
  137425. remainingCount: number;
  137426. /**
  137427. * Defines the total number of tasks
  137428. */
  137429. totalCount: number;
  137430. /**
  137431. * Defines the task that was just processed
  137432. */
  137433. task: AbstractAssetTask;
  137434. /**
  137435. * Creates a AssetsProgressEvent
  137436. * @param remainingCount defines the number of remaining tasks to process
  137437. * @param totalCount defines the total number of tasks
  137438. * @param task defines the task that was just processed
  137439. */
  137440. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  137441. }
  137442. /**
  137443. * Define a task used by AssetsManager to load meshes
  137444. */
  137445. export class MeshAssetTask extends AbstractAssetTask {
  137446. /**
  137447. * Defines the name of the task
  137448. */
  137449. name: string;
  137450. /**
  137451. * Defines the list of mesh's names you want to load
  137452. */
  137453. meshesNames: any;
  137454. /**
  137455. * Defines the root url to use as a base to load your meshes and associated resources
  137456. */
  137457. rootUrl: string;
  137458. /**
  137459. * Defines the filename of the scene to load from
  137460. */
  137461. sceneFilename: string;
  137462. /**
  137463. * Gets the list of loaded meshes
  137464. */
  137465. loadedMeshes: Array<AbstractMesh>;
  137466. /**
  137467. * Gets the list of loaded particle systems
  137468. */
  137469. loadedParticleSystems: Array<IParticleSystem>;
  137470. /**
  137471. * Gets the list of loaded skeletons
  137472. */
  137473. loadedSkeletons: Array<Skeleton>;
  137474. /**
  137475. * Gets the list of loaded animation groups
  137476. */
  137477. loadedAnimationGroups: Array<AnimationGroup>;
  137478. /**
  137479. * Callback called when the task is successful
  137480. */
  137481. onSuccess: (task: MeshAssetTask) => void;
  137482. /**
  137483. * Callback called when the task is successful
  137484. */
  137485. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  137486. /**
  137487. * Creates a new MeshAssetTask
  137488. * @param name defines the name of the task
  137489. * @param meshesNames defines the list of mesh's names you want to load
  137490. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  137491. * @param sceneFilename defines the filename of the scene to load from
  137492. */
  137493. constructor(
  137494. /**
  137495. * Defines the name of the task
  137496. */
  137497. name: string,
  137498. /**
  137499. * Defines the list of mesh's names you want to load
  137500. */
  137501. meshesNames: any,
  137502. /**
  137503. * Defines the root url to use as a base to load your meshes and associated resources
  137504. */
  137505. rootUrl: string,
  137506. /**
  137507. * Defines the filename of the scene to load from
  137508. */
  137509. sceneFilename: string);
  137510. /**
  137511. * Execute the current task
  137512. * @param scene defines the scene where you want your assets to be loaded
  137513. * @param onSuccess is a callback called when the task is successfully executed
  137514. * @param onError is a callback called if an error occurs
  137515. */
  137516. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137517. }
  137518. /**
  137519. * Define a task used by AssetsManager to load text content
  137520. */
  137521. export class TextFileAssetTask extends AbstractAssetTask {
  137522. /**
  137523. * Defines the name of the task
  137524. */
  137525. name: string;
  137526. /**
  137527. * Defines the location of the file to load
  137528. */
  137529. url: string;
  137530. /**
  137531. * Gets the loaded text string
  137532. */
  137533. text: string;
  137534. /**
  137535. * Callback called when the task is successful
  137536. */
  137537. onSuccess: (task: TextFileAssetTask) => void;
  137538. /**
  137539. * Callback called when the task is successful
  137540. */
  137541. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  137542. /**
  137543. * Creates a new TextFileAssetTask object
  137544. * @param name defines the name of the task
  137545. * @param url defines the location of the file to load
  137546. */
  137547. constructor(
  137548. /**
  137549. * Defines the name of the task
  137550. */
  137551. name: string,
  137552. /**
  137553. * Defines the location of the file to load
  137554. */
  137555. url: string);
  137556. /**
  137557. * Execute the current task
  137558. * @param scene defines the scene where you want your assets to be loaded
  137559. * @param onSuccess is a callback called when the task is successfully executed
  137560. * @param onError is a callback called if an error occurs
  137561. */
  137562. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137563. }
  137564. /**
  137565. * Define a task used by AssetsManager to load binary data
  137566. */
  137567. export class BinaryFileAssetTask extends AbstractAssetTask {
  137568. /**
  137569. * Defines the name of the task
  137570. */
  137571. name: string;
  137572. /**
  137573. * Defines the location of the file to load
  137574. */
  137575. url: string;
  137576. /**
  137577. * Gets the lodaded data (as an array buffer)
  137578. */
  137579. data: ArrayBuffer;
  137580. /**
  137581. * Callback called when the task is successful
  137582. */
  137583. onSuccess: (task: BinaryFileAssetTask) => void;
  137584. /**
  137585. * Callback called when the task is successful
  137586. */
  137587. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  137588. /**
  137589. * Creates a new BinaryFileAssetTask object
  137590. * @param name defines the name of the new task
  137591. * @param url defines the location of the file to load
  137592. */
  137593. constructor(
  137594. /**
  137595. * Defines the name of the task
  137596. */
  137597. name: string,
  137598. /**
  137599. * Defines the location of the file to load
  137600. */
  137601. url: string);
  137602. /**
  137603. * Execute the current task
  137604. * @param scene defines the scene where you want your assets to be loaded
  137605. * @param onSuccess is a callback called when the task is successfully executed
  137606. * @param onError is a callback called if an error occurs
  137607. */
  137608. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137609. }
  137610. /**
  137611. * Define a task used by AssetsManager to load images
  137612. */
  137613. export class ImageAssetTask extends AbstractAssetTask {
  137614. /**
  137615. * Defines the name of the task
  137616. */
  137617. name: string;
  137618. /**
  137619. * Defines the location of the image to load
  137620. */
  137621. url: string;
  137622. /**
  137623. * Gets the loaded images
  137624. */
  137625. image: HTMLImageElement;
  137626. /**
  137627. * Callback called when the task is successful
  137628. */
  137629. onSuccess: (task: ImageAssetTask) => void;
  137630. /**
  137631. * Callback called when the task is successful
  137632. */
  137633. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  137634. /**
  137635. * Creates a new ImageAssetTask
  137636. * @param name defines the name of the task
  137637. * @param url defines the location of the image to load
  137638. */
  137639. constructor(
  137640. /**
  137641. * Defines the name of the task
  137642. */
  137643. name: string,
  137644. /**
  137645. * Defines the location of the image to load
  137646. */
  137647. url: string);
  137648. /**
  137649. * Execute the current task
  137650. * @param scene defines the scene where you want your assets to be loaded
  137651. * @param onSuccess is a callback called when the task is successfully executed
  137652. * @param onError is a callback called if an error occurs
  137653. */
  137654. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137655. }
  137656. /**
  137657. * Defines the interface used by texture loading tasks
  137658. */
  137659. export interface ITextureAssetTask<TEX extends BaseTexture> {
  137660. /**
  137661. * Gets the loaded texture
  137662. */
  137663. texture: TEX;
  137664. }
  137665. /**
  137666. * Define a task used by AssetsManager to load 2D textures
  137667. */
  137668. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  137669. /**
  137670. * Defines the name of the task
  137671. */
  137672. name: string;
  137673. /**
  137674. * Defines the location of the file to load
  137675. */
  137676. url: string;
  137677. /**
  137678. * Defines if mipmap should not be generated (default is false)
  137679. */
  137680. noMipmap?: boolean | undefined;
  137681. /**
  137682. * Defines if texture must be inverted on Y axis (default is false)
  137683. */
  137684. invertY?: boolean | undefined;
  137685. /**
  137686. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  137687. */
  137688. samplingMode: number;
  137689. /**
  137690. * Gets the loaded texture
  137691. */
  137692. texture: Texture;
  137693. /**
  137694. * Callback called when the task is successful
  137695. */
  137696. onSuccess: (task: TextureAssetTask) => void;
  137697. /**
  137698. * Callback called when the task is successful
  137699. */
  137700. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  137701. /**
  137702. * Creates a new TextureAssetTask object
  137703. * @param name defines the name of the task
  137704. * @param url defines the location of the file to load
  137705. * @param noMipmap defines if mipmap should not be generated (default is false)
  137706. * @param invertY defines if texture must be inverted on Y axis (default is false)
  137707. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  137708. */
  137709. constructor(
  137710. /**
  137711. * Defines the name of the task
  137712. */
  137713. name: string,
  137714. /**
  137715. * Defines the location of the file to load
  137716. */
  137717. url: string,
  137718. /**
  137719. * Defines if mipmap should not be generated (default is false)
  137720. */
  137721. noMipmap?: boolean | undefined,
  137722. /**
  137723. * Defines if texture must be inverted on Y axis (default is false)
  137724. */
  137725. invertY?: boolean | undefined,
  137726. /**
  137727. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  137728. */
  137729. samplingMode?: number);
  137730. /**
  137731. * Execute the current task
  137732. * @param scene defines the scene where you want your assets to be loaded
  137733. * @param onSuccess is a callback called when the task is successfully executed
  137734. * @param onError is a callback called if an error occurs
  137735. */
  137736. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137737. }
  137738. /**
  137739. * Define a task used by AssetsManager to load cube textures
  137740. */
  137741. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  137742. /**
  137743. * Defines the name of the task
  137744. */
  137745. name: string;
  137746. /**
  137747. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  137748. */
  137749. url: string;
  137750. /**
  137751. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  137752. */
  137753. extensions?: string[] | undefined;
  137754. /**
  137755. * Defines if mipmaps should not be generated (default is false)
  137756. */
  137757. noMipmap?: boolean | undefined;
  137758. /**
  137759. * Defines the explicit list of files (undefined by default)
  137760. */
  137761. files?: string[] | undefined;
  137762. /**
  137763. * Gets the loaded texture
  137764. */
  137765. texture: CubeTexture;
  137766. /**
  137767. * Callback called when the task is successful
  137768. */
  137769. onSuccess: (task: CubeTextureAssetTask) => void;
  137770. /**
  137771. * Callback called when the task is successful
  137772. */
  137773. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  137774. /**
  137775. * Creates a new CubeTextureAssetTask
  137776. * @param name defines the name of the task
  137777. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  137778. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  137779. * @param noMipmap defines if mipmaps should not be generated (default is false)
  137780. * @param files defines the explicit list of files (undefined by default)
  137781. */
  137782. constructor(
  137783. /**
  137784. * Defines the name of the task
  137785. */
  137786. name: string,
  137787. /**
  137788. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  137789. */
  137790. url: string,
  137791. /**
  137792. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  137793. */
  137794. extensions?: string[] | undefined,
  137795. /**
  137796. * Defines if mipmaps should not be generated (default is false)
  137797. */
  137798. noMipmap?: boolean | undefined,
  137799. /**
  137800. * Defines the explicit list of files (undefined by default)
  137801. */
  137802. files?: string[] | undefined);
  137803. /**
  137804. * Execute the current task
  137805. * @param scene defines the scene where you want your assets to be loaded
  137806. * @param onSuccess is a callback called when the task is successfully executed
  137807. * @param onError is a callback called if an error occurs
  137808. */
  137809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137810. }
  137811. /**
  137812. * Define a task used by AssetsManager to load HDR cube textures
  137813. */
  137814. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  137815. /**
  137816. * Defines the name of the task
  137817. */
  137818. name: string;
  137819. /**
  137820. * Defines the location of the file to load
  137821. */
  137822. url: string;
  137823. /**
  137824. * Defines the desired size (the more it increases the longer the generation will be)
  137825. */
  137826. size: number;
  137827. /**
  137828. * Defines if mipmaps should not be generated (default is false)
  137829. */
  137830. noMipmap: boolean;
  137831. /**
  137832. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  137833. */
  137834. generateHarmonics: boolean;
  137835. /**
  137836. * 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)
  137837. */
  137838. gammaSpace: boolean;
  137839. /**
  137840. * Internal Use Only
  137841. */
  137842. reserved: boolean;
  137843. /**
  137844. * Gets the loaded texture
  137845. */
  137846. texture: HDRCubeTexture;
  137847. /**
  137848. * Callback called when the task is successful
  137849. */
  137850. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  137851. /**
  137852. * Callback called when the task is successful
  137853. */
  137854. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  137855. /**
  137856. * Creates a new HDRCubeTextureAssetTask object
  137857. * @param name defines the name of the task
  137858. * @param url defines the location of the file to load
  137859. * @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.
  137860. * @param noMipmap defines if mipmaps should not be generated (default is false)
  137861. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  137862. * @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)
  137863. * @param reserved Internal use only
  137864. */
  137865. constructor(
  137866. /**
  137867. * Defines the name of the task
  137868. */
  137869. name: string,
  137870. /**
  137871. * Defines the location of the file to load
  137872. */
  137873. url: string,
  137874. /**
  137875. * Defines the desired size (the more it increases the longer the generation will be)
  137876. */
  137877. size: number,
  137878. /**
  137879. * Defines if mipmaps should not be generated (default is false)
  137880. */
  137881. noMipmap?: boolean,
  137882. /**
  137883. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  137884. */
  137885. generateHarmonics?: boolean,
  137886. /**
  137887. * 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)
  137888. */
  137889. gammaSpace?: boolean,
  137890. /**
  137891. * Internal Use Only
  137892. */
  137893. reserved?: boolean);
  137894. /**
  137895. * Execute the current task
  137896. * @param scene defines the scene where you want your assets to be loaded
  137897. * @param onSuccess is a callback called when the task is successfully executed
  137898. * @param onError is a callback called if an error occurs
  137899. */
  137900. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137901. }
  137902. /**
  137903. * Define a task used by AssetsManager to load Equirectangular cube textures
  137904. */
  137905. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  137906. /**
  137907. * Defines the name of the task
  137908. */
  137909. name: string;
  137910. /**
  137911. * Defines the location of the file to load
  137912. */
  137913. url: string;
  137914. /**
  137915. * Defines the desired size (the more it increases the longer the generation will be)
  137916. */
  137917. size: number;
  137918. /**
  137919. * Defines if mipmaps should not be generated (default is false)
  137920. */
  137921. noMipmap: boolean;
  137922. /**
  137923. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  137924. * but the standard material would require them in Gamma space) (default is true)
  137925. */
  137926. gammaSpace: boolean;
  137927. /**
  137928. * Gets the loaded texture
  137929. */
  137930. texture: EquiRectangularCubeTexture;
  137931. /**
  137932. * Callback called when the task is successful
  137933. */
  137934. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  137935. /**
  137936. * Callback called when the task is successful
  137937. */
  137938. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  137939. /**
  137940. * Creates a new EquiRectangularCubeTextureAssetTask object
  137941. * @param name defines the name of the task
  137942. * @param url defines the location of the file to load
  137943. * @param size defines the desired size (the more it increases the longer the generation will be)
  137944. * If the size is omitted this implies you are using a preprocessed cubemap.
  137945. * @param noMipmap defines if mipmaps should not be generated (default is false)
  137946. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  137947. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  137948. * (default is true)
  137949. */
  137950. constructor(
  137951. /**
  137952. * Defines the name of the task
  137953. */
  137954. name: string,
  137955. /**
  137956. * Defines the location of the file to load
  137957. */
  137958. url: string,
  137959. /**
  137960. * Defines the desired size (the more it increases the longer the generation will be)
  137961. */
  137962. size: number,
  137963. /**
  137964. * Defines if mipmaps should not be generated (default is false)
  137965. */
  137966. noMipmap?: boolean,
  137967. /**
  137968. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  137969. * but the standard material would require them in Gamma space) (default is true)
  137970. */
  137971. gammaSpace?: boolean);
  137972. /**
  137973. * Execute the current task
  137974. * @param scene defines the scene where you want your assets to be loaded
  137975. * @param onSuccess is a callback called when the task is successfully executed
  137976. * @param onError is a callback called if an error occurs
  137977. */
  137978. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  137979. }
  137980. /**
  137981. * This class can be used to easily import assets into a scene
  137982. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  137983. */
  137984. export class AssetsManager {
  137985. private _scene;
  137986. private _isLoading;
  137987. protected _tasks: AbstractAssetTask[];
  137988. protected _waitingTasksCount: number;
  137989. protected _totalTasksCount: number;
  137990. /**
  137991. * Callback called when all tasks are processed
  137992. */
  137993. onFinish: (tasks: AbstractAssetTask[]) => void;
  137994. /**
  137995. * Callback called when a task is successful
  137996. */
  137997. onTaskSuccess: (task: AbstractAssetTask) => void;
  137998. /**
  137999. * Callback called when a task had an error
  138000. */
  138001. onTaskError: (task: AbstractAssetTask) => void;
  138002. /**
  138003. * Callback called when a task is done (whatever the result is)
  138004. */
  138005. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  138006. /**
  138007. * Observable called when all tasks are processed
  138008. */
  138009. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  138010. /**
  138011. * Observable called when a task had an error
  138012. */
  138013. onTaskErrorObservable: Observable<AbstractAssetTask>;
  138014. /**
  138015. * Observable called when all tasks were executed
  138016. */
  138017. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  138018. /**
  138019. * Observable called when a task is done (whatever the result is)
  138020. */
  138021. onProgressObservable: Observable<IAssetsProgressEvent>;
  138022. /**
  138023. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  138024. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  138025. */
  138026. useDefaultLoadingScreen: boolean;
  138027. /**
  138028. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  138029. * when all assets have been downloaded.
  138030. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  138031. */
  138032. autoHideLoadingUI: boolean;
  138033. /**
  138034. * Creates a new AssetsManager
  138035. * @param scene defines the scene to work on
  138036. */
  138037. constructor(scene: Scene);
  138038. /**
  138039. * Add a MeshAssetTask to the list of active tasks
  138040. * @param taskName defines the name of the new task
  138041. * @param meshesNames defines the name of meshes to load
  138042. * @param rootUrl defines the root url to use to locate files
  138043. * @param sceneFilename defines the filename of the scene file
  138044. * @returns a new MeshAssetTask object
  138045. */
  138046. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  138047. /**
  138048. * Add a TextFileAssetTask to the list of active tasks
  138049. * @param taskName defines the name of the new task
  138050. * @param url defines the url of the file to load
  138051. * @returns a new TextFileAssetTask object
  138052. */
  138053. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  138054. /**
  138055. * Add a BinaryFileAssetTask to the list of active tasks
  138056. * @param taskName defines the name of the new task
  138057. * @param url defines the url of the file to load
  138058. * @returns a new BinaryFileAssetTask object
  138059. */
  138060. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  138061. /**
  138062. * Add a ImageAssetTask to the list of active tasks
  138063. * @param taskName defines the name of the new task
  138064. * @param url defines the url of the file to load
  138065. * @returns a new ImageAssetTask object
  138066. */
  138067. addImageTask(taskName: string, url: string): ImageAssetTask;
  138068. /**
  138069. * Add a TextureAssetTask to the list of active tasks
  138070. * @param taskName defines the name of the new task
  138071. * @param url defines the url of the file to load
  138072. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  138073. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  138074. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  138075. * @returns a new TextureAssetTask object
  138076. */
  138077. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  138078. /**
  138079. * Add a CubeTextureAssetTask to the list of active tasks
  138080. * @param taskName defines the name of the new task
  138081. * @param url defines the url of the file to load
  138082. * @param extensions defines the extension to use to load the cube map (can be null)
  138083. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  138084. * @param files defines the list of files to load (can be null)
  138085. * @returns a new CubeTextureAssetTask object
  138086. */
  138087. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  138088. /**
  138089. *
  138090. * Add a HDRCubeTextureAssetTask to the list of active tasks
  138091. * @param taskName defines the name of the new task
  138092. * @param url defines the url of the file to load
  138093. * @param size defines the size you want for the cubemap (can be null)
  138094. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  138095. * @param generateHarmonics defines if you want to automatically generate (true by default)
  138096. * @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)
  138097. * @param reserved Internal use only
  138098. * @returns a new HDRCubeTextureAssetTask object
  138099. */
  138100. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  138101. /**
  138102. *
  138103. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  138104. * @param taskName defines the name of the new task
  138105. * @param url defines the url of the file to load
  138106. * @param size defines the size you want for the cubemap (can be null)
  138107. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  138108. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  138109. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  138110. * @returns a new EquiRectangularCubeTextureAssetTask object
  138111. */
  138112. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  138113. /**
  138114. * Remove a task from the assets manager.
  138115. * @param task the task to remove
  138116. */
  138117. removeTask(task: AbstractAssetTask): void;
  138118. private _decreaseWaitingTasksCount;
  138119. private _runTask;
  138120. /**
  138121. * Reset the AssetsManager and remove all tasks
  138122. * @return the current instance of the AssetsManager
  138123. */
  138124. reset(): AssetsManager;
  138125. /**
  138126. * Start the loading process
  138127. * @return the current instance of the AssetsManager
  138128. */
  138129. load(): AssetsManager;
  138130. /**
  138131. * Start the loading process as an async operation
  138132. * @return a promise returning the list of failed tasks
  138133. */
  138134. loadAsync(): Promise<void>;
  138135. }
  138136. }
  138137. declare module BABYLON {
  138138. /**
  138139. * Wrapper class for promise with external resolve and reject.
  138140. */
  138141. export class Deferred<T> {
  138142. /**
  138143. * The promise associated with this deferred object.
  138144. */
  138145. readonly promise: Promise<T>;
  138146. private _resolve;
  138147. private _reject;
  138148. /**
  138149. * The resolve method of the promise associated with this deferred object.
  138150. */
  138151. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  138152. /**
  138153. * The reject method of the promise associated with this deferred object.
  138154. */
  138155. get reject(): (reason?: any) => void;
  138156. /**
  138157. * Constructor for this deferred object.
  138158. */
  138159. constructor();
  138160. }
  138161. }
  138162. declare module BABYLON {
  138163. /**
  138164. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  138165. */
  138166. export class MeshExploder {
  138167. private _centerMesh;
  138168. private _meshes;
  138169. private _meshesOrigins;
  138170. private _toCenterVectors;
  138171. private _scaledDirection;
  138172. private _newPosition;
  138173. private _centerPosition;
  138174. /**
  138175. * Explodes meshes from a center mesh.
  138176. * @param meshes The meshes to explode.
  138177. * @param centerMesh The mesh to be center of explosion.
  138178. */
  138179. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  138180. private _setCenterMesh;
  138181. /**
  138182. * Get class name
  138183. * @returns "MeshExploder"
  138184. */
  138185. getClassName(): string;
  138186. /**
  138187. * "Exploded meshes"
  138188. * @returns Array of meshes with the centerMesh at index 0.
  138189. */
  138190. getMeshes(): Array<Mesh>;
  138191. /**
  138192. * Explodes meshes giving a specific direction
  138193. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  138194. */
  138195. explode(direction?: number): void;
  138196. }
  138197. }
  138198. declare module BABYLON {
  138199. /**
  138200. * Class used to help managing file picking and drag'n'drop
  138201. */
  138202. export class FilesInput {
  138203. /**
  138204. * List of files ready to be loaded
  138205. */
  138206. static get FilesToLoad(): {
  138207. [key: string]: File;
  138208. };
  138209. /**
  138210. * Callback called when a file is processed
  138211. */
  138212. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  138213. private _engine;
  138214. private _currentScene;
  138215. private _sceneLoadedCallback;
  138216. private _progressCallback;
  138217. private _additionalRenderLoopLogicCallback;
  138218. private _textureLoadingCallback;
  138219. private _startingProcessingFilesCallback;
  138220. private _onReloadCallback;
  138221. private _errorCallback;
  138222. private _elementToMonitor;
  138223. private _sceneFileToLoad;
  138224. private _filesToLoad;
  138225. /**
  138226. * Creates a new FilesInput
  138227. * @param engine defines the rendering engine
  138228. * @param scene defines the hosting scene
  138229. * @param sceneLoadedCallback callback called when scene is loaded
  138230. * @param progressCallback callback called to track progress
  138231. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  138232. * @param textureLoadingCallback callback called when a texture is loading
  138233. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  138234. * @param onReloadCallback callback called when a reload is requested
  138235. * @param errorCallback callback call if an error occurs
  138236. */
  138237. 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);
  138238. private _dragEnterHandler;
  138239. private _dragOverHandler;
  138240. private _dropHandler;
  138241. /**
  138242. * Calls this function to listen to drag'n'drop events on a specific DOM element
  138243. * @param elementToMonitor defines the DOM element to track
  138244. */
  138245. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  138246. /**
  138247. * Release all associated resources
  138248. */
  138249. dispose(): void;
  138250. private renderFunction;
  138251. private drag;
  138252. private drop;
  138253. private _traverseFolder;
  138254. private _processFiles;
  138255. /**
  138256. * Load files from a drop event
  138257. * @param event defines the drop event to use as source
  138258. */
  138259. loadFiles(event: any): void;
  138260. private _processReload;
  138261. /**
  138262. * Reload the current scene from the loaded files
  138263. */
  138264. reload(): void;
  138265. }
  138266. }
  138267. declare module BABYLON {
  138268. /**
  138269. * Defines the root class used to create scene optimization to use with SceneOptimizer
  138270. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138271. */
  138272. export class SceneOptimization {
  138273. /**
  138274. * Defines the priority of this optimization (0 by default which means first in the list)
  138275. */
  138276. priority: number;
  138277. /**
  138278. * Gets a string describing the action executed by the current optimization
  138279. * @returns description string
  138280. */
  138281. getDescription(): string;
  138282. /**
  138283. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138284. * @param scene defines the current scene where to apply this optimization
  138285. * @param optimizer defines the current optimizer
  138286. * @returns true if everything that can be done was applied
  138287. */
  138288. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138289. /**
  138290. * Creates the SceneOptimization object
  138291. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  138292. * @param desc defines the description associated with the optimization
  138293. */
  138294. constructor(
  138295. /**
  138296. * Defines the priority of this optimization (0 by default which means first in the list)
  138297. */
  138298. priority?: number);
  138299. }
  138300. /**
  138301. * Defines an optimization used to reduce the size of render target textures
  138302. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138303. */
  138304. export class TextureOptimization extends SceneOptimization {
  138305. /**
  138306. * Defines the priority of this optimization (0 by default which means first in the list)
  138307. */
  138308. priority: number;
  138309. /**
  138310. * 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
  138311. */
  138312. maximumSize: number;
  138313. /**
  138314. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  138315. */
  138316. step: number;
  138317. /**
  138318. * Gets a string describing the action executed by the current optimization
  138319. * @returns description string
  138320. */
  138321. getDescription(): string;
  138322. /**
  138323. * Creates the TextureOptimization object
  138324. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  138325. * @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
  138326. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  138327. */
  138328. constructor(
  138329. /**
  138330. * Defines the priority of this optimization (0 by default which means first in the list)
  138331. */
  138332. priority?: number,
  138333. /**
  138334. * 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
  138335. */
  138336. maximumSize?: number,
  138337. /**
  138338. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  138339. */
  138340. step?: number);
  138341. /**
  138342. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138343. * @param scene defines the current scene where to apply this optimization
  138344. * @param optimizer defines the current optimizer
  138345. * @returns true if everything that can be done was applied
  138346. */
  138347. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138348. }
  138349. /**
  138350. * Defines an optimization used to increase or decrease the rendering resolution
  138351. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138352. */
  138353. export class HardwareScalingOptimization extends SceneOptimization {
  138354. /**
  138355. * Defines the priority of this optimization (0 by default which means first in the list)
  138356. */
  138357. priority: number;
  138358. /**
  138359. * Defines the maximum scale to use (2 by default)
  138360. */
  138361. maximumScale: number;
  138362. /**
  138363. * Defines the step to use between two passes (0.5 by default)
  138364. */
  138365. step: number;
  138366. private _currentScale;
  138367. private _directionOffset;
  138368. /**
  138369. * Gets a string describing the action executed by the current optimization
  138370. * @return description string
  138371. */
  138372. getDescription(): string;
  138373. /**
  138374. * Creates the HardwareScalingOptimization object
  138375. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  138376. * @param maximumScale defines the maximum scale to use (2 by default)
  138377. * @param step defines the step to use between two passes (0.5 by default)
  138378. */
  138379. constructor(
  138380. /**
  138381. * Defines the priority of this optimization (0 by default which means first in the list)
  138382. */
  138383. priority?: number,
  138384. /**
  138385. * Defines the maximum scale to use (2 by default)
  138386. */
  138387. maximumScale?: number,
  138388. /**
  138389. * Defines the step to use between two passes (0.5 by default)
  138390. */
  138391. step?: number);
  138392. /**
  138393. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138394. * @param scene defines the current scene where to apply this optimization
  138395. * @param optimizer defines the current optimizer
  138396. * @returns true if everything that can be done was applied
  138397. */
  138398. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138399. }
  138400. /**
  138401. * Defines an optimization used to remove shadows
  138402. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138403. */
  138404. export class ShadowsOptimization extends SceneOptimization {
  138405. /**
  138406. * Gets a string describing the action executed by the current optimization
  138407. * @return description string
  138408. */
  138409. getDescription(): string;
  138410. /**
  138411. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138412. * @param scene defines the current scene where to apply this optimization
  138413. * @param optimizer defines the current optimizer
  138414. * @returns true if everything that can be done was applied
  138415. */
  138416. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138417. }
  138418. /**
  138419. * Defines an optimization used to turn post-processes off
  138420. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138421. */
  138422. export class PostProcessesOptimization extends SceneOptimization {
  138423. /**
  138424. * Gets a string describing the action executed by the current optimization
  138425. * @return description string
  138426. */
  138427. getDescription(): string;
  138428. /**
  138429. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138430. * @param scene defines the current scene where to apply this optimization
  138431. * @param optimizer defines the current optimizer
  138432. * @returns true if everything that can be done was applied
  138433. */
  138434. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138435. }
  138436. /**
  138437. * Defines an optimization used to turn lens flares off
  138438. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138439. */
  138440. export class LensFlaresOptimization extends SceneOptimization {
  138441. /**
  138442. * Gets a string describing the action executed by the current optimization
  138443. * @return description string
  138444. */
  138445. getDescription(): string;
  138446. /**
  138447. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138448. * @param scene defines the current scene where to apply this optimization
  138449. * @param optimizer defines the current optimizer
  138450. * @returns true if everything that can be done was applied
  138451. */
  138452. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138453. }
  138454. /**
  138455. * Defines an optimization based on user defined callback.
  138456. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138457. */
  138458. export class CustomOptimization extends SceneOptimization {
  138459. /**
  138460. * Callback called to apply the custom optimization.
  138461. */
  138462. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  138463. /**
  138464. * Callback called to get custom description
  138465. */
  138466. onGetDescription: () => string;
  138467. /**
  138468. * Gets a string describing the action executed by the current optimization
  138469. * @returns description string
  138470. */
  138471. getDescription(): string;
  138472. /**
  138473. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138474. * @param scene defines the current scene where to apply this optimization
  138475. * @param optimizer defines the current optimizer
  138476. * @returns true if everything that can be done was applied
  138477. */
  138478. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138479. }
  138480. /**
  138481. * Defines an optimization used to turn particles off
  138482. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138483. */
  138484. export class ParticlesOptimization extends SceneOptimization {
  138485. /**
  138486. * Gets a string describing the action executed by the current optimization
  138487. * @return description string
  138488. */
  138489. getDescription(): string;
  138490. /**
  138491. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138492. * @param scene defines the current scene where to apply this optimization
  138493. * @param optimizer defines the current optimizer
  138494. * @returns true if everything that can be done was applied
  138495. */
  138496. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138497. }
  138498. /**
  138499. * Defines an optimization used to turn render targets off
  138500. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138501. */
  138502. export class RenderTargetsOptimization extends SceneOptimization {
  138503. /**
  138504. * Gets a string describing the action executed by the current optimization
  138505. * @return description string
  138506. */
  138507. getDescription(): string;
  138508. /**
  138509. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138510. * @param scene defines the current scene where to apply this optimization
  138511. * @param optimizer defines the current optimizer
  138512. * @returns true if everything that can be done was applied
  138513. */
  138514. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  138515. }
  138516. /**
  138517. * Defines an optimization used to merge meshes with compatible materials
  138518. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138519. */
  138520. export class MergeMeshesOptimization extends SceneOptimization {
  138521. private static _UpdateSelectionTree;
  138522. /**
  138523. * Gets or sets a boolean which defines if optimization octree has to be updated
  138524. */
  138525. static get UpdateSelectionTree(): boolean;
  138526. /**
  138527. * Gets or sets a boolean which defines if optimization octree has to be updated
  138528. */
  138529. static set UpdateSelectionTree(value: boolean);
  138530. /**
  138531. * Gets a string describing the action executed by the current optimization
  138532. * @return description string
  138533. */
  138534. getDescription(): string;
  138535. private _canBeMerged;
  138536. /**
  138537. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  138538. * @param scene defines the current scene where to apply this optimization
  138539. * @param optimizer defines the current optimizer
  138540. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  138541. * @returns true if everything that can be done was applied
  138542. */
  138543. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  138544. }
  138545. /**
  138546. * Defines a list of options used by SceneOptimizer
  138547. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138548. */
  138549. export class SceneOptimizerOptions {
  138550. /**
  138551. * Defines the target frame rate to reach (60 by default)
  138552. */
  138553. targetFrameRate: number;
  138554. /**
  138555. * Defines the interval between two checkes (2000ms by default)
  138556. */
  138557. trackerDuration: number;
  138558. /**
  138559. * Gets the list of optimizations to apply
  138560. */
  138561. optimizations: SceneOptimization[];
  138562. /**
  138563. * Creates a new list of options used by SceneOptimizer
  138564. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  138565. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  138566. */
  138567. constructor(
  138568. /**
  138569. * Defines the target frame rate to reach (60 by default)
  138570. */
  138571. targetFrameRate?: number,
  138572. /**
  138573. * Defines the interval between two checkes (2000ms by default)
  138574. */
  138575. trackerDuration?: number);
  138576. /**
  138577. * Add a new optimization
  138578. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  138579. * @returns the current SceneOptimizerOptions
  138580. */
  138581. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  138582. /**
  138583. * Add a new custom optimization
  138584. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  138585. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  138586. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  138587. * @returns the current SceneOptimizerOptions
  138588. */
  138589. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  138590. /**
  138591. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  138592. * @param targetFrameRate defines the target frame rate (60 by default)
  138593. * @returns a SceneOptimizerOptions object
  138594. */
  138595. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  138596. /**
  138597. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  138598. * @param targetFrameRate defines the target frame rate (60 by default)
  138599. * @returns a SceneOptimizerOptions object
  138600. */
  138601. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  138602. /**
  138603. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  138604. * @param targetFrameRate defines the target frame rate (60 by default)
  138605. * @returns a SceneOptimizerOptions object
  138606. */
  138607. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  138608. }
  138609. /**
  138610. * Class used to run optimizations in order to reach a target frame rate
  138611. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  138612. */
  138613. export class SceneOptimizer implements IDisposable {
  138614. private _isRunning;
  138615. private _options;
  138616. private _scene;
  138617. private _currentPriorityLevel;
  138618. private _targetFrameRate;
  138619. private _trackerDuration;
  138620. private _currentFrameRate;
  138621. private _sceneDisposeObserver;
  138622. private _improvementMode;
  138623. /**
  138624. * Defines an observable called when the optimizer reaches the target frame rate
  138625. */
  138626. onSuccessObservable: Observable<SceneOptimizer>;
  138627. /**
  138628. * Defines an observable called when the optimizer enables an optimization
  138629. */
  138630. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  138631. /**
  138632. * Defines an observable called when the optimizer is not able to reach the target frame rate
  138633. */
  138634. onFailureObservable: Observable<SceneOptimizer>;
  138635. /**
  138636. * Gets a boolean indicating if the optimizer is in improvement mode
  138637. */
  138638. get isInImprovementMode(): boolean;
  138639. /**
  138640. * Gets the current priority level (0 at start)
  138641. */
  138642. get currentPriorityLevel(): number;
  138643. /**
  138644. * Gets the current frame rate checked by the SceneOptimizer
  138645. */
  138646. get currentFrameRate(): number;
  138647. /**
  138648. * Gets or sets the current target frame rate (60 by default)
  138649. */
  138650. get targetFrameRate(): number;
  138651. /**
  138652. * Gets or sets the current target frame rate (60 by default)
  138653. */
  138654. set targetFrameRate(value: number);
  138655. /**
  138656. * Gets or sets the current interval between two checks (every 2000ms by default)
  138657. */
  138658. get trackerDuration(): number;
  138659. /**
  138660. * Gets or sets the current interval between two checks (every 2000ms by default)
  138661. */
  138662. set trackerDuration(value: number);
  138663. /**
  138664. * Gets the list of active optimizations
  138665. */
  138666. get optimizations(): SceneOptimization[];
  138667. /**
  138668. * Creates a new SceneOptimizer
  138669. * @param scene defines the scene to work on
  138670. * @param options defines the options to use with the SceneOptimizer
  138671. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  138672. * @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)
  138673. */
  138674. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  138675. /**
  138676. * Stops the current optimizer
  138677. */
  138678. stop(): void;
  138679. /**
  138680. * Reset the optimizer to initial step (current priority level = 0)
  138681. */
  138682. reset(): void;
  138683. /**
  138684. * Start the optimizer. By default it will try to reach a specific framerate
  138685. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  138686. */
  138687. start(): void;
  138688. private _checkCurrentState;
  138689. /**
  138690. * Release all resources
  138691. */
  138692. dispose(): void;
  138693. /**
  138694. * Helper function to create a SceneOptimizer with one single line of code
  138695. * @param scene defines the scene to work on
  138696. * @param options defines the options to use with the SceneOptimizer
  138697. * @param onSuccess defines a callback to call on success
  138698. * @param onFailure defines a callback to call on failure
  138699. * @returns the new SceneOptimizer object
  138700. */
  138701. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  138702. }
  138703. }
  138704. declare module BABYLON {
  138705. /**
  138706. * Class used to serialize a scene into a string
  138707. */
  138708. export class SceneSerializer {
  138709. /**
  138710. * Clear cache used by a previous serialization
  138711. */
  138712. static ClearCache(): void;
  138713. /**
  138714. * Serialize a scene into a JSON compatible object
  138715. * @param scene defines the scene to serialize
  138716. * @returns a JSON compatible object
  138717. */
  138718. static Serialize(scene: Scene): any;
  138719. /**
  138720. * Serialize a mesh into a JSON compatible object
  138721. * @param toSerialize defines the mesh to serialize
  138722. * @param withParents defines if parents must be serialized as well
  138723. * @param withChildren defines if children must be serialized as well
  138724. * @returns a JSON compatible object
  138725. */
  138726. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  138727. }
  138728. }
  138729. declare module BABYLON {
  138730. /**
  138731. * Class used to host texture specific utilities
  138732. */
  138733. export class TextureTools {
  138734. /**
  138735. * Uses the GPU to create a copy texture rescaled at a given size
  138736. * @param texture Texture to copy from
  138737. * @param width defines the desired width
  138738. * @param height defines the desired height
  138739. * @param useBilinearMode defines if bilinear mode has to be used
  138740. * @return the generated texture
  138741. */
  138742. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  138743. }
  138744. }
  138745. declare module BABYLON {
  138746. /**
  138747. * This represents the different options available for the video capture.
  138748. */
  138749. export interface VideoRecorderOptions {
  138750. /** Defines the mime type of the video. */
  138751. mimeType: string;
  138752. /** Defines the FPS the video should be recorded at. */
  138753. fps: number;
  138754. /** Defines the chunk size for the recording data. */
  138755. recordChunckSize: number;
  138756. /** The audio tracks to attach to the recording. */
  138757. audioTracks?: MediaStreamTrack[];
  138758. }
  138759. /**
  138760. * This can help with recording videos from BabylonJS.
  138761. * This is based on the available WebRTC functionalities of the browser.
  138762. *
  138763. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  138764. */
  138765. export class VideoRecorder {
  138766. private static readonly _defaultOptions;
  138767. /**
  138768. * Returns whether or not the VideoRecorder is available in your browser.
  138769. * @param engine Defines the Babylon Engine.
  138770. * @returns true if supported otherwise false.
  138771. */
  138772. static IsSupported(engine: Engine): boolean;
  138773. private readonly _options;
  138774. private _canvas;
  138775. private _mediaRecorder;
  138776. private _recordedChunks;
  138777. private _fileName;
  138778. private _resolve;
  138779. private _reject;
  138780. /**
  138781. * True when a recording is already in progress.
  138782. */
  138783. get isRecording(): boolean;
  138784. /**
  138785. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  138786. * @param engine Defines the BabylonJS Engine you wish to record.
  138787. * @param options Defines options that can be used to customize the capture.
  138788. */
  138789. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  138790. /**
  138791. * Stops the current recording before the default capture timeout passed in the startRecording function.
  138792. */
  138793. stopRecording(): void;
  138794. /**
  138795. * Starts recording the canvas for a max duration specified in parameters.
  138796. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  138797. * If null no automatic download will start and you can rely on the promise to get the data back.
  138798. * @param maxDuration Defines the maximum recording time in seconds.
  138799. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  138800. * @return A promise callback at the end of the recording with the video data in Blob.
  138801. */
  138802. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  138803. /**
  138804. * Releases internal resources used during the recording.
  138805. */
  138806. dispose(): void;
  138807. private _handleDataAvailable;
  138808. private _handleError;
  138809. private _handleStop;
  138810. }
  138811. }
  138812. declare module BABYLON {
  138813. /**
  138814. * Class containing a set of static utilities functions for screenshots
  138815. */
  138816. export class ScreenshotTools {
  138817. /**
  138818. * Captures a screenshot of the current rendering
  138819. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  138820. * @param engine defines the rendering engine
  138821. * @param camera defines the source camera
  138822. * @param size This parameter can be set to a single number or to an object with the
  138823. * following (optional) properties: precision, width, height. If a single number is passed,
  138824. * it will be used for both width and height. If an object is passed, the screenshot size
  138825. * will be derived from the parameters. The precision property is a multiplier allowing
  138826. * rendering at a higher or lower resolution
  138827. * @param successCallback defines the callback receives a single parameter which contains the
  138828. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  138829. * src parameter of an <img> to display it
  138830. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  138831. * Check your browser for supported MIME types
  138832. */
  138833. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  138834. /**
  138835. * Captures a screenshot of the current rendering
  138836. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  138837. * @param engine defines the rendering engine
  138838. * @param camera defines the source camera
  138839. * @param size This parameter can be set to a single number or to an object with the
  138840. * following (optional) properties: precision, width, height. If a single number is passed,
  138841. * it will be used for both width and height. If an object is passed, the screenshot size
  138842. * will be derived from the parameters. The precision property is a multiplier allowing
  138843. * rendering at a higher or lower resolution
  138844. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  138845. * Check your browser for supported MIME types
  138846. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  138847. * to the src parameter of an <img> to display it
  138848. */
  138849. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  138850. /**
  138851. * Generates an image screenshot from the specified camera.
  138852. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  138853. * @param engine The engine to use for rendering
  138854. * @param camera The camera to use for rendering
  138855. * @param size This parameter can be set to a single number or to an object with the
  138856. * following (optional) properties: precision, width, height. If a single number is passed,
  138857. * it will be used for both width and height. If an object is passed, the screenshot size
  138858. * will be derived from the parameters. The precision property is a multiplier allowing
  138859. * rendering at a higher or lower resolution
  138860. * @param successCallback The callback receives a single parameter which contains the
  138861. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  138862. * src parameter of an <img> to display it
  138863. * @param mimeType The MIME type of the screenshot image (default: image/png).
  138864. * Check your browser for supported MIME types
  138865. * @param samples Texture samples (default: 1)
  138866. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  138867. * @param fileName A name for for the downloaded file.
  138868. */
  138869. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  138870. /**
  138871. * Generates an image screenshot from the specified camera.
  138872. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  138873. * @param engine The engine to use for rendering
  138874. * @param camera The camera to use for rendering
  138875. * @param size This parameter can be set to a single number or to an object with the
  138876. * following (optional) properties: precision, width, height. If a single number is passed,
  138877. * it will be used for both width and height. If an object is passed, the screenshot size
  138878. * will be derived from the parameters. The precision property is a multiplier allowing
  138879. * rendering at a higher or lower resolution
  138880. * @param mimeType The MIME type of the screenshot image (default: image/png).
  138881. * Check your browser for supported MIME types
  138882. * @param samples Texture samples (default: 1)
  138883. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  138884. * @param fileName A name for for the downloaded file.
  138885. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  138886. * to the src parameter of an <img> to display it
  138887. */
  138888. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  138889. /**
  138890. * Gets height and width for screenshot size
  138891. * @private
  138892. */
  138893. private static _getScreenshotSize;
  138894. }
  138895. }
  138896. declare module BABYLON {
  138897. /**
  138898. * Interface for a data buffer
  138899. */
  138900. export interface IDataBuffer {
  138901. /**
  138902. * Reads bytes from the data buffer.
  138903. * @param byteOffset The byte offset to read
  138904. * @param byteLength The byte length to read
  138905. * @returns A promise that resolves when the bytes are read
  138906. */
  138907. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  138908. /**
  138909. * The byte length of the buffer.
  138910. */
  138911. readonly byteLength: number;
  138912. }
  138913. /**
  138914. * Utility class for reading from a data buffer
  138915. */
  138916. export class DataReader {
  138917. /**
  138918. * The data buffer associated with this data reader.
  138919. */
  138920. readonly buffer: IDataBuffer;
  138921. /**
  138922. * The current byte offset from the beginning of the data buffer.
  138923. */
  138924. byteOffset: number;
  138925. private _dataView;
  138926. private _dataByteOffset;
  138927. /**
  138928. * Constructor
  138929. * @param buffer The buffer to read
  138930. */
  138931. constructor(buffer: IDataBuffer);
  138932. /**
  138933. * Loads the given byte length.
  138934. * @param byteLength The byte length to load
  138935. * @returns A promise that resolves when the load is complete
  138936. */
  138937. loadAsync(byteLength: number): Promise<void>;
  138938. /**
  138939. * Read a unsigned 32-bit integer from the currently loaded data range.
  138940. * @returns The 32-bit integer read
  138941. */
  138942. readUint32(): number;
  138943. /**
  138944. * Read a byte array from the currently loaded data range.
  138945. * @param byteLength The byte length to read
  138946. * @returns The byte array read
  138947. */
  138948. readUint8Array(byteLength: number): Uint8Array;
  138949. /**
  138950. * Read a string from the currently loaded data range.
  138951. * @param byteLength The byte length to read
  138952. * @returns The string read
  138953. */
  138954. readString(byteLength: number): string;
  138955. /**
  138956. * Skips the given byte length the currently loaded data range.
  138957. * @param byteLength The byte length to skip
  138958. */
  138959. skipBytes(byteLength: number): void;
  138960. }
  138961. }
  138962. declare module BABYLON {
  138963. /**
  138964. * A cursor which tracks a point on a path
  138965. */
  138966. export class PathCursor {
  138967. private path;
  138968. /**
  138969. * Stores path cursor callbacks for when an onchange event is triggered
  138970. */
  138971. private _onchange;
  138972. /**
  138973. * The value of the path cursor
  138974. */
  138975. value: number;
  138976. /**
  138977. * The animation array of the path cursor
  138978. */
  138979. animations: Animation[];
  138980. /**
  138981. * Initializes the path cursor
  138982. * @param path The path to track
  138983. */
  138984. constructor(path: Path2);
  138985. /**
  138986. * Gets the cursor point on the path
  138987. * @returns A point on the path cursor at the cursor location
  138988. */
  138989. getPoint(): Vector3;
  138990. /**
  138991. * Moves the cursor ahead by the step amount
  138992. * @param step The amount to move the cursor forward
  138993. * @returns This path cursor
  138994. */
  138995. moveAhead(step?: number): PathCursor;
  138996. /**
  138997. * Moves the cursor behind by the step amount
  138998. * @param step The amount to move the cursor back
  138999. * @returns This path cursor
  139000. */
  139001. moveBack(step?: number): PathCursor;
  139002. /**
  139003. * Moves the cursor by the step amount
  139004. * If the step amount is greater than one, an exception is thrown
  139005. * @param step The amount to move the cursor
  139006. * @returns This path cursor
  139007. */
  139008. move(step: number): PathCursor;
  139009. /**
  139010. * Ensures that the value is limited between zero and one
  139011. * @returns This path cursor
  139012. */
  139013. private ensureLimits;
  139014. /**
  139015. * Runs onchange callbacks on change (used by the animation engine)
  139016. * @returns This path cursor
  139017. */
  139018. private raiseOnChange;
  139019. /**
  139020. * Executes a function on change
  139021. * @param f A path cursor onchange callback
  139022. * @returns This path cursor
  139023. */
  139024. onchange(f: (cursor: PathCursor) => void): PathCursor;
  139025. }
  139026. }
  139027. declare module BABYLON {
  139028. /** @hidden */
  139029. export var blurPixelShader: {
  139030. name: string;
  139031. shader: string;
  139032. };
  139033. }
  139034. declare module BABYLON {
  139035. /** @hidden */
  139036. export var pointCloudVertexDeclaration: {
  139037. name: string;
  139038. shader: string;
  139039. };
  139040. }
  139041. // Mixins
  139042. interface Window {
  139043. mozIndexedDB: IDBFactory;
  139044. webkitIndexedDB: IDBFactory;
  139045. msIndexedDB: IDBFactory;
  139046. webkitURL: typeof URL;
  139047. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  139048. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  139049. WebGLRenderingContext: WebGLRenderingContext;
  139050. MSGesture: MSGesture;
  139051. CANNON: any;
  139052. AudioContext: AudioContext;
  139053. webkitAudioContext: AudioContext;
  139054. PointerEvent: any;
  139055. Math: Math;
  139056. Uint8Array: Uint8ArrayConstructor;
  139057. Float32Array: Float32ArrayConstructor;
  139058. mozURL: typeof URL;
  139059. msURL: typeof URL;
  139060. VRFrameData: any; // WebVR, from specs 1.1
  139061. DracoDecoderModule: any;
  139062. setImmediate(handler: (...args: any[]) => void): number;
  139063. }
  139064. interface HTMLCanvasElement {
  139065. requestPointerLock(): void;
  139066. msRequestPointerLock?(): void;
  139067. mozRequestPointerLock?(): void;
  139068. webkitRequestPointerLock?(): void;
  139069. /** Track wether a record is in progress */
  139070. isRecording: boolean;
  139071. /** Capture Stream method defined by some browsers */
  139072. captureStream(fps?: number): MediaStream;
  139073. }
  139074. interface CanvasRenderingContext2D {
  139075. msImageSmoothingEnabled: boolean;
  139076. }
  139077. interface MouseEvent {
  139078. mozMovementX: number;
  139079. mozMovementY: number;
  139080. webkitMovementX: number;
  139081. webkitMovementY: number;
  139082. msMovementX: number;
  139083. msMovementY: number;
  139084. }
  139085. interface Navigator {
  139086. mozGetVRDevices: (any: any) => any;
  139087. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  139088. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  139089. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  139090. webkitGetGamepads(): Gamepad[];
  139091. msGetGamepads(): Gamepad[];
  139092. webkitGamepads(): Gamepad[];
  139093. }
  139094. interface HTMLVideoElement {
  139095. mozSrcObject: any;
  139096. }
  139097. interface Math {
  139098. fround(x: number): number;
  139099. imul(a: number, b: number): number;
  139100. }
  139101. interface WebGLRenderingContext {
  139102. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  139103. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  139104. vertexAttribDivisor(index: number, divisor: number): void;
  139105. createVertexArray(): any;
  139106. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  139107. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  139108. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  139109. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  139110. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  139111. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  139112. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  139113. // Queries
  139114. createQuery(): WebGLQuery;
  139115. deleteQuery(query: WebGLQuery): void;
  139116. beginQuery(target: number, query: WebGLQuery): void;
  139117. endQuery(target: number): void;
  139118. getQueryParameter(query: WebGLQuery, pname: number): any;
  139119. getQuery(target: number, pname: number): any;
  139120. MAX_SAMPLES: number;
  139121. RGBA8: number;
  139122. READ_FRAMEBUFFER: number;
  139123. DRAW_FRAMEBUFFER: number;
  139124. UNIFORM_BUFFER: number;
  139125. HALF_FLOAT_OES: number;
  139126. RGBA16F: number;
  139127. RGBA32F: number;
  139128. R32F: number;
  139129. RG32F: number;
  139130. RGB32F: number;
  139131. R16F: number;
  139132. RG16F: number;
  139133. RGB16F: number;
  139134. RED: number;
  139135. RG: number;
  139136. R8: number;
  139137. RG8: number;
  139138. UNSIGNED_INT_24_8: number;
  139139. DEPTH24_STENCIL8: number;
  139140. MIN: number;
  139141. MAX: number;
  139142. /* Multiple Render Targets */
  139143. drawBuffers(buffers: number[]): void;
  139144. readBuffer(src: number): void;
  139145. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  139146. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  139147. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  139148. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  139149. // Occlusion Query
  139150. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  139151. ANY_SAMPLES_PASSED: number;
  139152. QUERY_RESULT_AVAILABLE: number;
  139153. QUERY_RESULT: number;
  139154. }
  139155. interface WebGLProgram {
  139156. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  139157. }
  139158. interface EXT_disjoint_timer_query {
  139159. QUERY_COUNTER_BITS_EXT: number;
  139160. TIME_ELAPSED_EXT: number;
  139161. TIMESTAMP_EXT: number;
  139162. GPU_DISJOINT_EXT: number;
  139163. QUERY_RESULT_EXT: number;
  139164. QUERY_RESULT_AVAILABLE_EXT: number;
  139165. queryCounterEXT(query: WebGLQuery, target: number): void;
  139166. createQueryEXT(): WebGLQuery;
  139167. beginQueryEXT(target: number, query: WebGLQuery): void;
  139168. endQueryEXT(target: number): void;
  139169. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  139170. deleteQueryEXT(query: WebGLQuery): void;
  139171. }
  139172. interface WebGLUniformLocation {
  139173. _currentState: any;
  139174. }
  139175. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  139176. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  139177. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  139178. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  139179. interface WebGLRenderingContext {
  139180. readonly RASTERIZER_DISCARD: number;
  139181. readonly DEPTH_COMPONENT24: number;
  139182. readonly TEXTURE_3D: number;
  139183. readonly TEXTURE_2D_ARRAY: number;
  139184. readonly TEXTURE_COMPARE_FUNC: number;
  139185. readonly TEXTURE_COMPARE_MODE: number;
  139186. readonly COMPARE_REF_TO_TEXTURE: number;
  139187. readonly TEXTURE_WRAP_R: number;
  139188. readonly HALF_FLOAT: number;
  139189. readonly RGB8: number;
  139190. readonly RED_INTEGER: number;
  139191. readonly RG_INTEGER: number;
  139192. readonly RGB_INTEGER: number;
  139193. readonly RGBA_INTEGER: number;
  139194. readonly R8_SNORM: number;
  139195. readonly RG8_SNORM: number;
  139196. readonly RGB8_SNORM: number;
  139197. readonly RGBA8_SNORM: number;
  139198. readonly R8I: number;
  139199. readonly RG8I: number;
  139200. readonly RGB8I: number;
  139201. readonly RGBA8I: number;
  139202. readonly R8UI: number;
  139203. readonly RG8UI: number;
  139204. readonly RGB8UI: number;
  139205. readonly RGBA8UI: number;
  139206. readonly R16I: number;
  139207. readonly RG16I: number;
  139208. readonly RGB16I: number;
  139209. readonly RGBA16I: number;
  139210. readonly R16UI: number;
  139211. readonly RG16UI: number;
  139212. readonly RGB16UI: number;
  139213. readonly RGBA16UI: number;
  139214. readonly R32I: number;
  139215. readonly RG32I: number;
  139216. readonly RGB32I: number;
  139217. readonly RGBA32I: number;
  139218. readonly R32UI: number;
  139219. readonly RG32UI: number;
  139220. readonly RGB32UI: number;
  139221. readonly RGBA32UI: number;
  139222. readonly RGB10_A2UI: number;
  139223. readonly R11F_G11F_B10F: number;
  139224. readonly RGB9_E5: number;
  139225. readonly RGB10_A2: number;
  139226. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  139227. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  139228. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  139229. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  139230. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  139231. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  139232. 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;
  139233. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  139234. readonly TRANSFORM_FEEDBACK: number;
  139235. readonly INTERLEAVED_ATTRIBS: number;
  139236. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  139237. createTransformFeedback(): WebGLTransformFeedback;
  139238. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  139239. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  139240. beginTransformFeedback(primitiveMode: number): void;
  139241. endTransformFeedback(): void;
  139242. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  139243. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  139244. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  139245. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  139246. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  139247. }
  139248. interface ImageBitmap {
  139249. readonly width: number;
  139250. readonly height: number;
  139251. close(): void;
  139252. }
  139253. interface WebGLQuery extends WebGLObject {
  139254. }
  139255. declare var WebGLQuery: {
  139256. prototype: WebGLQuery;
  139257. new(): WebGLQuery;
  139258. };
  139259. interface WebGLSampler extends WebGLObject {
  139260. }
  139261. declare var WebGLSampler: {
  139262. prototype: WebGLSampler;
  139263. new(): WebGLSampler;
  139264. };
  139265. interface WebGLSync extends WebGLObject {
  139266. }
  139267. declare var WebGLSync: {
  139268. prototype: WebGLSync;
  139269. new(): WebGLSync;
  139270. };
  139271. interface WebGLTransformFeedback extends WebGLObject {
  139272. }
  139273. declare var WebGLTransformFeedback: {
  139274. prototype: WebGLTransformFeedback;
  139275. new(): WebGLTransformFeedback;
  139276. };
  139277. interface WebGLVertexArrayObject extends WebGLObject {
  139278. }
  139279. declare var WebGLVertexArrayObject: {
  139280. prototype: WebGLVertexArrayObject;
  139281. new(): WebGLVertexArrayObject;
  139282. };
  139283. // Type definitions for WebVR API
  139284. // Project: https://w3c.github.io/webvr/
  139285. // Definitions by: six a <https://github.com/lostfictions>
  139286. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  139287. interface VRDisplay extends EventTarget {
  139288. /**
  139289. * Dictionary of capabilities describing the VRDisplay.
  139290. */
  139291. readonly capabilities: VRDisplayCapabilities;
  139292. /**
  139293. * z-depth defining the far plane of the eye view frustum
  139294. * enables mapping of values in the render target depth
  139295. * attachment to scene coordinates. Initially set to 10000.0.
  139296. */
  139297. depthFar: number;
  139298. /**
  139299. * z-depth defining the near plane of the eye view frustum
  139300. * enables mapping of values in the render target depth
  139301. * attachment to scene coordinates. Initially set to 0.01.
  139302. */
  139303. depthNear: number;
  139304. /**
  139305. * An identifier for this distinct VRDisplay. Used as an
  139306. * association point in the Gamepad API.
  139307. */
  139308. readonly displayId: number;
  139309. /**
  139310. * A display name, a user-readable name identifying it.
  139311. */
  139312. readonly displayName: string;
  139313. readonly isConnected: boolean;
  139314. readonly isPresenting: boolean;
  139315. /**
  139316. * If this VRDisplay supports room-scale experiences, the optional
  139317. * stage attribute contains details on the room-scale parameters.
  139318. */
  139319. readonly stageParameters: VRStageParameters | null;
  139320. /**
  139321. * Passing the value returned by `requestAnimationFrame` to
  139322. * `cancelAnimationFrame` will unregister the callback.
  139323. * @param handle Define the hanle of the request to cancel
  139324. */
  139325. cancelAnimationFrame(handle: number): void;
  139326. /**
  139327. * Stops presenting to the VRDisplay.
  139328. * @returns a promise to know when it stopped
  139329. */
  139330. exitPresent(): Promise<void>;
  139331. /**
  139332. * Return the current VREyeParameters for the given eye.
  139333. * @param whichEye Define the eye we want the parameter for
  139334. * @returns the eye parameters
  139335. */
  139336. getEyeParameters(whichEye: string): VREyeParameters;
  139337. /**
  139338. * Populates the passed VRFrameData with the information required to render
  139339. * the current frame.
  139340. * @param frameData Define the data structure to populate
  139341. * @returns true if ok otherwise false
  139342. */
  139343. getFrameData(frameData: VRFrameData): boolean;
  139344. /**
  139345. * Get the layers currently being presented.
  139346. * @returns the list of VR layers
  139347. */
  139348. getLayers(): VRLayer[];
  139349. /**
  139350. * Return a VRPose containing the future predicted pose of the VRDisplay
  139351. * when the current frame will be presented. The value returned will not
  139352. * change until JavaScript has returned control to the browser.
  139353. *
  139354. * The VRPose will contain the position, orientation, velocity,
  139355. * and acceleration of each of these properties.
  139356. * @returns the pose object
  139357. */
  139358. getPose(): VRPose;
  139359. /**
  139360. * Return the current instantaneous pose of the VRDisplay, with no
  139361. * prediction applied.
  139362. * @returns the current instantaneous pose
  139363. */
  139364. getImmediatePose(): VRPose;
  139365. /**
  139366. * The callback passed to `requestAnimationFrame` will be called
  139367. * any time a new frame should be rendered. When the VRDisplay is
  139368. * presenting the callback will be called at the native refresh
  139369. * rate of the HMD. When not presenting this function acts
  139370. * identically to how window.requestAnimationFrame acts. Content should
  139371. * make no assumptions of frame rate or vsync behavior as the HMD runs
  139372. * asynchronously from other displays and at differing refresh rates.
  139373. * @param callback Define the eaction to run next frame
  139374. * @returns the request handle it
  139375. */
  139376. requestAnimationFrame(callback: FrameRequestCallback): number;
  139377. /**
  139378. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  139379. * Repeat calls while already presenting will update the VRLayers being displayed.
  139380. * @param layers Define the list of layer to present
  139381. * @returns a promise to know when the request has been fulfilled
  139382. */
  139383. requestPresent(layers: VRLayer[]): Promise<void>;
  139384. /**
  139385. * Reset the pose for this display, treating its current position and
  139386. * orientation as the "origin/zero" values. VRPose.position,
  139387. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  139388. * updated when calling resetPose(). This should be called in only
  139389. * sitting-space experiences.
  139390. */
  139391. resetPose(): void;
  139392. /**
  139393. * The VRLayer provided to the VRDisplay will be captured and presented
  139394. * in the HMD. Calling this function has the same effect on the source
  139395. * canvas as any other operation that uses its source image, and canvases
  139396. * created without preserveDrawingBuffer set to true will be cleared.
  139397. * @param pose Define the pose to submit
  139398. */
  139399. submitFrame(pose?: VRPose): void;
  139400. }
  139401. declare var VRDisplay: {
  139402. prototype: VRDisplay;
  139403. new(): VRDisplay;
  139404. };
  139405. interface VRLayer {
  139406. leftBounds?: number[] | Float32Array | null;
  139407. rightBounds?: number[] | Float32Array | null;
  139408. source?: HTMLCanvasElement | null;
  139409. }
  139410. interface VRDisplayCapabilities {
  139411. readonly canPresent: boolean;
  139412. readonly hasExternalDisplay: boolean;
  139413. readonly hasOrientation: boolean;
  139414. readonly hasPosition: boolean;
  139415. readonly maxLayers: number;
  139416. }
  139417. interface VREyeParameters {
  139418. /** @deprecated */
  139419. readonly fieldOfView: VRFieldOfView;
  139420. readonly offset: Float32Array;
  139421. readonly renderHeight: number;
  139422. readonly renderWidth: number;
  139423. }
  139424. interface VRFieldOfView {
  139425. readonly downDegrees: number;
  139426. readonly leftDegrees: number;
  139427. readonly rightDegrees: number;
  139428. readonly upDegrees: number;
  139429. }
  139430. interface VRFrameData {
  139431. readonly leftProjectionMatrix: Float32Array;
  139432. readonly leftViewMatrix: Float32Array;
  139433. readonly pose: VRPose;
  139434. readonly rightProjectionMatrix: Float32Array;
  139435. readonly rightViewMatrix: Float32Array;
  139436. readonly timestamp: number;
  139437. }
  139438. interface VRPose {
  139439. readonly angularAcceleration: Float32Array | null;
  139440. readonly angularVelocity: Float32Array | null;
  139441. readonly linearAcceleration: Float32Array | null;
  139442. readonly linearVelocity: Float32Array | null;
  139443. readonly orientation: Float32Array | null;
  139444. readonly position: Float32Array | null;
  139445. readonly timestamp: number;
  139446. }
  139447. interface VRStageParameters {
  139448. sittingToStandingTransform?: Float32Array;
  139449. sizeX?: number;
  139450. sizeY?: number;
  139451. }
  139452. interface Navigator {
  139453. getVRDisplays(): Promise<VRDisplay[]>;
  139454. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  139455. }
  139456. interface Window {
  139457. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  139458. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  139459. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  139460. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  139461. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  139462. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  139463. }
  139464. interface Gamepad {
  139465. readonly displayId: number;
  139466. }
  139467. type XRSessionMode =
  139468. | "inline"
  139469. | "immersive-vr"
  139470. | "immersive-ar";
  139471. type XRReferenceSpaceType =
  139472. | "viewer"
  139473. | "local"
  139474. | "local-floor"
  139475. | "bounded-floor"
  139476. | "unbounded";
  139477. type XREnvironmentBlendMode =
  139478. | "opaque"
  139479. | "additive"
  139480. | "alpha-blend";
  139481. type XRVisibilityState =
  139482. | "visible"
  139483. | "visible-blurred"
  139484. | "hidden";
  139485. type XRHandedness =
  139486. | "none"
  139487. | "left"
  139488. | "right";
  139489. type XRTargetRayMode =
  139490. | "gaze"
  139491. | "tracked-pointer"
  139492. | "screen";
  139493. type XREye =
  139494. | "none"
  139495. | "left"
  139496. | "right";
  139497. interface XRSpace extends EventTarget {
  139498. }
  139499. interface XRRenderState {
  139500. depthNear?: number;
  139501. depthFar?: number;
  139502. inlineVerticalFieldOfView?: number;
  139503. baseLayer?: XRWebGLLayer;
  139504. }
  139505. interface XRInputSource {
  139506. handedness: XRHandedness;
  139507. targetRayMode: XRTargetRayMode;
  139508. targetRaySpace: XRSpace;
  139509. gripSpace: XRSpace | undefined;
  139510. gamepad: Gamepad | undefined;
  139511. profiles: Array<string>;
  139512. }
  139513. interface XRSession extends XRAnchorCreator {
  139514. addEventListener: Function;
  139515. removeEventListener: Function;
  139516. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  139517. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  139518. requestAnimationFrame: Function;
  139519. end(): Promise<void>;
  139520. renderState: XRRenderState;
  139521. inputSources: Array<XRInputSource>;
  139522. // AR hit test
  139523. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  139524. updateWorldTrackingState(options: {
  139525. planeDetectionState?: { enabled: boolean; }
  139526. }): void;
  139527. }
  139528. interface XRReferenceSpace extends XRSpace {
  139529. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  139530. onreset: any;
  139531. }
  139532. type XRPlaneSet = Set<XRPlane>;
  139533. type XRAnchorSet = Set<XRAnchor>;
  139534. interface XRFrame {
  139535. session: XRSession;
  139536. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  139537. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  139538. // Anchors
  139539. trackedAnchors?: XRAnchorSet;
  139540. // Planes
  139541. worldInformation: {
  139542. detectedPlanes?: XRPlaneSet;
  139543. };
  139544. }
  139545. interface XRViewerPose extends XRPose {
  139546. views: Array<XRView>;
  139547. }
  139548. interface XRPose {
  139549. transform: XRRigidTransform;
  139550. emulatedPosition: boolean;
  139551. }
  139552. interface XRWebGLLayerOptions {
  139553. antialias?: boolean;
  139554. depth?: boolean;
  139555. stencil?: boolean;
  139556. alpha?: boolean;
  139557. multiview?: boolean;
  139558. framebufferScaleFactor?: number;
  139559. }
  139560. declare var XRWebGLLayer: {
  139561. prototype: XRWebGLLayer;
  139562. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  139563. };
  139564. interface XRWebGLLayer {
  139565. framebuffer: WebGLFramebuffer;
  139566. framebufferWidth: number;
  139567. framebufferHeight: number;
  139568. getViewport: Function;
  139569. }
  139570. declare class XRRigidTransform {
  139571. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  139572. position: DOMPointReadOnly;
  139573. orientation: DOMPointReadOnly;
  139574. matrix: Float32Array;
  139575. inverse: XRRigidTransform;
  139576. }
  139577. interface XRView {
  139578. eye: XREye;
  139579. projectionMatrix: Float32Array;
  139580. transform: XRRigidTransform;
  139581. }
  139582. interface XRInputSourceChangeEvent {
  139583. session: XRSession;
  139584. removed: Array<XRInputSource>;
  139585. added: Array<XRInputSource>;
  139586. }
  139587. interface XRInputSourceEvent extends Event {
  139588. readonly frame: XRFrame;
  139589. readonly inputSource: XRInputSource;
  139590. }
  139591. // Experimental(er) features
  139592. declare class XRRay {
  139593. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  139594. origin: DOMPointReadOnly;
  139595. direction: DOMPointReadOnly;
  139596. matrix: Float32Array;
  139597. }
  139598. interface XRHitResult {
  139599. hitMatrix: Float32Array;
  139600. }
  139601. interface XRAnchor {
  139602. // remove?
  139603. id?: string;
  139604. anchorSpace: XRSpace;
  139605. lastChangedTime: number;
  139606. detach(): void;
  139607. }
  139608. interface XRPlane extends XRAnchorCreator {
  139609. orientation: "Horizontal" | "Vertical";
  139610. planeSpace: XRSpace;
  139611. polygon: Array<DOMPointReadOnly>;
  139612. lastChangedTime: number;
  139613. }
  139614. interface XRAnchorCreator {
  139615. // AR Anchors
  139616. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  139617. }